aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/test
diff options
context:
space:
mode:
authorEylon Malin <eylon.malin@intl.att.com>2019-09-10 16:31:01 +0300
committerEylon Malin <eylon.malin@intl.att.com>2019-09-12 08:51:25 +0300
commit2265215c803291e029add2db7912c7b1e25e0a8e (patch)
tree3082c232fa26483a0f1262efcc5c228d554280d1 /vid-app-common/src/test
parent77e77f77c89ca1bef622b12c71897ab1ab256216 (diff)
make Logging a service and inject it to SyncRestClient
Issue-ID: VID-611 Change-Id: I120782884351c55b2e0d1b4ca8bae1e2479d1d0a Signed-off-by: Eylon Malin <eylon.malin@intl.att.com>
Diffstat (limited to 'vid-app-common/src/test')
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/aai/AaiClientTest.java6
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/aai/AaiOverTLSClientServerTest.java24
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/aai/PombaRestInterfaceTest.java49
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/aai/util/AAIRestInterfaceTest.java51
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/aai/util/ParametrizedAAIRestInterfaceTest.java40
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/asdc/rest/SdcRestClientITTest.java11
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/asdc/rest/SdcRestClientTest.java10
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/client/SyncRestClientForHttpServerTest.java33
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/client/SyncRestClientForHttpsServerTest.java54
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/controller/LocalWebConfig.java9
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/RestMsoImplementationTest.java41
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientNewTest.java8
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTest.java6
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/rest/OutgoingRequestHeadersTest.java4
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/scheduler/SchedulerRestInterfaceTest.java13
15 files changed, 203 insertions, 156 deletions
diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/AaiClientTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/AaiClientTest.java
index 777729c03..7c08e942a 100644
--- a/vid-app-common/src/test/java/org/onap/vid/aai/AaiClientTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/aai/AaiClientTest.java
@@ -96,6 +96,7 @@ import org.onap.vid.model.probes.ExternalComponentStatus;
import org.onap.vid.model.probes.HttpRequestMetadata;
import org.onap.vid.model.probes.StatusMetadata;
import org.onap.vid.testUtils.TestUtils;
+import org.onap.vid.utils.Logging;
import org.onap.vid.utils.Unchecked;
import org.springframework.http.HttpMethod;
import org.springframework.test.context.ContextConfiguration;
@@ -648,7 +649,10 @@ public class AaiClientTest {
Response responseMock = mocks.getFakeResponse();
// prepare real AAIRestInterface and AaiClient, and wire mocks
- AAIRestInterface aaiRestInterface = new AAIRestInterface(httpsAuthClientMock, mock(ServletRequestHelper.class), mock(SystemPropertyHelper.class));
+ AAIRestInterface aaiRestInterface = new AAIRestInterface(httpsAuthClientMock,
+ mock(ServletRequestHelper.class),
+ mock(SystemPropertyHelper.class),
+ mock(Logging.class));
final AaiClient aaiClient = new AaiClient(aaiRestInterface, null, null);
when(httpsAuthClientMock.getClient(any())).thenReturn(javaxClientMock);
diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/AaiOverTLSClientServerTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/AaiOverTLSClientServerTest.java
index dd7b26c12..a9fe256c1 100644
--- a/vid-app-common/src/test/java/org/onap/vid/aai/AaiOverTLSClientServerTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/aai/AaiOverTLSClientServerTest.java
@@ -20,12 +20,17 @@
package org.onap.vid.aai;
+import static org.mockito.Mockito.mock;
+import static org.mockito.MockitoAnnotations.initMocks;
+
import com.fasterxml.jackson.core.JsonProcessingException;
import com.xebialabs.restito.semantics.Action;
import io.joshworks.restclient.http.HttpResponse;
import io.joshworks.restclient.http.mapper.ObjectMapper;
+import java.io.IOException;
import org.assertj.core.api.Assertions;
import org.glassfish.grizzly.http.util.HttpStatus;
+import org.jetbrains.annotations.NotNull;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
import org.mockito.Mock;
@@ -33,15 +38,12 @@ import org.onap.vid.aai.model.ResourceType;
import org.onap.vid.client.SyncRestClient;
import org.onap.vid.model.SubscriberList;
import org.onap.vid.testUtils.StubServerUtil;
+import org.onap.vid.utils.Logging;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import java.io.IOException;
-
-import static org.mockito.MockitoAnnotations.initMocks;
-
public class AaiOverTLSClientServerTest {
@Mock
@@ -107,8 +109,7 @@ public class AaiOverTLSClientServerTest {
@Test
public void shouldSearchNodeTypeByName() throws IOException, ParseException {
- ObjectMapper objectMapper = getFasterXmlObjectMapper();
- AaiOverTLSClient aaiOverTLSClient = new AaiOverTLSClient(new SyncRestClient(objectMapper), propertySupplier, serverUtil.constructTargetUrl("http", ""));
+ AaiOverTLSClient aaiOverTLSClient = createAaiOverTLSClient();
serverUtil.prepareGetCall("/nodes/generic-vnfs", new JSONParser().parse(searchNodesQueryResponsePayload), Action.status(HttpStatus.OK_200));
@@ -118,10 +119,19 @@ public class AaiOverTLSClientServerTest {
Assertions.assertThat(aaiNodeQueryResponseHttpResponse).isEqualTo(true);
}
+ @NotNull
+ private AaiOverTLSClient createAaiOverTLSClient() {
+ return new AaiOverTLSClient(
+ new SyncRestClient(getFasterXmlObjectMapper(), mock(Logging.class)),
+ propertySupplier,
+ serverUtil.constructTargetUrl("http", "")
+ );
+ }
+
@Test
public void shouldGetSubscribers() throws ParseException, JsonProcessingException {
ObjectMapper objectMapper = getFasterXmlObjectMapper();
- AaiOverTLSClient aaiOverTLSClient = new AaiOverTLSClient(new SyncRestClient(objectMapper), propertySupplier, serverUtil.constructTargetUrl("http", ""));
+ AaiOverTLSClient aaiOverTLSClient = createAaiOverTLSClient();
serverUtil.prepareGetCall("/business/customers", new JSONParser().parse(subscribersResponsePayload), Action.status(HttpStatus.OK_200));
diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/PombaRestInterfaceTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/PombaRestInterfaceTest.java
index b409c1f46..5de993c73 100644
--- a/vid-app-common/src/test/java/org/onap/vid/aai/PombaRestInterfaceTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/aai/PombaRestInterfaceTest.java
@@ -20,30 +20,9 @@
package org.onap.vid.aai;
-import org.mockito.Mock;
-import org.onap.vid.aai.util.HttpClientMode;
-import org.onap.vid.aai.util.HttpsAuthClient;
-import org.onap.vid.aai.util.ServletRequestHelper;
-import org.onap.vid.aai.util.SystemPropertyHelper;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.client.Invocation;
-import javax.ws.rs.client.WebTarget;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import java.io.IOException;
-import java.security.GeneralSecurityException;
-import java.util.UUID;
-import java.util.regex.Pattern;
-
import static org.assertj.core.api.Assertions.assertThat;
-
-import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.matches;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.verify;
@@ -53,6 +32,25 @@ import static org.onap.vid.aai.AaiOverTLSClientInterface.HEADERS.FROM_APP_ID_HEA
import static org.onap.vid.aai.AaiOverTLSClientInterface.HEADERS.TRANSACTION_ID_HEADER;
import static org.onap.vid.utils.Logging.REQUEST_ID_HEADER_KEY;
+import java.io.IOException;
+import java.security.GeneralSecurityException;
+import java.util.UUID;
+import java.util.regex.Pattern;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.client.Invocation;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import org.mockito.Mock;
+import org.onap.vid.aai.util.HttpClientMode;
+import org.onap.vid.aai.util.HttpsAuthClient;
+import org.onap.vid.aai.util.ServletRequestHelper;
+import org.onap.vid.aai.util.SystemPropertyHelper;
+import org.onap.vid.utils.Logging;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
public class PombaRestInterfaceTest {
private static final String UUID_REGEX = "[a-f0-9]{8}(-[a-f0-9]{4}){3}-[a-f0-9]{12}";
private static final String SAMPLE_APP_ID = "vid";
@@ -81,6 +79,9 @@ public class PombaRestInterfaceTest {
@Mock
private Response response;
+ @Mock
+ private Logging loggingService;
+
private PombaRestInterface pombaRestInterface;
@BeforeMethod
@@ -90,7 +91,7 @@ public class PombaRestInterfaceTest {
when(requestHelper.extractOrGenerateRequestId()).thenReturn(UUID.randomUUID().toString());
when(authClient.getClient(HttpClientMode.WITH_KEYSTORE)).thenReturn(client);
setUpBuilder();
- pombaRestInterface = new PombaRestInterface(authClient, requestHelper, systemPropertyHelper);
+ pombaRestInterface = new PombaRestInterface(authClient, requestHelper, systemPropertyHelper, loggingService);
}
@@ -124,4 +125,4 @@ public class PombaRestInterfaceTest {
when(builder.post(any(Entity.class))).thenReturn(response);
when(response.getStatusInfo()).thenReturn(Response.Status.OK);
}
-} \ No newline at end of file
+}
diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/util/AAIRestInterfaceTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/util/AAIRestInterfaceTest.java
index e64b2ac55..bf8a5a1bc 100644
--- a/vid-app-common/src/test/java/org/onap/vid/aai/util/AAIRestInterfaceTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/aai/util/AAIRestInterfaceTest.java
@@ -21,42 +21,38 @@
package org.onap.vid.aai.util;
+import static javax.ws.rs.core.Response.Status.BAD_REQUEST;
+import static javax.ws.rs.core.Response.Status.NOT_FOUND;
+import static javax.ws.rs.core.Response.Status.OK;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import static org.mockito.MockitoAnnotations.initMocks;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.util.Optional;
+import java.util.UUID;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.client.Invocation;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
import org.mockito.Mock;
import org.mockito.Mockito;
-
import org.onap.vid.aai.ExceptionWithRequestInfo;
import org.onap.vid.aai.exceptions.InvalidPropertyException;
import org.onap.vid.exceptions.GenericUncheckedException;
+import org.onap.vid.utils.Logging;
import org.onap.vid.utils.Unchecked;
import org.springframework.http.HttpMethod;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.client.Invocation;
-import javax.ws.rs.client.WebTarget;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-import java.util.Optional;
-import java.util.UUID;
-
-import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanConstructor;
-import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
-import static javax.ws.rs.core.Response.Status.*;
-import static junit.framework.TestCase.assertSame;
-import static junit.framework.TestCase.fail;
-import static org.junit.Assert.assertThat;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-import static org.mockito.MockitoAnnotations.initMocks;
-
public class AAIRestInterfaceTest {
@@ -80,6 +76,9 @@ public class AAIRestInterfaceTest {
private Response response;
@Mock
private SystemPropertyHelper systemPropertyHelper;
+ @Mock
+ private Logging loggingService;
+
private AAIRestInterface testSubject;
@@ -99,7 +98,7 @@ public class AAIRestInterfaceTest {
}
private AAIRestInterface createTestSubject() {
- return new AAIRestInterface(Optional.of(client), httpsAuthClient, servletRequestHelper, systemPropertyHelper);
+ return new AAIRestInterface(Optional.of(client), httpsAuthClient, servletRequestHelper, systemPropertyHelper, loggingService);
}
@Test
diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/util/ParametrizedAAIRestInterfaceTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/util/ParametrizedAAIRestInterfaceTest.java
index 82bb7275b..c0d3b962f 100644
--- a/vid-app-common/src/test/java/org/onap/vid/aai/util/ParametrizedAAIRestInterfaceTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/aai/util/ParametrizedAAIRestInterfaceTest.java
@@ -20,6 +20,21 @@
package org.onap.vid.aai.util;
+import static javax.ws.rs.core.Response.Status.NO_CONTENT;
+import static javax.ws.rs.core.Response.Status.OK;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.io.UnsupportedEncodingException;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Optional;
+import java.util.UUID;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.Invocation;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.Response;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -28,24 +43,9 @@ import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.onap.vid.aai.exceptions.InvalidPropertyException;
+import org.onap.vid.utils.Logging;
import org.testng.Assert;
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.Invocation;
-import javax.ws.rs.client.WebTarget;
-import javax.ws.rs.core.Response;
-import java.io.UnsupportedEncodingException;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Optional;
-import java.util.UUID;
-
-import static javax.ws.rs.core.Response.Status.NO_CONTENT;
-import static javax.ws.rs.core.Response.Status.OK;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
@RunWith(Parameterized.class)
public class ParametrizedAAIRestInterfaceTest {
@@ -67,6 +67,8 @@ public class ParametrizedAAIRestInterfaceTest {
private Response response;
@Mock
private SystemPropertyHelper systemPropertyHelper;
+ @Mock
+ private Logging loggingService;
private AAIRestInterface testSubject;
private Response.Status status;
@@ -93,13 +95,11 @@ public class ParametrizedAAIRestInterfaceTest {
}
private AAIRestInterface createTestSubject() {
- return new AAIRestInterface(Optional.of(client), httpsAuthClient, servletRequestHelper, systemPropertyHelper);
+ return new AAIRestInterface(Optional.of(client), httpsAuthClient, servletRequestHelper, systemPropertyHelper, loggingService);
}
@Test
- public void testRestDeleteWithValidResponse() throws Exception {
- // given
- String methodName = "Delete";
+ public void testRestDeleteWithValidResponse() {
// when
when(builder.delete()).thenReturn(response);
diff --git a/vid-app-common/src/test/java/org/onap/vid/asdc/rest/SdcRestClientITTest.java b/vid-app-common/src/test/java/org/onap/vid/asdc/rest/SdcRestClientITTest.java
index 589874d2a..fd946ebde 100644
--- a/vid-app-common/src/test/java/org/onap/vid/asdc/rest/SdcRestClientITTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/asdc/rest/SdcRestClientITTest.java
@@ -29,8 +29,12 @@ import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.matchesPattern;
import static org.hamcrest.collection.IsIterableContainingInOrder.contains;
import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
import static org.onap.vid.client.SyncRestClientInterface.HEADERS.X_ECOMP_INSTANCE_ID;
import static org.onap.vid.utils.Logging.REQUEST_ID_HEADER_KEY;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.xebialabs.restito.semantics.Call;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -55,8 +59,7 @@ import org.onap.vid.asdc.AsdcCatalogException;
import org.onap.vid.asdc.beans.Service;
import org.onap.vid.client.SyncRestClient;
import org.onap.vid.testUtils.StubServerUtil;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.xebialabs.restito.semantics.Call;
+import org.onap.vid.utils.Logging;
public class SdcRestClientITTest {
@@ -69,9 +72,9 @@ public class SdcRestClientITTest {
public static void setUpClass() throws GeneralSecurityException {
stubServer = new StubServerUtil();
stubServer.runSecuredServer();
- SyncRestClient syncRestClient = new SyncRestClient(createNaiveHttpClient());
+ SyncRestClient syncRestClient = new SyncRestClient(createNaiveHttpClient(), mock(Logging.class));
String serverUrl = stubServer.constructTargetUrl("https", "");
- sdcRestClient = new SdcRestClient(serverUrl, "", syncRestClient);
+ sdcRestClient = new SdcRestClient(serverUrl, "", syncRestClient, mock(Logging.class));
}
@AfterClass
diff --git a/vid-app-common/src/test/java/org/onap/vid/asdc/rest/SdcRestClientTest.java b/vid-app-common/src/test/java/org/onap/vid/asdc/rest/SdcRestClientTest.java
index 13fe761c6..837be5332 100644
--- a/vid-app-common/src/test/java/org/onap/vid/asdc/rest/SdcRestClientTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/asdc/rest/SdcRestClientTest.java
@@ -52,6 +52,7 @@ import org.onap.vid.asdc.AsdcCatalogException;
import org.onap.vid.asdc.AsdcClient;
import org.onap.vid.asdc.beans.Service;
import org.onap.vid.client.SyncRestClient;
+import org.onap.vid.utils.Logging;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@@ -80,6 +81,9 @@ public class SdcRestClientTest {
@Mock
private InputStream inputStream;
+ @Mock
+ private Logging loggingService;
+
private UUID randomId;
private Service sampleService;
@@ -92,7 +96,7 @@ public class SdcRestClientTest {
MockitoAnnotations.initMocks(this);
randomId = UUID.randomUUID();
sampleService = createTestService();
- restClient = new SdcRestClient(SAMPLE_BASE_URL, SAMPLE_AUTH, mockedSyncRestClient);
+ restClient = new SdcRestClient(SAMPLE_BASE_URL, SAMPLE_AUTH, mockedSyncRestClient, loggingService);
}
@@ -191,7 +195,7 @@ public class SdcRestClientTest {
setupMocks.accept(syncRestClient);
try {
- new SdcRestClient(SAMPLE_BASE_URL, SAMPLE_AUTH, syncRestClient).getServiceToscaModel(UUID.randomUUID());
+ new SdcRestClient(SAMPLE_BASE_URL, SAMPLE_AUTH, syncRestClient, loggingService).getServiceToscaModel(UUID.randomUUID());
} catch (Exception e) {
assertThat("root cause incorrect for " + ExceptionUtils.getStackTrace(e), ExceptionUtils.getRootCause(e), instanceOf(expectedType));
return; //OK
@@ -240,7 +244,7 @@ public class SdcRestClientTest {
setupMocks.accept(mockResponse);
try {
- new SdcRestClient(SAMPLE_BASE_URL, SAMPLE_AUTH, syncRestClient).getServiceToscaModel(UUID.randomUUID());
+ new SdcRestClient(SAMPLE_BASE_URL, SAMPLE_AUTH, syncRestClient, loggingService).getServiceToscaModel(UUID.randomUUID());
} catch (AsdcCatalogException e) {
assertThat(e.getMessage(), containsString(String.valueOf(mockResponse.getStatus())));
assertThat(e.getMessage(), containsString(exceptedBody));
diff --git a/vid-app-common/src/test/java/org/onap/vid/client/SyncRestClientForHttpServerTest.java b/vid-app-common/src/test/java/org/onap/vid/client/SyncRestClientForHttpServerTest.java
index 18b4089b5..b30cf5f32 100644
--- a/vid-app-common/src/test/java/org/onap/vid/client/SyncRestClientForHttpServerTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/client/SyncRestClientForHttpServerTest.java
@@ -20,31 +20,32 @@
package org.onap.vid.client;
+import static com.xebialabs.restito.builder.stub.StubHttp.whenHttp;
+import static com.xebialabs.restito.builder.verify.VerifyHttp.verifyHttp;
+import static com.xebialabs.restito.semantics.Action.contentType;
+import static com.xebialabs.restito.semantics.Action.ok;
+import static com.xebialabs.restito.semantics.Action.status;
+import static com.xebialabs.restito.semantics.Action.stringContent;
+import static org.mockito.Mockito.mock;
+import static org.testng.Assert.assertEquals;
+
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.ImmutableMap;
+import com.xebialabs.restito.semantics.Action;
import com.xebialabs.restito.semantics.Condition;
import com.xebialabs.restito.server.StubServer;
import io.joshworks.restclient.http.HttpResponse;
import io.joshworks.restclient.http.JsonNode;
+import java.util.Collections;
+import java.util.Map;
+import org.glassfish.grizzly.http.Method;
import org.glassfish.grizzly.http.util.HttpStatus;
-import com.xebialabs.restito.semantics.Action;
-import org.testng.annotations.BeforeMethod;
+import org.onap.vid.utils.Logging;
import org.testng.annotations.AfterMethod;
-import org.glassfish.grizzly.http.Method;
+import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import java.util.Collections;
-import java.util.Map;
-
-import static com.xebialabs.restito.builder.verify.VerifyHttp.verifyHttp;
-import static com.xebialabs.restito.builder.stub.StubHttp.whenHttp;
-import static com.xebialabs.restito.semantics.Action.stringContent;
-import static com.xebialabs.restito.semantics.Action.contentType;
-import static com.xebialabs.restito.semantics.Action.status;
-import static com.xebialabs.restito.semantics.Action.ok;
-import static org.testng.Assert.assertEquals;
-
public class SyncRestClientForHttpServerTest {
private static final SyncRestClientModel.TestModel testObject = new SyncRestClientModel.TestModel(1, "test");
@@ -53,12 +54,14 @@ public class SyncRestClientForHttpServerTest {
private StubServer stubServer;
private ObjectMapper objectMapper = new ObjectMapper();
private SyncRestClient syncRestClient;
+ private Logging mockLoggingService;
@BeforeMethod
public void setUp() {
stubServer = new StubServer();
stubServer.run();
- syncRestClient = new SyncRestClient();
+ mockLoggingService = mock(Logging.class);
+ syncRestClient = new SyncRestClient(mockLoggingService);
}
@AfterMethod
diff --git a/vid-app-common/src/test/java/org/onap/vid/client/SyncRestClientForHttpsServerTest.java b/vid-app-common/src/test/java/org/onap/vid/client/SyncRestClientForHttpsServerTest.java
index a1297bd7c..758dd070b 100644
--- a/vid-app-common/src/test/java/org/onap/vid/client/SyncRestClientForHttpsServerTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/client/SyncRestClientForHttpsServerTest.java
@@ -20,40 +20,40 @@
package org.onap.vid.client;
+import static com.xebialabs.restito.builder.stub.StubHttp.whenHttp;
+import static com.xebialabs.restito.builder.verify.VerifyHttp.verifyHttp;
+import static com.xebialabs.restito.semantics.Action.contentType;
+import static com.xebialabs.restito.semantics.Action.ok;
+import static com.xebialabs.restito.semantics.Action.stringContent;
+import static org.apache.http.client.config.RequestConfig.custom;
+import static org.mockito.Mockito.mock;
+import static org.testng.Assert.assertEquals;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.xebialabs.restito.semantics.Action;
+import com.xebialabs.restito.semantics.Condition;
+import com.xebialabs.restito.server.StubServer;
import io.joshworks.restclient.http.HttpResponse;
import io.joshworks.restclient.http.JsonNode;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
+import java.security.GeneralSecurityException;
+import java.util.Collections;
+import javax.net.ssl.SSLContext;
+import org.apache.http.config.Registry;
+import org.apache.http.config.RegistryBuilder;
import org.apache.http.conn.socket.ConnectionSocketFactory;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
-import com.fasterxml.jackson.core.JsonProcessingException;
+import org.apache.http.conn.ssl.SSLContextBuilder;
import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
-import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
-import org.apache.http.conn.ssl.SSLContextBuilder;
-import com.xebialabs.restito.semantics.Condition;
-import com.xebialabs.restito.server.StubServer;
-import com.xebialabs.restito.semantics.Action;
-import org.apache.http.config.RegistryBuilder;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.AfterMethod;
+import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.glassfish.grizzly.http.Method;
-import org.apache.http.client.HttpClient;
-import org.apache.http.config.Registry;
+import org.onap.vid.utils.Logging;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import java.security.GeneralSecurityException;
-import javax.net.ssl.SSLContext;
-import java.util.Collections;
-
-import static com.xebialabs.restito.builder.verify.VerifyHttp.verifyHttp;
-import static com.xebialabs.restito.builder.stub.StubHttp.whenHttp;
-import static com.xebialabs.restito.semantics.Action.stringContent;
-import static com.xebialabs.restito.semantics.Action.contentType;
-import static org.apache.http.client.config.RequestConfig.custom;
-import static com.xebialabs.restito.semantics.Action.ok;
-import static org.testng.Assert.assertEquals;
-
public class SyncRestClientForHttpsServerTest {
private static final SyncRestClientModel.TestModel testObject = new SyncRestClientModel.TestModel(1, "test");
@@ -62,12 +62,14 @@ public class SyncRestClientForHttpsServerTest {
private ObjectMapper objectMapper = new ObjectMapper();
private SyncRestClient syncRestClient;
+ private Logging mockLoggingService;
@BeforeMethod
public void setUp() throws GeneralSecurityException {
stubServer = new StubServer();
stubServer.secured().run();
- syncRestClient = new SyncRestClient(createNaiveHttpClient());
+ mockLoggingService = mock(Logging.class);
+ syncRestClient = new SyncRestClient(createNaiveHttpClient(), mockLoggingService);
}
@AfterMethod
diff --git a/vid-app-common/src/test/java/org/onap/vid/controller/LocalWebConfig.java b/vid-app-common/src/test/java/org/onap/vid/controller/LocalWebConfig.java
index 17e0c44e0..fcc314a3c 100644
--- a/vid-app-common/src/test/java/org/onap/vid/controller/LocalWebConfig.java
+++ b/vid-app-common/src/test/java/org/onap/vid/controller/LocalWebConfig.java
@@ -27,7 +27,6 @@ import java.util.concurrent.ExecutorService;
import javax.servlet.ServletContext;
import org.onap.vid.aai.AaiClient;
import org.onap.vid.aai.AaiClientInterface;
-import org.onap.vid.aai.AaiOverTLSClientInterface;
import org.onap.vid.aai.AaiResponseTranslator;
import org.onap.vid.aai.model.PortDetailsTranslator;
import org.onap.vid.aai.util.AAIRestInterface;
@@ -46,6 +45,7 @@ import org.onap.vid.services.AaiService;
import org.onap.vid.services.AaiServiceImpl;
import org.onap.vid.services.VidService;
import org.onap.vid.services.VidServiceImpl;
+import org.onap.vid.utils.Logging;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -103,8 +103,11 @@ public class LocalWebConfig {
}
@Bean(name = "aaiRestInterface")
- public AAIRestInterface aaiRestInterface(HttpsAuthClient httpsAuthClientFactory, ServletRequestHelper servletRequestHelper, SystemPropertyHelper systemPropertyHelper) {
- return new AAIRestInterface(httpsAuthClientFactory, servletRequestHelper, systemPropertyHelper);
+ public AAIRestInterface aaiRestInterface(HttpsAuthClient httpsAuthClientFactory,
+ ServletRequestHelper servletRequestHelper,
+ SystemPropertyHelper systemPropertyHelper,
+ Logging loggingService) {
+ return new AAIRestInterface(httpsAuthClientFactory, servletRequestHelper, systemPropertyHelper, loggingService);
}
@Bean
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/RestMsoImplementationTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/RestMsoImplementationTest.java
index 102c89ac1..e1b78740a 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/RestMsoImplementationTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/RestMsoImplementationTest.java
@@ -3,6 +3,7 @@
* VID
* ================================================================================
* Copyright (C) 2019 Nokia Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,35 +21,37 @@
package org.onap.vid.mso;
+import static org.assertj.core.api.Java6Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.when;
+import static org.mockito.MockitoAnnotations.initMocks;
+
import io.joshworks.restclient.request.HttpRequest;
+import java.io.IOException;
+import java.security.GeneralSecurityException;
+import java.util.Optional;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.MultivaluedHashMap;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Response;
import org.glassfish.jersey.client.JerseyInvocation;
import org.mockito.InjectMocks;
import org.mockito.Mock;
+import org.onap.vid.aai.util.HttpClientMode;
import org.onap.vid.aai.util.HttpsAuthClient;
import org.onap.vid.changeManagement.RequestDetailsWrapper;
import org.onap.vid.exceptions.GenericUncheckedException;
import org.onap.vid.mso.rest.RequestDetails;
+import org.onap.vid.utils.Logging;
import org.onap.vid.utils.SystemPropertiesWrapper;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.client.WebTarget;
-import javax.ws.rs.core.MultivaluedHashMap;
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.core.Response;
-
-import java.util.Optional;
-
-import static org.assertj.core.api.Java6Assertions.assertThat;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.when;
-import static org.mockito.MockitoAnnotations.initMocks;
-
public class RestMsoImplementationTest {
@Mock
@@ -75,15 +78,19 @@ public class RestMsoImplementationTest {
@Mock
private SystemPropertiesWrapper systemProperties;
+ @Mock
+ private Logging loggingService;
+
@InjectMocks
- private RestMsoImplementation restMsoImplementation = new RestMsoImplementation(mockHttpsAuthClient, systemProperties);
+ private RestMsoImplementation restMsoImplementation;
private String path = "/test_path/";
private String rawData = "test-row-data";
@BeforeClass
- public void setUp(){
+ public void setUp() throws GeneralSecurityException, IOException {
initMocks(this);
+ when(mockHttpsAuthClient.getClient(any(HttpClientMode.class))).thenReturn(mockClient);
when(systemProperties.getProperty(MsoProperties.MSO_PASSWORD)).thenReturn("OBF:1ghz1kfx1j1w1m7w1i271e8q1eas1hzj1m4i1iyy1kch1gdz");
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientNewTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientNewTest.java
index 65cfcc18d..f89eae25e 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientNewTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientNewTest.java
@@ -53,6 +53,7 @@ import org.onap.vid.mso.MsoProperties;
import org.onap.vid.mso.MsoResponseWrapper;
import org.onap.vid.mso.MsoResponseWrapperInterface;
import org.onap.vid.mso.RestObject;
+import org.onap.vid.utils.Logging;
import org.onap.vid.utils.SystemPropertiesWrapper;
import org.springframework.test.context.ContextConfiguration;
@@ -410,7 +411,7 @@ public class MsoRestClientNewTest {
String sourceId = "";
String endpoint = "";
final SyncRestClient client = mock(SyncRestClient.class);
- MsoRestClientNew testSubject = new MsoRestClientNew(client, "", null, new SystemPropertiesWrapper());
+ MsoRestClientNew testSubject = new MsoRestClientNew(client, "", null, new SystemPropertiesWrapper(), mock(Logging.class));
// setup
final HttpResponse<String> response = mock(HttpResponse.class);
@@ -474,10 +475,11 @@ public class MsoRestClientNewTest {
private MsoRestClientNew msoRestClient() {
final WebConfig webConfig = new WebConfig();
- return new MsoRestClientNew(new SyncRestClient(webConfig.unirestFasterxmlObjectMapper(new ObjectMapper())), baseUrl(), null, new SystemPropertiesWrapper());
+ return new MsoRestClientNew(new SyncRestClient(webConfig.unirestFasterxmlObjectMapper(new ObjectMapper()), mock(Logging.class)),
+ baseUrl(), null, new SystemPropertiesWrapper(), mock(Logging.class));
}
private MsoRestClientNew createTestSubject() {
- return new MsoRestClientNew(null, "", null, new SystemPropertiesWrapper());
+ return new MsoRestClientNew(null, "", null, new SystemPropertiesWrapper(), mock(Logging.class));
}
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTest.java
index 78982ef24..5486becad 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTest.java
@@ -64,6 +64,7 @@ import org.onap.vid.mso.MsoResponseWrapperInterface;
import org.onap.vid.mso.MsoUtil;
import org.onap.vid.mso.RestObject;
import org.onap.vid.mso.model.RequestReferences;
+import org.onap.vid.utils.Logging;
import org.onap.vid.utils.SystemPropertiesWrapper;
import org.springframework.http.HttpMethod;
import org.springframework.test.context.ContextConfiguration;
@@ -87,6 +88,9 @@ public class MsoRestClientTest {
@Mock
private SystemPropertiesWrapper systemProperties;
+ @Mock
+ private Logging loggingService;
+
private MsoRestClientNew restClient;
@@ -95,7 +99,7 @@ public class MsoRestClientTest {
initMocks(this);
when(systemProperties.getProperty(MsoProperties.MSO_PASSWORD)).thenReturn("OBF:1ghz1kfx1j1w1m7w1i271e8q1eas1hzj1m4i1iyy1kch1gdz");
when(systemProperties.getProperty("app_display_name")).thenReturn("vid");
- restClient = new MsoRestClientNew(client,baseUrl,null,systemProperties);
+ restClient = new MsoRestClientNew(client,baseUrl,null,systemProperties,loggingService);
}
@Test
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/rest/OutgoingRequestHeadersTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/rest/OutgoingRequestHeadersTest.java
index b70ba063f..20a05e334 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/rest/OutgoingRequestHeadersTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/rest/OutgoingRequestHeadersTest.java
@@ -52,6 +52,7 @@ import org.onap.vid.aai.util.ServletRequestHelper;
import org.onap.vid.aai.util.SystemPropertyHelper;
import org.onap.vid.controller.filter.PromiseEcompRequestIdFilter;
import org.onap.vid.testUtils.TestUtils;
+import org.onap.vid.utils.Logging;
import org.onap.vid.utils.Unchecked;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.web.context.request.RequestContextHolder;
@@ -74,6 +75,9 @@ public class OutgoingRequestHeadersTest {
@Mock
private ServletRequestHelper servletRequestHelper;
+ @Mock
+ private Logging loggingService;
+
@InjectMocks
private AAIRestInterface aaiRestInterface;
diff --git a/vid-app-common/src/test/java/org/onap/vid/scheduler/SchedulerRestInterfaceTest.java b/vid-app-common/src/test/java/org/onap/vid/scheduler/SchedulerRestInterfaceTest.java
index 60f867765..8765f02d3 100644
--- a/vid-app-common/src/test/java/org/onap/vid/scheduler/SchedulerRestInterfaceTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/scheduler/SchedulerRestInterfaceTest.java
@@ -21,8 +21,13 @@
package org.onap.vid.scheduler;
+import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
+import static org.mockito.Mockito.mock;
+
import com.fasterxml.jackson.core.JsonProcessingException;
import com.xebialabs.restito.semantics.Action;
+import java.util.HashMap;
+import java.util.Map;
import org.glassfish.grizzly.http.util.HttpStatus;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
@@ -33,13 +38,9 @@ import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
import org.onap.vid.mso.RestObject;
import org.onap.vid.testUtils.StubServerUtil;
+import org.onap.vid.utils.Logging;
import org.testng.annotations.AfterMethod;
-import java.util.HashMap;
-import java.util.Map;
-
-import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
-
@RunWith(MockitoJUnitRunner.class)
public class SchedulerRestInterfaceTest {
@@ -57,7 +58,7 @@ public class SchedulerRestInterfaceTest {
put(SchedulerProperties.SCHEDULER_SERVER_URL_VAL, SAMPLE_SCHEDULER_SERVER_URL);
}};
private static StubServerUtil serverUtil;
- private static SchedulerRestInterface schedulerInterface = new SchedulerRestInterface((key) -> DUMMY_SYSTEM_PROPERTIES.get(key));
+ private static SchedulerRestInterface schedulerInterface = new SchedulerRestInterface((key) -> DUMMY_SYSTEM_PROPERTIES.get(key), mock(Logging.class));
@BeforeClass
public static void setUpClass() {