diff options
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test')
5 files changed, 28 insertions, 30 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/RoutingTest.java b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/RoutingTest.java index 7be90264d6..d2e75b1ac1 100644 --- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/RoutingTest.java +++ b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/RoutingTest.java @@ -113,7 +113,7 @@ public class RoutingTest { @Test public void testAudit() { String msg = "This is a test audit"; - logger.info(Markers.AUDIT, msg); + logger.info(Markers.EXIT, msg); TestAppender appender = result.get(AUDIT); Assert.assertTrue(appender.contains( (event) -> Level.INFO.equals(event.getLevel()) && msg.equals(event.getFormattedMessage()))); diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/logback/EventTypeDiscriminatorTest.java b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/logback/EventTypeDiscriminatorTest.java index 2a71f72063..2001e16264 100644 --- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/logback/EventTypeDiscriminatorTest.java +++ b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/logback/EventTypeDiscriminatorTest.java @@ -79,7 +79,7 @@ public class EventTypeDiscriminatorTest { EventTypeDiscriminator discriminator = new EventTypeDiscriminator(); LoggingEvent event = new LoggingEvent(); event.setLevel(Level.ERROR); - event.setMarker(Markers.AUDIT); + event.setMarker(Markers.EXIT); assertEquals(ERROR, discriminator.getDiscriminatingValue(event)); } @@ -97,7 +97,7 @@ public class EventTypeDiscriminatorTest { EventTypeDiscriminator discriminator = new EventTypeDiscriminator(); LoggingEvent event = new LoggingEvent(); event.setLevel(Level.WARN); - event.setMarker(Markers.AUDIT); + event.setMarker(Markers.EXIT); assertEquals(ERROR, discriminator.getDiscriminatingValue(event)); } @@ -115,7 +115,7 @@ public class EventTypeDiscriminatorTest { EventTypeDiscriminator discriminator = new EventTypeDiscriminator(); LoggingEvent event = new LoggingEvent(); event.setLevel(Level.DEBUG); - event.setMarker(Markers.AUDIT); + event.setMarker(Markers.EXIT); assertEquals(DEBUG, discriminator.getDiscriminatingValue(event)); } @@ -133,7 +133,7 @@ public class EventTypeDiscriminatorTest { EventTypeDiscriminator discriminator = new EventTypeDiscriminator(); LoggingEvent event = new LoggingEvent(); event.setLevel(Level.TRACE); - event.setMarker(Markers.AUDIT); + event.setMarker(Markers.EXIT); assertEquals(DEBUG, discriminator.getDiscriminatingValue(event)); } @@ -196,7 +196,7 @@ public class EventTypeDiscriminatorTest { EventTypeDiscriminator discriminator = new EventTypeDiscriminator(); LoggingEvent event = new LoggingEvent(); event.setLevel(Level.INFO); - event.setMarker(Markers.AUDIT); + event.setMarker(Markers.EXIT); assertEquals("Audit", discriminator.getDiscriminatingValue(event)); } diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/slf4j/LoggingContextTest.java b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/slf4j/LoggingContextTest.java index 1e7cfe834f..9ecd5567e0 100644 --- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/slf4j/LoggingContextTest.java +++ b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/slf4j/LoggingContextTest.java @@ -147,7 +147,7 @@ public class LoggingContextTest { String random = UUID.randomUUID().toString(); ContextData context = ContextData.builder().serviceName(random).build(); LoggingContext.put(context); - assertEquals(context, LoggingContext.get()); + assertEquals(context.getServiceName(), LoggingContext.get().getServiceName()); } @Test @@ -156,7 +156,7 @@ public class LoggingContextTest { String random = UUID.randomUUID().toString(); ContextData context = ContextData.builder().requestId(random).build(); LoggingContext.put(context); - assertEquals(context, LoggingContext.get()); + assertEquals(context.getRequestId(), LoggingContext.get().getRequestId()); } @Test @@ -165,7 +165,7 @@ public class LoggingContextTest { String random = UUID.randomUUID().toString(); ContextData context = ContextData.builder().partnerName(random).build(); LoggingContext.put(context); - assertEquals(context, LoggingContext.get()); + assertEquals(context.getPartnerName(), LoggingContext.get().getPartnerName()); } } diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/slf4j/RequestContextProviderTest.java b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/slf4j/RequestContextProviderTest.java index c4c1677637..e0f8e40e4b 100644 --- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/slf4j/RequestContextProviderTest.java +++ b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/slf4j/RequestContextProviderTest.java @@ -16,16 +16,14 @@ package org.openecomp.sdc.logging.slf4j; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - import java.util.Collections; import java.util.EnumMap; import java.util.Map; import org.junit.Test; import org.openecomp.sdc.logging.api.ContextData; +import static org.junit.Assert.*; + /** * Unit-test retrieving values from client-provided request data. * diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/slf4j/SLF4JLoggerWrapperTest.java b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/slf4j/SLF4JLoggerWrapperTest.java index c8ee347a8b..2b98fc898f 100644 --- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/slf4j/SLF4JLoggerWrapperTest.java +++ b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/slf4j/SLF4JLoggerWrapperTest.java @@ -19,6 +19,7 @@ package org.openecomp.sdc.logging.slf4j; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; +import static org.onap.logging.ref.slf4j.ONAPLogConstants.ResponseStatus.COMPLETE; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; @@ -28,7 +29,6 @@ import java.util.Map; import org.junit.Test; import org.openecomp.sdc.logging.api.AuditData; import org.openecomp.sdc.logging.api.MetricsData; -import org.openecomp.sdc.logging.api.StatusCode; import org.slf4j.Logger; import org.slf4j.MDC; import org.slf4j.Marker; @@ -44,7 +44,7 @@ public class SLF4JLoggerWrapperTest { @Test public void auditDoesNotFailWhenInputNull() { - new SLF4JLoggerWrapper(this.getClass()).audit(null); + new SLF4JLoggerWrapper(this.getClass()).auditExit(null); } @Test @@ -56,7 +56,7 @@ public class SLF4JLoggerWrapperTest { public void auditBeginTimeAvailableWhenPassed() { SpyLogger spy = createSpy(); long start = System.currentTimeMillis(); - new SLF4JLoggerWrapper(spy).audit(AuditData.builder().startTime(start).build()); + new SLF4JLoggerWrapper(spy).auditExit(AuditData.builder().startTime(start).build()); assertNotNull(spy.mdc().get(AuditField.BEGIN_TIMESTAMP.asKey())); } @@ -72,7 +72,7 @@ public class SLF4JLoggerWrapperTest { public void auditEndTimeAvailableWhenPassed() { SpyLogger spy = createSpy(); long end = System.currentTimeMillis(); - new SLF4JLoggerWrapper(spy).audit(AuditData.builder().endTime(end).build()); + new SLF4JLoggerWrapper(spy).auditExit(AuditData.builder().endTime(end).build()); assertNotNull(spy.mdc().get(AuditField.END_TIMESTAMP.asKey())); } @@ -88,7 +88,7 @@ public class SLF4JLoggerWrapperTest { public void auditElapsedTimeAvailableWhenPassed() { SpyLogger spy = createSpy(); long start = System.currentTimeMillis(); - new SLF4JLoggerWrapper(spy).audit(AuditData.builder() + new SLF4JLoggerWrapper(spy).auditExit(AuditData.builder() .startTime(start).endTime(start + 777).build()); assertEquals("777", spy.mdc().get(AuditField.ELAPSED_TIME.asKey())); } @@ -105,21 +105,21 @@ public class SLF4JLoggerWrapperTest { @Test public void auditStatusCodeAvailableWhenPassed() { SpyLogger spy = createSpy(); - new SLF4JLoggerWrapper(spy).audit(AuditData.builder().statusCode(StatusCode.COMPLETE).build()); - assertEquals(StatusCode.COMPLETE.name(), spy.mdc().get(AuditField.STATUS_CODE.asKey())); + new SLF4JLoggerWrapper(spy).auditExit(AuditData.builder().statusCode(COMPLETE).build()); + assertEquals(COMPLETE.name(), spy.mdc().get(AuditField.STATUS_CODE.asKey())); } @Test public void metricsStatusCodeAvailableWhenPassed() { SpyLogger spy = createSpy(); - new SLF4JLoggerWrapper(spy).metrics(MetricsData.builder().statusCode(StatusCode.COMPLETE).build()); - assertEquals(StatusCode.COMPLETE.name(), spy.mdc().get(MetricsField.STATUS_CODE.asKey())); + new SLF4JLoggerWrapper(spy).metrics(MetricsData.builder().statusCode(COMPLETE).build()); + assertEquals(COMPLETE.name(), spy.mdc().get(MetricsField.STATUS_CODE.asKey())); } @Test public void auditStatusCodeEmptyWhenNotPassed() { SpyLogger spy = createSpy(); - new SLF4JLoggerWrapper(spy).audit(AuditData.builder().build()); + new SLF4JLoggerWrapper(spy).auditExit(AuditData.builder().build()); assertNull(spy.mdc().get(AuditField.STATUS_CODE.asKey())); } @@ -134,7 +134,7 @@ public class SLF4JLoggerWrapperTest { public void auditResponseCodeAvailableWhenPassed() { final String responseCode = "AuditSpyResponse"; SpyLogger spy = createSpy(); - new SLF4JLoggerWrapper(spy).audit(AuditData.builder().responseCode(responseCode).build()); + new SLF4JLoggerWrapper(spy).auditExit(AuditData.builder().responseCode(responseCode).build()); assertEquals(responseCode, spy.mdc().get(AuditField.RESPONSE_CODE.asKey())); } @@ -149,7 +149,7 @@ public class SLF4JLoggerWrapperTest { @Test public void auditResponseCodeEmptyWhenNotPassed() { SpyLogger spy = createSpy(); - new SLF4JLoggerWrapper(spy).audit(AuditData.builder().build()); + new SLF4JLoggerWrapper(spy).auditExit(AuditData.builder().build()); assertNull(spy.mdc().get(AuditField.RESPONSE_CODE.asKey())); } @@ -164,7 +164,7 @@ public class SLF4JLoggerWrapperTest { public void auditResponseDescriptionAvailableWhenPassed() { final String responseDescription = "AuditSpyDescription"; SpyLogger spy = createSpy(); - new SLF4JLoggerWrapper(spy).audit(AuditData.builder().responseDescription(responseDescription).build()); + new SLF4JLoggerWrapper(spy).auditExit(AuditData.builder().responseDescription(responseDescription).build()); assertEquals(responseDescription, spy.mdc().get(AuditField.RESPONSE_DESCRIPTION.asKey())); } @@ -179,7 +179,7 @@ public class SLF4JLoggerWrapperTest { @Test public void auditResponseDescriptionEmptyWhenNotPassed() { SpyLogger spy = createSpy(); - new SLF4JLoggerWrapper(spy).audit(AuditData.builder().build()); + new SLF4JLoggerWrapper(spy).auditExit(AuditData.builder().build()); assertNull(spy.mdc().get(AuditField.RESPONSE_DESCRIPTION.asKey())); } @@ -194,7 +194,7 @@ public class SLF4JLoggerWrapperTest { public void auditClientIpAddressAvailableWhenPassed() { final String ipAddress = "10.56.20.20"; SpyLogger spy = createSpy(); - new SLF4JLoggerWrapper(spy).audit(AuditData.builder().clientIpAddress(ipAddress).build()); + new SLF4JLoggerWrapper(spy).auditExit(AuditData.builder().clientIpAddress(ipAddress).build()); assertEquals(ipAddress, spy.mdc().get(AuditField.CLIENT_IP_ADDRESS.asKey())); } @@ -209,7 +209,7 @@ public class SLF4JLoggerWrapperTest { @Test public void auditClientIpAddressEmptyWhenNotPassed() { SpyLogger spy = createSpy(); - new SLF4JLoggerWrapper(spy).audit(AuditData.builder().build()); + new SLF4JLoggerWrapper(spy).auditExit(AuditData.builder().build()); assertNull(spy.mdc().get(AuditField.CLIENT_IP_ADDRESS.asKey())); } @@ -294,7 +294,7 @@ public class SLF4JLoggerWrapperTest { } private boolean isAuditMethod(Method method, Object[] args) { - return isSpecialLogMethod(method, args, Markers.AUDIT); + return isSpecialLogMethod(method, args, Markers.EXIT); } private boolean isSpecialLogMethod(Method method, Object[] args, Marker marker) { |