From 1e61754c29fc99636de692a0fb9d2ef1a4ba9e61 Mon Sep 17 00:00:00 2001 From: "Ben David, Elad (eb7504)" Date: Sun, 3 Nov 2019 17:22:48 +0200 Subject: Align logging to Onap-ELS 2019.11 Change-Id: I1750493d5c9f2eab8c1395f0fbc9ae66cf74b0a6 Issue-ID: SDC-2639 Signed-off-by: Ben David, Elad (eb7504) --- .../java/org/openecomp/sdc/logging/api/AuditDataTest.java | 5 +++-- .../org/openecomp/sdc/logging/api/LoggerFactoryTest.java | 2 +- .../org/openecomp/sdc/logging/api/MetricsDataTest.java | 5 +++-- .../openecomp/sdc/logging/servlet/AuditTrackerTest.java | 14 +++++++------- .../openecomp/sdc/logging/servlet/ContextTrackerTest.java | 4 ++-- 5 files changed, 16 insertions(+), 14 deletions(-) (limited to 'openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/test/java/org/openecomp') diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/test/java/org/openecomp/sdc/logging/api/AuditDataTest.java b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/test/java/org/openecomp/sdc/logging/api/AuditDataTest.java index 98da27dcc5..b4e2d96348 100644 --- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/test/java/org/openecomp/sdc/logging/api/AuditDataTest.java +++ b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/test/java/org/openecomp/sdc/logging/api/AuditDataTest.java @@ -18,6 +18,7 @@ package org.openecomp.sdc.logging.api; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; +import static org.onap.logging.ref.slf4j.ONAPLogConstants.ResponseStatus.COMPLETE; import org.junit.Test; @@ -38,7 +39,7 @@ public class AuditDataTest { final String responseDescription = "Response-Description"; final String ipAddress = "DUMMY.IP.ADDRESS"; - AuditData data = AuditData.builder().startTime(start).endTime(end).statusCode(StatusCode.COMPLETE) + AuditData data = AuditData.builder().startTime(start).endTime(end).statusCode(COMPLETE) .responseCode(responseCode).responseDescription(responseDescription) .clientIpAddress(ipAddress).build(); @@ -47,7 +48,7 @@ public class AuditDataTest { assertEquals(start, data.getStartTime()); assertEquals(responseCode, data.getResponseCode()); assertEquals(responseDescription, data.getResponseDescription()); - assertEquals(StatusCode.COMPLETE, data.getStatusCode()); + assertEquals(COMPLETE, data.getStatusCode()); } @Test diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/test/java/org/openecomp/sdc/logging/api/LoggerFactoryTest.java b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/test/java/org/openecomp/sdc/logging/api/LoggerFactoryTest.java index 6f860af60a..e6998f35e8 100644 --- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/test/java/org/openecomp/sdc/logging/api/LoggerFactoryTest.java +++ b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/test/java/org/openecomp/sdc/logging/api/LoggerFactoryTest.java @@ -71,7 +71,7 @@ public class LoggerFactoryTest { logger.warn(""); logger.info(""); logger.debug(""); - logger.audit(null); + logger.auditExit(null); logger.metrics(MetricsData.builder().build()); } } diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/test/java/org/openecomp/sdc/logging/api/MetricsDataTest.java b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/test/java/org/openecomp/sdc/logging/api/MetricsDataTest.java index 43f913ecab..9c9aa81bc7 100644 --- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/test/java/org/openecomp/sdc/logging/api/MetricsDataTest.java +++ b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/test/java/org/openecomp/sdc/logging/api/MetricsDataTest.java @@ -18,6 +18,7 @@ package org.openecomp.sdc.logging.api; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; +import static org.onap.logging.ref.slf4j.ONAPLogConstants.ResponseStatus.COMPLETE; import org.junit.Test; @@ -40,7 +41,7 @@ public class MetricsDataTest { final String targetEntity = "Metrics-Target-Entity"; final String targetVirtualEntity = "Metrics-Target-Virtual-Entity"; - MetricsData data = MetricsData.builder().startTime(start).endTime(end).statusCode(StatusCode.COMPLETE) + MetricsData data = MetricsData.builder().startTime(start).endTime(end).statusCode(COMPLETE) .responseCode(responseCode).responseDescription(responseDescription) .clientIpAddress(ipAddress).targetEntity(targetEntity) .targetVirtualEntity(targetVirtualEntity).build(); @@ -50,7 +51,7 @@ public class MetricsDataTest { assertEquals(start, data.getStartTime()); assertEquals(responseCode, data.getResponseCode()); assertEquals(responseDescription, data.getResponseDescription()); - assertEquals(StatusCode.COMPLETE, data.getStatusCode()); + assertEquals(COMPLETE, data.getStatusCode()); assertEquals(targetEntity, data.getTargetEntity()); assertEquals(targetVirtualEntity, data.getTargetVirtualEntity()); diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/test/java/org/openecomp/sdc/logging/servlet/AuditTrackerTest.java b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/test/java/org/openecomp/sdc/logging/servlet/AuditTrackerTest.java index 1bd13a9dfd..36c0957069 100644 --- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/test/java/org/openecomp/sdc/logging/servlet/AuditTrackerTest.java +++ b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/test/java/org/openecomp/sdc/logging/servlet/AuditTrackerTest.java @@ -27,9 +27,9 @@ import static org.mockito.Mockito.when; import javax.servlet.http.HttpServletRequest; import org.junit.Test; import org.mockito.ArgumentCaptor; +import org.onap.logging.ref.slf4j.ONAPLogConstants.ResponseStatus; import org.openecomp.sdc.logging.api.AuditData; import org.openecomp.sdc.logging.api.Logger; -import org.openecomp.sdc.logging.api.StatusCode; /** * Test initialization and of audit tracker and log invocation. @@ -73,7 +73,7 @@ public class AuditTrackerTest { tracker.preRequest(mock(HttpServletRequest.class)); tracker.postRequest(mock(RequestProcessingResult.class)); - verify(logger, never()).audit(any(AuditData.class)); + verify(logger, never()).auditExit(any(AuditData.class)); } @Test @@ -87,7 +87,7 @@ public class AuditTrackerTest { tracker.postRequest(mock(RequestProcessingResult.class)); ArgumentCaptor auditDataCaptor = ArgumentCaptor.forClass(AuditData.class); - verify(logger).audit(auditDataCaptor.capture()); + verify(logger).auditExit(auditDataCaptor.capture()); assertTrue(auditDataCaptor.getValue().getEndTime() > 0); } @@ -104,7 +104,7 @@ public class AuditTrackerTest { tracker.postRequest(result); ArgumentCaptor auditDataCaptor = ArgumentCaptor.forClass(AuditData.class); - verify(logger).audit(auditDataCaptor.capture()); + verify(logger).auditExit(auditDataCaptor.capture()); AuditData capturedAuditData = auditDataCaptor.getValue(); assertEquals(Integer.toString(result.getStatus()), capturedAuditData.getResponseCode()); @@ -127,7 +127,7 @@ public class AuditTrackerTest { tracker.postRequest(mock(RequestProcessingResult.class)); ArgumentCaptor auditDataCaptor = ArgumentCaptor.forClass(AuditData.class); - verify(logger).audit(auditDataCaptor.capture()); + verify(logger).auditExit(auditDataCaptor.capture()); AuditData capturedAuditData = auditDataCaptor.getValue(); assertEquals(address, capturedAuditData.getClientIpAddress()); @@ -141,8 +141,8 @@ public class AuditTrackerTest { } @Override - public StatusCode getStatusCode() { - return StatusCode.ERROR; + public ResponseStatus getStatusCode() { + return ResponseStatus.ERROR; } @Override diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/test/java/org/openecomp/sdc/logging/servlet/ContextTrackerTest.java b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/test/java/org/openecomp/sdc/logging/servlet/ContextTrackerTest.java index 59c690d763..f1066c447b 100644 --- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/test/java/org/openecomp/sdc/logging/servlet/ContextTrackerTest.java +++ b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/test/java/org/openecomp/sdc/logging/servlet/ContextTrackerTest.java @@ -119,7 +119,7 @@ public class ContextTrackerTest { } @Test - public void partnerNameAbsentWhenNotGiven() { + public void partnerNameIsUnknownWhenNotGiven() { mockStatic(LoggingContext.class); @@ -131,7 +131,7 @@ public class ContextTrackerTest { LoggingContext.put(contextDataCaptor.capture()); - assertNull(contextDataCaptor.getValue().getPartnerName()); + assertEquals(contextDataCaptor.getValue().getPartnerName(), "UNKNOWN"); } @Test -- cgit 1.2.3-korg