summaryrefslogtreecommitdiffstats
path: root/aai-els-onap-logging/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'aai-els-onap-logging/src/test/java')
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/aai/aailog/filter/AaiAuditLogContainerFilterTest.java27
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/aai/aailog/filter/RestClientLoggingInterceptorTest.java119
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/aai/aailog/filter/RestControllerClientLoggingInterceptorTest.java126
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/aai/domain/restResponseInfo/InfoTest.java7
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/aai/domain/restResponseInfo/ObjectFactoryTest.java10
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/aai/exceptions/AAIExceptionTest.java25
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/aai/exceptions/AAIExceptionWithInfoTest.java17
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/aai/logging/CNNameTest.java32
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/aai/logging/CustomLogPatternLayoutTest.java6
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/aai/logging/DME2RestFlagTest.java13
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorLogHelperTest.java62
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorObjectFormatExceptionTest.java4
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorObjectNotFoundExceptionTest.java38
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorObjectTest.java24
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/aai/logging/LogFormatToolsTest.java6
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/aai/logging/LoggingContextTest.java13
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/aai/logging/StopWatchNotStartedExceptionTest.java8
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/aai/logging/StopWatchTest.java11
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/aai/util/AAIApplicationConfigTest.java12
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/aai/util/AAIConfigTest.java6
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/aai/util/FormatDateTest.java5
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/aai/util/LogFile.java10
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/AuditLogContainerFilterTest.java3
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/AuditLogServletFilterTest.java3
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/LoggingContainerFilterTest.java2
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/MDCSetupTest.java3
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/MetricLogClientFilterTest.java5
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/PayloadLoggingClientFilterTest.java3
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/SimpleJaxrsHeadersMapTest.java2
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/SimpleServletHeadersMapTest.java2
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/logging/ref/slf4j/ONAPLogAdapterTest.java103
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/logging/ref/slf4j/ONAPLogConstantsTest.java20
32 files changed, 391 insertions, 336 deletions
diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/aailog/filter/AaiAuditLogContainerFilterTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/aailog/filter/AaiAuditLogContainerFilterTest.java
index 5f23e668..246586d0 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/aai/aailog/filter/AaiAuditLogContainerFilterTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/aai/aailog/filter/AaiAuditLogContainerFilterTest.java
@@ -17,8 +17,20 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.aailog.filter;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.when;
+
+import java.net.URI;
+
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.container.ContainerResponseContext;
+import javax.ws.rs.core.MultivaluedHashMap;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.UriInfo;
+
import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -30,16 +42,6 @@ import org.onap.logging.filter.base.Constants;
import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.slf4j.MDC;
-import javax.ws.rs.container.ContainerRequestContext;
-import javax.ws.rs.container.ContainerResponseContext;
-import javax.ws.rs.core.MultivaluedHashMap;
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.core.UriInfo;
-import java.net.URI;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.when;
-
@RunWith(MockitoJUnitRunner.class)
public class AaiAuditLogContainerFilterTest {
@Mock
@@ -59,6 +61,7 @@ public class AaiAuditLogContainerFilterTest {
public void tearDown() {
MDC.clear();
}
+
@Test
public void partnerAndServiceNameValueTest() throws java.net.URISyntaxException {
@@ -69,8 +72,7 @@ public class AaiAuditLogContainerFilterTest {
URI uri = null;
try {
uri = new URI("https://localhost:9999/onap/aai/network/logical-link");
- }
- catch (java.net.URISyntaxException e) {
+ } catch (java.net.URISyntaxException e) {
throw e;
}
when(uriInfo.getAbsolutePath()).thenReturn(uri);
@@ -82,4 +84,3 @@ public class AaiAuditLogContainerFilterTest {
}
}
-
diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/aailog/filter/RestClientLoggingInterceptorTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/aailog/filter/RestClientLoggingInterceptorTest.java
index 601a13be..f8d23f39 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/aai/aailog/filter/RestClientLoggingInterceptorTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/aai/aailog/filter/RestClientLoggingInterceptorTest.java
@@ -17,8 +17,18 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.aailog.filter;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Mockito.doReturn;
+
+import java.net.InetAddress;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.UnknownHostException;
+
import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -32,75 +42,66 @@ import org.slf4j.MDC;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpRequest;
-import java.net.InetAddress;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.UnknownHostException;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Mockito.doReturn;
-
@RunWith(MockitoJUnitRunner.class)
public class RestClientLoggingInterceptorTest {
- @Mock
- private HttpRequest httpRequest;
+ @Mock
+ private HttpRequest httpRequest;
- @Spy
- @InjectMocks
- private RestClientLoggingInterceptor restClientLoggingInterceptor;
+ @Spy
+ @InjectMocks
+ private RestClientLoggingInterceptor restClientLoggingInterceptor;
- @After
- public void tearDown() {
- MDC.clear();
- }
+ @After
+ public void tearDown() {
+ MDC.clear();
+ }
- @Test
- public void setupHeadersTest() {
- String transId="37b3ab2a-e57e-4fe8-8d8f-eee3019efce6";
- HttpHeaders headers = new HttpHeaders();
- headers.add(Constants.HttpHeaders.TRANSACTION_ID, transId);
- restClientLoggingInterceptor.setupHeaders(httpRequest, headers);
+ @Test
+ public void setupHeadersTest() {
+ String transId = "37b3ab2a-e57e-4fe8-8d8f-eee3019efce6";
+ HttpHeaders headers = new HttpHeaders();
+ headers.add(Constants.HttpHeaders.TRANSACTION_ID, transId);
+ restClientLoggingInterceptor.setupHeaders(httpRequest, headers);
- assertEquals(transId, headers.getFirst(Constants.HttpHeaders.TRANSACTION_ID));
- assertEquals(transId, headers.getFirst(Constants.HttpHeaders.ECOMP_REQUEST_ID));
- assertEquals(transId, headers.getFirst(ONAPLogConstants.Headers.REQUEST_ID));
- assertEquals(transId, headers.getFirst(Constants.HttpHeaders.HEADER_REQUEST_ID));
- }
+ assertEquals(transId, headers.getFirst(Constants.HttpHeaders.TRANSACTION_ID));
+ assertEquals(transId, headers.getFirst(Constants.HttpHeaders.ECOMP_REQUEST_ID));
+ assertEquals(transId, headers.getFirst(ONAPLogConstants.Headers.REQUEST_ID));
+ assertEquals(transId, headers.getFirst(Constants.HttpHeaders.HEADER_REQUEST_ID));
+ }
- @Test
- public void getServiceNameTest() throws URISyntaxException {
- URI uri = null;
- try {
- uri = new URI("https://localhost:9999/aai/v1/cloud-infrastructure/complexes/complex/complex-1");
- } catch (URISyntaxException e) {
- throw e;
- }
- doReturn(uri).when(httpRequest).getURI();
- String serviceName = restClientLoggingInterceptor.getServiceName(httpRequest);
-
- assertEquals("/aai/v1/cloud-infrastructure/complexes", serviceName);
+ @Test
+ public void getServiceNameTest() throws URISyntaxException {
+ URI uri = null;
+ try {
+ uri = new URI("https://localhost:9999/aai/v1/cloud-infrastructure/complexes/complex/complex-1");
+ } catch (URISyntaxException e) {
+ throw e;
}
+ doReturn(uri).when(httpRequest).getURI();
+ String serviceName = restClientLoggingInterceptor.getServiceName(httpRequest);
+
+ assertEquals("/aai/v1/cloud-infrastructure/complexes", serviceName);
+ }
- @Test
- public void setupMDCTest() throws URISyntaxException {
- URI uri = new URI("https://localhost:9999/aai/v1/cloud-infrastructure/complexes/complex/complex-1");
- doReturn(uri).when(httpRequest).getURI();
- HttpHeaders headers = new HttpHeaders();
- restClientLoggingInterceptor.pre(httpRequest, headers);
- assertEquals("/aai/v1/cloud-infrastructure/complexes", MDC.get(ONAPLogConstants.MDCs.TARGET_SERVICE_NAME) );
- assertEquals("INPROGRESS", MDC.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE));
- String serverFQDN = "";
- InetAddress addr = null;
- try {
- addr = InetAddress.getLocalHost();
- serverFQDN = addr.getCanonicalHostName();
+ @Test
+ public void setupMDCTest() throws URISyntaxException {
+ URI uri = new URI("https://localhost:9999/aai/v1/cloud-infrastructure/complexes/complex/complex-1");
+ doReturn(uri).when(httpRequest).getURI();
+ HttpHeaders headers = new HttpHeaders();
+ restClientLoggingInterceptor.pre(httpRequest, headers);
+ assertEquals("/aai/v1/cloud-infrastructure/complexes", MDC.get(ONAPLogConstants.MDCs.TARGET_SERVICE_NAME));
+ assertEquals("INPROGRESS", MDC.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE));
+ String serverFQDN = "";
+ InetAddress addr = null;
+ try {
+ addr = InetAddress.getLocalHost();
+ serverFQDN = addr.getCanonicalHostName();
- } catch (UnknownHostException e) {
- serverFQDN = "";
- }
- assertEquals(serverFQDN, MDC.get(ONAPLogConstants.MDCs.SERVER_FQDN));
- assertNotNull(headers.getFirst(ONAPLogConstants.Headers.INVOCATION_ID));
+ } catch (UnknownHostException e) {
+ serverFQDN = "";
}
+ assertEquals(serverFQDN, MDC.get(ONAPLogConstants.MDCs.SERVER_FQDN));
+ assertNotNull(headers.getFirst(ONAPLogConstants.Headers.INVOCATION_ID));
+ }
}
diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/aailog/filter/RestControllerClientLoggingInterceptorTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/aailog/filter/RestControllerClientLoggingInterceptorTest.java
index 48cb3efc..9c4b2655 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/aai/aailog/filter/RestControllerClientLoggingInterceptorTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/aai/aailog/filter/RestControllerClientLoggingInterceptorTest.java
@@ -17,91 +17,91 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.aailog.filter;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
import com.sun.jersey.api.client.ClientRequest;
+
+import java.net.InetAddress;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.UnknownHostException;
+
+import javax.ws.rs.core.MultivaluedHashMap;
+import javax.ws.rs.core.MultivaluedMap;
+
import org.junit.After;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
-import org.mockito.Mock;
import org.mockito.Spy;
import org.mockito.junit.MockitoJUnitRunner;
import org.onap.logging.filter.base.Constants;
import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.slf4j.MDC;
-import javax.ws.rs.core.MultivaluedHashMap;
-import javax.ws.rs.core.MultivaluedMap;
-import java.net.InetAddress;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.UnknownHostException;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Mockito.doReturn;
-
@RunWith(MockitoJUnitRunner.class)
public class RestControllerClientLoggingInterceptorTest {
- private ClientRequest clientRequest;
+ private ClientRequest clientRequest;
- @Spy
- @InjectMocks
- private RestControllerClientLoggingInterceptor restControllerClientLoggingInterceptor;
+ @Spy
+ @InjectMocks
+ private RestControllerClientLoggingInterceptor restControllerClientLoggingInterceptor;
- @Before
- public void init() throws URISyntaxException {
- System.setProperty("javax.ws.rs.ext.RuntimeDelegate", "com.sun.ws.rs.ext.RuntimeDelegateImpl");
- clientRequest = ClientRequest.create().build(new URI("https://localhost:9999/aai/v1/cloud-infrastructure/complexes/complex/complex-1"),
- "GET");
- }
+ @Before
+ public void init() throws URISyntaxException {
+ System.setProperty("javax.ws.rs.ext.RuntimeDelegate", "com.sun.ws.rs.ext.RuntimeDelegateImpl");
+ clientRequest = ClientRequest.create().build(
+ new URI("https://localhost:9999/aai/v1/cloud-infrastructure/complexes/complex/complex-1"), "GET");
+ }
- @After
- public void tearDown() {
- MDC.clear();
- }
+ @After
+ public void tearDown() {
+ MDC.clear();
+ }
- @Test
- public void setupHeadersTest() throws java.net.URISyntaxException {
-
- String transId="37b3ab2a-e57e-4fe8-8d8f-eee3019efce6";
- MultivaluedMap<String, Object> requestHeaders = new MultivaluedHashMap<String, Object>();
- requestHeaders.add(Constants.HttpHeaders.TRANSACTION_ID, transId);
- clientRequest.getHeaders().putAll(requestHeaders);
- restControllerClientLoggingInterceptor.pre(clientRequest);
- MultivaluedMap<String, Object> headers = clientRequest.getHeaders();
-
- assertEquals(transId, headers.getFirst(Constants.HttpHeaders.TRANSACTION_ID));
- assertEquals(transId, headers.getFirst(Constants.HttpHeaders.ECOMP_REQUEST_ID));
- assertEquals(transId, headers.getFirst(ONAPLogConstants.Headers.REQUEST_ID));
- assertEquals(transId, headers.getFirst(Constants.HttpHeaders.HEADER_REQUEST_ID));
- assertNotNull(headers.getFirst(ONAPLogConstants.Headers.INVOCATION_ID));
- }
+ @Test
+ public void setupHeadersTest() throws java.net.URISyntaxException {
- @Test
- public void getServiceNameTest() {
- String serviceName = restControllerClientLoggingInterceptor.getServiceName(clientRequest);
- assertEquals("/aai/v1/cloud-infrastructure/complexes", serviceName);
- }
+ String transId = "37b3ab2a-e57e-4fe8-8d8f-eee3019efce6";
+ MultivaluedMap<String, Object> requestHeaders = new MultivaluedHashMap<String, Object>();
+ requestHeaders.add(Constants.HttpHeaders.TRANSACTION_ID, transId);
+ clientRequest.getHeaders().putAll(requestHeaders);
+ restControllerClientLoggingInterceptor.pre(clientRequest);
+ MultivaluedMap<String, Object> headers = clientRequest.getHeaders();
+
+ assertEquals(transId, headers.getFirst(Constants.HttpHeaders.TRANSACTION_ID));
+ assertEquals(transId, headers.getFirst(Constants.HttpHeaders.ECOMP_REQUEST_ID));
+ assertEquals(transId, headers.getFirst(ONAPLogConstants.Headers.REQUEST_ID));
+ assertEquals(transId, headers.getFirst(Constants.HttpHeaders.HEADER_REQUEST_ID));
+ assertNotNull(headers.getFirst(ONAPLogConstants.Headers.INVOCATION_ID));
+ }
+
+ @Test
+ public void getServiceNameTest() {
+ String serviceName = restControllerClientLoggingInterceptor.getServiceName(clientRequest);
+ assertEquals("/aai/v1/cloud-infrastructure/complexes", serviceName);
+ }
+
+ @Test
+ public void setupMDCTest() throws URISyntaxException {
+ restControllerClientLoggingInterceptor.pre(clientRequest);
+ assertEquals("/aai/v1/cloud-infrastructure/complexes", MDC.get(ONAPLogConstants.MDCs.TARGET_SERVICE_NAME));
+ assertEquals("INPROGRESS", MDC.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE));
+ String serverFQDN = "";
+ InetAddress addr = null;
+ try {
+ addr = InetAddress.getLocalHost();
+ serverFQDN = addr.getCanonicalHostName();
- @Test
- public void setupMDCTest() throws URISyntaxException {
- restControllerClientLoggingInterceptor.pre(clientRequest);
- assertEquals("/aai/v1/cloud-infrastructure/complexes", MDC.get(ONAPLogConstants.MDCs.TARGET_SERVICE_NAME) );
- assertEquals("INPROGRESS", MDC.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE));
- String serverFQDN = "";
- InetAddress addr = null;
- try {
- addr = InetAddress.getLocalHost();
- serverFQDN = addr.getCanonicalHostName();
-
- } catch (UnknownHostException e) {
- serverFQDN = "";
- }
- assertEquals(serverFQDN, MDC.get(ONAPLogConstants.MDCs.SERVER_FQDN));
+ } catch (UnknownHostException e) {
+ serverFQDN = "";
}
+ assertEquals(serverFQDN, MDC.get(ONAPLogConstants.MDCs.SERVER_FQDN));
+ }
}
diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/domain/restResponseInfo/InfoTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/domain/restResponseInfo/InfoTest.java
index 1d19e5bf..6e1b0ea4 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/aai/domain/restResponseInfo/InfoTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/aai/domain/restResponseInfo/InfoTest.java
@@ -26,11 +26,11 @@
package org.onap.aai.domain.restResponseInfo;
-import org.junit.Test;
+import static org.junit.Assert.assertTrue;
import java.util.List;
-import static org.junit.Assert.assertTrue;
+import org.junit.Test;
public class InfoTest {
private Info info = new Info();
@@ -38,7 +38,8 @@ public class InfoTest {
@Test
public void infoTest() {
Info.ResponseMessages responseMessages = info.getResponseMessages();
- if (responseMessages == null) responseMessages = new Info.ResponseMessages();
+ if (responseMessages == null)
+ responseMessages = new Info.ResponseMessages();
List<Info.ResponseMessages.ResponseMessage> list = responseMessages.getResponseMessage();
Info.ResponseMessages.ResponseMessage respMsg = new Info.ResponseMessages.ResponseMessage();
diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/domain/restResponseInfo/ObjectFactoryTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/domain/restResponseInfo/ObjectFactoryTest.java
index 55205794..fe95d183 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/aai/domain/restResponseInfo/ObjectFactoryTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/aai/domain/restResponseInfo/ObjectFactoryTest.java
@@ -26,17 +26,19 @@
package org.onap.aai.domain.restResponseInfo;
-import org.junit.Test;
-
import static org.junit.Assert.assertNotNull;
+import org.junit.Test;
+
public class ObjectFactoryTest {
private ObjectFactory objectFactory = new ObjectFactory();
@Test
public void objectFactoryTest() {
- Info.ResponseMessages.ResponseMessage.Variables variables = objectFactory.createInfoResponseMessagesResponseMessageVariables();
- Info.ResponseMessages.ResponseMessage responseMessage = objectFactory.createInfoResponseMessagesResponseMessage();
+ Info.ResponseMessages.ResponseMessage.Variables variables =
+ objectFactory.createInfoResponseMessagesResponseMessageVariables();
+ Info.ResponseMessages.ResponseMessage responseMessage =
+ objectFactory.createInfoResponseMessagesResponseMessage();
Info.ResponseMessages responseMessages = objectFactory.createInfoResponseMessages();
Info info = objectFactory.createInfo();
diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/exceptions/AAIExceptionTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/exceptions/AAIExceptionTest.java
index 4f08607f..b489a0ab 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/aai/exceptions/AAIExceptionTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/aai/exceptions/AAIExceptionTest.java
@@ -17,25 +17,26 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.exceptions;
-import org.junit.Test;
-import org.onap.aai.logging.AaiElsErrorCode;
-import org.onap.aai.logging.ErrorObject;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
-import javax.ws.rs.core.Response;
import java.io.IOException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import javax.ws.rs.core.Response;
+import org.junit.Test;
+import org.onap.aai.logging.AaiElsErrorCode;
+import org.onap.aai.logging.ErrorObject;
public class AAIExceptionTest {
private AAIException aaiException;
@Test
public void defaultAAIExceptionTest() {
- //AAI_4000=5:4:ERROR:4000:500:3002:Internal Error:900
+ // AAI_4000=5:4:ERROR:4000:500:3002:Internal Error:900
aaiException = new AAIException();
assertEquals(AAIException.DEFAULT_EXCEPTION_CODE, aaiException.getCode());
@@ -53,7 +54,8 @@ public class AAIExceptionTest {
@Test
public void aaiExceptionTest() {
- //5:1:WARN:3303:403:3300:Too many objects would be returned by this request, please refine your request and retry:500
+ // 5:1:WARN:3303:403:3300:Too many objects would be returned by this request, please refine your request and
+ // retry:500
aaiException = new AAIException("AAI_3303");
assertEquals("AAI_3303", aaiException.getCode());
@@ -65,13 +67,15 @@ public class AAIExceptionTest {
assertEquals(errorObject.getRESTErrorCode(), "3300");
assertEquals(errorObject.getErrorCode(), "3303");
assertEquals(errorObject.getAaiElsErrorCode(), AaiElsErrorCode.BUSINESS_PROCESS_ERROR);
- assertEquals(errorObject.getErrorText(), "Too many objects would be returned by this request, please refine your request and retry");
+ assertEquals(errorObject.getErrorText(),
+ "Too many objects would be returned by this request, please refine your request and retry");
assertNotNull(aaiException.getTemplateVars());
}
@Test
public void aaiExceptionTestWithDetails() {
- //5:1:WARN:3303:403:3300:Too many objects would be returned by this request, please refine your request and retry:500
+ // 5:1:WARN:3303:403:3300:Too many objects would be returned by this request, please refine your request and
+ // retry:500
final String testDetails = "Test details";
aaiException = new AAIException("AAI_3303", testDetails);
assertEquals(testDetails, aaiException.getMessage());
@@ -98,4 +102,3 @@ public class AAIExceptionTest {
assertNotNull(aaiException.getTemplateVars());
}
}
-
diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/exceptions/AAIExceptionWithInfoTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/exceptions/AAIExceptionWithInfoTest.java
index dbfe60d5..84284ec5 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/aai/exceptions/AAIExceptionWithInfoTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/aai/exceptions/AAIExceptionWithInfoTest.java
@@ -17,15 +17,16 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.exceptions;
-import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import java.io.IOException;
import java.util.HashMap;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import org.junit.Test;
public class AAIExceptionWithInfoTest {
@@ -36,7 +37,7 @@ public class AAIExceptionWithInfoTest {
@Test
public void aaiExceptionWithInfoTest() {
- aaiException = new AAIExceptionWithInfo(new HashMap<String, Object>(), testInfo );
+ aaiException = new AAIExceptionWithInfo(new HashMap<String, Object>(), testInfo);
assertEquals(testInfo, aaiException.getInfo());
assertNotNull(aaiException.getInfoHash());
@@ -44,7 +45,7 @@ public class AAIExceptionWithInfoTest {
@Test
public void aaiExceptionWithCodeInfoTest() {
- aaiException = new AAIExceptionWithInfo("AAI_3300", new HashMap<String, Object>(), testInfo );
+ aaiException = new AAIExceptionWithInfo("AAI_3300", new HashMap<String, Object>(), testInfo);
assertEquals(testInfo, aaiException.getInfo());
assertEquals("AAI_3300", aaiException.getCode());
@@ -54,7 +55,7 @@ public class AAIExceptionWithInfoTest {
@Test
public void aaiExceptionWithCodeDetailsInfoTest() {
- aaiException = new AAIExceptionWithInfo("AAI_3300", testDetails, new HashMap<String, Object>(), testInfo );
+ aaiException = new AAIExceptionWithInfo("AAI_3300", testDetails, new HashMap<String, Object>(), testInfo);
assertEquals(testInfo, aaiException.getInfo());
assertEquals("AAI_3300", aaiException.getCode());
@@ -65,7 +66,8 @@ public class AAIExceptionWithInfoTest {
@Test
public void aaiExceptionWithCodeThrowableDetailsInfoTest() {
- aaiException = new AAIExceptionWithInfo("AAI_3300", new IOException("File not found"), testDetails, new HashMap<String, Object>(), testInfo );
+ aaiException = new AAIExceptionWithInfo("AAI_3300", new IOException("File not found"), testDetails,
+ new HashMap<String, Object>(), testInfo);
assertEquals(testInfo, aaiException.getInfo());
assertEquals("AAI_3300", aaiException.getCode());
@@ -76,4 +78,3 @@ public class AAIExceptionWithInfoTest {
}
}
-
diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/CNNameTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/CNNameTest.java
index 01b7bda1..d95aefa0 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/CNNameTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/CNNameTest.java
@@ -20,7 +20,15 @@
package org.onap.aai.logging;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.when;
+
import ch.qos.logback.access.spi.IAccessEvent;
+
+import java.security.cert.X509Certificate;
+
+import javax.security.auth.x500.X500Principal;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -30,12 +38,6 @@ import org.mockito.Spy;
import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.mock.web.MockHttpServletRequest;
-import javax.security.auth.x500.X500Principal;
-import java.security.cert.X509Certificate;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.when;
-
@RunWith(MockitoJUnitRunner.class)
public class CNNameTest {
@Mock
@@ -52,8 +54,9 @@ public class CNNameTest {
public void setup() {
when(cnName.isStarted()).thenReturn(true);
}
+
@Test
- public void basicAuthTest(){
+ public void basicAuthTest() {
MockHttpServletRequest https = new MockHttpServletRequest();
https.addHeader("Authorization", "Basic dXNlcjpwYXNzd29yZA==");
@@ -64,8 +67,9 @@ public class CNNameTest {
assertEquals("user", cnName.convert(accessEvent));
}
+
@Test
- public void incorrectHeaderBasicAuthTest(){
+ public void incorrectHeaderBasicAuthTest() {
MockHttpServletRequest https = new MockHttpServletRequest();
@@ -77,8 +81,9 @@ public class CNNameTest {
assertEquals("-", cnName.convert(accessEvent));
}
+
@Test
- public void noCipherSuiteTest(){
+ public void noCipherSuiteTest() {
MockHttpServletRequest https = new MockHttpServletRequest();
@@ -90,17 +95,18 @@ public class CNNameTest {
assertEquals("-", cnName.convert(accessEvent));
}
+
@Test
- public void certificateTest(){
+ public void certificateTest() {
String testSubject = "CN=TestName, OU=TestOU, O=TestOrg, C=Country";
- X509Certificate[] certChain = { cert };
+ X509Certificate[] certChain = {cert};
MockHttpServletRequest https = new MockHttpServletRequest();
https.setAttribute("javax.servlet.request.cipher_suite", "");
- https.setAttribute("javax.servlet.request.X509Certificate", certChain );
+ https.setAttribute("javax.servlet.request.X509Certificate", certChain);
when(accessEvent.getRequest()).thenReturn(https);
- when(cert.getSubjectX500Principal()).thenReturn(new X500Principal(testSubject) );
+ when(cert.getSubjectX500Principal()).thenReturn(new X500Principal(testSubject));
assertEquals(testSubject, cnName.convert(accessEvent));
}
diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/CustomLogPatternLayoutTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/CustomLogPatternLayoutTest.java
index 71a07aa1..28be0bf0 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/CustomLogPatternLayoutTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/CustomLogPatternLayoutTest.java
@@ -20,16 +20,16 @@
package org.onap.aai.logging;
-import org.junit.Test;
-
import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+
public class CustomLogPatternLayoutTest {
private CustomLogPatternLayout customLogPatternLayout = new CustomLogPatternLayout();
@Test
- public void defaultConverterTest(){
+ public void defaultConverterTest() {
assertEquals(customLogPatternLayout.getDefaultConverterMap().get("z"), CNName.class.getName());
assertEquals(customLogPatternLayout.getDefaultConverterMap().get("y"), DME2RestFlag.class.getName());
diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/DME2RestFlagTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/DME2RestFlagTest.java
index 737cb624..c29e29d6 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/DME2RestFlagTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/DME2RestFlagTest.java
@@ -20,7 +20,11 @@
package org.onap.aai.logging;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.when;
+
import ch.qos.logback.access.spi.IAccessEvent;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -29,9 +33,6 @@ import org.mockito.Mock;
import org.mockito.Spy;
import org.mockito.junit.MockitoJUnitRunner;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.when;
-
@RunWith(MockitoJUnitRunner.class)
public class DME2RestFlagTest {
@@ -46,8 +47,9 @@ public class DME2RestFlagTest {
public void setup() {
when(dme2RestFlag.isStarted()).thenReturn(true);
}
+
@Test
- public void dme2Test(){
+ public void dme2Test() {
String[] contextArray = {"a", "b", "c"};
String[] routeOfferArray = {"d", "e", "f"};
String[] versionArray = {"1", "2", "3"};
@@ -56,8 +58,9 @@ public class DME2RestFlagTest {
when(accessEvent.getRequestParameter("version")).thenReturn(versionArray);
assertEquals("DME2", dme2RestFlag.convert(accessEvent));
}
+
@Test
- public void restTest(){
+ public void restTest() {
String[] contextArray = {""};
String[] routeOfferArray = {""};
String[] versionArray = {""};
diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorLogHelperTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorLogHelperTest.java
index ae174691..99522771 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorLogHelperTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorLogHelperTest.java
@@ -20,6 +20,16 @@
package org.onap.aai.logging;
+import static java.lang.Thread.sleep;
+import static org.junit.Assert.*;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.ws.rs.core.MediaType;
+
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -32,15 +42,6 @@ import org.onap.aai.util.LogFile;
import org.onap.aai.util.MapperUtil;
import org.slf4j.MDC;
-import javax.ws.rs.core.MediaType;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import static java.lang.Thread.sleep;
-import static org.junit.Assert.*;
-
public class ErrorLogHelperTest {
private static final String ErrorLogFileName = "error.log";
@@ -50,14 +51,16 @@ public class ErrorLogHelperTest {
System.setProperty("AJSC_HOME", ".");
}
+
@After
- public void cleanup() throws IOException{
+ public void cleanup() throws IOException {
MDC.clear();
LogFile.deleteContents(ErrorLogFileName);
}
+
@Test
public void logErrorTest() throws IOException, InterruptedException {
- //||main|UNKNOWN||||ERROR|500|Node cannot be deleted:3100:Bad Request:|ERR.5.4.6110
+ // ||main|UNKNOWN||||ERROR|500|Node cannot be deleted:3100:Bad Request:|ERR.5.4.6110
ErrorLogHelper.logError("AAI_6110");
sleep(5000);
String logContents = LogFile.getContents(ErrorLogFileName);
@@ -66,15 +69,15 @@ public class ErrorLogHelperTest {
String logContentParts[] = logContents.split("\\|");
- assertTrue(logContentParts.length >= 11 );
- assertEquals ("ERROR", logContentParts[7]);
- assertEquals (AaiElsErrorCode.BUSINESS_PROCESS_ERROR, logContentParts[8]);
- assertTrue (logContentParts[10].startsWith("ERR.5.4.6110"));
+ assertTrue(logContentParts.length >= 11);
+ assertEquals("ERROR", logContentParts[7]);
+ assertEquals(AaiElsErrorCode.BUSINESS_PROCESS_ERROR, logContentParts[8]);
+ assertTrue(logContentParts[10].startsWith("ERR.5.4.6110"));
}
@Test
public void logErrorWithMessageTest() throws IOException, InterruptedException {
- //||main|UNKNOWN||||ERROR|500|Node cannot be deleted:3100:Bad Request:|ERR.5.4.6110 message
+ // ||main|UNKNOWN||||ERROR|500|Node cannot be deleted:3100:Bad Request:|ERR.5.4.6110 message
String errorMessage = "Object is referenced by additional objects";
ErrorLogHelper.logError("AAI_6110", errorMessage);
sleep(5000);
@@ -84,14 +87,14 @@ public class ErrorLogHelperTest {
String logContentParts[] = logContents.split("\\|");
- assertTrue(logContentParts.length >= 11 );
- assertTrue (logContentParts[9].contains(errorMessage));
- assertTrue (logContentParts[10].startsWith("ERR.5.4.6110"));
+ assertTrue(logContentParts.length >= 11);
+ assertTrue(logContentParts[9].contains(errorMessage));
+ assertTrue(logContentParts[10].startsWith("ERR.5.4.6110"));
}
@Test
- public void getRESTAPIPolicyErrorResponseTest() throws AAIException{
- //AAI_3002=5:1:WARN:3002:400:3002:Error writing output performing %1 on %2:300
+ public void getRESTAPIPolicyErrorResponseTest() throws AAIException {
+ // AAI_3002=5:1:WARN:3002:400:3002:Error writing output performing %1 on %2:300
ArrayList<MediaType> headers = new ArrayList<MediaType>(Arrays.asList(MediaType.APPLICATION_JSON_TYPE));
ArrayList<String> args = new ArrayList<String>(Arrays.asList("PUT", "resource"));
@@ -110,9 +113,10 @@ public class ErrorLogHelperTest {
assertTrue(vars.contains("PUT"));
assertTrue(vars.contains("resource"));
}
+
@Test
- public void getRESTAPIServiceErrorResponseTest() throws AAIException{
- //AAI_3009=5:6:WARN:3009:400:3009:Malformed URL:300
+ public void getRESTAPIServiceErrorResponseTest() throws AAIException {
+ // AAI_3009=5:6:WARN:3009:400:3009:Malformed URL:300
ArrayList<MediaType> headers = new ArrayList<MediaType>(Arrays.asList(MediaType.APPLICATION_JSON_TYPE));
ArrayList<String> args = new ArrayList<String>();
@@ -120,7 +124,8 @@ public class ErrorLogHelperTest {
String errorResponse = ErrorLogHelper.getRESTAPIErrorResponse(headers, aaie, args);
assertNotNull(errorResponse);
- org.onap.aai.domain.restServiceException.RESTResponse resp = MapperUtil.readAsObjectOf(org.onap.aai.domain.restServiceException.RESTResponse.class, errorResponse);
+ org.onap.aai.domain.restServiceException.RESTResponse resp =
+ MapperUtil.readAsObjectOf(org.onap.aai.domain.restServiceException.RESTResponse.class, errorResponse);
org.onap.aai.domain.restServiceException.RequestError requestError = resp.getRequestError();
assertNotNull(requestError);
ServiceException serviceException = requestError.getServiceException();
@@ -128,9 +133,10 @@ public class ErrorLogHelperTest {
assertEquals("SVC3009", serviceException.getMessageId());
}
+
@Test
- public void getRESTAPIServiceErrorResponseWithLoggingTest() throws IOException, InterruptedException{
- //AAI_3009=5:6:WARN:3009:400:3009:Malformed URL:300
+ public void getRESTAPIServiceErrorResponseWithLoggingTest() throws IOException, InterruptedException {
+ // AAI_3009=5:6:WARN:3009:400:3009:Malformed URL:300
ArrayList<MediaType> headers = new ArrayList<MediaType>(Arrays.asList(MediaType.APPLICATION_JSON_TYPE));
ArrayList<String> args = new ArrayList<String>();
@@ -143,8 +149,8 @@ public class ErrorLogHelperTest {
assertNotNull(logContents);
String logContentParts[] = logContents.split("\\|");
- assertTrue(logContentParts.length >= 11 );
- assertTrue (logContentParts[10].startsWith("ERR.5.6.3009"));
+ assertTrue(logContentParts.length >= 11);
+ assertTrue(logContentParts[10].startsWith("ERR.5.6.3009"));
}
diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorObjectFormatExceptionTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorObjectFormatExceptionTest.java
index a5a8e496..97934723 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorObjectFormatExceptionTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorObjectFormatExceptionTest.java
@@ -20,10 +20,10 @@
package org.onap.aai.logging;
-import org.junit.Test;
-
import static org.junit.Assert.assertTrue;
+import org.junit.Test;
+
public class ErrorObjectFormatExceptionTest {
@Test
diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorObjectNotFoundExceptionTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorObjectNotFoundExceptionTest.java
index 8bffe4ff..6be89425 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorObjectNotFoundExceptionTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorObjectNotFoundExceptionTest.java
@@ -20,11 +20,11 @@
package org.onap.aai.logging;
-import org.junit.Test;
+import static org.junit.Assert.*;
import java.io.IOException;
-import static org.junit.Assert.*;
+import org.junit.Test;
public class ErrorObjectNotFoundExceptionTest {
@@ -33,18 +33,21 @@ public class ErrorObjectNotFoundExceptionTest {
ErrorObjectNotFoundException e = new ErrorObjectNotFoundException();
assertTrue(e instanceof Exception);
}
+
@Test
public void errorObjectNotFoundExceptionWithMessageTest() {
ErrorObjectNotFoundException e = new ErrorObjectNotFoundException("Error Message");
assertTrue(e instanceof Exception);
assertEquals("Error Message", e.getMessage());
}
+
@Test
public void errorObjectNotFoundExceptionWithCauseTest() {
ErrorObjectNotFoundException e = new ErrorObjectNotFoundException(new ArithmeticException());
assertTrue(e instanceof Exception);
assertTrue(e.getCause() instanceof ArithmeticException);
}
+
@Test
public void errorObjectNotFoundExceptionWithMsgCauseTest() {
ErrorObjectNotFoundException e = new ErrorObjectNotFoundException("Error Message", new ArithmeticException());
@@ -52,10 +55,12 @@ public class ErrorObjectNotFoundExceptionTest {
assertTrue(e.getCause() instanceof ArithmeticException);
assertEquals("Error Message", e.getMessage());
}
+
@Test
public void errorObjectNotFoundExceptionTest() {
- ErrorObjectNotFoundException e = new ErrorObjectNotFoundException("Error Message", new ArithmeticException(), true, true);
+ ErrorObjectNotFoundException e =
+ new ErrorObjectNotFoundException("Error Message", new ArithmeticException(), true, true);
assertTrue(e instanceof Exception);
assertTrue(e.getCause() instanceof ArithmeticException);
assertEquals("Error Message", e.getMessage());
@@ -63,7 +68,8 @@ public class ErrorObjectNotFoundExceptionTest {
assertTrue((e.getSuppressed())[0] instanceof IOException);
assertEquals("Test IO Exception", (e.getSuppressed())[0].getMessage());
- ErrorObjectNotFoundException e1 = new ErrorObjectNotFoundException("Error Message", new ArithmeticException(), false, true);
+ ErrorObjectNotFoundException e1 =
+ new ErrorObjectNotFoundException("Error Message", new ArithmeticException(), false, true);
e1.addSuppressed(new IOException("Test IO Exception"));
assertTrue((e1.getSuppressed() == null) || e1.getSuppressed().length == 0);
@@ -72,29 +78,31 @@ public class ErrorObjectNotFoundExceptionTest {
@Test
public void errorObjectNotFoundExceptionStackTraceTest() {
- ErrorObjectNotFoundException e1 = new ErrorObjectNotFoundException("Error Message", new ArithmeticException(), true, true);
+ ErrorObjectNotFoundException e1 =
+ new ErrorObjectNotFoundException("Error Message", new ArithmeticException(), true, true);
try {
throw e1;
- }
- catch (ErrorObjectNotFoundException e) {
+ } catch (ErrorObjectNotFoundException e) {
StackTraceElement[] stackTrace = e.getStackTrace();
assertNotNull(stackTrace);
assertTrue(stackTrace.length > 0);
}
- ErrorObjectNotFoundException e2 = new ErrorObjectNotFoundException("Error Message", new ArithmeticException(), true, false);
+ ErrorObjectNotFoundException e2 =
+ new ErrorObjectNotFoundException("Error Message", new ArithmeticException(), true, false);
try {
throw e2;
- }
- catch (ErrorObjectNotFoundException e) {
+ } catch (ErrorObjectNotFoundException e) {
StackTraceElement[] stackTrace = e.getStackTrace();
assertTrue(stackTrace == null || stackTrace.length == 0);
}
}
- /*public ErrorObjectNotFoundException(String message, Throwable cause, boolean enableSuppression,
- boolean writableStackTrace) {
- super(message, cause, enableSuppression, writableStackTrace);
- // TODO Auto-generated constructor stub
- }*/
+ /*
+ * public ErrorObjectNotFoundException(String message, Throwable cause, boolean enableSuppression,
+ * boolean writableStackTrace) {
+ * super(message, cause, enableSuppression, writableStackTrace);
+ * // TODO Auto-generated constructor stub
+ * }
+ */
}
diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorObjectTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorObjectTest.java
index ff20105c..a0fcf655 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorObjectTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorObjectTest.java
@@ -20,11 +20,11 @@
package org.onap.aai.logging;
-import org.junit.Test;
+import static org.junit.Assert.assertEquals;
import javax.ws.rs.core.Response;
-import static org.junit.Assert.assertEquals;
+import org.junit.Test;
public class ErrorObjectTest {
private ErrorObject errorObject;
@@ -37,18 +37,21 @@ public class ErrorObjectTest {
private static final String ERROR_TEXT = "Test data error";
private static final String ERROR_PATTERN = "ERR.5.4.4000";
private static final String ERROR_SEVERITY_CODE = "2";
+
@Test
public void errorObjectDefaultConstructorTest() {
errorObject = new ErrorObject();
assertEquals("3002", errorObject.getRESTErrorCode());
- assertEquals(Response.Status.fromStatusCode(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()), errorObject.getHTTPResponseCode());
- assertEquals(AaiElsErrorCode.UNKNOWN_ERROR,errorObject.getAaiElsErrorCode());
+ assertEquals(Response.Status.fromStatusCode(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()),
+ errorObject.getHTTPResponseCode());
+ assertEquals(AaiElsErrorCode.UNKNOWN_ERROR, errorObject.getAaiElsErrorCode());
assertEquals(ERROR_SEVERITY_CODE, errorObject.getSeverityCode(ERROR_SEVERITY));
}
+
@Test
public void errorObjectConstructor7Test() {
errorObject = new ErrorObject(ERROR_DISPOSITION, ERROR_CATEGORY, ERROR_SEVERITY, ERROR_HTTP_RESPONSE_CODE,
- ERROR_REST_CODE, ERROR_CODE, ERROR_TEXT);
+ ERROR_REST_CODE, ERROR_CODE, ERROR_TEXT);
assertEquals(ERROR_DISPOSITION, errorObject.getDisposition());
assertEquals(ERROR_SEVERITY, errorObject.getSeverity());
assertEquals(ERROR_CATEGORY, errorObject.getCategory());
@@ -56,7 +59,7 @@ public class ErrorObjectTest {
assertEquals(ERROR_REST_CODE, errorObject.getRESTErrorCode());
assertEquals(ERROR_CODE, errorObject.getErrorCode());
assertEquals(ERROR_TEXT, errorObject.getErrorText());
- assertEquals(AaiElsErrorCode.UNKNOWN_ERROR,errorObject.getAaiElsErrorCode());
+ assertEquals(AaiElsErrorCode.UNKNOWN_ERROR, errorObject.getAaiElsErrorCode());
assertEquals(ERROR_SEVERITY_CODE, errorObject.getSeverityCode(ERROR_SEVERITY));
}
@@ -66,18 +69,20 @@ public class ErrorObjectTest {
assertEquals(ERROR_DISPOSITION, errorObject.getDisposition());
assertEquals(ERROR_SEVERITY, errorObject.getSeverity());
assertEquals(ERROR_CATEGORY, errorObject.getCategory());
- assertEquals(Response.Status.fromStatusCode(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()), errorObject.getHTTPResponseCode());
+ assertEquals(Response.Status.fromStatusCode(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()),
+ errorObject.getHTTPResponseCode());
assertEquals("3002", errorObject.getRESTErrorCode());
assertEquals(ERROR_CODE, errorObject.getErrorCode());
assertEquals(ERROR_TEXT, errorObject.getErrorText());
- assertEquals(AaiElsErrorCode.UNKNOWN_ERROR,errorObject.getAaiElsErrorCode());
+ assertEquals(AaiElsErrorCode.UNKNOWN_ERROR, errorObject.getAaiElsErrorCode());
assertEquals(ERROR_PATTERN, errorObject.getErrorCodeString());
assertEquals(ERROR_SEVERITY_CODE, errorObject.getSeverityCode(ERROR_SEVERITY));
}
@Test
public void errorObjectConstructor6Test() {
- errorObject = new ErrorObject(ERROR_SEVERITY, ERROR_HTTP_RESPONSE_CODE, ERROR_CODE, ERROR_TEXT, ERROR_DISPOSITION, ERROR_CATEGORY);
+ errorObject = new ErrorObject(ERROR_SEVERITY, ERROR_HTTP_RESPONSE_CODE, ERROR_CODE, ERROR_TEXT,
+ ERROR_DISPOSITION, ERROR_CATEGORY);
assertEquals(ERROR_DISPOSITION, errorObject.getDisposition());
assertEquals(ERROR_SEVERITY, errorObject.getSeverity());
assertEquals(ERROR_CATEGORY, errorObject.getCategory());
@@ -91,5 +96,4 @@ public class ErrorObjectTest {
}
-
}
diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/LogFormatToolsTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/LogFormatToolsTest.java
index 695d7c08..b352cb14 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/LogFormatToolsTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/LogFormatToolsTest.java
@@ -20,12 +20,12 @@
package org.onap.aai.logging;
-import org.junit.Test;
-import org.onap.aai.exceptions.AAIException;
-
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+
public class LogFormatToolsTest {
@Test
diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/LoggingContextTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/LoggingContextTest.java
index 4fe60315..d793eb77 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/LoggingContextTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/LoggingContextTest.java
@@ -20,20 +20,21 @@
package org.onap.aai.logging;
-import org.junit.After;
-import org.junit.Test;
-import org.slf4j.MDC;
+import static org.junit.Assert.*;
import java.util.concurrent.TimeUnit;
-import static org.junit.Assert.*;
+import org.junit.After;
+import org.junit.Test;
+import org.slf4j.MDC;
public class LoggingContextTest {
@After
- public void cleanup(){
+ public void cleanup() {
MDC.clear();
}
+
@Test
public void elapsedTimeTest() {
LoggingContext.elapsedTime(300, TimeUnit.MILLISECONDS);
@@ -41,6 +42,7 @@ public class LoggingContextTest {
LoggingContext.init();
assertNull(MDC.get(LoggingContext.LoggingField.ELAPSED_TIME.toString()));
}
+
@Test
public void stopWatchTest() {
LoggingContext.init();
@@ -53,6 +55,7 @@ public class LoggingContextTest {
assertFalse(LoggingContext.isStopWatchStarted());
assertTrue(elapsedTime > 0);
}
+
@Test
public void putClearTest() {
String testServiceName = "TEST-SVC-NAME";
diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/StopWatchNotStartedExceptionTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/StopWatchNotStartedExceptionTest.java
index 8a4123f0..2c9c52c5 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/StopWatchNotStartedExceptionTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/StopWatchNotStartedExceptionTest.java
@@ -20,31 +20,33 @@
package org.onap.aai.logging;
-import org.junit.Test;
-
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-public class StopWatchNotStartedExceptionTest {
+import org.junit.Test;
+public class StopWatchNotStartedExceptionTest {
@Test
public void stopWatchNotStartedExceptionTest() {
StopWatchNotStartedException e = new StopWatchNotStartedException();
assertTrue(e instanceof RuntimeException);
}
+
@Test
public void stopWatchNotStartedExceptionWithMessageTest() {
StopWatchNotStartedException e = new StopWatchNotStartedException("Error Message");
assertTrue(e instanceof RuntimeException);
assertEquals("Error Message", e.getMessage());
}
+
@Test
public void stopWatchNotStartedExceptionWithCauseTest() {
StopWatchNotStartedException e = new StopWatchNotStartedException(new ArithmeticException());
assertTrue(e instanceof RuntimeException);
assertTrue(e.getCause() instanceof ArithmeticException);
}
+
@Test
public void stopWatchNotStartedExceptionWithMsgCauseTest() {
StopWatchNotStartedException e = new StopWatchNotStartedException("Error Message", new ArithmeticException());
diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/StopWatchTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/StopWatchTest.java
index 50a2d053..34aecd56 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/StopWatchTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/StopWatchTest.java
@@ -20,19 +20,20 @@
package org.onap.aai.logging;
+import static java.lang.Thread.sleep;
+import static org.junit.Assert.*;
+
import org.junit.After;
import org.junit.Test;
import org.slf4j.MDC;
-import static java.lang.Thread.sleep;
-import static org.junit.Assert.*;
-
public class StopWatchTest {
@After
public void cleanup() {
MDC.clear();
}
+
@Test
public void elapsedTimeTest() throws InterruptedException {
StopWatch.start();
@@ -40,6 +41,7 @@ public class StopWatchTest {
StopWatch.stop();
assertTrue(Long.parseLong(MDC.get(LoggingContext.LoggingField.ELAPSED_TIME.toString())) >= 1000L);
}
+
@Test
public void elapsedTimeConditionalTest() throws InterruptedException {
StopWatch.conditionalStart();
@@ -49,12 +51,13 @@ public class StopWatchTest {
long elapsedTime = Long.parseLong(elapsedTimeStr);
assertTrue(elapsedTime >= 1000L);
}
+
@Test
public void clearTest() throws InterruptedException {
StopWatch.start();
sleep(1010);
StopWatch.stop();
- assertNotNull( MDC.get(LoggingContext.LoggingField.ELAPSED_TIME.toString()));
+ assertNotNull(MDC.get(LoggingContext.LoggingField.ELAPSED_TIME.toString()));
StopWatch.clear();
assertNull(MDC.get(LoggingContext.LoggingField.STOP_WATCH_START.toString()));
diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/util/AAIApplicationConfigTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/util/AAIApplicationConfigTest.java
index 24efee3d..7d51ccc2 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/aai/util/AAIApplicationConfigTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/aai/util/AAIApplicationConfigTest.java
@@ -19,15 +19,16 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.util;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
import org.junit.Before;
import org.junit.Test;
import org.onap.aai.exceptions.AAIException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
public class AAIApplicationConfigTest {
@Before
@@ -39,6 +40,7 @@ public class AAIApplicationConfigTest {
public void truststoreTest() throws AAIException {
assertEquals("truststore.jks", AAIApplicationConfig.getTruststore());
}
+
@Test
public void keystoreTest() throws AAIException {
assertEquals("keystore.jks", AAIApplicationConfig.getKeystore());
@@ -58,6 +60,7 @@ public class AAIApplicationConfigTest {
public void getValueTest() throws AAIException {
assertEquals("certificates", AAIApplicationConfig.get("server.certs.location"));
}
+
@Test
public void getIntValueTest() throws AAIException {
assertTrue(8446 == AAIApplicationConfig.getInt("server.port"));
@@ -70,6 +73,7 @@ public class AAIApplicationConfigTest {
@Test
public void getValueWithReplacementTest() throws AAIException {
- assertEquals("/opt/app/aai/etc/auth/aai-client-cert.p12", AAIApplicationConfig.get("schema.service.ssl.key-store"));
+ assertEquals("/opt/app/aai/etc/auth/aai-client-cert.p12",
+ AAIApplicationConfig.get("schema.service.ssl.key-store"));
}
}
diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/util/AAIConfigTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/util/AAIConfigTest.java
index 86d6c202..dad8c351 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/aai/util/AAIConfigTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/aai/util/AAIConfigTest.java
@@ -19,14 +19,15 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.util;
+import static org.junit.Assert.*;
+
import org.junit.Before;
import org.junit.Test;
import org.onap.aai.exceptions.AAIException;
-import static org.junit.Assert.*;
-
public class AAIConfigTest {
@Before
@@ -43,6 +44,7 @@ public class AAIConfigTest {
public void getValueTest() throws AAIException {
assertEquals("10", AAIConfig.get("aai.logging.maxStackTraceEntries"));
}
+
@Test
public void getIntValueTest() throws AAIException {
assertTrue(10 == AAIConfig.getInt("aai.logging.maxStackTraceEntries"));
diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/util/FormatDateTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/util/FormatDateTest.java
index 38ac5de5..b1be62a1 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/aai/util/FormatDateTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/aai/util/FormatDateTest.java
@@ -19,13 +19,14 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.util;
+import static org.junit.Assert.assertNotNull;
+
import org.junit.Test;
import org.onap.aai.exceptions.AAIException;
-import static org.junit.Assert.assertNotNull;
-
public class FormatDateTest {
private FormatDate formatDate = null;
diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/util/LogFile.java b/aai-els-onap-logging/src/test/java/org/onap/aai/util/LogFile.java
index b94686bb..3ace6f01 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/aai/util/LogFile.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/aai/util/LogFile.java
@@ -17,6 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.util;
import java.io.File;
@@ -31,7 +32,7 @@ import org.apache.commons.io.IOUtils;
* Utility class to read/delete contents of log file
*/
public class LogFile {
-
+
public static String getContents(String fileName) throws IOException {
FileInputStream fileInputStream = null;
@@ -39,12 +40,13 @@ public class LogFile {
try {
fileInputStream = new FileInputStream("logs/" + fileName);
contents = IOUtils.toString(fileInputStream, "UTF-8");
- }
- finally {
- if (fileInputStream != null) fileInputStream.close();
+ } finally {
+ if (fileInputStream != null)
+ fileInputStream.close();
}
return contents;
}
+
public static void deleteContents(String fileName) throws IOException {
FileUtils.write(new File("logs/" + fileName), "", Charset.defaultCharset());
}
diff --git a/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/AuditLogContainerFilterTest.java b/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/AuditLogContainerFilterTest.java
index 119bdf1e..8ac9f12d 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/AuditLogContainerFilterTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/AuditLogContainerFilterTest.java
@@ -22,11 +22,13 @@ package org.onap.logging.filter.base;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.when;
+
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerResponseContext;
import javax.ws.rs.core.MultivaluedHashMap;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.UriInfo;
+
import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -61,7 +63,6 @@ public class AuditLogContainerFilterTest {
MDC.clear();
}
-
@Test
public void filterTest() {
MultivaluedMap<String, String> headerMap = new MultivaluedHashMap<>();
diff --git a/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/AuditLogServletFilterTest.java b/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/AuditLogServletFilterTest.java
index d3f0f9f5..afdfe059 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/AuditLogServletFilterTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/AuditLogServletFilterTest.java
@@ -21,12 +21,13 @@
package org.onap.logging.filter.base;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
import static org.mockito.Mockito.when;
+
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+
import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
diff --git a/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/LoggingContainerFilterTest.java b/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/LoggingContainerFilterTest.java
index 4d1f102a..6390c8ea 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/LoggingContainerFilterTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/LoggingContainerFilterTest.java
@@ -21,8 +21,10 @@
package org.onap.logging.filter.base;
import static org.junit.Assert.assertEquals;
+
import javax.ws.rs.core.MultivaluedHashMap;
import javax.ws.rs.core.MultivaluedMap;
+
import org.junit.Test;
import org.onap.logging.ref.slf4j.ONAPLogConstants;
diff --git a/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/MDCSetupTest.java b/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/MDCSetupTest.java
index 9c89da5a..e47db8ce 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/MDCSetupTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/MDCSetupTest.java
@@ -24,11 +24,14 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.mockito.Mockito.when;
+
import java.util.HashMap;
+
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MultivaluedHashMap;
import javax.ws.rs.core.MultivaluedMap;
+
import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
diff --git a/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/MetricLogClientFilterTest.java b/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/MetricLogClientFilterTest.java
index 6f6a0ff1..daa57625 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/MetricLogClientFilterTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/MetricLogClientFilterTest.java
@@ -23,16 +23,17 @@ package org.onap.logging.filter.base;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.mockito.Mockito.doReturn;
+
import java.net.URI;
import java.net.URISyntaxException;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
-import java.util.HashMap;
-import java.util.Map;
+
import javax.ws.rs.client.ClientRequestContext;
import javax.ws.rs.core.MultivaluedHashMap;
import javax.ws.rs.core.MultivaluedMap;
+
import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
diff --git a/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/PayloadLoggingClientFilterTest.java b/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/PayloadLoggingClientFilterTest.java
index c2446a3f..61e7014b 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/PayloadLoggingClientFilterTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/PayloadLoggingClientFilterTest.java
@@ -22,11 +22,14 @@ package org.onap.logging.filter.base;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.when;
+
import java.io.IOException;
import java.net.URISyntaxException;
+
import javax.ws.rs.client.ClientRequestContext;
import javax.ws.rs.core.MultivaluedHashMap;
import javax.ws.rs.core.MultivaluedMap;
+
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
diff --git a/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/SimpleJaxrsHeadersMapTest.java b/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/SimpleJaxrsHeadersMapTest.java
index e2c5da9c..0ae919fc 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/SimpleJaxrsHeadersMapTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/SimpleJaxrsHeadersMapTest.java
@@ -21,8 +21,10 @@
package org.onap.logging.filter.base;
import static org.junit.Assert.assertEquals;
+
import javax.ws.rs.core.MultivaluedHashMap;
import javax.ws.rs.core.MultivaluedMap;
+
import org.junit.Test;
import org.onap.logging.ref.slf4j.ONAPLogConstants;
diff --git a/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/SimpleServletHeadersMapTest.java b/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/SimpleServletHeadersMapTest.java
index fff67768..ccde0000 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/SimpleServletHeadersMapTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/SimpleServletHeadersMapTest.java
@@ -22,7 +22,9 @@ package org.onap.logging.filter.base;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.when;
+
import javax.servlet.http.HttpServletRequest;
+
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
diff --git a/aai-els-onap-logging/src/test/java/org/onap/logging/ref/slf4j/ONAPLogAdapterTest.java b/aai-els-onap-logging/src/test/java/org/onap/logging/ref/slf4j/ONAPLogAdapterTest.java
index 9549eaa9..f6ed9614 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/logging/ref/slf4j/ONAPLogAdapterTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/logging/ref/slf4j/ONAPLogAdapterTest.java
@@ -21,20 +21,6 @@
package org.onap.logging.ref.slf4j;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.slf4j.MDC;
-import org.slf4j.event.Level;
-import org.springframework.mock.web.MockHttpServletRequest;
-import org.testng.Assert;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.Test;
-
-import javax.xml.bind.DatatypeConverter;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNot.not;
@@ -44,6 +30,21 @@ import static org.hamcrest.core.IsSame.sameInstance;
import static org.hamcrest.core.StringEndsWith.endsWith;
import static org.hamcrest.number.OrderingComparison.lessThan;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+import javax.xml.bind.DatatypeConverter;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
+import org.slf4j.event.Level;
+import org.springframework.mock.web.MockHttpServletRequest;
+import org.testng.Assert;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.Test;
+
/**
* Tests for {@link ONAPLogAdapter}.
*/
@@ -68,8 +69,7 @@ public class ONAPLogAdapterTest {
try {
ONAPLogAdapter.checkNotNull(null);
Assert.fail("Should throw NullPointerException");
- }
- catch (final NullPointerException e) {
+ } catch (final NullPointerException e) {
}
}
@@ -126,12 +126,11 @@ public class ONAPLogAdapterTest {
assertThat(invokeTimestampString, endsWith("Z"));
final long invokeTimestamp = DatatypeConverter.parseDateTime(invokeTimestampString).getTimeInMillis();
assertThat(Math.abs(System.currentTimeMillis() - invokeTimestamp), lessThan(5000L));
- }
- finally {
+ } finally {
MDC.clear();
}
}
-
+
/**
* Test ENTERING with an EMPTY_STRING serviceName.
*/
@@ -166,8 +165,7 @@ public class ONAPLogAdapterTest {
assertThat(invokeTimestampString, endsWith("Z"));
final long invokeTimestamp = DatatypeConverter.parseDateTime(invokeTimestampString).getTimeInMillis();
assertThat(Math.abs(System.currentTimeMillis() - invokeTimestamp), lessThan(5000L));
- }
- finally {
+ } finally {
MDC.clear();
}
}
@@ -217,8 +215,7 @@ public class ONAPLogAdapterTest {
assertThat(MDC.get("somekey"), is("somevalue"));
adapter.exiting();
assertThat(MDC.get("somekey"), nullValue());
- }
- finally {
+ } finally {
MDC.clear();
}
}
@@ -238,7 +235,7 @@ public class ONAPLogAdapterTest {
final UUID asyncUUID = adapter.invoke(ONAPLogConstants.InvocationMode.SYNCHRONOUS);
assertThat(asyncUUID, notNullValue());
- final UUID agnosticUUID = adapter.invoke((ONAPLogConstants.InvocationMode)null);
+ final UUID agnosticUUID = adapter.invoke((ONAPLogConstants.InvocationMode) null);
assertThat(agnosticUUID, notNullValue());
}
@@ -253,13 +250,14 @@ public class ONAPLogAdapterTest {
final ONAPLogAdapter adapter = new ONAPLogAdapter(logger);
final Map<String, String> headers = new HashMap<>();
- final ONAPLogAdapter.RequestBuilder builder = new ONAPLogAdapter.RequestBuilder<ONAPLogAdapter.RequestBuilder>() {
- @Override
- public ONAPLogAdapter.RequestBuilder setHeader(final String name, final String value) {
- headers.put(name, value);
- return this;
- }
- };
+ final ONAPLogAdapter.RequestBuilder builder =
+ new ONAPLogAdapter.RequestBuilder<ONAPLogAdapter.RequestBuilder>() {
+ @Override
+ public ONAPLogAdapter.RequestBuilder setHeader(final String name, final String value) {
+ headers.put(name, value);
+ return this;
+ }
+ };
try {
final UUID uuid = adapter.invoke(builder, ONAPLogConstants.InvocationMode.SYNCHRONOUS);
@@ -267,8 +265,7 @@ public class ONAPLogAdapterTest {
assertThat(headers.get(ONAPLogConstants.Headers.INVOCATION_ID), is(uuid.toString()));
assertThat(headers.containsKey(ONAPLogConstants.Headers.PARTNER_NAME), is(true));
assertThat(headers.containsKey(ONAPLogConstants.Headers.REQUEST_ID), is(true));
- }
- finally {
+ } finally {
MDC.clear();
}
}
@@ -283,13 +280,14 @@ public class ONAPLogAdapterTest {
final ONAPLogAdapter adapter = new ONAPLogAdapter(logger);
final Map<String, String> headers = new HashMap<>();
- final ONAPLogAdapter.RequestBuilder builder = new ONAPLogAdapter.RequestBuilder<ONAPLogAdapter.RequestBuilder>() {
- @Override
- public ONAPLogAdapter.RequestBuilder setHeader(final String name, final String value) {
- headers.put(name, value);
- return this;
- }
- };
+ final ONAPLogAdapter.RequestBuilder builder =
+ new ONAPLogAdapter.RequestBuilder<ONAPLogAdapter.RequestBuilder>() {
+ @Override
+ public ONAPLogAdapter.RequestBuilder setHeader(final String name, final String value) {
+ headers.put(name, value);
+ return this;
+ }
+ };
try {
final UUID uuid = adapter.invoke(builder);
@@ -297,8 +295,7 @@ public class ONAPLogAdapterTest {
assertThat(headers.get(ONAPLogConstants.Headers.INVOCATION_ID), is(uuid.toString()));
assertThat(headers.containsKey(ONAPLogConstants.Headers.PARTNER_NAME), is(true));
assertThat(headers.containsKey(ONAPLogConstants.Headers.REQUEST_ID), is(true));
- }
- finally {
+ } finally {
MDC.clear();
}
}
@@ -312,8 +309,7 @@ public class ONAPLogAdapterTest {
request.setRequestURI("/ctx0");
request.setServerName("srv0");
- final ONAPLogAdapter.HttpServletRequestAdapter adapter
- = new ONAPLogAdapter.HttpServletRequestAdapter(request);
+ final ONAPLogAdapter.HttpServletRequestAdapter adapter = new ONAPLogAdapter.HttpServletRequestAdapter(request);
assertThat(adapter.getHeader("uuid"), is(uuid.toString()));
assertThat(adapter.getRequestURI(), is("/ctx0"));
assertThat(adapter.getServerAddress(), is("srv0"));
@@ -323,8 +319,7 @@ public class ONAPLogAdapterTest {
public void testServiceDescriptor() {
final String uuid = UUID.randomUUID().toString();
- final ONAPLogAdapter.ServiceDescriptor adapter
- = new ONAPLogAdapter.ServiceDescriptor();
+ final ONAPLogAdapter.ServiceDescriptor adapter = new ONAPLogAdapter.ServiceDescriptor();
adapter.setServiceUUID(uuid);
adapter.setServiceName("name0");
@@ -341,8 +336,7 @@ public class ONAPLogAdapterTest {
public void testResponseDescriptor() {
final String uuid = UUID.randomUUID().toString();
- final ONAPLogAdapter.ResponseDescriptor adapter
- = new ONAPLogAdapter.ResponseDescriptor();
+ final ONAPLogAdapter.ResponseDescriptor adapter = new ONAPLogAdapter.ResponseDescriptor();
adapter.setResponseCode("code0");
adapter.setResponseDescription("desc0");
adapter.setResponseSeverity(Level.INFO);
@@ -385,20 +379,17 @@ public class ONAPLogAdapterTest {
// Generate (and log) an invocationID, then use it to
// invoke another component.
- final RESTClient client = new RESTClient(); // implements ONAPLogAdapter.RequestBuilder<RESTClient>.
+ final RESTClient client = new RESTClient(); // implements ONAPLogAdapter.RequestBuilder<RESTClient>.
adapter.invoke(client, ONAPLogConstants.InvocationMode.SYNCHRONOUS);
- final RESTRequest request = null; // TODO: build real request.
- final RESTResponse response = client.execute(request); // TODO: handle real response.
+ final RESTRequest request = null; // TODO: build real request.
+ final RESTResponse response = client.execute(request); // TODO: handle real response.
// Set response details prior to #exiting.
// (Obviously there'd be errorhandling, etc. IRL).
- adapter.getResponseDescriptor()
- .setResponseCode((String)null)
- .setResponseSeverity(Level.INFO)
+ adapter.getResponseDescriptor().setResponseCode((String) null).setResponseSeverity(Level.INFO)
.setResponseStatus(ONAPLogConstants.ResponseStatus.COMPLETE);
- }
- finally {
+ } finally {
// Return, logging EXIT marker, with response MDCs.
diff --git a/aai-els-onap-logging/src/test/java/org/onap/logging/ref/slf4j/ONAPLogConstantsTest.java b/aai-els-onap-logging/src/test/java/org/onap/logging/ref/slf4j/ONAPLogConstantsTest.java
index 9a46f05b..6dc5e59c 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/logging/ref/slf4j/ONAPLogConstantsTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/logging/ref/slf4j/ONAPLogConstantsTest.java
@@ -21,16 +21,16 @@
package org.onap.logging.ref.slf4j;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsInstanceOf.instanceOf;
+
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import org.testng.Assert;
import org.testng.annotations.Test;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.core.Is.is;
-import static org.hamcrest.core.IsInstanceOf.instanceOf;
-
/**
* Tests for {@link ONAPLogConstants}.
*/
@@ -51,8 +51,7 @@ public class ONAPLogConstantsTest {
c.setAccessible(true);
c.newInstance();
Assert.fail("Should fail for hidden constructor.");
- }
- catch (final InvocationTargetException e) {
+ } catch (final InvocationTargetException e) {
assertThat(e.getCause(), instanceOf(UnsupportedOperationException.class));
}
}
@@ -82,8 +81,7 @@ public class ONAPLogConstantsTest {
@Test
public void testInvocationModeToString() {
- assertThat(ONAPLogConstants.InvocationMode.SYNCHRONOUS.toString(),
- is("SYNCHRONOUS"));
+ assertThat(ONAPLogConstants.InvocationMode.SYNCHRONOUS.toString(), is("SYNCHRONOUS"));
}
@Test
@@ -114,8 +112,7 @@ public class ONAPLogConstantsTest {
try {
c.getDeclaredConstructors()[0].newInstance();
Assert.fail("Should fail for hidden constructor.");
- }
- catch (final IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
}
@@ -124,8 +121,7 @@ public class ONAPLogConstantsTest {
constructor.setAccessible(true);
constructor.newInstance();
Assert.fail("Should fail even when invoked.");
- }
- catch (final InvocationTargetException e) {
+ } catch (final InvocationTargetException e) {
assertThat(e.getCause(), instanceOf(UnsupportedOperationException.class));
}
}