diff --git a/message-broker-nats/build.gradle b/message-broker-nats/build.gradle index 3dc497c..82b7376 100644 --- a/message-broker-nats/build.gradle +++ b/message-broker-nats/build.gradle @@ -1,6 +1,6 @@ coppuccino { coverage { - minimumCoverage = 0.87 + minimumCoverage = 0.86 } } diff --git a/message-broker-nats/src/main/java/com/mx/path/service/facility/messaging/nats/NatsConfiguration.java b/message-broker-nats/src/main/java/com/mx/path/service/facility/messaging/nats/NatsConfiguration.java index 2e44cdd..e09ddc2 100644 --- a/message-broker-nats/src/main/java/com/mx/path/service/facility/messaging/nats/NatsConfiguration.java +++ b/message-broker-nats/src/main/java/com/mx/path/service/facility/messaging/nats/NatsConfiguration.java @@ -2,9 +2,7 @@ import java.time.Duration; -import lombok.AccessLevel; import lombok.Data; -import lombok.Getter; import com.mx.common.configuration.ConfigurationField; @@ -13,7 +11,7 @@ public class NatsConfiguration { private static final int DEFAULT_DISPATCHER_COUNT = 1; private static final boolean DEFAULT_ENABLED = true; private static final String DEFAULT_SERVERS = "nats://127.0.0.1:4222"; - private static final int DEFAULT_TIMEOUT_IN_MILLISECONDS = 10000; + private static final Duration DEFAULT_TIMEOUT = Duration.ofMillis(10000); private static final String DEFAULT_TLS_CA_CERT_PATH = null; private static final String DEFAULT_TLS_CLIENT_CERT_PATH = null; private static final String DEFAULT_TLS_CLIENT_KEY_PATH = null; @@ -28,16 +26,8 @@ public class NatsConfiguration { @ConfigurationField(required = true, placeholder = "nats://127.0.0.1:4222") private String servers = DEFAULT_SERVERS; - /** - * @deprecated use timeout - */ - @Deprecated @ConfigurationField - @Getter(AccessLevel.PRIVATE) - private Integer timeoutInMilliseconds = null; - - @ConfigurationField - private Duration timeout = null; + private Duration timeout = DEFAULT_TIMEOUT; @ConfigurationField private String tlsCaCertPath = DEFAULT_TLS_CA_CERT_PATH; @@ -50,20 +40,4 @@ public class NatsConfiguration { @ConfigurationField private boolean tlsDisabled = DEFAULT_TLS_DISABLED; - - /** - * Maintain backward compatibility. Remove with timeoutInMilliseconds - * @return timeout as a Duration - */ - public final Duration getTimeout() { - if (timeout == null) { - if (timeoutInMilliseconds != null) { - timeout = Duration.ofMillis(timeoutInMilliseconds); - } else { - timeout = Duration.ofMillis(DEFAULT_TIMEOUT_IN_MILLISECONDS); - } - } - - return timeout; - } } diff --git a/message-broker-nats/src/test/groovy/com/mx/messaging/nats/NatsConfigurationTest.groovy b/message-broker-nats/src/test/groovy/com/mx/messaging/nats/NatsConfigurationTest.groovy index 2ed2fac..658fd09 100644 --- a/message-broker-nats/src/test/groovy/com/mx/messaging/nats/NatsConfigurationTest.groovy +++ b/message-broker-nats/src/test/groovy/com/mx/messaging/nats/NatsConfigurationTest.groovy @@ -18,13 +18,6 @@ class NatsConfigurationTest extends Specification { def subject = new NatsConfiguration() when: - subject.setTimeoutInMilliseconds(201) - - then: "uses timeoutInMilliseconds" - subject.getTimeout() == Duration.ofMillis(201) - - when: - subject.setTimeoutInMilliseconds(null) subject.setTimeout(Duration.ofSeconds(2)) then: "uses timeout" @@ -52,22 +45,6 @@ class NatsConfigurationTest extends Specification { when: configurations.tap { - put("timeoutInMilliseconds", 4000) - } - - result = binder.build(NatsConfiguration, configurations) - - then: - verifyAll(result) { - it.isEnabled() - it.getServers() == "nats://127.0.0.1:4223" - it.getDispatcherCount() == 9 - it.getTimeout() == Duration.ofSeconds(4) // uses timeoutInMilliseconds - } - - when: - configurations.tap { - remove("timeoutInMilliseconds") put("timeout", "11s") }