X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=policy-agent%2Fsrc%2Ftest%2Fjava%2Forg%2Foransc%2Fpolicyagent%2Ftasks%2FEnvironmentProcessorTest.java;h=efabba386baaafcdcfd78fe84b62704a3ddec6cd;hb=a26055e5007e75a5aa9551305ea4da211e80df14;hp=c22629b4bc246224cab982066c72b43137cde9b0;hpb=af0bd57583b2ea2b408b9fa1ca7c0c36e4a45757;p=nonrtric.git diff --git a/policy-agent/src/test/java/org/oransc/policyagent/tasks/EnvironmentProcessorTest.java b/policy-agent/src/test/java/org/oransc/policyagent/tasks/EnvironmentProcessorTest.java index c22629b4..efabba38 100644 --- a/policy-agent/src/test/java/org/oransc/policyagent/tasks/EnvironmentProcessorTest.java +++ b/policy-agent/src/test/java/org/oransc/policyagent/tasks/EnvironmentProcessorTest.java @@ -20,9 +20,9 @@ package org.oransc.policyagent.tasks; +import static ch.qos.logback.classic.Level.WARN; import static org.assertj.core.api.Assertions.assertThat; -import ch.qos.logback.classic.Level; import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.core.read.ListAppender; @@ -35,7 +35,7 @@ import org.oransc.policyagent.exceptions.EnvironmentLoaderException; import org.oransc.policyagent.utils.LoggingUtils; import reactor.test.StepVerifier; -public class EnvironmentProcessorTest { +class EnvironmentProcessorTest { private static final String CONSUL_HOST = "CONSUL_HOST"; private static final String CONSUL_HOST_VALUE = "consulHost"; @@ -46,7 +46,7 @@ public class EnvironmentProcessorTest { private static final String HOSTNAME_VALUE = "hostname"; @Test - public void allPropertiesAvailableWithHostname_thenAllPropertiesAreReturnedWithGivenConsulPort() { + void allPropertiesAvailableWithHostname_thenAllPropertiesAreReturnedWithGivenConsulPort() { Properties systemEnvironment = new Properties(); String consulPort = "8080"; systemEnvironment.put(CONSUL_HOST, CONSUL_HOST_VALUE); @@ -66,7 +66,7 @@ public class EnvironmentProcessorTest { } @Test - public void consulHostMissing_thenExceptionReturned() { + void consulHostMissing_thenExceptionReturned() { Properties systemEnvironment = new Properties(); StepVerifier.create(EnvironmentProcessor.readEnvironmentVariables(systemEnvironment)) @@ -76,7 +76,7 @@ public class EnvironmentProcessorTest { } @Test - public void withAllPropertiesExceptConsulPort_thenAllPropertiesAreReturnedWithDefaultConsulPortAndWarning() { + void withAllPropertiesExceptConsulPort_thenAllPropertiesAreReturnedWithDefaultConsulPortAndWarning() { Properties systemEnvironment = new Properties(); systemEnvironment.put(CONSUL_HOST, CONSUL_HOST_VALUE); systemEnvironment.put(CONFIG_BINDING_SERVICE, CONFIG_BINDING_SERVICE_VALUE); @@ -90,18 +90,18 @@ public class EnvironmentProcessorTest { .appName(HOSTNAME_VALUE) // .build(); - final ListAppender logAppender = LoggingUtils.getLogListAppender(EnvironmentProcessor.class); + final ListAppender logAppender = + LoggingUtils.getLogListAppender(EnvironmentProcessor.class, WARN); StepVerifier.create(EnvironmentProcessor.readEnvironmentVariables(systemEnvironment)) .expectNext(expectedEnvProperties).expectComplete(); - assertThat(logAppender.list.get(0).getLevel()).isEqualTo(Level.WARN); - assertThat(logAppender.list.toString() - .contains("$CONSUL_PORT variable will be set to default port " + defaultConsulPort)).isTrue(); + assertThat(logAppender.list.get(0).getFormattedMessage()) + .isEqualTo("$CONSUL_PORT variable will be set to default port " + defaultConsulPort); } @Test - public void configBindingServiceMissing_thenExceptionReturned() { + void configBindingServiceMissing_thenExceptionReturned() { Properties systemEnvironment = new Properties(); systemEnvironment.put(CONSUL_HOST, CONSUL_HOST_VALUE); @@ -112,7 +112,7 @@ public class EnvironmentProcessorTest { } @Test - public void allPropertiesAvailableWithServiceName_thenAllPropertiesAreReturned() { + void allPropertiesAvailableWithServiceName_thenAllPropertiesAreReturned() { Properties systemEnvironment = new Properties(); String consulPort = "8080"; systemEnvironment.put(CONSUL_HOST, CONSUL_HOST_VALUE); @@ -132,7 +132,7 @@ public class EnvironmentProcessorTest { } @Test - public void serviceNameAndHostnameMissing_thenExceptionIsReturned() { + void serviceNameAndHostnameMissing_thenExceptionIsReturned() { Properties systemEnvironment = new Properties(); systemEnvironment.put(CONSUL_HOST, CONSUL_HOST_VALUE); systemEnvironment.put(CONFIG_BINDING_SERVICE, CONFIG_BINDING_SERVICE_VALUE);