summaryrefslogtreecommitdiffstats
path: root/pomba/service-decomposition
diff options
context:
space:
mode:
Diffstat (limited to 'pomba/service-decomposition')
-rw-r--r--pomba/service-decomposition/pom.xml6
-rw-r--r--pomba/service-decomposition/src/main/java/org/onap/sdnc/apps/pomba/servicedecomposition/exception/DiscoveryException.java2
-rw-r--r--pomba/service-decomposition/src/main/java/org/onap/sdnc/apps/pomba/servicedecomposition/service/SpringServiceImpl.java2
-rw-r--r--pomba/service-decomposition/src/main/java/org/onap/sdnc/apps/pomba/servicedecomposition/service/rs/RestServiceImpl.java2
-rw-r--r--pomba/service-decomposition/src/main/java/org/onap/sdnc/apps/pomba/servicedecomposition/util/RestUtil.java25
-rw-r--r--pomba/service-decomposition/src/test/java/org/onap/sdnc/apps/pomba/servicedecomposition/componenttest/mockito/WebConfigurationTest.java3
6 files changed, 26 insertions, 14 deletions
diff --git a/pomba/service-decomposition/pom.xml b/pomba/service-decomposition/pom.xml
index b66ed25..6252246 100644
--- a/pomba/service-decomposition/pom.xml
+++ b/pomba/service-decomposition/pom.xml
@@ -98,6 +98,12 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>com.vaadin.external.google</groupId>
+ <artifactId>android-json</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
diff --git a/pomba/service-decomposition/src/main/java/org/onap/sdnc/apps/pomba/servicedecomposition/exception/DiscoveryException.java b/pomba/service-decomposition/src/main/java/org/onap/sdnc/apps/pomba/servicedecomposition/exception/DiscoveryException.java
index 107f98b..eee34fe 100644
--- a/pomba/service-decomposition/src/main/java/org/onap/sdnc/apps/pomba/servicedecomposition/exception/DiscoveryException.java
+++ b/pomba/service-decomposition/src/main/java/org/onap/sdnc/apps/pomba/servicedecomposition/exception/DiscoveryException.java
@@ -20,7 +20,7 @@ package org.onap.sdnc.apps.pomba.servicedecomposition.exception;
import javax.ws.rs.core.Response.Status;
public class DiscoveryException extends Exception {
- public static enum Error {
+ public enum Error {
FETCH_RESOURCE_FAILED("SD.0001", "A&AI query failed: %s"),
RELATIONSHIP_LINK_PARSE_ERROR("SD.0002", "Error in parsing relationship link"),
SERVICE_INSTANCE_NOT_FOUND("SD.0003", "Service Instance not Found"),
diff --git a/pomba/service-decomposition/src/main/java/org/onap/sdnc/apps/pomba/servicedecomposition/service/SpringServiceImpl.java b/pomba/service-decomposition/src/main/java/org/onap/sdnc/apps/pomba/servicedecomposition/service/SpringServiceImpl.java
index 4a0f0ed..191eb32 100644
--- a/pomba/service-decomposition/src/main/java/org/onap/sdnc/apps/pomba/servicedecomposition/service/SpringServiceImpl.java
+++ b/pomba/service-decomposition/src/main/java/org/onap/sdnc/apps/pomba/servicedecomposition/service/SpringServiceImpl.java
@@ -30,7 +30,7 @@ import org.springframework.beans.factory.annotation.Autowired;
@org.springframework.stereotype.Service
public class SpringServiceImpl implements SpringService {
private static EELFLogger log = EELFManager.getInstance().getLogger(SpringServiceImpl.class);
- public static String APP_NAME = "ServiceDiscovery";
+ public static final String APP_NAME = "ServiceDiscovery";
@Autowired
private RestClient aaiClient;
diff --git a/pomba/service-decomposition/src/main/java/org/onap/sdnc/apps/pomba/servicedecomposition/service/rs/RestServiceImpl.java b/pomba/service-decomposition/src/main/java/org/onap/sdnc/apps/pomba/servicedecomposition/service/rs/RestServiceImpl.java
index 19734f0..12c3935 100644
--- a/pomba/service-decomposition/src/main/java/org/onap/sdnc/apps/pomba/servicedecomposition/service/rs/RestServiceImpl.java
+++ b/pomba/service-decomposition/src/main/java/org/onap/sdnc/apps/pomba/servicedecomposition/service/rs/RestServiceImpl.java
@@ -61,7 +61,7 @@ public class RestServiceImpl implements RestService {
adapter.getServiceDescriptor().setServiceName(SERVICE_NAME);
adapter.entering(request);
try {
- if (!this.basicAuthHeader.equals(authorization)) {
+ if (authorization == null || !this.basicAuthHeader.equals(authorization)) {
throw new DiscoveryException(UNAUTHORIZED, Status.UNAUTHORIZED);
}
diff --git a/pomba/service-decomposition/src/main/java/org/onap/sdnc/apps/pomba/servicedecomposition/util/RestUtil.java b/pomba/service-decomposition/src/main/java/org/onap/sdnc/apps/pomba/servicedecomposition/util/RestUtil.java
index 8d74670..3043269 100644
--- a/pomba/service-decomposition/src/main/java/org/onap/sdnc/apps/pomba/servicedecomposition/util/RestUtil.java
+++ b/pomba/service-decomposition/src/main/java/org/onap/sdnc/apps/pomba/servicedecomposition/util/RestUtil.java
@@ -24,15 +24,18 @@ import static org.onap.sdnc.apps.pomba.servicedecomposition.exception.DiscoveryE
import static org.onap.sdnc.apps.pomba.servicedecomposition.exception.DiscoveryException.Error.SERVICE_RELATIONSHIP_PARSE_ERROR;
import com.sun.jersey.core.util.MultivaluedMapImpl;
+
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response.Status;
+
import org.json.JSONArray;
import org.json.JSONObject;
import org.onap.aai.restclient.client.OperationResult;
@@ -43,6 +46,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+
+
public class RestUtil {
// Parameters for Query AAI Model Data API
// HTTP headers
@@ -116,7 +121,7 @@ public class RestUtil {
String url = baseURL + generateServiceInstanceURL(aaiServiceInstancePath, serviceInstanceId);
// Response from service instance API call
JSONObject serviceInstancePayload = new JSONObject(
- getResource(aaiClient, url, transactionId, MediaType.valueOf(MediaType.APPLICATION_XML)));
+ getResource(aaiClient, url, transactionId));
// Handle the case if the service instance is not found in AAI
if (serviceInstancePayload == null || serviceInstancePayload.length() == 0) {
logger.info("Service Instance " + serviceInstanceId + " is not found from AAI");
@@ -153,7 +158,7 @@ public class RestUtil {
// Logic to Create the Generic VNF JSON and extract further relationships
for (JSONObject vnfPayload : vnfList) {
List<String> vnfcLinkLst = extractRelatedLink(vnfPayload, Catalog.VNFC.resourceName);
- if (vnfcLinkLst != null && vnfcLinkLst.size() != 0) {
+ if (vnfcLinkLst != null && !vnfcLinkLst.isEmpty()) {
logger.info("The number of the API call for vnfc is:" + vnfcLinkLst.size());
List<JSONObject> vnfcList = processResourceList(aaiClient, baseURL, transactionId,
Catalog.VNFC.resourceName, vnfcLinkLst);
@@ -165,7 +170,7 @@ public class RestUtil {
}
List<String> networkLinkLst = extractRelatedLink(vnfPayload, Catalog.L3NETWORK.resourceName);
- if (networkLinkLst != null && networkLinkLst.size() != 0) {
+ if (networkLinkLst != null && !networkLinkLst.isEmpty()) {
logger.info("The number of the API call for l3-network is:" + networkLinkLst.size());
List<JSONObject> networkList = processResourceList(aaiClient, baseURL, transactionId,
Catalog.L3NETWORK.resourceName, networkLinkLst);
@@ -176,7 +181,7 @@ public class RestUtil {
logger.info("No l3-network found for vnf-id:" + vnfPayload.getString("vnf-id"));
}
List<String> vserverLinkLst = extractRelatedLink(vnfPayload, Catalog.VSERVER.resourceName);
- if (vserverLinkLst != null && vserverLinkLst.size() != 0) {
+ if (vserverLinkLst != null && !vserverLinkLst.isEmpty()) {
logger.info("The number of the API call for vserver is:" + vserverLinkLst.size());
List<JSONObject> vserverList = processResourceList(aaiClient, baseURL, transactionId,
Catalog.VSERVER.resourceName, vserverLinkLst);
@@ -195,7 +200,7 @@ public class RestUtil {
}
// Add generic vnf with related resource payload to response
- if (vnfLst != null && vnfLst.size() != 0) {
+ if (vnfLst != null && !vnfLst.isEmpty()) {
response.put(Catalog.VNF.collectionName, vnfLst);
}
@@ -226,7 +231,7 @@ public class RestUtil {
// Response from generic VNF API call
JSONObject resourcePayload = new JSONObject(
- getResource(aaiClient, resourceURL, transactionId, MediaType.valueOf(MediaType.APPLICATION_XML)));
+ getResource(aaiClient, resourceURL, transactionId));
if (resourcePayload == null || resourcePayload.length() == 0) {
logger.info("Resource with url " + resourceLink + " is not found from AAI");
} else {
@@ -270,12 +275,12 @@ public class RestUtil {
logger.info("Related-To Object found null");
continue;
}
- List<String> relatedLinkList = relationMap.get(relatedToObj.toString());
+ List<String> relatedLinkList = relationMap.get(relatedToObj);
if (relatedLinkList == null) {
relatedLinkList = new ArrayList<>();
- relationMap.put(relatedToObj.toString(), relatedLinkList);
+ relationMap.put(relatedToObj, relatedLinkList);
}
- relatedLinkList.add(relatedLinkObj.toString());
+ relatedLinkList.add(relatedLinkObj);
}
}
return relationMap;
@@ -289,7 +294,7 @@ public class RestUtil {
* @return
* @throws DiscoveryException
*/
- private static String getResource(RestClient client, String url, String transId, MediaType mediaType)
+ private static String getResource(RestClient client, String url, String transId)
throws DiscoveryException {
OperationResult result = client.get(url, buildHeaders(transId), MediaType.valueOf(MediaType.APPLICATION_JSON));
diff --git a/pomba/service-decomposition/src/test/java/org/onap/sdnc/apps/pomba/servicedecomposition/componenttest/mockito/WebConfigurationTest.java b/pomba/service-decomposition/src/test/java/org/onap/sdnc/apps/pomba/servicedecomposition/componenttest/mockito/WebConfigurationTest.java
index 9728a48..11d58cb 100644
--- a/pomba/service-decomposition/src/test/java/org/onap/sdnc/apps/pomba/servicedecomposition/componenttest/mockito/WebConfigurationTest.java
+++ b/pomba/service-decomposition/src/test/java/org/onap/sdnc/apps/pomba/servicedecomposition/componenttest/mockito/WebConfigurationTest.java
@@ -19,6 +19,7 @@
package org.onap.sdnc.apps.pomba.servicedecomposition.componenttest.mockito;
import static junit.framework.TestCase.assertEquals;
+import static org.mockito.Mockito.mock;
import org.junit.Test;
import org.onap.sdnc.apps.pomba.servicedecomposition.WebConfiguration;
@@ -30,7 +31,7 @@ public class WebConfigurationTest {
public void runTest() {
WebConfiguration webConfiguration = new WebConfiguration();
WebMvcConfigurerAdapter webMvcConfigurerAdapter = webConfiguration.forwardToIndex();
- ViewResolverRegistry registry = new ViewResolverRegistry();
+ ViewResolverRegistry registry = mock(ViewResolverRegistry.class);
webMvcConfigurerAdapter.configureViewResolvers(registry);
assertEquals(registry.hasRegistrations(), false);
}