aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/main
diff options
context:
space:
mode:
authorBartosz Gardziejewski <bartosz.gardziejewski@nokia.com>2019-03-04 14:57:03 +0100
committerBartosz Gardziejewski <bartosz.gardziejewski@nokia.com>2019-03-11 09:13:24 +0100
commitaddf93c4f22bc4a2c4edcabeea3f36e0065cbb6c (patch)
treea91586acf99c24130bde55cfd44ebe3673241113 /vid-app-common/src/main
parent7c64fbbaff5985acb3a6aea977c5c15b4f2f59e1 (diff)
Increasing test coverage for vid.mso.rest
Change-Id: Ie672d561c5f1c674cce979e0f640027bb6fc0fa7 Issue-ID: VID-387 Signed-off-by: Bartosz Gardziejewski <bartosz.gardziejewski@nokia.com>
Diffstat (limited to 'vid-app-common/src/main')
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/MsoConfig.java5
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/RestMsoImplementation.java18
-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/mso/rest/Task.java3
4 files changed, 18 insertions, 12 deletions
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 563e798df..a472268a3 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
@@ -23,6 +23,7 @@ package org.onap.vid.controller;
import io.joshworks.restclient.http.mapper.ObjectMapper;
import org.onap.portalsdk.core.util.SystemProperties;
import org.onap.vid.aai.AaiClientInterface;
+import org.onap.vid.aai.util.HttpsAuthClient;
import org.onap.vid.client.SyncRestClient;
import org.onap.vid.factories.MsoRequestFactory;
import org.onap.vid.mso.MsoBusinessLogic;
@@ -47,10 +48,10 @@ public class MsoConfig {
}
@Bean
- public MsoRestClientNew msoClient(ObjectMapper unirestObjectMapper){
+ public MsoRestClientNew msoClient(ObjectMapper unirestObjectMapper, HttpsAuthClient httpsAuthClient){
// Satisfy both interfaces -- MsoInterface and RestMsoImplementation
return new MsoRestClientNew(new SyncRestClient(unirestObjectMapper), SystemProperties.getProperty(
- MsoProperties.MSO_SERVER_URL));
+ MsoProperties.MSO_SERVER_URL),httpsAuthClient);
}
@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 ff12bb8bc..e14ac0e11 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
@@ -51,7 +51,7 @@ import static org.onap.vid.utils.Logging.*;
/**
* Created by pickjonathan on 26/06/2017.
*/
-public abstract class RestMsoImplementation implements RestInterface {
+public class RestMsoImplementation implements RestInterface {
/**
* The logger.
@@ -62,7 +62,7 @@ public abstract class RestMsoImplementation implements RestInterface {
/** The client. */
private Client client = null;
- @Autowired
+
protected HttpsAuthClient httpsAuthClient;
private static final String START_LOG = " start";
@@ -79,6 +79,11 @@ public abstract class RestMsoImplementation implements RestInterface {
* Instantiates a new mso rest interface.
*/
+ @Autowired
+ protected RestMsoImplementation(HttpsAuthClient httpsAuthClient){
+ this.httpsAuthClient=httpsAuthClient;
+ }
+
@SuppressWarnings("Duplicates")
protected MultivaluedHashMap<String, Object> initMsoClient()
{
@@ -139,7 +144,7 @@ public abstract class RestMsoImplementation implements RestInterface {
MultivaluedHashMap<String, Object> commonHeaders = initMsoClient();
Logging.logRequest(outgoingRequestsLogger, HttpMethod.GET, url);
- final Response cres = client.target(url)
+ final Response cres = client.target(url)
.request()
.accept(APPLICATION_JSON)
.headers(commonHeaders)
@@ -219,7 +224,8 @@ public abstract class RestMsoImplementation implements RestInterface {
.accept(APPLICATION_JSON)
.headers(commonHeaders)
//.entity(r)
- .build("DELETE", Entity.entity(r, MediaType.APPLICATION_JSON)).invoke();
+ .build("DELETE", Entity.entity(r, MediaType.APPLICATION_JSON))
+ .invoke();
Logging.logResponse(outgoingRequestsLogger, HttpMethod.DELETE, url, cres);
int status = cres.getStatus();
restObject.setStatusCode (status);
@@ -245,6 +251,7 @@ public abstract class RestMsoImplementation implements RestInterface {
catch ( Exception e ) {
logger.debug(EELFLoggerDelegate.debugLogger,"<== " + methodName + NO_RESPONSE_ENTITY_LOG
+ e.getMessage());
+ throw e;
}
}
@@ -252,7 +259,6 @@ public abstract class RestMsoImplementation implements RestInterface {
{
logger.debug(EELFLoggerDelegate.debugLogger,"<== " + methodName + WITH_URL_LOG +url+ EXCEPTION_LOG + e.toString());
throw e;
-
}
}
@@ -349,7 +355,6 @@ public abstract class RestMsoImplementation implements RestInterface {
restObject.setStatusCode (status);
return restObject;
-
}
@Override
@@ -383,6 +388,7 @@ public abstract class RestMsoImplementation implements RestInterface {
catch ( Exception e ) {
logger.debug(EELFLoggerDelegate.debugLogger,"<== " + methodName + NO_RESPONSE_ENTITY_LOG
+ e.getMessage());
+ throw e;
}
int status = cres.getStatus();
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 76e61b35f..b47981ecf 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
@@ -26,6 +26,7 @@ import org.apache.commons.codec.binary.Base64;
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.aai.util.HttpsAuthClient;
import org.onap.vid.changeManagement.MsoRequestDetails;
import org.onap.vid.changeManagement.RequestDetailsWrapper;
import org.onap.vid.client.SyncRestClient;
@@ -61,7 +62,8 @@ public class MsoRestClientNew extends RestMsoImplementation implements MsoInterf
*/
EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MsoRestClientNew.class);
- public MsoRestClientNew(SyncRestClient client, String baseUrl) {
+ public MsoRestClientNew(SyncRestClient client, String baseUrl, HttpsAuthClient authClient) {
+ super(authClient);
this.client = client;
this.baseUrl = baseUrl;
this.commonHeaders = initCommonHeaders();
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/Task.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/Task.java
index 23a5119e9..1956d8a95 100644
--- a/vid-app-common/src/main/java/org/onap/vid/mso/rest/Task.java
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/Task.java
@@ -133,7 +133,4 @@ public class Task {
public void setValidResponses(List<String> validResponses) {
this.validResponses = validResponses;
}
-
-
-
}