aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/test/java
diff options
context:
space:
mode:
authorEylon Malin <eylon.malin@intl.att.com>2019-09-12 12:21:34 +0300
committerEylon Malin <eylon.malin@intl.att.com>2019-09-12 12:21:34 +0300
commit079dfc9647074f7e40c8b5fe3eac5bd2b50ade0c (patch)
tree7b27aba211972394aa60e3bf09a0e2bf53074244 /vid-app-common/src/test/java
parentca6f40516028602d3551856301cd9d7cda65f812 (diff)
add UT to logRequest of Logging
Issue-ID: VID-611 Signed-off-by: Eylon Malin <eylon.malin@intl.att.com> Change-Id: Ibbe32350b2a6ce02a833ab65346afde9e85fc6e2
Diffstat (limited to 'vid-app-common/src/test/java')
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/utils/LoggingUtilsTest.java49
1 files changed, 39 insertions, 10 deletions
diff --git a/vid-app-common/src/test/java/org/onap/vid/utils/LoggingUtilsTest.java b/vid-app-common/src/test/java/org/onap/vid/utils/LoggingUtilsTest.java
index ae769a322..c22b59c69 100644
--- a/vid-app-common/src/test/java/org/onap/vid/utils/LoggingUtilsTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/utils/LoggingUtilsTest.java
@@ -20,27 +20,56 @@
package org.onap.vid.utils;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.mockito.ArgumentMatchers.contains;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.onap.vid.testUtils.RegExMatcher.matchesRegEx;
+import static org.testng.AssertJUnit.assertEquals;
+
+import com.att.eelf.configuration.EELFLogger;
import com.fasterxml.jackson.core.JsonLocation;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.security.UnrecoverableKeyException;
+import java.security.cert.CertificateException;
+import javax.crypto.BadPaddingException;
+import javax.net.ssl.SSLHandshakeException;
+import javax.ws.rs.ProcessingException;
+import org.mockito.ArgumentCaptor;
import org.onap.vid.exceptions.GenericUncheckedException;
+import org.springframework.http.HttpMethod;
+import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import sun.security.provider.certpath.SunCertPathBuilderException;
import sun.security.validator.ValidatorException;
-import javax.crypto.BadPaddingException;
-import javax.net.ssl.SSLHandshakeException;
-import javax.ws.rs.ProcessingException;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.security.UnrecoverableKeyException;
-import java.security.cert.CertificateException;
+public class LoggingUtilsTest {
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.onap.vid.testUtils.RegExMatcher.matchesRegEx;
+ private EELFLogger loggerMock;
-public class LoggingUtilsTest {
+ private Logging logginService = new Logging();
+
+ @BeforeMethod
+ public void setUp() {
+ loggerMock = mock(EELFLogger.class);
+ }
+
+ @Test
+ public void whenLogRequest_thenLoggedInDebug() {
+ //when
+ String url = "someUrl";
+ logginService.logRequest(loggerMock, HttpMethod.GET, url);
+
+ //then
+ ArgumentCaptor<Object> argumentCaptor = ArgumentCaptor.forClass(Object.class);
+ verify(loggerMock).debug(contains("Sending"), argumentCaptor.capture());
+ assertEquals("GET", argumentCaptor.getAllValues().get(0));
+ assertEquals(url, argumentCaptor.getAllValues().get(1));
+ }
@DataProvider
public static Object[][] exceptions() {