aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common
diff options
context:
space:
mode:
Diffstat (limited to 'vid-app-common')
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/PombaRestInterface.java28
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/util/AAIRestInterface.java52
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/rest/SdcRestClient.java13
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/client/SyncRestClient.java27
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/MsoConfig.java15
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/WebConfig.java31
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/RestMsoImplementation.java49
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java4
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/scheduler/SchedulerRestInterface.java40
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/utils/Logging.java39
-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
25 files changed, 374 insertions, 283 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/PombaRestInterface.java b/vid-app-common/src/main/java/org/onap/vid/aai/PombaRestInterface.java
index 2f69e397c..e9895e635 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/PombaRestInterface.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/PombaRestInterface.java
@@ -22,25 +22,31 @@
package org.onap.vid.aai;
-import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
-import org.onap.vid.aai.util.*;
-import org.onap.vid.utils.Logging;
-import org.springframework.http.HttpMethod;
+import static org.onap.vid.utils.Logging.REQUEST_ID_HEADER_KEY;
+import java.util.UUID;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-import java.util.UUID;
-
-import static org.onap.vid.utils.Logging.REQUEST_ID_HEADER_KEY;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.vid.aai.util.AAIRestInterface;
+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.springframework.http.HttpMethod;
public class PombaRestInterface extends AAIRestInterface {
private Client client = null;
- public PombaRestInterface (HttpsAuthClient httpsAuthClientFactory, ServletRequestHelper servletRequestHelper, SystemPropertyHelper systemPropertyHelper) {
- super(httpsAuthClientFactory, servletRequestHelper, systemPropertyHelper);
+ public PombaRestInterface (HttpsAuthClient httpsAuthClientFactory,
+ ServletRequestHelper servletRequestHelper,
+ SystemPropertyHelper systemPropertyHelper,
+ Logging loggingService) {
+ super(httpsAuthClientFactory, servletRequestHelper, systemPropertyHelper, loggingService);
}
@Override
@@ -64,7 +70,7 @@ public class PombaRestInterface extends AAIRestInterface {
try {
initRestClient();
- Logging.logRequest(outgoingRequestsLogger, HttpMethod.POST, url, payload);
+ loggingService.logRequest(outgoingRequestsLogger, HttpMethod.POST, url, payload);
final Response cres = client.target(url)
.request()
.accept(MediaType.APPLICATION_JSON)
@@ -72,7 +78,7 @@ public class PombaRestInterface extends AAIRestInterface {
.header(FROM_APP_ID_HEADER, fromAppId)
.header(REQUEST_ID_HEADER_KEY, extractOrGenerateRequestId())
.post(Entity.entity(payload, MediaType.APPLICATION_JSON));
- Logging.logResponse(outgoingRequestsLogger, HttpMethod.POST, url, cres);
+ loggingService.logResponse(outgoingRequestsLogger, HttpMethod.POST, url, cres);
if (cres.getStatusInfo().getFamily().equals(Response.Status.Family.SUCCESSFUL)) {
logger.info(EELFLoggerDelegate.errorLogger, getValidResponseLogMessage(methodName));
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/util/AAIRestInterface.java b/vid-app-common/src/main/java/org/onap/vid/aai/util/AAIRestInterface.java
index 92d8de757..034800516 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/util/AAIRestInterface.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/util/AAIRestInterface.java
@@ -21,7 +21,20 @@
package org.onap.vid.aai.util;
+import static org.apache.commons.lang3.ObjectUtils.defaultIfNull;
+import static org.onap.vid.utils.Logging.REQUEST_ID_HEADER_KEY;
+
import com.att.eelf.configuration.EELFLogger;
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.net.URLEncoder;
+import java.util.Optional;
+import java.util.UUID;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.client.Invocation;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
@@ -33,20 +46,6 @@ import org.onap.vid.utils.Unchecked;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpMethod;
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.client.Invocation;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-import java.net.URLEncoder;
-import java.util.Optional;
-import java.util.UUID;
-
-import static org.apache.commons.lang3.ObjectUtils.defaultIfNull;
-import static org.onap.vid.utils.Logging.REQUEST_ID_HEADER_KEY;
-
/**
* The Class AAIRestInterface.
@@ -68,6 +67,7 @@ public class AAIRestInterface {
protected HttpsAuthClient httpsAuthClientFactory;
private final ServletRequestHelper servletRequestHelper;
private final SystemPropertyHelper systemPropertyHelper;
+ protected final Logging loggingService;
protected static final String START_STRING = " start";
protected static final String TRANSACTION_ID_HEADER = "X-TransactionId";
@@ -75,10 +75,14 @@ public class AAIRestInterface {
protected static final String SUCCESSFUL_API_MESSAGE = " REST api call was successful!";
protected static final String URL_DECLARATION = ", url=";
- public AAIRestInterface(HttpsAuthClient httpsAuthClientFactory, ServletRequestHelper servletRequestHelper, SystemPropertyHelper systemPropertyHelper) {
+ public AAIRestInterface(HttpsAuthClient httpsAuthClientFactory,
+ ServletRequestHelper servletRequestHelper,
+ SystemPropertyHelper systemPropertyHelper,
+ Logging loggingService) {
this.httpsAuthClientFactory = httpsAuthClientFactory;
this.servletRequestHelper = servletRequestHelper;
this.systemPropertyHelper = systemPropertyHelper;
+ this.loggingService = loggingService;
initRestClient();
}
@@ -86,10 +90,14 @@ public class AAIRestInterface {
* For testing purpose
*/
AAIRestInterface(Optional<Client> client,
- HttpsAuthClient httpsAuthClientFactory, ServletRequestHelper servletRequestHelper, SystemPropertyHelper systemPropertyHelper){
+ HttpsAuthClient httpsAuthClientFactory,
+ ServletRequestHelper servletRequestHelper,
+ SystemPropertyHelper systemPropertyHelper,
+ Logging loggingService){
this.httpsAuthClientFactory = httpsAuthClientFactory;
this.servletRequestHelper = servletRequestHelper;
this.systemPropertyHelper = systemPropertyHelper;
+ this.loggingService = loggingService;
if (client != null && client.isPresent()){
this.client = client.get();
}
@@ -182,7 +190,7 @@ public class AAIRestInterface {
logger.debug(EELFLoggerDelegate.debugLogger, methodName + START_STRING);
logger.debug(EELFLoggerDelegate.debugLogger, url + " for the get REST API");
- Logging.logRequest(outgoingRequestsLogger, method, url, payload);
+ loggingService.logRequest(outgoingRequestsLogger, method, url, payload);
final Response response;
Invocation.Builder requestBuilder = client.target(url)
@@ -201,7 +209,7 @@ public class AAIRestInterface {
requestBuilder.build(method.name(), Entity.entity(payload, MediaType.APPLICATION_JSON));
response = restInvocation.invoke();
- Logging.logResponse(outgoingRequestsLogger, method, url, response);
+ loggingService.logResponse(outgoingRequestsLogger, method, url, response);
if (response.getStatusInfo().getFamily() == Response.Status.Family.SUCCESSFUL) {
logger.debug(EELFLoggerDelegate.debugLogger, methodName + SUCCESSFUL_API_MESSAGE);
@@ -242,7 +250,7 @@ public class AAIRestInterface {
try {
initRestClient();
- Logging.logRequest(outgoingRequestsLogger, HttpMethod.DELETE, url);
+ loggingService.logRequest(outgoingRequestsLogger, HttpMethod.DELETE, url);
final Response cres = client.target(url)
.request()
.accept(MediaType.APPLICATION_JSON)
@@ -250,7 +258,7 @@ public class AAIRestInterface {
.header(FROM_APP_ID_HEADER, sourceID)
.header(REQUEST_ID_HEADER_KEY, extractOrGenerateRequestId())
.delete();
- Logging.logResponse(outgoingRequestsLogger, HttpMethod.DELETE, url, cres);
+ loggingService.logResponse(outgoingRequestsLogger, HttpMethod.DELETE, url, cres);
if (cres.getStatusInfo().equals(Response.Status.NOT_FOUND)) {
logger.debug(EELFLoggerDelegate.debugLogger, "Resource does not exist...: " + cres.getStatus()
+ ":" + cres.readEntity(String.class));
@@ -306,7 +314,7 @@ public class AAIRestInterface {
Response response = null;
try {
initRestClient();
- Logging.logRequest(outgoingRequestsLogger, HttpMethod.POST, url, payload);
+ loggingService.logRequest(outgoingRequestsLogger, HttpMethod.POST, url, payload);
response = authenticateRequest(client.target(url)
.request()
.accept(xml ? MediaType.APPLICATION_XML : MediaType.APPLICATION_JSON)
@@ -314,7 +322,7 @@ public class AAIRestInterface {
.header(FROM_APP_ID_HEADER, fromAppId))
.header(REQUEST_ID_HEADER_KEY, extractOrGenerateRequestId())
.post(Entity.entity(payload, MediaType.APPLICATION_JSON));
- Logging.logResponse(outgoingRequestsLogger, HttpMethod.POST, url, response);
+ loggingService.logResponse(outgoingRequestsLogger, HttpMethod.POST, url, response);
if (response.getStatusInfo().getFamily().equals(Response.Status.Family.SUCCESSFUL)) {
logger.info(EELFLoggerDelegate.errorLogger, getValidResponseLogMessage(methodName));
diff --git a/vid-app-common/src/main/java/org/onap/vid/asdc/rest/SdcRestClient.java b/vid-app-common/src/main/java/org/onap/vid/asdc/rest/SdcRestClient.java
index 1de9715ee..9e139a02a 100644
--- a/vid-app-common/src/main/java/org/onap/vid/asdc/rest/SdcRestClient.java
+++ b/vid-app-common/src/main/java/org/onap/vid/asdc/rest/SdcRestClient.java
@@ -30,7 +30,6 @@ import static org.onap.vid.client.SyncRestClientInterface.HEADERS.CONTENT_TYPE;
import static org.onap.vid.client.SyncRestClientInterface.HEADERS.X_ECOMP_INSTANCE_ID;
import static org.onap.vid.client.UnirestPatchKt.extractRawAsString;
import static org.onap.vid.utils.Logging.REQUEST_ID_HEADER_KEY;
-import static org.onap.vid.utils.Logging.logRequest;
import com.att.eelf.configuration.EELFLogger;
import com.google.common.collect.ImmutableMap;
@@ -63,23 +62,25 @@ public class SdcRestClient implements AsdcClient {
private String baseUrl;
private String path;
private String auth;
- private static final EELFLogger LOGGER = Logging.getRequestsLogger("asdc");
+ private static final EELFLogger LOGGER = Logging.getRequestsLogger("sdc");
private SyncRestClientInterface syncRestClient;
+ private Logging loggingService;
- public SdcRestClient(String baseUrl, String auth, SyncRestClientInterface client) {
+ public SdcRestClient(String baseUrl, String auth, SyncRestClientInterface client, Logging loggingService) {
this.syncRestClient = client;
this.auth = auth;
this.baseUrl = baseUrl;
this.path = VidProperties.getPropertyWithDefault(ModelConstants.ASDC_SVC_API_PATH, ModelConstants.DEFAULT_ASDC_SVC_API_PATH);
+ this.loggingService = loggingService;
}
@Override
public Service getService(UUID uuid) throws AsdcCatalogException {
String finalUrl = String.format(METADATA_URL_TEMPLATE, baseUrl, path, uuid);
- logRequest(LOGGER, HttpMethod.GET, finalUrl);
+ loggingService.logRequest(LOGGER, HttpMethod.GET, finalUrl);
return Try
.of(() -> syncRestClient.get(finalUrl, prepareHeaders(auth, APPLICATION_JSON), Collections.emptyMap(), Service.class))
@@ -94,7 +95,7 @@ public class SdcRestClient implements AsdcClient {
HttpResponseWithRequestInfo<InputStream> responseWithRequestInfo = getServiceInputStream(uuid, false);
if (responseWithRequestInfo.getResponse().getStatus()>399) {
- Logging.logResponse(LOGGER, HttpMethod.GET,
+ loggingService.logRequest(LOGGER, HttpMethod.GET,
responseWithRequestInfo.getRequestUrl(), responseWithRequestInfo.getResponse());
String body = extractRawAsString(responseWithRequestInfo.getResponse());
@@ -124,7 +125,7 @@ public class SdcRestClient implements AsdcClient {
@Override
public HttpResponseWithRequestInfo<InputStream> getServiceInputStream(UUID serviceUuid, boolean warpException) {
String finalUrl = String.format(TOSCA_MODEL_URL_TEMPLATE, baseUrl, path, serviceUuid);
- logRequest(LOGGER, HttpMethod.GET, finalUrl);
+ loggingService.logRequest(LOGGER, HttpMethod.GET, finalUrl);
try {
HttpResponse<InputStream> httpResponse = syncRestClient.getStream(finalUrl, prepareHeaders(auth, APPLICATION_OCTET_STREAM), Collections.emptyMap());
return new HttpResponseWithRequestInfo<>(httpResponse, finalUrl, HttpMethod.GET);
diff --git a/vid-app-common/src/main/java/org/onap/vid/client/SyncRestClient.java b/vid-app-common/src/main/java/org/onap/vid/client/SyncRestClient.java
index 50556e7ec..18f87223c 100644
--- a/vid-app-common/src/main/java/org/onap/vid/client/SyncRestClient.java
+++ b/vid-app-common/src/main/java/org/onap/vid/client/SyncRestClient.java
@@ -23,6 +23,7 @@ package org.onap.vid.client;
import static org.apache.commons.lang3.StringUtils.isEmpty;
import static org.onap.vid.client.UnirestPatchKt.patched;
+import com.att.eelf.configuration.EELFLogger;
import io.joshworks.restclient.http.HttpResponse;
import io.joshworks.restclient.http.JsonNode;
import io.joshworks.restclient.http.RestClient;
@@ -42,6 +43,7 @@ import java.security.cert.CertificateException;
import java.util.Map;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLException;
+import org.apache.commons.lang3.ObjectUtils;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.conn.ssl.SSLContexts;
import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
@@ -51,29 +53,38 @@ import org.eclipse.jetty.util.security.Password;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.portalsdk.core.util.SystemProperties;
import org.onap.vid.properties.VidProperties;
+import org.onap.vid.utils.Logging;
public class SyncRestClient implements SyncRestClientInterface {
private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(SyncRestClient.class);
private static final String[] SUPPORTED_SSL_VERSIONS = {"TLSv1", "TLSv1.2"};
private static final String HTTPS_SCHEMA = "https://";
private static final String HTTP_SCHEMA = "http://";
+ private final Logging loggingService;
+ private final EELFLogger outgoingRequestsLogger;
private RestClient restClient;
- public SyncRestClient() {
- restClient = RestClient.newClient().objectMapper(defaultObjectMapper()).httpClient(defaultHttpClient()).build();
+ public SyncRestClient(Logging loggingService) {
+ this(null, null, loggingService);
}
- public SyncRestClient(ObjectMapper objectMapper) {
- restClient = RestClient.newClient().objectMapper(objectMapper).httpClient(defaultHttpClient()).build();
+ public SyncRestClient(ObjectMapper objectMapper, Logging loggingService) {
+ this(null, objectMapper, loggingService);
}
- public SyncRestClient(CloseableHttpClient httpClient) {
- restClient = RestClient.newClient().objectMapper(defaultObjectMapper()).httpClient(httpClient).build();
+ public SyncRestClient(CloseableHttpClient httpClient, Logging loggingService) {
+ this(httpClient, null, loggingService);
}
- public SyncRestClient(CloseableHttpClient httpClient, ObjectMapper objectMapper) {
- restClient = RestClient.newClient().objectMapper(objectMapper).httpClient(httpClient).build();
+ public SyncRestClient(CloseableHttpClient httpClient, ObjectMapper objectMapper, Logging loggingService) {
+ restClient = RestClient
+ .newClient()
+ .objectMapper(ObjectUtils.defaultIfNull(objectMapper, defaultObjectMapper()))
+ .httpClient(ObjectUtils.defaultIfNull(httpClient , defaultHttpClient()))
+ .build();
+ this.loggingService = loggingService;
+ this.outgoingRequestsLogger = Logging.getRequestsLogger("syncRestClient");
}
@Override
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/MsoConfig.java b/vid-app-common/src/main/java/org/onap/vid/controller/MsoConfig.java
index 20cf6f038..5b05caa7a 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controller/MsoConfig.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/MsoConfig.java
@@ -33,6 +33,7 @@ import org.onap.vid.mso.MsoProperties;
import org.onap.vid.mso.rest.MsoRestClientNew;
import org.onap.vid.services.CloudOwnerService;
import org.onap.vid.services.CloudOwnerServiceImpl;
+import org.onap.vid.utils.Logging;
import org.onap.vid.utils.SystemPropertiesWrapper;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -48,10 +49,18 @@ public class MsoConfig {
}
@Bean
- public MsoRestClientNew msoClient(ObjectMapper unirestObjectMapper, HttpsAuthClient httpsAuthClient, SystemPropertiesWrapper systemPropertiesWrapper){
+ public MsoRestClientNew msoClient(ObjectMapper unirestObjectMapper,
+ HttpsAuthClient httpsAuthClient,
+ SystemPropertiesWrapper systemPropertiesWrapper,
+ Logging loggingService){
// Satisfy both interfaces -- MsoInterface and RestMsoImplementation
- return new MsoRestClientNew(new SyncRestClient(unirestObjectMapper), SystemProperties.getProperty(
- MsoProperties.MSO_SERVER_URL),httpsAuthClient, systemPropertiesWrapper);
+ return new MsoRestClientNew(
+ new SyncRestClient(unirestObjectMapper, loggingService),
+ SystemProperties.getProperty(MsoProperties.MSO_SERVER_URL),
+ httpsAuthClient,
+ systemPropertiesWrapper,
+ loggingService
+ );
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/WebConfig.java b/vid-app-common/src/main/java/org/onap/vid/controller/WebConfig.java
index b9908d1e3..99845f06d 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controller/WebConfig.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/WebConfig.java
@@ -55,7 +55,6 @@ import org.onap.vid.asdc.parser.ToscaParserImpl2;
import org.onap.vid.asdc.parser.VidNotionsBuilder;
import org.onap.vid.asdc.rest.SdcRestClient;
import org.onap.vid.client.SyncRestClient;
-import org.onap.vid.client.SyncRestClientInterface;
import org.onap.vid.properties.AsdcClientConfiguration;
import org.onap.vid.properties.VidProperties;
import org.onap.vid.scheduler.SchedulerService;
@@ -67,6 +66,7 @@ import org.onap.vid.services.AaiServiceImpl;
import org.onap.vid.services.ChangeManagementService;
import org.onap.vid.services.PombaService;
import org.onap.vid.services.PombaServiceImpl;
+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;
@@ -119,13 +119,19 @@ public class WebConfig {
}
@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
- public PombaRestInterface getPombaRestInterface(HttpsAuthClient httpsAuthClientFactory, ServletRequestHelper servletRequestHelper, SystemPropertyHelper systemPropertyHelper) {
- return new PombaRestInterface(httpsAuthClientFactory, servletRequestHelper, systemPropertyHelper);
+ public PombaRestInterface getPombaRestInterface(HttpsAuthClient httpsAuthClientFactory,
+ ServletRequestHelper servletRequestHelper,
+ SystemPropertyHelper systemPropertyHelper,
+ Logging loggingService) {
+ return new PombaRestInterface(httpsAuthClientFactory, servletRequestHelper, systemPropertyHelper, loggingService);
}
@Bean
@@ -150,18 +156,13 @@ public class WebConfig {
}
@Bean
- public AsdcClient sdcClient(AsdcClientConfiguration asdcClientConfiguration, SyncRestClientInterface syncRestClient) {
+ public AsdcClient sdcClient(AsdcClientConfiguration asdcClientConfiguration, Logging loggingService) {
String auth = asdcClientConfiguration.getAsdcClientAuth();
String host = asdcClientConfiguration.getAsdcClientHost();
String protocol = asdcClientConfiguration.getAsdcClientProtocol();
int port = asdcClientConfiguration.getAsdcClientPort();
- return new SdcRestClient(protocol + "://" + host + ":" + port + "/", auth, syncRestClient);
- }
-
- @Bean
- public SyncRestClientInterface syncRestClient() {
- return new SyncRestClient();
+ return new SdcRestClient(protocol + "://" + host + ":" + port + "/", auth, new SyncRestClient(loggingService), loggingService);
}
@Bean
@@ -190,8 +191,10 @@ public class WebConfig {
}
@Bean
- public AaiOverTLSClientInterface aaiOverTLSClient(ObjectMapper unirestObjectMapper, SystemProperties systemProperties){
- return new AaiOverTLSClient(new SyncRestClient(unirestObjectMapper), new AaiOverTLSPropertySupplier());
+ public AaiOverTLSClientInterface aaiOverTLSClient(ObjectMapper unirestObjectMapper, SystemProperties systemProperties, Logging loggingService){
+ return new AaiOverTLSClient(
+ new SyncRestClient(unirestObjectMapper, loggingService),
+ new AaiOverTLSPropertySupplier());
}
@Bean
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/RestMsoImplementation.java b/vid-app-common/src/main/java/org/onap/vid/mso/RestMsoImplementation.java
index 17af75200..ee1eb0429 100644
--- a/vid-app-common/src/main/java/org/onap/vid/mso/RestMsoImplementation.java
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/RestMsoImplementation.java
@@ -20,8 +20,21 @@
package org.onap.vid.mso;
+import static org.onap.vid.utils.Logging.ONAP_REQUEST_ID_HEADER_KEY;
+import static org.onap.vid.utils.Logging.REQUEST_ID_HEADER_KEY;
+import static org.onap.vid.utils.Logging.getMethodCallerName;
+import static org.onap.vid.utils.Logging.getMethodName;
+
import com.att.eelf.configuration.EELFLogger;
import com.fasterxml.jackson.databind.ObjectMapper;
+import java.util.Collections;
+import java.util.Optional;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.client.Invocation;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedHashMap;
+import javax.ws.rs.core.Response;
import org.apache.commons.codec.binary.Base64;
import org.apache.http.HttpException;
import org.eclipse.jetty.util.security.Password;
@@ -37,22 +50,12 @@ import org.onap.vid.utils.SystemPropertiesWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpMethod;
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.client.Invocation;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedHashMap;
-import javax.ws.rs.core.Response;
-import java.util.Collections;
-import java.util.Optional;
-
-import static org.onap.vid.utils.Logging.*;
-
/**
* Created by pickjonathan on 26/06/2017.
*/
public class RestMsoImplementation implements RestInterface {
+
/**
* The logger.
*/
@@ -65,6 +68,7 @@ public class RestMsoImplementation implements RestInterface {
protected HttpsAuthClient httpsAuthClient;
protected SystemPropertiesWrapper systemProperties;
+ protected final Logging loggingService;
private static final String START_LOG = " start";
private static final String APPLICATION_JSON = "application/json";
@@ -81,9 +85,10 @@ public class RestMsoImplementation implements RestInterface {
*/
@Autowired
- protected RestMsoImplementation(HttpsAuthClient httpsAuthClient, SystemPropertiesWrapper systemProperties){
+ protected RestMsoImplementation(HttpsAuthClient httpsAuthClient, SystemPropertiesWrapper systemProperties, Logging loggingService){
this.httpsAuthClient=httpsAuthClient;
this.systemProperties = systemProperties;
+ this.loggingService = loggingService;
}
@SuppressWarnings("Duplicates")
@@ -145,13 +150,13 @@ public class RestMsoImplementation implements RestInterface {
url = systemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path;
MultivaluedHashMap<String, Object> commonHeaders = initMsoClient();
- Logging.logRequest(outgoingRequestsLogger, HttpMethod.GET, url);
+ loggingService.logRequest(outgoingRequestsLogger, HttpMethod.GET, url);
final Response cres = client.target(url)
.request()
.accept(APPLICATION_JSON)
.headers(commonHeaders)
.get();
- Logging.logResponse(outgoingRequestsLogger, HttpMethod.GET, url, cres);
+ loggingService.logResponse(outgoingRequestsLogger, HttpMethod.GET, url, cres);
cres.bufferEntity();
status = cres.getStatus();
@@ -185,13 +190,13 @@ public class RestMsoImplementation implements RestInterface {
logger.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + " sending request to url= " + url);
MultivaluedHashMap<String, Object> commonHeaders = initMsoClient();
- Logging.logRequest(outgoingRequestsLogger, HttpMethod.GET, url);
+ loggingService.logRequest(outgoingRequestsLogger, HttpMethod.GET, url);
final Response cres = client.target(url)
.request()
.accept(APPLICATION_JSON)
.headers(commonHeaders)
.get();
- Logging.logResponse(outgoingRequestsLogger, HttpMethod.GET, url, cres);
+ loggingService.logResponse(outgoingRequestsLogger, HttpMethod.GET, url, cres);
final RestObject<T> restObject = cresToRestObject(cres, clazz);
int status = cres.getStatus();
@@ -219,7 +224,7 @@ public class RestMsoImplementation implements RestInterface {
MultivaluedHashMap<String, Object> commonHeaders = initMsoClient();
url = systemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path;
- Logging.logRequest(outgoingRequestsLogger, HttpMethod.DELETE, url, r);
+ loggingService.logRequest(outgoingRequestsLogger, HttpMethod.DELETE, url, r);
cres = client.target(url)
.request()
@@ -228,7 +233,7 @@ public class RestMsoImplementation implements RestInterface {
//.entity(r)
.build("DELETE", Entity.entity(r, MediaType.APPLICATION_JSON))
.invoke();
- Logging.logResponse(outgoingRequestsLogger, HttpMethod.DELETE, url, cres);
+ loggingService.logResponse(outgoingRequestsLogger, HttpMethod.DELETE, url, cres);
int status = cres.getStatus();
restObject.setStatusCode (status);
@@ -310,7 +315,7 @@ public class RestMsoImplementation implements RestInterface {
userId.ifPresent(id->commonHeaders.put("X-RequestorID", Collections.singletonList(id)));
url = systemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path;
- Logging.logRequest(outgoingRequestsLogger, httpMethod, url, payload);
+ loggingService.logRequest(outgoingRequestsLogger, httpMethod, url, payload);
// Change the content length
final Invocation.Builder restBuilder = client.target(url)
.request()
@@ -322,7 +327,7 @@ public class RestMsoImplementation implements RestInterface {
restBuilder.build(httpMethod.name(), Entity.entity(payload, MediaType.APPLICATION_JSON));
final Response cres = restInvocation.invoke();
- Logging.logResponse(outgoingRequestsLogger, httpMethod, url, cres);
+ loggingService.logResponse(outgoingRequestsLogger, httpMethod, url, cres);
return cresToRestObject(cres, tClass);
}
catch (Exception e) {
@@ -372,7 +377,7 @@ public class RestMsoImplementation implements RestInterface {
MultivaluedHashMap<String, Object> commonHeaders = initMsoClient();
url = systemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path;
- Logging.logRequest(outgoingRequestsLogger, HttpMethod.PUT, url, r);
+ loggingService.logRequest(outgoingRequestsLogger, HttpMethod.PUT, url, r);
// Change the content length
final Response cres = client.target(url)
.request()
@@ -381,7 +386,7 @@ public class RestMsoImplementation implements RestInterface {
//.header("content-length", 201)
.put(Entity.entity(r, MediaType.APPLICATION_JSON));
- Logging.logResponse(outgoingRequestsLogger, HttpMethod.PUT, url, cres);
+ loggingService.logResponse(outgoingRequestsLogger, HttpMethod.PUT, url, cres);
try {
t = (T) cres.readEntity(t.getClass());
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java
index 4b8a974e3..b2ccde93b 100644
--- a/vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java
@@ -77,8 +77,8 @@ public class MsoRestClientNew extends RestMsoImplementation implements MsoInterf
*/
EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MsoRestClientNew.class);
- public MsoRestClientNew(SyncRestClient client, String baseUrl, HttpsAuthClient authClient, SystemPropertiesWrapper systemPropertiesWrapper) {
- super(authClient,systemPropertiesWrapper);
+ public MsoRestClientNew(SyncRestClient client, String baseUrl, HttpsAuthClient authClient, SystemPropertiesWrapper systemPropertiesWrapper, Logging loggingService) {
+ super(authClient,systemPropertiesWrapper, loggingService);
this.client = client;
this.baseUrl = baseUrl;
this.commonHeaders = initCommonHeaders();
diff --git a/vid-app-common/src/main/java/org/onap/vid/scheduler/SchedulerRestInterface.java b/vid-app-common/src/main/java/org/onap/vid/scheduler/SchedulerRestInterface.java
index 001a8ae6d..8d45bee87 100644
--- a/vid-app-common/src/main/java/org/onap/vid/scheduler/SchedulerRestInterface.java
+++ b/vid-app-common/src/main/java/org/onap/vid/scheduler/SchedulerRestInterface.java
@@ -20,11 +20,17 @@
package org.onap.vid.scheduler;
+import static org.onap.vid.utils.KotlinUtilsKt.JACKSON_OBJECT_MAPPER;
+import static org.onap.vid.utils.Logging.REQUEST_ID_HEADER_KEY;
+
import com.att.eelf.configuration.EELFLogger;
-import com.fasterxml.jackson.core.type.TypeReference;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import io.joshworks.restclient.http.HttpResponse;
+import java.util.Base64;
+import java.util.Collections;
+import java.util.Map;
+import java.util.function.Function;
import org.apache.http.HttpException;
import org.eclipse.jetty.util.security.Password;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
@@ -36,17 +42,10 @@ import org.onap.vid.exceptions.GenericUncheckedException;
import org.onap.vid.mso.RestObject;
import org.onap.vid.mso.RestObjectWithRequestInfo;
import org.onap.vid.utils.Logging;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpMethod;
import org.springframework.stereotype.Service;
-import java.util.Base64;
-import java.util.Collections;
-import java.util.Map;
-import java.util.function.Function;
-
-import static org.onap.vid.utils.KotlinUtilsKt.JACKSON_OBJECT_MAPPER;
-import static org.onap.vid.utils.Logging.REQUEST_ID_HEADER_KEY;
-
@Service
public class SchedulerRestInterface implements SchedulerRestInterfaceIfc {
@@ -57,14 +56,19 @@ public class SchedulerRestInterface implements SchedulerRestInterfaceIfc {
private Function<String, String> propertyGetter;
private Map<String, String> commonHeaders;
- public SchedulerRestInterface() {
- this.propertyGetter = SystemProperties::getProperty;
- }
+ private Logging loggingService;
- public SchedulerRestInterface(Function<String, String> propertyGetter) {
+ public SchedulerRestInterface(Function<String, String> propertyGetter, Logging loggingService) {
+ this.loggingService = loggingService;
this.propertyGetter = propertyGetter;
}
+ @Autowired
+ public SchedulerRestInterface(Logging loggingService) {
+ this.loggingService = loggingService;
+ this.propertyGetter = SystemProperties::getProperty;
+ }
+
public void initRestClient() {
logger.info("Starting to initialize rest client ");
String authStringEnc = calcEncodedAuthString();
@@ -72,7 +76,7 @@ public class SchedulerRestInterface implements SchedulerRestInterfaceIfc {
commonHeaders = Maps.newHashMap();
commonHeaders.put("Authorization", "Basic " + authStringEnc);
- syncRestClient = new SyncRestClient();
+ syncRestClient = new SyncRestClient(loggingService);
logger.info("\t<== Client Initialized \n");
}
@@ -87,14 +91,14 @@ public class SchedulerRestInterface implements SchedulerRestInterfaceIfc {
String methodName = "Get";
url = String.format("%s%s", propertyGetter.apply(SchedulerProperties.SCHEDULER_SERVER_URL_VAL), path);
initRestClient();
- Logging.logRequest(outgoingRequestsLogger, HttpMethod.GET, url);
+ loggingService.logRequest(outgoingRequestsLogger, HttpMethod.GET, url);
Map<String, String> requestHeaders = ImmutableMap.<String, String>builder()
.putAll(commonHeaders)
.put(REQUEST_ID_HEADER_KEY, Logging.extractOrGenerateRequestId())
.build();
final HttpResponse<String> response = syncRestClient.get(url, requestHeaders,
Collections.emptyMap(), String.class);
- Logging.logResponse(outgoingRequestsLogger, HttpMethod.GET, url, response);
+ loggingService.logRequest(outgoingRequestsLogger, HttpMethod.GET, url, response);
status = response.getStatus();
restObject.setStatusCode(status);
rawData = response.getBody();
@@ -121,13 +125,13 @@ public class SchedulerRestInterface implements SchedulerRestInterfaceIfc {
public <T> void Delete(T t, String sourceID, String path, RestObject<T> restObject) {
initRestClient();
String url = String.format("%s%s", propertyGetter.apply(SchedulerProperties.SCHEDULER_SERVER_URL_VAL), path);
- Logging.logRequest(outgoingRequestsLogger, HttpMethod.DELETE, url);
+ loggingService.logRequest(outgoingRequestsLogger, HttpMethod.DELETE, url);
Map<String, String> requestHeaders = ImmutableMap.<String, String>builder()
.putAll(commonHeaders)
.put(REQUEST_ID_HEADER_KEY, Logging.extractOrGenerateRequestId()).build();
final HttpResponse<T> response = (HttpResponse<T>) syncRestClient.delete(url, requestHeaders, t.getClass());
- Logging.logResponse(outgoingRequestsLogger, HttpMethod.DELETE, url, response);
+ loggingService.logRequest(outgoingRequestsLogger, HttpMethod.DELETE, url, response);
int status = response.getStatus();
restObject.setStatusCode(status);
diff --git a/vid-app-common/src/main/java/org/onap/vid/utils/Logging.java b/vid-app-common/src/main/java/org/onap/vid/utils/Logging.java
index 71478fcf1..77b7ee869 100644
--- a/vid-app-common/src/main/java/org/onap/vid/utils/Logging.java
+++ b/vid-app-common/src/main/java/org/onap/vid/utils/Logging.java
@@ -20,37 +20,34 @@
package org.onap.vid.utils;
+import static org.apache.commons.lang3.ObjectUtils.defaultIfNull;
+import static org.apache.commons.lang3.exception.ExceptionUtils.getRootCause;
+import static org.apache.commons.lang3.exception.ExceptionUtils.getThrowableList;
+import static org.onap.vid.utils.Streams.not;
+
import com.att.eelf.configuration.EELFLogger;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.google.common.collect.ImmutableList;
import io.joshworks.restclient.http.HttpResponse;
+import java.util.Arrays;
+import java.util.Optional;
+import java.util.UUID;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.Response;
import org.apache.commons.lang3.StringUtils;
-import org.onap.vid.exceptions.GenericUncheckedException;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.portalsdk.core.util.SystemProperties;
+import org.onap.vid.exceptions.GenericUncheckedException;
import org.springframework.http.HttpMethod;
+import org.springframework.stereotype.Service;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.ProcessingException;
-import javax.ws.rs.core.Response;
-import java.util.Arrays;
-import java.util.Optional;
-import java.util.UUID;
-
-import static org.apache.commons.lang3.ObjectUtils.defaultIfNull;
-import static org.apache.commons.lang3.exception.ExceptionUtils.getRootCause;
-import static org.apache.commons.lang3.exception.ExceptionUtils.getThrowableList;
-import static org.onap.vid.utils.Streams.not;
-
+@Service
public class Logging {
- private Logging() {
- }
-
public static final String HTTP_REQUESTS_OUTGOING = "http.requests.outgoing.";
public static final String REQUEST_ID_HEADER_KEY = SystemProperties.ECOMP_REQUEST_ID;
@@ -84,7 +81,7 @@ public class Logging {
return EELFLoggerDelegate.getLogger(HTTP_REQUESTS_OUTGOING +serverName);
}
- public static void logRequest(final EELFLogger logger, final HttpMethod method, final String url, final Object body) {
+ public void logRequest(final EELFLogger logger, final HttpMethod method, final String url, final Object body) {
if (!logger.isDebugEnabled()) {
return;
}
@@ -103,11 +100,11 @@ public class Logging {
}
}
- public static void logRequest(final EELFLogger logger, final HttpMethod method, final String url) {
+ public void logRequest(final EELFLogger logger, final HttpMethod method, final String url) {
logger.debug("Sending {} {}", method.name(), url);
}
- public static <T> void logResponse(final EELFLogger logger, final HttpMethod method, final String url, final Response response, final Class<T> entityClass) {
+ public <T> void logResponse(final EELFLogger logger, final HttpMethod method, final String url, final Response response, final Class<T> entityClass) {
if (!logger.isDebugEnabled()) {
return;
}
@@ -124,7 +121,7 @@ public class Logging {
}
}
- public static <T> void logResponse(final EELFLogger logger, final HttpMethod method, final String url, final HttpResponse<T> response) {
+ public <T> void logResponse(final EELFLogger logger, final HttpMethod method, final String url, final HttpResponse<T> response) {
try {
logger.debug("Received {} {} Status: {} . Body: {}", method.name(), url, response.getStatus(), response.getBody());
}
@@ -133,7 +130,7 @@ public class Logging {
}
}
- public static void logResponse(final EELFLogger logger, final HttpMethod method, final String url, final Response response) {
+ public void logResponse(final EELFLogger logger, final HttpMethod method, final String url, final Response response) {
logResponse(logger, method, url, response, String.class);
}
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() {