summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xdeliveries/pom.xml8
-rwxr-xr-xepsdk-app-onap/pom.xml30
-rwxr-xr-xepsdk-app-onap/src/main/webapp/WEB-INF/jsp/serviceModels.jsp2
-rw-r--r--pom.xml35
-rwxr-xr-xvid-app-common/pom.xml67
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java2
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/AaiClientInterface.java7
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/AaiOverTLSClient.java34
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/AaiOverTLSClientInterface.java3
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/AsdcClient.java7
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/local/LocalAsdcClient.java13
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/rest/SdcRestClient.java14
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/ProbeController.java32
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/ProbeInterface.java26
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/WebConfig.java5
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/probes/HttpRequestMetadata.java2
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogic.java3
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java28
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/RestObjectWithRequestInfo.java15
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/scheduler/SchedulerService.java5
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/scheduler/SchedulerServiceImpl.java2
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/AaiServiceImpl.java18
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/VidService.java4
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/VidServiceImpl.java38
-rw-r--r--vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js4
-rw-r--r--vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.html4
-rw-r--r--vid-app-common/src/main/webapp/app/vid/styles/modal-create-new.css5
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/aai/AaiClientTest.java8
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/aai/AaiOverTLSClientTest.java63
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/asdc/rest/SdcRestClientTest.java21
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/controller/AaiControllerTest.java25
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/controller/LocalWebConfig.java4
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java32
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/AaiServiceImplTest.java996
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/SchedulerServiceImplTest.java8
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/VidServiceImplTest.java56
-rw-r--r--vid-ext-services-simulator/pom.xml27
-rw-r--r--vid-webpack-master/pom.xml2
38 files changed, 1233 insertions, 422 deletions
diff --git a/deliveries/pom.xml b/deliveries/pom.xml
index 43131b32f..42af6ab31 100755
--- a/deliveries/pom.xml
+++ b/deliveries/pom.xml
@@ -96,14 +96,6 @@
</plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-deploy-plugin</artifactId>
- <version>2.8</version>
- <configuration>
- <skip>true</skip>
- </configuration>
- </plugin>
</plugins>
</build>
diff --git a/epsdk-app-onap/pom.xml b/epsdk-app-onap/pom.xml
index 20f9c0f3a..f817f8db6 100755
--- a/epsdk-app-onap/pom.xml
+++ b/epsdk-app-onap/pom.xml
@@ -16,7 +16,7 @@
<parent>
<groupId>org.onap.oparent</groupId>
<artifactId>oparent</artifactId>
- <version>1.2.3</version>
+ <version>2.0.0</version>
<relativePath/>
</parent>
@@ -31,10 +31,10 @@
<!-- Skip assembling the zip; assemble via mvn -Dskipassembly=false .. -->
<skipassembly>true</skipassembly>
<nexusproxy>https://nexus.onap.org</nexusproxy>
- <snapshotNexusPath>/content/repositories/snapshots/</snapshotNexusPath>
- <releaseNexusPath>/content/repositories/releases/</releaseNexusPath>
- <stagingNexusPath>/content/repositories/staging/</stagingNexusPath>
- <sitePath>/content/sites/site/org/onap/vid/${project.version}</sitePath>
+ <snapshotNexusPath>content/repositories/snapshots/</snapshotNexusPath>
+ <releaseNexusPath>content/repositories/releases/</releaseNexusPath>
+ <stagingNexusPath>content/repositories/staging/</stagingNexusPath>
+ <sitePath>content/sites/site/org/onap/vid/${project.version}</sitePath>
<!-- SONAR -->
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
@@ -48,17 +48,17 @@
<repository>
<id>ecomp-releases</id>
<name>VID Release Repository</name>
- <url>${nexusproxy}${releaseNexusPath}</url>
+ <url>${nexusproxy}/${releaseNexusPath}</url>
</repository>
<repository>
<id>ecomp-snapshots</id>
<name>VID Snapshot Repository</name>
- <url>${nexusproxy}${snapshotNexusPath}</url>
+ <url>${nexusproxy}/${snapshotNexusPath}</url>
</repository>
<repository>
<id>ecomp-staging</id>
<name>VID Staging Repository</name>
- <url>${nexusproxy}${stagingNexusPath}</url>
+ <url>${nexusproxy}/${stagingNexusPath}</url>
</repository>
<repository>
<!-- Snapshots repository has ECOMP snapshot artifacts -->
@@ -81,7 +81,7 @@
<!-- added for javadoc -->
<site>
<id>ecomp-site</id>
- <url>dav:${nexusproxy}${sitePath}</url>
+ <url>dav:${nexusproxy}/${sitePath}</url>
</site>
</distributionManagement>
@@ -110,18 +110,6 @@
<build>
<finalName>vid</finalName>
<plugins>
- <plugin>
- <groupId>org.sonatype.plugins</groupId>
- <artifactId>nexus-staging-maven-plugin</artifactId>
- <version>1.6.7</version>
- <extensions>true</extensions>
- <configuration>
- <nexusUrl>${nexusproxy}</nexusUrl>
- <stagingProfileId>176c31dfe190a</stagingProfileId>
- <serverId>ecomp-staging</serverId>
- </configuration>
- </plugin>
-
<!-- Compile to Java 1.8 class output format -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
diff --git a/epsdk-app-onap/src/main/webapp/WEB-INF/jsp/serviceModels.jsp b/epsdk-app-onap/src/main/webapp/WEB-INF/jsp/serviceModels.jsp
index fb55c1168..13d1d08c9 100755
--- a/epsdk-app-onap/src/main/webapp/WEB-INF/jsp/serviceModels.jsp
+++ b/epsdk-app-onap/src/main/webapp/WEB-INF/jsp/serviceModels.jsp
@@ -40,7 +40,7 @@
<script src="app/vid/scripts/filters/date.filter.js"></script>
<script src="app/vid/scripts/modals/change-management-manual-tasks-controller/change-management-manual-tasks.controller.js"></script>
<script src="app/vid/scripts/modals/new-change-management/new-change-management.controller.js"></script>
-
+<script src="app/vid/scripts/modals/vf-module-homing-data-action/vf-module-homing-data-action.controller.js"></script>
<script src="app/vid/scripts/modals/new-test-environment/new-test-environment.controller.js"></script>
<script src="app/vid/scripts/modals/alert-modal/alert-modal.controller.js"></script>
<script src="app/vid/scripts/controller/aaiSubscriberController.js"></script>
diff --git a/pom.xml b/pom.xml
index 0e5726722..b91431abc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
<parent>
<groupId>org.onap.oparent</groupId>
<artifactId>oparent</artifactId>
- <version>1.2.3</version>
+ <version>2.0.0</version>
<relativePath/>
</parent>
@@ -66,7 +66,7 @@
<!-- added for javadoc -->
<site>
<id>ecomp-site</id>
- <url>dav:${nexusproxy}${sitePath}</url>
+ <url>dav:${nexusproxy}/${sitePath}</url>
</site>
</distributionManagement>
@@ -88,10 +88,10 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<build.version>5.0.0-SNAPSHOT</build.version>
<nexusproxy>https://nexus.onap.org</nexusproxy>
- <snapshotNexusPath>/content/repositories/snapshots/</snapshotNexusPath>
- <releaseNexusPath>/content/repositories/releases/</releaseNexusPath>
- <stagingNexusPath>/content/repositories/staging/</stagingNexusPath>
- <sitePath>/content/sites/site/org/onap/vid/${project.version}</sitePath>
+ <snapshotNexusPath>content/repositories/snapshots/</snapshotNexusPath>
+ <releaseNexusPath>content/repositories/releases/</releaseNexusPath>
+ <stagingNexusPath>content/repositories/staging/</stagingNexusPath>
+ <sitePath>content/sites/site/org/onap/vid/${project.version}</sitePath>
</properties>
<build>
@@ -99,20 +99,15 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
- <version>1.3.1</version>
- </plugin>
- <plugin>
- <groupId>org.sonatype.plugins</groupId>
- <artifactId>nexus-staging-maven-plugin</artifactId>
- <version>1.6.7</version>
- <extensions>true</extensions>
+ <version>2.7</version>
<configuration>
- <nexusUrl>${nexusproxy}</nexusUrl>
- <stagingProfileId>176c31dfe190a</stagingProfileId>
- <serverId>ecomp-staging</serverId>
+ <!--
+ Update all modules of aggregator
+ http://www.mojohaus.org/versions-maven-plugin/set-mojo.html#artifactId
+ -->
+ <artifactId>*</artifactId>
</configuration>
</plugin>
-
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
@@ -128,12 +123,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-deploy-plugin</artifactId>
- <version>2.8</version>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
<configuration>
diff --git a/vid-app-common/pom.xml b/vid-app-common/pom.xml
index aefd58dc4..6a48190bd 100755
--- a/vid-app-common/pom.xml
+++ b/vid-app-common/pom.xml
@@ -17,7 +17,7 @@
<parent>
<groupId>org.onap.oparent</groupId>
<artifactId>oparent</artifactId>
- <version>1.2.3</version>
+ <version>2.0.0</version>
<relativePath/>
</parent>
@@ -36,10 +36,10 @@
<!-- Skip assembling the zip by default -->
<skipassembly>true</skipassembly>
<nexusproxy>https://nexus.onap.org</nexusproxy>
- <snapshotNexusPath>/content/repositories/snapshots/</snapshotNexusPath>
- <releaseNexusPath>/content/repositories/releases/</releaseNexusPath>
- <stagingNexusPath>/content/repositories/staging/</stagingNexusPath>
- <sitePath>/content/sites/site/org/onap/vid/${project.version}</sitePath>
+ <snapshotNexusPath>content/repositories/snapshots/</snapshotNexusPath>
+ <releaseNexusPath>content/repositories/releases/</releaseNexusPath>
+ <stagingNexusPath>content/repositories/staging/</stagingNexusPath>
+ <sitePath>content/sites/site/org/onap/vid/${project.version}</sitePath>
<aspectj.version>1.8.9</aspectj.version>
<kotlin.version>1.3.11</kotlin.version>
@@ -48,6 +48,9 @@
<eirslett.version>1.6</eirslett.version>
<node.version>v6.16.0</node.version>
+ <!-- override using -Drelease_version=foo -Dpatch_version=bar -->
+ <release_version>${env.RELEASE_VERSION}</release_version>
+ <patch_version/>
</properties>
@@ -58,17 +61,17 @@
<repository>
<id>ecomp-releases</id>
<name>VID Release Repository</name>
- <url>${nexusproxy}${releaseNexusPath}</url>
+ <url>${nexusproxy}/${releaseNexusPath}</url>
</repository>
<repository>
<id>ecomp-snapshots</id>
<name>VID Snapshot Repository</name>
- <url>${nexusproxy}${snapshotNexusPath}</url>
+ <url>${nexusproxy}/${snapshotNexusPath}</url>
</repository>
<repository>
<id>ecomp-staging</id>
<name>VID Staging Repository</name>
- <url>${nexusproxy}${stagingNexusPath}</url>
+ <url>${nexusproxy}/${stagingNexusPath}</url>
</repository>
<repository>
<!-- Snapshots repository has ECOMP snapshot artifacts -->
@@ -92,7 +95,7 @@
<!-- added for javadoc -->
<site>
<id>ecomp-site</id>
- <url>dav:${nexusproxy}${sitePath}</url>
+ <url>dav:${nexusproxy}/${sitePath}</url>
</site>
</distributionManagement>
@@ -126,18 +129,6 @@
</execution>
</executions>
</plugin>
-
- <plugin>
- <groupId>org.sonatype.plugins</groupId>
- <artifactId>nexus-staging-maven-plugin</artifactId>
- <version>1.6.7</version>
- <extensions>true</extensions>
- <configuration>
- <nexusUrl>${nexusproxy}</nexusUrl>
- <stagingProfileId>176c31dfe190a</stagingProfileId>
- <serverId>ecomp-staging</serverId>
- </configuration>
- </plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
@@ -184,6 +175,16 @@
</configuration>
</execution>
<execution>
+ <id>npm config list</id>
+ <configuration>
+ <arguments>config ls -l</arguments>
+ </configuration>
+ <goals>
+ <goal>npm</goal>
+ </goals>
+ <phase>generate-resources</phase>
+ </execution>
+ <execution>
<id>npm install</id>
<configuration>
<arguments>install</arguments>
@@ -241,6 +242,30 @@
</plugin>
<plugin>
+ <groupId>com.google.code.maven-replacer-plugin</groupId>
+ <artifactId>replacer</artifactId>
+ <version>1.5.3</version>
+ <executions>
+ <execution>
+ <phase>prepare-package</phase>
+ <goals>
+ <goal>replace</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <regex>false</regex>
+ <file>${project.basedir}/src/main/webapp/app/vid/scripts/constants/version.json</file>
+ <replacements>
+ <replacement>
+ <token>BUILD_NUMBER</token>
+ <value>${release_version}.${patch_version}.${env.BUILD_NUMBER}</value>
+ </replacement>
+ </replacements>
+ </configuration>
+ </plugin>
+
+ <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire.version}</version>
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java b/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java
index 1710d984f..7b78f0712 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java
@@ -744,7 +744,7 @@ public class AaiClient implements AaiClientInterface {
}
@Override
- public ExternalComponentStatus probeAaiGetAllSubscribers(){
+ public ExternalComponentStatus probeComponent(){
long startTime = System.currentTimeMillis();
try {
AaiResponseWithRequestInfo<SubscriberList> responseWithRequestInfo = getAllSubscribers(true);
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/AaiClientInterface.java b/vid-app-common/src/main/java/org/onap/vid/aai/AaiClientInterface.java
index 43be049a6..3f914649d 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/AaiClientInterface.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/AaiClientInterface.java
@@ -31,13 +31,12 @@ import org.onap.vid.aai.model.AaiGetTenatns.GetTenantsResponse;
import org.onap.vid.aai.model.PortDetailsTranslator;
import org.onap.vid.aai.model.Properties;
import org.onap.vid.aai.model.ResourceType;
+import org.onap.vid.controller.ProbeInterface;
import org.onap.vid.model.SubscriberList;
-import org.onap.vid.model.probes.ExternalComponentStatus;
-
/**
* Created by Oren on 7/4/17.
*/
-public interface AaiClientInterface {
+public interface AaiClientInterface extends ProbeInterface {
boolean isNodeTypeExistsByName(String name, ResourceType type);
@@ -87,8 +86,6 @@ public interface AaiClientInterface {
AaiResponse getInstanceGroupsByVnfInstanceId(String vnfInstanceId);
- ExternalComponentStatus probeAaiGetAllSubscribers();
-
Response doAaiGet(String uri, boolean xml);
String getCloudOwnerByCloudRegionId(String cloudRegionId);
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/AaiOverTLSClient.java b/vid-app-common/src/main/java/org/onap/vid/aai/AaiOverTLSClient.java
index 86c6f4aca..6dc7b6860 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/AaiOverTLSClient.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/AaiOverTLSClient.java
@@ -23,6 +23,7 @@ package org.onap.vid.aai;
import io.joshworks.restclient.http.HttpResponse;
import io.joshworks.restclient.http.JsonNode;
import io.vavr.collection.HashMap;
+import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.onap.portalsdk.core.util.SystemProperties;
import org.onap.vid.aai.model.ResourceType;
@@ -30,6 +31,10 @@ import org.onap.vid.aai.util.AAIProperties;
import org.onap.vid.client.SyncRestClientInterface;
import org.onap.vid.exceptions.GenericUncheckedException;
import org.onap.vid.model.SubscriberList;
+import org.onap.vid.model.probes.ExternalComponentStatus;
+import org.onap.vid.model.probes.HttpRequestMetadata;
+import org.onap.vid.utils.Logging;
+import org.springframework.http.HttpMethod;
import javax.ws.rs.core.MediaType;
import java.nio.charset.StandardCharsets;
@@ -37,7 +42,11 @@ import java.util.Base64;
import java.util.Collections;
import java.util.Map;
-import static org.onap.vid.aai.AaiOverTLSClientInterface.HEADERS.*;
+import static org.onap.vid.aai.AaiOverTLSClientInterface.HEADERS.ACCEPT;
+import static org.onap.vid.aai.AaiOverTLSClientInterface.HEADERS.CONTENT_TYPE;
+import static org.onap.vid.aai.AaiOverTLSClientInterface.HEADERS.FROM_APP_ID_HEADER;
+import static org.onap.vid.aai.AaiOverTLSClientInterface.HEADERS.REQUEST_ID;
+import static org.onap.vid.aai.AaiOverTLSClientInterface.HEADERS.TRANSACTION_ID_HEADER;
public class AaiOverTLSClient implements AaiOverTLSClientInterface {
@@ -88,6 +97,29 @@ public class AaiOverTLSClient implements AaiOverTLSClientInterface {
return syncRestClient.get(uri, getRequestHeaders(), Collections.emptyMap(), SubscriberList.class);
}
+ @Override
+ public ExternalComponentStatus probeComponent() {
+ String url = urlBase + String.format(URIS.SUBSCRIBERS, 0);
+ long startTime = System.currentTimeMillis();
+ ExternalComponentStatus externalComponentStatus;
+
+ try {
+ HttpResponse<SubscriberList> allSubscribers = getAllSubscribers();
+
+ HttpRequestMetadata httpRequestMetadata = new HttpRequestMetadata(HttpMethod.GET, allSubscribers.getStatus(), url,
+ IOUtils.toString(allSubscribers.getRawBody()), "VID-AAI connection using new client works", System.currentTimeMillis() - startTime);
+ externalComponentStatus = new ExternalComponentStatus(ExternalComponentStatus.Component.AAI, allSubscribers.isSuccessful(), httpRequestMetadata);
+
+ } catch (Exception e) {
+ HttpRequestMetadata httpRequestMetadata = new HttpRequestMetadata(HttpMethod.GET, 0,
+ url, "", Logging.exceptionToDescription(e), System.currentTimeMillis() - startTime);
+ externalComponentStatus = new ExternalComponentStatus(ExternalComponentStatus.Component.AAI, false, httpRequestMetadata);
+ }
+
+ return externalComponentStatus;
+ }
+
+
private Map<String, String> getRequestHeaders() {
Map<String, String> result = HashMap.of(
TRANSACTION_ID_HEADER, propertySupplier.getRandomUUID(),
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/AaiOverTLSClientInterface.java b/vid-app-common/src/main/java/org/onap/vid/aai/AaiOverTLSClientInterface.java
index 02f01e79e..4cc95890d 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/AaiOverTLSClientInterface.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/AaiOverTLSClientInterface.java
@@ -23,9 +23,10 @@ package org.onap.vid.aai;
import io.joshworks.restclient.http.HttpResponse;
import org.onap.portalsdk.core.util.SystemProperties;
import org.onap.vid.aai.model.ResourceType;
+import org.onap.vid.controller.ProbeInterface;
import org.onap.vid.model.SubscriberList;
-public interface AaiOverTLSClientInterface {
+public interface AaiOverTLSClientInterface extends ProbeInterface {
class URIS {
diff --git a/vid-app-common/src/main/java/org/onap/vid/asdc/AsdcClient.java b/vid-app-common/src/main/java/org/onap/vid/asdc/AsdcClient.java
index 37d3d2e97..fc04080d9 100644
--- a/vid-app-common/src/main/java/org/onap/vid/asdc/AsdcClient.java
+++ b/vid-app-common/src/main/java/org/onap/vid/asdc/AsdcClient.java
@@ -3,6 +3,7 @@
* VID
* ================================================================================
* Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nokia. 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,6 +21,7 @@
package org.onap.vid.asdc;
+import io.joshworks.restclient.http.HttpResponse;
import org.onap.vid.asdc.beans.Service;
import java.nio.file.Path;
@@ -32,6 +34,7 @@ public interface AsdcClient {
class URIS{
public static final String METADATA_URL_TEMPLATE = "%s%s/%s/metadata";
public static final String TOSCA_MODEL_URL_TEMPLATE = "%s%s/%s/toscaModel";
+ public static final String HEALTH_CHECK_ENDPOINT = "sdc2/rest/healthCheck";
}
/**
* Gets the service.
@@ -51,4 +54,8 @@ public interface AsdcClient {
*/
Path getServiceToscaModel(UUID uuid) throws AsdcCatalogException;
+
+ HttpResponse<String> checkSDCConnectivity();
+
+ String getBaseUrl();
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/asdc/local/LocalAsdcClient.java b/vid-app-common/src/main/java/org/onap/vid/asdc/local/LocalAsdcClient.java
index 4e5574afd..7cfd094df 100644
--- a/vid-app-common/src/main/java/org/onap/vid/asdc/local/LocalAsdcClient.java
+++ b/vid-app-common/src/main/java/org/onap/vid/asdc/local/LocalAsdcClient.java
@@ -3,6 +3,7 @@
* VID
* ================================================================================
* Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nokia. 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.
@@ -23,6 +24,7 @@ package org.onap.vid.asdc.local;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
+import io.joshworks.restclient.http.HttpResponse;
import org.json.JSONArray;
import org.json.JSONObject;
import org.onap.vid.asdc.AsdcCatalogException;
@@ -156,6 +158,17 @@ public class LocalAsdcClient implements AsdcClient {
}
}
+ @Override
+ public HttpResponse<String> checkSDCConnectivity() {
+ return HttpResponse.fallback("");
+ }
+
+
+ @Override
+ public String getBaseUrl(){
+ return "";
+ }
+
/**
* The Class Builder.
*/
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 ab07aaeed..a82110744 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
@@ -22,6 +22,7 @@ package org.onap.vid.asdc.rest;
import com.att.eelf.configuration.EELFLogger;
import com.google.common.collect.ImmutableMap;
+import io.joshworks.restclient.http.HttpResponse;
import io.vavr.control.Try;
import org.onap.portalsdk.core.util.SystemProperties;
import org.onap.vid.asdc.AsdcCatalogException;
@@ -97,6 +98,19 @@ public class SdcRestClient implements AsdcClient {
}
+ @Override
+ public HttpResponse<String> checkSDCConnectivity() {
+ String finalUrl = baseUrl + URIS.HEALTH_CHECK_ENDPOINT;
+
+ return syncRestClient
+ .get(finalUrl, prepareHeaders(auth, APPLICATION_JSON), Collections.emptyMap(), String.class);
+ }
+
+ @Override
+ public String getBaseUrl() {
+ return baseUrl;
+ }
+
private Map<String, String> prepareHeaders(String auth, String contentType) {
return ImmutableMap.of(
X_ECOMP_INSTANCE_ID, SystemProperties.getProperty(APP_DISPLAY_NAME),
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/ProbeController.java b/vid-app-common/src/main/java/org/onap/vid/controller/ProbeController.java
index 7695e2435..c181c6f30 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controller/ProbeController.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/ProbeController.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -21,42 +21,28 @@
package org.onap.vid.controller;
import org.onap.portalsdk.core.controller.RestrictedBaseController;
-import org.onap.vid.aai.AaiClient;
import org.onap.vid.model.probes.ExternalComponentStatus;
-import org.onap.vid.mso.MsoBusinessLogic;
-import org.onap.vid.scheduler.SchedulerService;
-import org.onap.vid.services.VidService;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
-import java.util.ArrayList;
import java.util.List;
+import java.util.stream.Collectors;
@RestController
@RequestMapping("probe")
public class ProbeController extends RestrictedBaseController {
- private final AaiClient aaiClient;
- private final VidService vidService;
- private final MsoBusinessLogic msoBusinessLogic;
- private final SchedulerService schedulerService;
+ private final List<ProbeInterface> probes;
@Autowired
- public ProbeController(AaiClient aaiClient, VidService vidService, MsoBusinessLogic msoBusinessLogic, SchedulerService schedulerService) {
- this.aaiClient = aaiClient;
- this.vidService = vidService;
- this.msoBusinessLogic = msoBusinessLogic;
- this.schedulerService = schedulerService;
+ public ProbeController(List<ProbeInterface> probes) {
+ this.probes = probes;
}
- @RequestMapping(method= RequestMethod.GET)
+ @GetMapping
public List<ExternalComponentStatus> getProbe() {
- List<ExternalComponentStatus> componentStatuses = new ArrayList<>();
- componentStatuses.add(aaiClient.probeAaiGetAllSubscribers());
- componentStatuses.add(schedulerService.probeGetSchedulerChangeManagements());
- return componentStatuses;
+ return probes.stream().map(ProbeInterface::probeComponent).collect(Collectors.toList());
}
-
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/ProbeInterface.java b/vid-app-common/src/main/java/org/onap/vid/controller/ProbeInterface.java
new file mode 100644
index 000000000..1b3265971
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/ProbeInterface.java
@@ -0,0 +1,26 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2019 Nokia 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.vid.controller;
+
+import org.onap.vid.model.probes.ExternalComponentStatus;
+
+public interface ProbeInterface {
+ ExternalComponentStatus probeComponent();
+}
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 e00c2d7a5..fc656fc14 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
@@ -69,11 +69,6 @@ public class WebConfig {
@Bean
- public VidService vidService(AsdcClient asdcClient, FeatureManager featureManager) {
- return new VidServiceImpl(asdcClient, featureManager);
- }
-
- @Bean
public SchedulerService schedulerService(ChangeManagementService changeManagementService) {
return new SchedulerServiceImpl(changeManagementService);
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/probes/HttpRequestMetadata.java b/vid-app-common/src/main/java/org/onap/vid/model/probes/HttpRequestMetadata.java
index bf2c3ec67..1638a376c 100644
--- a/vid-app-common/src/main/java/org/onap/vid/model/probes/HttpRequestMetadata.java
+++ b/vid-app-common/src/main/java/org/onap/vid/model/probes/HttpRequestMetadata.java
@@ -3,6 +3,7 @@
* VID
* ================================================================================
* Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nokia. 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.
@@ -21,6 +22,7 @@
package org.onap.vid.model.probes;
import com.google.common.base.MoreObjects;
+import io.joshworks.restclient.http.HttpResponse;
import org.apache.commons.lang3.StringUtils;
import org.onap.vid.aai.ExceptionWithRequestInfo;
import org.onap.vid.aai.ResponseWithRequestInfo;
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogic.java b/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogic.java
index 3b2cdb1bf..ed64d2066 100644
--- a/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogic.java
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogic.java
@@ -24,6 +24,7 @@ package org.onap.vid.mso;
import org.onap.vid.changeManagement.RequestDetailsWrapper;
import org.onap.vid.changeManagement.WorkflowRequestDetail;
import org.onap.vid.controller.OperationalEnvironmentController;
+import org.onap.vid.controller.ProbeInterface;
import org.onap.vid.model.SOWorkflowList;
import org.onap.vid.model.SoftDeleteRequest;
import org.onap.vid.mso.model.OperationalEnvironmentActivateInfo;
@@ -36,7 +37,7 @@ import org.onap.vid.mso.rest.Task;
import java.util.List;
import java.util.UUID;
-public interface MsoBusinessLogic {
+public interface MsoBusinessLogic extends ProbeInterface {
// this function should get params from tosca and send them to instance at mso, then return success response.
MsoResponseWrapper createSvcInstance(RequestDetails msoRequest);
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java b/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java
index 64c405a39..dbeaa90cb 100644
--- a/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java
@@ -27,6 +27,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import io.joshworks.restclient.http.HttpResponse;
+import org.apache.commons.collections4.ListUtils;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.portalsdk.core.util.SystemProperties;
import org.onap.vid.changeManagement.ChangeManagementRequest;
@@ -37,6 +38,9 @@ import org.onap.vid.exceptions.GenericUncheckedException;
import org.onap.vid.model.RequestReferencesContainer;
import org.onap.vid.model.SOWorkflowList;
import org.onap.vid.model.SoftDeleteRequest;
+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.mso.model.CloudConfiguration;
import org.onap.vid.mso.model.ModelInfo;
import org.onap.vid.mso.model.OperationalEnvironmentActivateInfo;
@@ -52,6 +56,7 @@ import org.onap.vid.mso.rest.RequestWrapper;
import org.onap.vid.mso.rest.Task;
import org.onap.vid.mso.rest.TaskList;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.togglz.core.manager.FeatureManager;
@@ -404,7 +409,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
} catch (IOException e) {
throw new GenericUncheckedException(e);
}
- return requestList.getRequestList();
+ return ListUtils.emptyIfNull(requestList.getRequestList());
}
@@ -858,6 +863,27 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
return msoClientInterface.addRelationshipToServiceInstance(requestDetails, addRelationshipsPath);
}
+
+ @Override
+ public ExternalComponentStatus probeComponent() {
+ String url = SystemProperties.getProperty(
+ MsoProperties.MSO_SERVER_URL) + "/" + SystemProperties.getProperty(MsoProperties.MSO_REST_API_GET_ORC_REQS);
+ long startTime = System.currentTimeMillis();
+ ExternalComponentStatus externalComponentStatus;
+
+ try {
+ String rawBody = objectMapper.writeValueAsString(getOrchestrationRequestsForDashboard());
+ StatusMetadata statusMetadata=new HttpRequestMetadata(HttpMethod.GET,200,url,rawBody,"VID-SO",System.currentTimeMillis() - startTime);
+
+ externalComponentStatus = new ExternalComponentStatus(ExternalComponentStatus.Component.MSO, true, statusMetadata);
+ } catch (Exception e) {
+ StatusMetadata statusMetadata = new HttpRequestMetadata(HttpMethod.GET, HttpStatus.INTERNAL_SERVER_ERROR.value(), url, "", e.getMessage(), System.currentTimeMillis() - startTime);
+ externalComponentStatus = new ExternalComponentStatus(ExternalComponentStatus.Component.MSO, false, statusMetadata);
+ }
+
+ return externalComponentStatus;
+ }
+
private void validateUpdateVnfConfig(RequestDetails requestDetails) {
final String noValidPayloadMsg = "No valid payload in " + ChangeManagementRequest.CONFIG_UPDATE + " request";
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/RestObjectWithRequestInfo.java b/vid-app-common/src/main/java/org/onap/vid/mso/RestObjectWithRequestInfo.java
index 84f204c6e..ed41bf264 100644
--- a/vid-app-common/src/main/java/org/onap/vid/mso/RestObjectWithRequestInfo.java
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/RestObjectWithRequestInfo.java
@@ -3,13 +3,14 @@
* VID
* ================================================================================
* Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nokia. 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.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -22,6 +23,8 @@ package org.onap.vid.mso;
import org.springframework.http.HttpMethod;
+import java.util.Objects;
+
public class RestObjectWithRequestInfo<T> {
private final RestObject<T> restObject;
@@ -38,6 +41,14 @@ public class RestObjectWithRequestInfo<T> {
this.httpMethod = httpMethod;
}
+ public RestObjectWithRequestInfo(HttpMethod httpMethod, String requestedUrl, RestObject<T> restObject) {
+ this.httpMethod = httpMethod;
+ this.requestedUrl = requestedUrl;
+ this.restObject = restObject;
+ this.httpCode = restObject.getStatusCode();
+ this.rawData = restObject.getRaw();
+ }
+
public RestObject<T> getRestObject() {
return restObject;
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/scheduler/SchedulerService.java b/vid-app-common/src/main/java/org/onap/vid/scheduler/SchedulerService.java
index 5a38bc08a..643cd22af 100644
--- a/vid-app-common/src/main/java/org/onap/vid/scheduler/SchedulerService.java
+++ b/vid-app-common/src/main/java/org/onap/vid/scheduler/SchedulerService.java
@@ -20,8 +20,7 @@
package org.onap.vid.scheduler;
-import org.onap.vid.model.probes.ExternalComponentStatus;
+import org.onap.vid.controller.ProbeInterface;
-public interface SchedulerService {
- ExternalComponentStatus probeGetSchedulerChangeManagements();
+public interface SchedulerService extends ProbeInterface {
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/scheduler/SchedulerServiceImpl.java b/vid-app-common/src/main/java/org/onap/vid/scheduler/SchedulerServiceImpl.java
index d4f136a01..5513cf4a6 100644
--- a/vid-app-common/src/main/java/org/onap/vid/scheduler/SchedulerServiceImpl.java
+++ b/vid-app-common/src/main/java/org/onap/vid/scheduler/SchedulerServiceImpl.java
@@ -40,7 +40,7 @@ public class SchedulerServiceImpl implements SchedulerService{
}
@Override
- public ExternalComponentStatus probeGetSchedulerChangeManagements() {
+ public ExternalComponentStatus probeComponent() {
long startTime = System.currentTimeMillis();
try {
RestObjectWithRequestInfo response = this.changeManagementService.getSchedulerChangeManagementsWithRequestInfo();
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/AaiServiceImpl.java b/vid-app-common/src/main/java/org/onap/vid/services/AaiServiceImpl.java
index 83832bfd0..d01f0f7ad 100644
--- a/vid-app-common/src/main/java/org/onap/vid/services/AaiServiceImpl.java
+++ b/vid-app-common/src/main/java/org/onap/vid/services/AaiServiceImpl.java
@@ -88,17 +88,13 @@ public class AaiServiceImpl implements AaiService {
private List<Service> convertModelToService(Model model) {
List<Service> services = new ArrayList<>();
- String category = "";
if(validateModel(model)){
- if(model.getModelType() != null) {
- category = model.getModelType();
- }
-
for (ModelVer modelVer: model.getModelVers().getModelVer()) {
- Service service = new Service.ServiceBuilder().setUuid(modelVer.getModelVersionId())
+ Service service = new Service.ServiceBuilder()
+ .setUuid(modelVer.getModelVersionId())
.setInvariantUUID(model.getModelInvariantId())
- .setCategory(category)
+ .setCategory(model.getModelType() != null ? model.getModelType() : "")
.setVersion(modelVer.getModelVersion())
.setName( modelVer.getModelName())
.setDistributionStatus(modelVer.getDistributionStatus())
@@ -357,7 +353,7 @@ public class AaiServiceImpl implements AaiService {
@Override
public AaiResponse<AaiGetVnfResponse> getVNFData(String globalSubscriberId, String serviceType) {
- AaiResponse response = aaiClient.getVNFData(globalSubscriberId, serviceType);
+ AaiResponse<AaiGetVnfResponse> response = aaiClient.getVNFData(globalSubscriberId, serviceType);
return filterChangeManagementVNFCandidatesResponse(response);
}
@@ -375,7 +371,7 @@ public class AaiServiceImpl implements AaiService {
return response;
}
- return new AaiResponse();
+ return new AaiResponse<>();
}
@Override
@@ -474,9 +470,9 @@ public class AaiServiceImpl implements AaiService {
public AaiResponse getInstanceGroupsByVnfInstanceId(String vnfInstanceId){
AaiResponse<AaiGetRelatedInstanceGroupsByVnfId> aaiResponse = aaiClient.getInstanceGroupsByVnfInstanceId(vnfInstanceId);
if(aaiResponse.getHttpCode() == HttpStatus.SC_OK){
- return new AaiResponse(convertGetInstanceGroupsResponseToSimpleResponse(aaiResponse.getT()), aaiResponse.getErrorMessage(), aaiResponse.getHttpCode());
+ return new AaiResponse<>(convertGetInstanceGroupsResponseToSimpleResponse(aaiResponse.getT()), aaiResponse.getErrorMessage(), aaiResponse.getHttpCode());
}
- return aaiClient.getInstanceGroupsByVnfInstanceId(vnfInstanceId);
+ return aaiResponse;
}
@Override
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/VidService.java b/vid-app-common/src/main/java/org/onap/vid/services/VidService.java
index 75343080b..18d8398a3 100644
--- a/vid-app-common/src/main/java/org/onap/vid/services/VidService.java
+++ b/vid-app-common/src/main/java/org/onap/vid/services/VidService.java
@@ -3,6 +3,7 @@
* VID
* ================================================================================
* Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nokia. 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.
@@ -21,9 +22,10 @@
package org.onap.vid.services;
import org.onap.vid.asdc.AsdcCatalogException;
+import org.onap.vid.controller.ProbeInterface;
import org.onap.vid.model.ServiceModel;
-public interface VidService {
+public interface VidService extends ProbeInterface {
ServiceModel getService(String uuid) throws AsdcCatalogException;
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/VidServiceImpl.java b/vid-app-common/src/main/java/org/onap/vid/services/VidServiceImpl.java
index d14c13ec1..9d6f74def 100644
--- a/vid-app-common/src/main/java/org/onap/vid/services/VidServiceImpl.java
+++ b/vid-app-common/src/main/java/org/onap/vid/services/VidServiceImpl.java
@@ -8,9 +8,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,6 +23,7 @@ package org.onap.vid.services;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
+import io.joshworks.restclient.http.HttpResponse;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException;
import org.onap.vid.asdc.AsdcCatalogException;
@@ -33,7 +34,11 @@ import org.onap.vid.asdc.parser.ToscaParserImpl;
import org.onap.vid.asdc.parser.ToscaParserImpl2;
import org.onap.vid.exceptions.GenericUncheckedException;
import org.onap.vid.model.ServiceModel;
+import org.onap.vid.model.probes.ExternalComponentStatus;
+import org.onap.vid.model.probes.HttpRequestMetadata;
+import org.onap.vid.utils.Logging;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpMethod;
import org.togglz.core.manager.FeatureManager;
import java.nio.file.Path;
@@ -47,6 +52,7 @@ import static org.onap.vid.properties.Features.FLAG_SERVICE_MODEL_CACHE;
* The Class VidController.
*/
+@org.springframework.stereotype.Service
public class VidServiceImpl implements VidService {
/**
* The Constant LOG.
@@ -56,7 +62,6 @@ public class VidServiceImpl implements VidService {
protected final AsdcClient asdcClient;
private final FeatureManager featureManager;
- @Autowired
private ToscaParserImpl2 toscaParser;
private final LoadingCache<String, ServiceModel> serviceModelCache;
@@ -67,10 +72,11 @@ public class VidServiceImpl implements VidService {
}
}
- public VidServiceImpl(AsdcClient asdcClient, FeatureManager featureManager) {
+ @Autowired
+ public VidServiceImpl(AsdcClient asdcClient, ToscaParserImpl2 toscaParser, FeatureManager featureManager) {
this.asdcClient = asdcClient;
this.featureManager = featureManager;
-
+ this.toscaParser=toscaParser;
this.serviceModelCache = CacheBuilder.newBuilder()
.maximumSize(1000)
.expireAfterAccess(7, TimeUnit.DAYS)
@@ -96,7 +102,7 @@ public class VidServiceImpl implements VidService {
public ServiceModel getService(String uuid) throws AsdcCatalogException {
if (featureManager.isActive(FLAG_SERVICE_MODEL_CACHE)) {
return getServiceFromCache(uuid);
- }else {
+ } else {
return getServiceFromSdc(uuid);
}
}
@@ -136,10 +142,26 @@ public class VidServiceImpl implements VidService {
return tosca.makeServiceModel(uuid, serviceCsar, asdcServiceMetadata);
}
}
-
+
@Override
- public void invalidateServiceCache(){
+ public void invalidateServiceCache() {
serviceModelCache.invalidateAll();
}
+ @Override
+ public ExternalComponentStatus probeComponent() {
+ long startTime = System.currentTimeMillis();
+ ExternalComponentStatus externalComponentStatus;
+ try {
+ HttpResponse<String> stringHttpResponse = asdcClient.checkSDCConnectivity();
+ HttpRequestMetadata httpRequestMetadata = new HttpRequestMetadata(HttpMethod.GET, stringHttpResponse.getStatus(), asdcClient.getBaseUrl() + AsdcClient.URIS.HEALTH_CHECK_ENDPOINT, stringHttpResponse.getBody(), "SDC healthCheck",
+ System.currentTimeMillis() - startTime);
+ externalComponentStatus = new ExternalComponentStatus(ExternalComponentStatus.Component.SDC, stringHttpResponse.isSuccessful(), httpRequestMetadata);
+ } catch (Exception e) {
+ HttpRequestMetadata httpRequestMetadata = new HttpRequestMetadata(HttpMethod.GET, 0,
+ AsdcClient.URIS.HEALTH_CHECK_ENDPOINT, "", Logging.exceptionToDescription(e), System.currentTimeMillis() - startTime);
+ externalComponentStatus = new ExternalComponentStatus(ExternalComponentStatus.Component.SDC, false, httpRequestMetadata);
+ }
+ return externalComponentStatus;
+ }
}
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js
index 02242cb37..2eaa7513e 100644
--- a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js
@@ -222,9 +222,7 @@
try{
var requestInfoData ={};
var requestParametersData ={};
- var moduleToScale = _.find(vnf.vfModules, function(key, item){
- return !item.scale;
- });
+ var moduleToScale = _.find(vnf.vfModules, {"scale": true});
if (vnf.availableVersions && vnf.availableVersions.length!=0){
requestInfoData ={
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.html b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.html
index 1c91ba5e9..611b8e5ef 100644
--- a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.html
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.html
@@ -65,9 +65,9 @@
<option ng-repeat="version in vnfName.availableVersions">{{version.modelInfo.modelVersion}}</option>
</select>
</td>
- <td class="col-md-1 vnf-versions-name">
+ <td class="col-md-1 vnf-versions-file">
<input ng-model="vnfName.filePath" onchange="angular.element(this).scope().selectFileForVNFName(this)" type="file" id="{{vnfName['invariant-id']}}" class="vnf-files-select" />
- <span class="vnf-versions-name">Select File<span class="caret"></span></span></td>
+ <span class="vnf-versions-file">Select File<span class="caret"></span></span></td>
</tr>
</tbody>
</table>
diff --git a/vid-app-common/src/main/webapp/app/vid/styles/modal-create-new.css b/vid-app-common/src/main/webapp/app/vid/styles/modal-create-new.css
index 9c6a06992..92ed6aa27 100644
--- a/vid-app-common/src/main/webapp/app/vid/styles/modal-create-new.css
+++ b/vid-app-common/src/main/webapp/app/vid/styles/modal-create-new.css
@@ -192,9 +192,12 @@ a.item-unselected:before {
.vnf-versions-name {
padding-top: 6px;
font-family: "OpenSans-Regular";
+}
+.vnf-versions-file {
+ padding-top: 6px;
+ font-family: "OpenSans-Regular";
position: absolute;
}
-
.vnf-versions-select-as-text {
font-family: "OpenSans-Regular";
appearance: none;
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 b98e20010..fdeeb0076 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
@@ -146,8 +146,8 @@ public class AaiClientTest {
new AaiResponseWithRequestInfo<>(
HttpMethod.GET, "url", new AaiResponse<>(subscribers, null, 200),
"rawData"));
- Mockito.when(aaiClientMock.probeAaiGetAllSubscribers()).thenCallRealMethod();
- ExternalComponentStatus result = aaiClientMock.probeAaiGetAllSubscribers();
+ Mockito.when(aaiClientMock.probeComponent()).thenCallRealMethod();
+ ExternalComponentStatus result = aaiClientMock.probeComponent();
assertThat(statusDataReflected(result),is(statusDataReflected(expectedStatus)));
assertThat(requestMetadataReflected(result.getMetadata()),is(requestMetadataReflected(expectedStatus.getMetadata())));
}
@@ -278,8 +278,8 @@ public class AaiClientTest {
}
private ExternalComponentStatus callProbeAaiGetAllSubscribersAndAssertNotAvailable() {
- Mockito.when(aaiClientMock.probeAaiGetAllSubscribers()).thenCallRealMethod();
- ExternalComponentStatus result = aaiClientMock.probeAaiGetAllSubscribers();
+ Mockito.when(aaiClientMock.probeComponent()).thenCallRealMethod();
+ ExternalComponentStatus result = aaiClientMock.probeComponent();
assertFalse(result.isAvailable());
return result;
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/AaiOverTLSClientTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/AaiOverTLSClientTest.java
index 43fb5a3bb..a1b750e53 100644
--- a/vid-app-common/src/test/java/org/onap/vid/aai/AaiOverTLSClientTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/aai/AaiOverTLSClientTest.java
@@ -21,21 +21,32 @@
package org.onap.vid.aai;
import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Lists;
+import com.google.gson.Gson;
+import io.joshworks.restclient.http.HttpResponse;
+import org.apache.commons.io.IOUtils;
import org.mockito.Answers;
import org.mockito.Mock;
-import org.mockito.Mockito;
import org.onap.vid.aai.model.ResourceType;
import org.onap.vid.client.SyncRestClient;
+import org.onap.vid.model.Subscriber;
import org.onap.vid.model.SubscriberList;
+import org.onap.vid.model.probes.ExternalComponentStatus;
+import org.springframework.http.HttpStatus;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import java.io.InputStream;
import java.util.Collections;
+import java.util.List;
import java.util.Map;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.contains;
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 AaiOverTLSClientTest {
@@ -49,6 +60,9 @@ public class AaiOverTLSClientTest {
@Mock
private AaiOverTLSPropertySupplier propertySupplier;
+ @Mock
+ private HttpResponse<SubscriberList> response;
+
@BeforeMethod
public void setUp() {
initMocks(this);
@@ -60,7 +74,7 @@ public class AaiOverTLSClientTest {
mockPropertyReader();
aaiRestClient.isNodeTypeExistsByName("name", ResourceType.GENERIC_VNF);
- Mockito.verify(syncRestClient).get(contains(SEARCH_NODES_QUERY_SEARCH_NODE_TYPE),
+ verify(syncRestClient).get(contains(SEARCH_NODES_QUERY_SEARCH_NODE_TYPE),
eq(getHeaders()), eq(Collections.emptyMap()));
}
@@ -69,15 +83,49 @@ public class AaiOverTLSClientTest {
mockPropertyReader();
aaiRestClient.getAllSubscribers();
- Mockito.verify(syncRestClient).get(contains(SUBSCRIBERS),
+ verify(syncRestClient).get(contains(SUBSCRIBERS),
eq(getHeaders()), eq(Collections.emptyMap()), eq(SubscriberList.class));
}
+
+ @Test
+ public void probeMechanismShouldReturnAllSubscribers() {
+ mockPropertyReader();
+ List<Subscriber> subscribers = Lists.newArrayList(new Subscriber());
+
+ SubscriberList subscriberList = new SubscriberList(subscribers);
+ InputStream json = IOUtils.toInputStream(new Gson().toJson(subscriberList));
+ when(syncRestClient.get(contains(SUBSCRIBERS), eq(getHeaders()), eq(Collections.emptyMap()),
+ eq(SubscriberList.class))).thenReturn(response);
+ when(response.getStatus()).thenReturn(HttpStatus.OK.value());
+ when(response.getRawBody()).thenReturn(json);
+ when(response.isSuccessful()).thenReturn(true);
+
+
+ ExternalComponentStatus externalComponentStatus = aaiRestClient.probeComponent();
+
+ assertThat(externalComponentStatus.isAvailable()).isTrue();
+ assertThat(externalComponentStatus.getComponent()).isEqualTo(ExternalComponentStatus.Component.AAI);
+ }
+
+ @Test
+ public void probeMechanismShouldHandleExceptionProperly(){
+ mockPropertyReader();
+ when(syncRestClient.get(contains(SUBSCRIBERS), eq(getHeaders()), eq(Collections.emptyMap()),
+ eq(SubscriberList.class))).thenThrow(new RuntimeException("call failed"));
+
+ ExternalComponentStatus externalComponentStatus = aaiRestClient.probeComponent();
+
+ assertThat(externalComponentStatus.isAvailable()).isFalse();
+ assertThat(externalComponentStatus.getComponent()).isEqualTo(ExternalComponentStatus.Component.AAI);
+ assertThat(externalComponentStatus.getMetadata().getDescription()).containsSequence("call failed");
+ }
+
private void mockPropertyReader() {
- Mockito.when(propertySupplier.getPassword()).thenReturn("Pass");
- Mockito.when(propertySupplier.getUsername()).thenReturn("User");
- Mockito.when(propertySupplier.getRequestId()).thenReturn("1");
- Mockito.when(propertySupplier.getRandomUUID()).thenReturn("2");
+ when(propertySupplier.getPassword()).thenReturn("Pass");
+ when(propertySupplier.getUsername()).thenReturn("User");
+ when(propertySupplier.getRequestId()).thenReturn("1");
+ when(propertySupplier.getRandomUUID()).thenReturn("2");
}
private Map<String,String> getHeaders(){
@@ -85,5 +133,4 @@ public class AaiOverTLSClientTest {
put("X-FromAppId", "VidAaiController").put("Accept", "application/json").put("X-ECOMP-RequestID", "1").
put("X-TransactionId", "2").put("Content-Type", "application/json").build();
}
-
}
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 5202661da..a20571785 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
@@ -27,17 +27,23 @@ import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
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 java.io.InputStream;
import java.nio.file.Path;
+import java.util.Collections;
import java.util.UUID;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
-import static org.mockito.ArgumentMatchers.*;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyMap;
+import static org.mockito.ArgumentMatchers.contains;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.ArgumentMatchers.matches;
import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class)
@@ -60,6 +66,9 @@ public class SdcRestClientTest {
private HttpResponse<InputStream> httpStreamResponse;
@Mock
+ private HttpResponse<String> httpStringResponse;
+
+ @Mock
private InputStream inputStream;
private UUID randomId;
@@ -123,6 +132,16 @@ public class SdcRestClientTest {
restClient.getServiceToscaModel(randomId);
}
+ @Test
+ public void shouldCallSDCHealthCheck() {
+ when(mockedSyncRestClient.get(contains(AsdcClient.URIS.HEALTH_CHECK_ENDPOINT), anyMap(),
+ eq(Collections.emptyMap()), eq(String.class))).thenReturn(httpStringResponse);
+
+
+ HttpResponse<String> stringHttpResponse = restClient.checkSDCConnectivity();
+
+ assertThat(httpStringResponse, is(stringHttpResponse));
+ }
private Service createTestService() {
Service service = new Service();
diff --git a/vid-app-common/src/test/java/org/onap/vid/controller/AaiControllerTest.java b/vid-app-common/src/test/java/org/onap/vid/controller/AaiControllerTest.java
index 35e098c1b..301101399 100644
--- a/vid-app-common/src/test/java/org/onap/vid/controller/AaiControllerTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/controller/AaiControllerTest.java
@@ -199,5 +199,30 @@ public class AaiControllerTest {
pnf.setPnfName("TestPnf");
return pnf;
}
+
+ public void getPNFInstances_shouldReturnOKResponseFromAAIService() throws Exception {
+ String globalCustomerId = "testCustomerId";
+ String serviceType = "testServiceType";
+ String modelVersionId = UUID.nameUUIDFromBytes("modelVersionId".getBytes()).toString();
+ String modelInvariantId = UUID.nameUUIDFromBytes("modelInvariantId".getBytes()).toString();
+ String cloudRegion = "testRegion";
+ String equipVendor = "testVendor";
+ String equipModel = "model123";
+ String urlTemplate = "/aai_get_pnf_instances/{globalCustomerId}/{serviceType}/{modelVersionId}/{modelInvariantId}/{cloudRegion}/{equipVendor}/{equipModel}";
+ String expectedResponseBody = "myResponse";
+ AaiResponse<String> aaiResponse = new AaiResponse<>(expectedResponseBody, "", HttpStatus.OK.value());
+
+ given(aaiService
+ .getPNFData(globalCustomerId, serviceType, modelVersionId, modelInvariantId, cloudRegion, equipVendor,
+ equipModel)).willReturn(aaiResponse);
+
+ mockMvc.perform(
+ get(urlTemplate, globalCustomerId, serviceType, modelVersionId,
+ modelInvariantId, cloudRegion, equipVendor, equipModel)
+ .contentType(MediaType.APPLICATION_JSON)
+ .accept(MediaType.APPLICATION_JSON))
+ .andExpect(status().isOk())
+ .andExpect(content().string(expectedResponseBody));
+ }
}
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 6a49396ed..7e50c8959 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
@@ -60,8 +60,8 @@ public class LocalWebConfig {
@Bean
- public VidService vidService(AsdcClient asdcClient, FeatureManager featureManager) {
- return new VidServiceImpl(asdcClient, featureManager);
+ public VidService vidService(AsdcClient asdcClient, ToscaParserImpl2 toscaParserImpl2,FeatureManager featureManager) {
+ return new VidServiceImpl(asdcClient,toscaParserImpl2, featureManager);
}
@Bean
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java
index f54756e76..a7fa8cd13 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java
@@ -23,12 +23,17 @@ package org.onap.vid.mso;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.collect.Lists;
+import com.google.gson.Gson;
import io.joshworks.restclient.http.HttpResponse;
import org.apache.commons.io.IOUtils;
import org.jetbrains.annotations.NotNull;
import org.mockito.hamcrest.MockitoHamcrest;
import org.onap.vid.changeManagement.WorkflowRequestDetail;
import org.onap.vid.model.SOWorkflowList;
+import org.onap.vid.model.probes.ExternalComponentStatus;
+import org.onap.vid.mso.rest.RequestList;
+import org.onap.vid.mso.rest.RequestWrapper;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@@ -84,8 +89,10 @@ import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.ArgumentMatchers.endsWith;
import static org.mockito.BDDMockito.given;
+import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
import static org.onap.vid.controller.MsoController.CONFIGURATION_ID;
import static org.onap.vid.controller.MsoController.REQUEST_TYPE;
import static org.onap.vid.controller.MsoController.SVC_INSTANCE_ID;
@@ -1384,6 +1391,31 @@ public class MsoBusinessLogicImplTest extends AbstractTestNGSpringContextTests {
msoBusinessLogic.getWorkflowListByModelId("sampleModelId");
}
+
+ @Test
+ public void probeShouldReturnOrchestrationRequestsAndConnectionStatus(){
+ MsoResponseWrapper wrapper = getMsoResponseWrapper();
+ given(msoInterface.getOrchestrationRequest(anyString(),anyString(),
+ anyString(),any(RestObject.class),anyBoolean())).willReturn(wrapper);
+
+ ExternalComponentStatus externalComponentStatus = msoBusinessLogic.probeComponent();
+
+ assertThat(externalComponentStatus.isAvailable()).isTrue();
+ assertThat(externalComponentStatus.getComponent()).isEqualTo(ExternalComponentStatus.Component.MSO);
+ }
+
+ @NotNull
+ private MsoResponseWrapper getMsoResponseWrapper() {
+ MsoResponseWrapper wrapper=new MsoResponseWrapper();
+ RequestWrapper requestWrapper = new RequestWrapper();
+ requestWrapper.setRequest(new Request());
+ RequestList requestList = new RequestList();
+ List<RequestWrapper> response = Lists.newArrayList(requestWrapper);
+ requestList.setRequestList(response);
+ wrapper.setEntity(new Gson().toJson(requestList));
+ return wrapper;
+ }
+
private WorkflowRequestDetail createWorkflowRequestDetail() {
WorkflowRequestDetail workflowRequestDetail = new WorkflowRequestDetail();
org.onap.vid.changeManagement.RequestParameters requestParameters = new org.onap.vid.changeManagement.RequestParameters();
diff --git a/vid-app-common/src/test/java/org/onap/vid/services/AaiServiceImplTest.java b/vid-app-common/src/test/java/org/onap/vid/services/AaiServiceImplTest.java
index e9f94ca0e..068cc0053 100644
--- a/vid-app-common/src/test/java/org/onap/vid/services/AaiServiceImplTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/services/AaiServiceImplTest.java
@@ -21,258 +21,770 @@
package org.onap.vid.services;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import javax.ws.rs.core.Response;
-import org.jeasy.random.EasyRandom;
-import org.jeasy.random.EasyRandomParameters;
-import org.jeasy.random.randomizers.misc.BooleanRandomizer;
-import org.jeasy.random.randomizers.text.StringRandomizer;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import io.joshworks.restclient.http.HttpResponse;
+import org.apache.http.HttpStatus;
+import org.jetbrains.annotations.NotNull;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.vid.aai.AaiClientInterface;
import org.onap.vid.aai.AaiGetVnfResponse;
import org.onap.vid.aai.AaiOverTLSClientInterface;
import org.onap.vid.aai.AaiResponse;
import org.onap.vid.aai.AaiResponseTranslator;
+import org.onap.vid.aai.ServiceInstancesSearchResults;
+import org.onap.vid.aai.ServiceSubscription;
+import org.onap.vid.aai.ServiceSubscriptions;
+import org.onap.vid.aai.Services;
+import org.onap.vid.aai.SubscriberFilteredResults;
+import org.onap.vid.aai.model.AaiGetInstanceGroupsByCloudRegion;
+import org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.AaiGetRelatedInstanceGroupsByVnfId;
+import org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.RelatedToProperty;
+import org.onap.vid.aai.model.AaiGetOperationalEnvironments.OperationalEnvironmentList;
+import org.onap.vid.aai.model.AaiGetPnfs.Pnf;
import org.onap.vid.aai.model.AaiGetServicesRequestModel.GetServicesAAIRespone;
import org.onap.vid.aai.model.AaiGetTenatns.GetTenantsResponse;
+import org.onap.vid.aai.model.GetServiceModelsByDistributionStatusResponse;
+import org.onap.vid.aai.model.InstanceGroupInfo;
+import org.onap.vid.aai.model.LogicalLinkResponse;
+import org.onap.vid.aai.model.Model;
+import org.onap.vid.aai.model.ModelVer;
+import org.onap.vid.aai.model.ModelVers;
+import org.onap.vid.aai.model.PortDetailsTranslator;
+import org.onap.vid.aai.model.Properties;
+import org.onap.vid.aai.model.Relationship;
+import org.onap.vid.aai.model.RelationshipData;
+import org.onap.vid.aai.model.RelationshipList;
+import org.onap.vid.aai.model.Result;
+import org.onap.vid.aai.model.ServiceRelationships;
import org.onap.vid.aai.model.VnfResult;
+import org.onap.vid.asdc.beans.Service;
+import org.onap.vid.model.Subscriber;
+import org.onap.vid.model.SubscriberList;
+import org.onap.vid.model.aaiTree.AAITreeNode;
+import org.onap.vid.model.aaiTree.RelatedVnf;
+import org.onap.vid.model.aaiTree.ServiceInstance;
import org.onap.vid.roles.RoleValidator;
-import org.onap.vid.roles.RoleValidatorByRoles;
+import javax.ws.rs.core.Response;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+@RunWith(MockitoJUnitRunner.class)
public class AaiServiceImplTest {
- private static final long STATIC_SEED = 5336L;
- private EasyRandomParameters parameters = new EasyRandomParameters()
- .randomize(String.class, new StringRandomizer(4, 4, STATIC_SEED))
- .randomize(Boolean.class, new BooleanRandomizer(STATIC_SEED));
- private EasyRandom modelGenerator = new EasyRandom(parameters);
-
- private AaiClientInterface aaiClient = mock(AaiClientInterface.class);
- private AaiOverTLSClientInterface aaiSslClient = mock(AaiOverTLSClientInterface.class);
- private AaiResponseTranslator aaiResponseTranslator = mock(AaiResponseTranslator.class);
- private AAITreeNodeBuilder aaiTreeNode = mock(AAITreeNodeBuilder.class);
- private AAIServiceTree aaiServiceTree = mock(AAIServiceTree.class);
-
- private AaiServiceImpl aaiService = new AaiServiceImpl(
- aaiClient, aaiSslClient, aaiResponseTranslator, aaiTreeNode, aaiServiceTree
- );
-
- @Test
- public void shouldRetrievePnf() {
- // given
- String globalCustomerId = "global_customer";
- String serviceType = "service_type";
- String modelVersionId = "model_version";
- String modelInvariantId = "model_invariant_id";
- String cloudRegion = "cloud_region";
- String equipVendor = "equip_vendor";
- String equipModel = "equip_model";
-
- AaiResponse response = mock(AaiResponse.class);
- when(aaiClient.getPNFData(
- globalCustomerId, serviceType, modelVersionId, modelInvariantId, cloudRegion, equipVendor, equipModel
- )).thenReturn(response);
-
- // when
- AaiResponse actual = aaiService.getPNFData(
- globalCustomerId, serviceType, modelVersionId, modelInvariantId, cloudRegion, equipVendor, equipModel
- );
-
- // then
- assertThat(response).isEqualTo(actual);
- }
-
- @Test
- @SuppressWarnings("unchecked")
- public void shouldRetrieveSpecificPnf() {
- // given
- String pnfId = "some_pnf_id";
-
- AaiResponse response = mock(AaiResponse.class);
- when(aaiClient.getSpecificPnf(pnfId)).thenReturn(response);
-
- // when
- AaiResponse actual = aaiService.getSpecificPnf(pnfId);
-
- // then
- assertThat(response).isEqualTo(actual);
- }
-
- @Test
- public void shouldRetrieveTenantsByInvariantId() {
- // given
- List<String> modelInvariantId = new ArrayList<>();
-
- Response response = mock(Response.class);
- when(aaiClient.getVersionByInvariantId(modelInvariantId)).thenReturn(response);
-
- // when
- Response actual = aaiService.getVersionByInvariantId(modelInvariantId);
-
- // then
- assertThat(response).isEqualTo(actual);
- }
-
- @Test
- @SuppressWarnings("unchecked")
- public void shouldRetrieveTenants() {
- // given
- String globalCustomerId = "global_customer";
- String serviceType = "service_type";
-
- GetTenantsResponse permittedTenant = new GetTenantsResponse(
- "cloud_region", "cloud_owner", "permitted_tenant", "tenant_id", false
- );
- GetTenantsResponse unpermittedTenant = new GetTenantsResponse(
- "cloud_region", "cloud_owner", "unpermitted_tenant", "tenant_id", false
- );
-
- AaiResponse<GetTenantsResponse[]> response = mock(AaiResponse.class);
- when(response.getT()).thenReturn(new GetTenantsResponse[]{ permittedTenant, unpermittedTenant });
- when(aaiClient.getTenants(globalCustomerId, serviceType)).thenReturn(response);
-
- RoleValidator roleValidator = mock(RoleValidatorByRoles.class);
- when(roleValidator.isTenantPermitted(globalCustomerId, serviceType, "permitted_tenant")).thenReturn(true);
- when(roleValidator.isTenantPermitted(globalCustomerId, serviceType, "unpermitted_tenant")).thenReturn(false);
-
- // when
- AaiResponse actual = aaiService.getTenants(globalCustomerId, serviceType, roleValidator);
-
- // then
- assertThat(response).isEqualTo(actual);
- assertThat(permittedTenant.isPermitted).isTrue();
- assertThat(unpermittedTenant.isPermitted).isFalse();
- }
-
- @Test
- public void shouldRetrieveVNFs() {
- // given
- String globalSubscriber = "global_subscriber";
- String serviceType = "service_type";
- String serviceInstanceId = "service_instance";
-
- AaiResponse response = mock(AaiResponse.class);
- when(aaiClient.getVNFData(globalSubscriber, serviceType, serviceInstanceId)).thenReturn(response);
-
- // when
- AaiResponse actual = aaiService.getVNFData(globalSubscriber, serviceType, serviceInstanceId);
-
- // then
- assertThat(response).isEqualTo(actual);
- }
-
- @Test
- @SuppressWarnings("unchecked")
- public void shouldRetrieveAndFilterVNFsBySubscriberAndServiceType() {
- // given
- String globalSubscriber = "global_subscriber";
- String serviceType = "service_type";
-
- VnfResult genericVnf = new VnfResult();
- genericVnf.nodeType = "generic-vnf";
-
- VnfResult serviceInstance = new VnfResult();
- serviceInstance.nodeType = "service-instance";
-
- VnfResult someVnf = new VnfResult();
- someVnf.nodeType = "some-vnf";
-
- AaiResponse<AaiGetVnfResponse> response = mock(AaiResponse.class);
- AaiGetVnfResponse vnfs = new AaiGetVnfResponse();
- vnfs.results = Arrays.asList(genericVnf, serviceInstance, someVnf);
- when(response.getT()).thenReturn(vnfs);
-
- when(aaiClient.getVNFData(globalSubscriber, serviceType)).thenReturn(response);
-
- // when
- AaiResponse actual = aaiService.getVNFData(globalSubscriber, serviceType);
-
- // then
- assertThat(response).isEqualTo(actual);
- assertThat(response.getT().results).containsOnly(genericVnf, serviceInstance);
- }
-
- @Test
- @SuppressWarnings("unchecked")
- public void getServicesShouldMarkAllServicesAsPermitted() {
- // given
- RoleValidator roleValidator = modelGenerator.nextObject(RoleValidatorByRoles.class);
-
- GetServicesAAIRespone inputPayload = modelGenerator.nextObject(GetServicesAAIRespone.class);
- assertThat(inputPayload.service.stream().allMatch(service -> service.isPermitted)).isFalse();
-
- when(aaiClient.getServices()).thenReturn(new AaiResponse<>(inputPayload, "", 200));
-
- // when
- AaiResponse<GetServicesAAIRespone> result = aaiService.getServices(roleValidator);
- GetServicesAAIRespone outputPayload = result.getT();
-
- // then
- assertThat(outputPayload.service.stream().allMatch(service -> service.isPermitted)).isTrue();
- }
-
- @Test
- public void shouldGetNodeTemplateInstances() {
- // given
- String globalCustomerId = "gcid";
- String serviceType = "st";
- String modelVersionId = "mvid";
- String modelInvariantId = "miid";
- String cloudRegion = "cr";
-
- // when
- aaiService
- .getNodeTemplateInstances(globalCustomerId, serviceType, modelVersionId, modelInvariantId, cloudRegion);
-
- // then
- verify(aaiClient)
- .getNodeTemplateInstances(globalCustomerId, serviceType, modelVersionId, modelInvariantId, cloudRegion);
- }
-
- @Test
- public void shouldGetNetworkCollectionDetails() {
- // given
- String serviceInstanceId = "siid";
-
- // when
- aaiService.getNetworkCollectionDetails(serviceInstanceId);
-
- // then
- verify(aaiClient).getNetworkCollectionDetails(serviceInstanceId);
- }
-
- @Test
- public void shouldGetInstanceGroupsByCloudRegion() {
- // given
- String cloudOwner = "co";
- String cloudRegionId = "crid";
- String networkFunction = "nf";
-
- // when
- aaiService.getInstanceGroupsByCloudRegion(cloudOwner, cloudRegionId, networkFunction);
-
- // then
- verify(aaiClient).getInstanceGroupsByCloudRegion(cloudOwner, cloudRegionId, networkFunction);
- }
-
- @Test
- public void getAAIServiceTree() {
- // given
- String globalCustomerId = "gcid";
- String serviceType = "st";
- String serviceInstanceId = "siid";
-
- // when
- aaiService.getAAIServiceTree(globalCustomerId, serviceType, serviceInstanceId);
-
- // then
- verify(aaiServiceTree).getServiceInstanceTopology(globalCustomerId, serviceType, serviceInstanceId);
- }
-} \ No newline at end of file
+ private static final String GLOBAL_CUSTOMER_ID = "GLOBAL_CUSTOMER_ID";
+ private static final String CLOUD_REGION_ID = "CLOUD_REGION_ID";
+ private static final String VNF_TYPE = "VNF_TYPE";
+ private static final String TENANT_ID = "TENANT_ID";
+ private static final String TENANT_NAME = "TENANT_NAME";
+ private static final String SERVICE_TYPE = "SERVICE_TYPE";
+ private static final String CORRECT_VALUE = "CORRECT_VALUE";
+ private static final String SUBSCRIBER_ID = "SUBSCRIBER_ID_EXPECTED";
+ private static final String STATUS_TEXT = "STATUS_TEXT";
+ private static final String GLOBAL_SUBSCRIBER_ID = "GLOBAL_SUBSCRIBER_ID";
+ private static final String GLOBAL_SUBSCRIBER_ID_NULL_RESPONSE = "ID_NULL";
+ private static final String VNF_INSTANCE_ID_OK = "VNF_INSTANCE_ID_OK";
+ private static final String VNF_INSTANCE_ID_FAIL = "VNF_INSTANCE_ID_FAIL";
+ private static final String PARENT_NAME = "PARENT_NAME";
+ private static final String PARENT_ID = "PARENT_ID";
+ private static final String INVARIANT_ID = "INVARIANT_ID";
+ private static final String GROUP_TYPE_FAILING = "GROUP_TYPE_FAILING";
+ private static final String GROUP_ROLE_OK = "GROUP_ROLE_OK";
+ private static final String GROUP_ROLE_FAILING = "GROUP_ROLE_FAILING";
+ private static final String group_type_ok = "GROUP_TYPE_OK";
+ private static final String CLOUD_TYPE = "CLOUD_TYPE";
+
+ @Mock
+ private HttpResponse<SubscriberList> responseAllSubscribers;
+ @Mock
+ private AaiResponse<OperationalEnvironmentList> aaiResponseOpEnvList;
+ @Mock
+ private AaiResponse aaiResponse;
+ @Mock
+ private AaiResponse<JsonNode> aaiResponseJsonNode;
+ @Mock
+ private RoleValidator roleValidator;
+
+ @Mock
+ private AaiClientInterface aaiClient;
+ @Mock
+ private AaiOverTLSClientInterface aaiOverTLSClient;
+ @Mock
+ private AaiResponseTranslator aaiResponseTranslator;
+ @Mock
+ private AAIServiceTree aaiServiceTree;
+
+ @InjectMocks
+ private AaiServiceImpl aaiService;
+
+
+ @Test
+ public void shouldGetFullSubscriberListWithoutValidator() {
+ when(aaiOverTLSClient.getAllSubscribers()).thenReturn(responseAllSubscribers);
+
+ HttpResponse<SubscriberList> actualResponse = aaiService.getFullSubscriberList();
+
+ assertThat(actualResponse).isEqualTo(responseAllSubscribers);
+ }
+
+ @Test
+ public void shouldGetFullSubscriberListWithValidator() {
+ Subscriber subscriber = createSubscriber();
+ SubscriberList subscriberList = new SubscriberList(Collections.singletonList(subscriber));
+
+ when(aaiOverTLSClient.getAllSubscribers()).thenReturn(responseAllSubscribers);
+ when(responseAllSubscribers.getBody()).thenReturn(subscriberList);
+ when(responseAllSubscribers.getStatusText()).thenReturn(STATUS_TEXT);
+ when(responseAllSubscribers.getStatus()).thenReturn(HttpStatus.SC_OK);
+ SubscriberFilteredResults expectedSubscribers = new SubscriberFilteredResults(roleValidator, subscriberList,
+ STATUS_TEXT, HttpStatus.SC_OK);
+
+ SubscriberFilteredResults actualSubscribers = aaiService.getFullSubscriberList(roleValidator);
+
+ assertThat(actualSubscribers.getHttpCode()).isEqualTo(expectedSubscribers.getHttpCode());
+ assertThat(actualSubscribers.getErrorMessage()).isEqualTo(expectedSubscribers.getErrorMessage());
+ }
+
+ @Test
+ public void shouldGetOperationalEnvironments() {
+ when(aaiClient.getOperationalEnvironments(anyString(), anyString()))
+ .thenReturn(aaiResponseOpEnvList);
+
+ AaiResponse<OperationalEnvironmentList> expectedEnvList =
+ aaiService.getOperationalEnvironments(anyString(), anyString());
+
+ assertThat(expectedEnvList).isEqualTo(aaiResponseOpEnvList);
+ }
+
+ @Test
+ public void shouldGetSubscriberData() {
+ Services services = createAaiResponseServices();
+ AaiResponse<Services> aaiResponseServices = new AaiResponse<>(services, null, HttpStatus.SC_OK);
+
+ when(aaiClient.getSubscriberData(SUBSCRIBER_ID)).thenReturn(aaiResponseServices);
+ when(roleValidator.isServicePermitted(eq(GLOBAL_CUSTOMER_ID), anyString())).thenReturn(Boolean.TRUE);
+
+ AaiResponse actualResponse = aaiService.getSubscriberData(SUBSCRIBER_ID, roleValidator);
+ List<ServiceSubscription> actualServiceSubscriptions = ((AaiResponse<Services>) actualResponse)
+ .getT().serviceSubscriptions.serviceSubscription;
+
+ assertThat(actualResponse).isEqualTo(aaiResponseServices);
+ assertThat(actualServiceSubscriptions).allMatch(s -> s.isPermitted);
+ }
+
+ @Test
+ public void shouldGetServiceInstanceEmptySearchResults() {
+ ServiceInstancesSearchResults serviceInstancesSearchResults = new ServiceInstancesSearchResults();
+ AaiResponse<ServiceInstancesSearchResults> emptyResponse = new AaiResponse<>(serviceInstancesSearchResults,
+ null, HttpStatus.SC_OK);
+
+ AaiResponse actualResponse = aaiService.getServiceInstanceSearchResults(null, null,
+ null, null, null);
+
+ assertThat(actualResponse).isEqualToComparingFieldByFieldRecursively(emptyResponse);
+ }
+
+ @Test
+ public void shouldGetVersionByInvariantId() {
+ Response response = mock(Response.class);
+ when(aaiClient.getVersionByInvariantId(any())).thenReturn(response);
+
+ Response actualResponse = aaiService.getVersionByInvariantId(any());
+
+ assertThat(actualResponse).isEqualTo(response);
+ }
+
+ @Test
+ public void shouldGetSpecificPnf() {
+ AaiResponse<Pnf> expectedResponse = new AaiResponse<>(new Pnf(), null, HttpStatus.SC_OK);
+ when(aaiClient.getSpecificPnf(anyString())).thenReturn(expectedResponse);
+
+ AaiResponse<Pnf> actualResponse = aaiService.getSpecificPnf(anyString());
+
+ assertThat(actualResponse).isEqualTo(expectedResponse);
+ }
+
+ @Test
+ public void shouldGetPnfData() {
+ when(aaiClient.getPNFData(anyString(), anyString(), anyString(), anyString(), anyString(), anyString(),
+ anyString())).thenReturn(aaiResponse);
+
+ AaiResponse actualResponse = aaiService.getPNFData(anyString(), anyString(), anyString(), anyString(),
+ anyString(), anyString(), anyString());
+
+ assertThat(actualResponse).isEqualTo(aaiResponse);
+ }
+
+ @Test
+ public void shouldGetServices() {
+ org.onap.vid.aai.model.AaiGetServicesRequestModel.Service s1 =
+ createService("ID1", "V1", "D1");
+ org.onap.vid.aai.model.AaiGetServicesRequestModel.Service s2 =
+ createService("ID2", "V2", "D2");
+
+ GetServicesAAIRespone services = new GetServicesAAIRespone();
+ services.service = Arrays.asList(s1, s2);
+
+ AaiResponse<GetServicesAAIRespone> aaiResponseServices =
+ new AaiResponse<>(services, null, HttpStatus.SC_OK);
+
+ when(aaiClient.getServices()).thenReturn(aaiResponseServices);
+
+ Object actualObjectOfResponse = aaiService.getServices(roleValidator).getT();
+
+ assertThat(actualObjectOfResponse).isNotNull();
+ assertThat(((GetServicesAAIRespone) actualObjectOfResponse).service).allMatch(s -> s.isPermitted);
+ }
+
+ @Test
+ public void shouldGetTenants() {
+ GetTenantsResponse tenant1 = new GetTenantsResponse("REGION_ID1", "CLOUD_OWNER1",
+ "TENANT_NAME1", "TENANT_ID1", true);
+ GetTenantsResponse tenant2 = new GetTenantsResponse("REGION_ID2", "CLOUD_OWNER2",
+ "TENANT_NAME2", "TENANT_ID2", false);
+ GetTenantsResponse[] tenants = {tenant1, tenant2};
+ AaiResponse<GetTenantsResponse[]> aaiGetTenantsResponse = new AaiResponse<>(tenants,
+ null, HttpStatus.SC_OK);
+
+ when(aaiClient.getTenants(anyString(), anyString())).thenReturn(aaiGetTenantsResponse);
+ when(roleValidator.isTenantPermitted(anyString(), anyString(), anyString()))
+ .thenReturn(Boolean.TRUE);
+
+ GetTenantsResponse[] actualResponses = aaiService
+ .getTenants(anyString(), anyString(), roleValidator).getT();
+
+ assertThat(actualResponses).isNotNull();
+ assertThat(actualResponses.length).isEqualTo(2);
+ assertThat(actualResponses).allMatch(tenant -> tenant.isPermitted);
+ }
+
+ @Test
+ public void shouldGetVNFDataWithoutFiltering() {
+ when(aaiClient.getVNFData(anyString(), anyString(), anyString())).thenReturn(aaiResponse);
+
+ AaiResponse actualResponse = aaiService.getVNFData(anyString(), anyString(), anyString());
+
+ assertThat(actualResponse).isEqualTo(aaiResponse);
+ }
+
+ @Test
+ public void shouldGetVNFDataWithFiltering() {
+ VnfResult vnfResult1 = createVnfResult("ID1", "generic-vnf");
+ VnfResult vnfResult2 = createVnfResult("ID2", "service-instance");
+ VnfResult vnfResult3 = createVnfResult("ID3", "anything-else");
+
+ List<VnfResult> vnfResults = Arrays.asList(vnfResult1, vnfResult2, vnfResult3);
+ AaiResponse<AaiGetVnfResponse> aaiResponseGetVnfResponse = createAaiResponseVnfResponse(vnfResults);
+
+ vnfResults = Arrays.asList(vnfResult1, vnfResult2);
+ AaiResponse<AaiGetVnfResponse> expectedResponseWithReturnedVnfs = createAaiResponseVnfResponse(vnfResults);
+ AaiResponse expectedResponseWithoutReturnedVnfs = new AaiResponse();
+
+ when(aaiClient.getVNFData(GLOBAL_SUBSCRIBER_ID, SERVICE_TYPE)).thenReturn(aaiResponseGetVnfResponse);
+ when(aaiClient.getVNFData(GLOBAL_SUBSCRIBER_ID_NULL_RESPONSE, SERVICE_TYPE)).thenReturn(null);
+
+ AaiResponse<AaiGetVnfResponse> actualResponseWithReturnedVnfs =
+ aaiService.getVNFData(GLOBAL_SUBSCRIBER_ID, SERVICE_TYPE);
+ AaiResponse<AaiGetVnfResponse> actualResponseWithoutReturnedVnfs =
+ aaiService.getVNFData(GLOBAL_SUBSCRIBER_ID_NULL_RESPONSE, SERVICE_TYPE);
+
+ assertThat(actualResponseWithReturnedVnfs)
+ .isEqualToComparingFieldByFieldRecursively(expectedResponseWithReturnedVnfs);
+ assertThat(actualResponseWithoutReturnedVnfs)
+ .isEqualToComparingFieldByField(expectedResponseWithoutReturnedVnfs);
+ }
+
+ @Test
+ public void shouldGetAaiZones() {
+ when(aaiClient.getAllAicZones()).thenReturn(aaiResponse);
+
+ AaiResponse actualResponse = aaiService.getAaiZones();
+
+ assertThat(actualResponse).isEqualTo(aaiResponse);
+ }
+
+ @Test
+ public void shouldGetAicZoneForPnf() {
+ ServiceRelationships relationsService = createServiceRelationships();
+ AaiResponse<ServiceRelationships> expectedServiceInstanceResp =
+ new AaiResponse<>(relationsService, null, HttpStatus.SC_OK);
+ AaiResponse<String> expectedResponse = new AaiResponse<>(CORRECT_VALUE, null, HttpStatus.SC_OK);
+
+ when(aaiClient.getServiceInstance(anyString(), anyString(), anyString()))
+ .thenReturn(expectedServiceInstanceResp);
+
+ AaiResponse actualResponse = aaiService.getAicZoneForPnf(anyString(), anyString(), anyString());
+
+ assertThat(actualResponse).isEqualToComparingFieldByField(expectedResponse);
+ }
+
+ @Test
+ public void shouldGetNodeTemplateInstances() {
+ when(aaiClient.getNodeTemplateInstances(anyString(), anyString(), anyString(),
+ anyString(), anyString())).thenReturn(aaiResponse);
+
+ AaiResponse expectedResponse = aaiService.getNodeTemplateInstances(anyString(), anyString(), anyString(),
+ anyString(), anyString());
+
+ assertThat(expectedResponse).isEqualTo(aaiResponse);
+ }
+
+ @Test
+ public void shouldGetNetworkCollectionDetails() {
+ when(aaiClient.getNetworkCollectionDetails(anyString())).thenReturn(aaiResponse);
+
+ AaiResponse expectedResponse = aaiService.getNetworkCollectionDetails(anyString());
+
+ assertThat(expectedResponse).isEqualTo(aaiResponse);
+ }
+
+ @Test
+ public void shouldGetInstanceGroupsByCloudRegion() {
+ AaiGetInstanceGroupsByCloudRegion aaiGetInstanceGroupsByCloudRegion =
+ mock(AaiGetInstanceGroupsByCloudRegion.class);
+ AaiResponse<AaiGetInstanceGroupsByCloudRegion> expectedResponse =
+ new AaiResponse<>(aaiGetInstanceGroupsByCloudRegion, null, HttpStatus.SC_OK);
+
+ when(aaiClient.getInstanceGroupsByCloudRegion(anyString(), anyString(), anyString()))
+ .thenReturn(expectedResponse);
+ AaiResponse<AaiGetInstanceGroupsByCloudRegion> actualResponse =
+ aaiService.getInstanceGroupsByCloudRegion(anyString(), anyString(), anyString());
+
+ assertThat(actualResponse).isEqualTo(expectedResponse);
+ }
+
+ @Test
+ public void shouldGetServicesByDistributionStatus() {
+ Result resultWithModelType = createResult("MODEL_TYPE1", "1");
+ Result resultWithEmptyModelType = createResult(null, "2");
+ Result resultWithoutModel = new Result();
+ resultWithoutModel.setModel(null);
+ Result resultWithoutValidModel = createResultWithoutValidModel();
+ List<Result> results = Arrays.asList(resultWithModelType, resultWithEmptyModelType, resultWithoutModel,
+ resultWithoutValidModel);
+
+ GetServiceModelsByDistributionStatusResponse serviceModels = new GetServiceModelsByDistributionStatusResponse();
+ serviceModels.setResults(results);
+
+ AaiResponse<GetServiceModelsByDistributionStatusResponse> serviceModelsByDistributionStatusResponse
+ = new AaiResponse<>(serviceModels, null, HttpStatus.SC_OK);
+
+ Service[] expectedServices = {
+ createService("MODEL_TYPE1", "1"),
+ createService("", "2")
+ };
+
+ when(aaiClient.getServiceModelsByDistributionStatus()).thenReturn(serviceModelsByDistributionStatusResponse);
+ Collection<Service> actualServices = aaiService.getServicesByDistributionStatus();
+
+ assertThat(actualServices)
+ .hasSize(2)
+ .usingFieldByFieldElementComparator()
+ .containsExactly(expectedServices);
+ }
+
+ @Test
+ public void shouldReturnEmptyListOfServices() {
+ AaiResponse<GetServiceModelsByDistributionStatusResponse> emptyResponse
+ = new AaiResponse<>(null, null, HttpStatus.SC_OK);
+
+ when(aaiClient.getServiceModelsByDistributionStatus()).thenReturn(emptyResponse);
+ Collection<Service> actualServices = aaiService.getServicesByDistributionStatus();
+
+ assertThat(actualServices).isEqualTo(Collections.EMPTY_LIST);
+ }
+
+ @Test
+ public void shouldGetServiceInstanceAssociatedPnfs() {
+ ServiceRelationships relationsList = createServiceRelationships();
+ LogicalLinkResponse logicalLinkResponse = new LogicalLinkResponse();
+ logicalLinkResponse.setRelationshipList(relationsList.getRelationshipList());
+
+ AaiResponse<LogicalLinkResponse> aaiResponseLogicalLinkResponse =
+ new AaiResponse<>(logicalLinkResponse, null, HttpStatus.SC_OK);
+ AaiResponse<ServiceRelationships> aaiResponseServiceRelations =
+ new AaiResponse<>(relationsList, null, HttpStatus.SC_OK);
+
+ when(aaiClient.getServiceInstance(anyString(), anyString(), anyString()))
+ .thenReturn(aaiResponseServiceRelations);
+ when(aaiClient.getLogicalLink(anyString())).thenReturn(aaiResponseLogicalLinkResponse);
+
+
+ List<String> expectedPnfs = Collections.singletonList(CORRECT_VALUE);
+ List<String> actualPnfs = aaiService.getServiceInstanceAssociatedPnfs(anyString(), anyString(), anyString());
+
+ assertThat(actualPnfs).isEqualTo(expectedPnfs);
+ }
+
+ @Test
+ public void shouldGetPortMirroringConfigData() {
+ AaiResponseTranslator.PortMirroringConfigData expectedData
+ = mock(AaiResponseTranslator.PortMirroringConfigData.class);
+
+ when(aaiClient.getCloudRegionAndSourceByPortMirroringConfigurationId(anyString())).thenReturn(aaiResponseJsonNode);
+ when(aaiResponseTranslator.extractPortMirroringConfigData(aaiResponseJsonNode)).thenReturn(expectedData);
+
+ AaiResponseTranslator.PortMirroringConfigData actualData = aaiService.getPortMirroringConfigData(anyString());
+ assertThat(actualData).isEqualTo(expectedData);
+ }
+
+
+ @Test
+ public void shouldGetInstanceGroupsByVnfInstanceId() {
+ List<InstanceGroupInfo> instanceGroupInfo = Collections.singletonList(new InstanceGroupInfo(CORRECT_VALUE));
+ AaiGetRelatedInstanceGroupsByVnfId relatedInstanceGroups = new AaiGetRelatedInstanceGroupsByVnfId();
+ relatedInstanceGroups.setRelationshipList(createRelationshipList());
+
+ AaiResponse<AaiGetRelatedInstanceGroupsByVnfId> correctCodeResponse =
+ new AaiResponse<>(relatedInstanceGroups, null, HttpStatus.SC_OK);
+
+ AaiResponse<List<InstanceGroupInfo>> expectedCorrectCodeResponse =
+ new AaiResponse<>(instanceGroupInfo, null, HttpStatus.SC_OK);
+ AaiResponse<AaiGetRelatedInstanceGroupsByVnfId> expectedIncorrectCodeResponse =
+ new AaiResponse<>(relatedInstanceGroups, null, HttpStatus.SC_PAYMENT_REQUIRED);
+ List<InstanceGroupInfo> expectedCorrectResponseObject = expectedCorrectCodeResponse.getT();
+
+ when(aaiClient.getInstanceGroupsByVnfInstanceId(VNF_INSTANCE_ID_OK)).thenReturn(correctCodeResponse);
+ when(aaiClient.getInstanceGroupsByVnfInstanceId(VNF_INSTANCE_ID_FAIL)).thenReturn(expectedIncorrectCodeResponse);
+
+ AaiResponse actualCorrectCodeResponse = aaiService.getInstanceGroupsByVnfInstanceId(VNF_INSTANCE_ID_OK);
+ AaiResponse actualIncorrectCodeResponse = aaiService.getInstanceGroupsByVnfInstanceId(VNF_INSTANCE_ID_FAIL);
+
+ List<InstanceGroupInfo> actualCorrectResponseObject =
+ (List<InstanceGroupInfo>) actualCorrectCodeResponse.getT();
+
+ assertThat(actualCorrectResponseObject)
+ .usingFieldByFieldElementComparator()
+ .hasSameElementsAs(expectedCorrectResponseObject);
+
+ assertThat(actualIncorrectCodeResponse).isEqualTo(expectedIncorrectCodeResponse);
+ }
+
+ @Test
+ public void shouldGetHomingDataByVfModule() {
+ GetTenantsResponse expectedResponse = new GetTenantsResponse();
+ when(aaiClient.getHomingDataByVfModule(anyString(), anyString())).thenReturn(expectedResponse);
+
+ GetTenantsResponse actualResponse = aaiService.getHomingDataByVfModule(anyString(), anyString());
+ assertThat(actualResponse).isEqualTo(expectedResponse);
+ }
+
+ @Test
+ public void shouldSearchGroupMembers() {
+ Properties properties = createProperties();
+ Map<String, Properties> regionsAndTenants = createRegionsAndTenantsMap(properties);
+
+ AAITreeNode validTreeNode = new AAITreeNode();
+ addAdditionalPropertiesToAaiTreeNode(validTreeNode);
+ List<AAITreeNode> validNodes = Arrays.asList(validTreeNode, validTreeNode);
+
+ AAITreeNode validBranch = createTree(validNodes);
+ addAdditionalPropertiesToAaiTreeNode(validBranch);
+ List<AAITreeNode> testedBranches = Collections.singletonList(validBranch);
+
+ AAITreeNode testedTree = createTree(testedBranches);
+
+ RelatedVnf expectedVnf = createExpectedVnf(validBranch);
+ List<RelatedVnf> expectedResult = Collections.singletonList(expectedVnf);
+
+ when(aaiServiceTree.buildAAITree(anyString(), any())).thenReturn(Collections.singletonList(testedTree));
+ when(aaiClient.getCloudRegionAndTenantByVnfId(anyString())).thenReturn(regionsAndTenants);
+
+ List<RelatedVnf> actualGroupMembers = aaiService.searchGroupMembers(GLOBAL_CUSTOMER_ID, SERVICE_TYPE,
+ INVARIANT_ID, GROUP_TYPE_FAILING, GROUP_ROLE_FAILING);
+
+ assertThat(actualGroupMembers)
+ .usingFieldByFieldElementComparator()
+ .hasSameElementsAs(expectedResult);
+ }
+
+ @Test
+ public void shouldGetPortMirroringSourcePorts() {
+ PortDetailsTranslator.PortDetails details = mock(PortDetailsTranslator.PortDetails.class);
+ List<PortDetailsTranslator.PortDetails> expectedDetailsList = Arrays.asList(
+ details, details, details
+ );
+
+ when(aaiClient.getPortMirroringSourcePorts(anyString())).thenReturn(expectedDetailsList);
+ List<PortDetailsTranslator.PortDetails> actualDetails = aaiService.getPortMirroringSourcePorts(anyString());
+
+ assertThat(actualDetails).isEqualTo(expectedDetailsList);
+ }
+
+ @Test
+ public void shouldGetAAIServiceTree() throws JsonProcessingException {
+ ServiceInstance serviceInstance = mock(ServiceInstance.class);
+ String expectedResult = new ObjectMapper().writeValueAsString(serviceInstance);
+
+ when(aaiServiceTree.getServiceInstanceTopology(anyString(), anyString(), anyString()))
+ .thenReturn(serviceInstance);
+ String actualResult = aaiService.getAAIServiceTree(anyString(), anyString(), anyString());
+
+ assertThat(actualResult).isEqualTo(expectedResult);
+ }
+
+ @NotNull
+ private Map<String, Properties> createRegionsAndTenantsMap(Properties properties) {
+ Map<String, Properties> regionsAndTenants = new HashMap<>();
+ regionsAndTenants.put("tenant", properties);
+ regionsAndTenants.put("cloud-region", properties);
+ return regionsAndTenants;
+ }
+
+ private Properties createProperties() {
+ Properties properties = new Properties();
+ properties.setTenantId(TENANT_ID);
+ properties.setTenantName(TENANT_NAME);
+ properties.setCloudRegionId(CLOUD_REGION_ID);
+ return properties;
+ }
+
+ @NotNull
+ private RelatedVnf createExpectedVnf(AAITreeNode validBranch) {
+ RelatedVnf expectedVnf = RelatedVnf.from(validBranch);
+ expectedVnf.setTenantId(TENANT_ID);
+ expectedVnf.setTenantName(TENANT_NAME);
+ expectedVnf.setLcpCloudRegionId(CLOUD_REGION_ID);
+ expectedVnf.setServiceInstanceId(PARENT_ID);
+ expectedVnf.setServiceInstanceName(PARENT_NAME);
+ expectedVnf.setInstanceType(VNF_TYPE);
+
+ return expectedVnf;
+ }
+
+
+ private AAITreeNode createTree(List<AAITreeNode> children) {
+ AAITreeNode tree = new AAITreeNode();
+ tree.addChildren(children);
+ tree.setId(PARENT_ID);
+ tree.setName(PARENT_NAME);
+ return tree;
+ }
+
+ private void addAdditionalPropertiesToAaiTreeNode(AAITreeNode tree) {
+ Map<String, Object> additionalProperties = new HashMap<>();
+ additionalProperties.put("instance-group-role", GROUP_ROLE_OK);
+ additionalProperties.put("instance-group-type", group_type_ok);
+ additionalProperties.put("vnf-type", VNF_TYPE);
+ additionalProperties.put("cloud-region", CLOUD_TYPE);
+ tree.setAdditionalProperties(additionalProperties);
+ }
+
+ private org.onap.vid.asdc.beans.Service createService(String category, String suffix) {
+ return new Service.ServiceBuilder()
+ .setUuid("MODELVER_VERSION_ID" + suffix)
+ .setInvariantUUID("MODEL_INVARIANT_NAME" + suffix)
+ .setCategory(category)
+ .setVersion("MODELVER_VERSION" + suffix)
+ .setName("MODELVER_NAME" + suffix)
+ .setDistributionStatus("MODELVER_DIST_STATUS" + suffix)
+ .setToscaModelURL(null)
+ .setLifecycleState(null)
+ .setArtifacts(null)
+ .setResources(null)
+ .build();
+ }
+
+ @NotNull
+ private Result createResultWithoutValidModel() {
+ ModelVers modelVers = new ModelVers();
+ modelVers.setModelVer(Collections.singletonList(new ModelVer()));
+
+ Model model = new Model();
+ model.setModelVers(modelVers);
+
+ Result result1 = new Result();
+ result1.setModel(model);
+ return result1;
+ }
+
+ @NotNull
+ private Result createResult(String modelType, String suffix) {
+ ModelVer modelVer = new ModelVer();
+ modelVer.setModelVersionId("MODELVER_VERSION_ID" + suffix);
+ modelVer.setModelVersion("MODELVER_VERSION" + suffix);
+ modelVer.setModelName("MODELVER_NAME" + suffix);
+ modelVer.setDistributionStatus("MODELVER_DIST_STATUS" + suffix);
+
+ ModelVers modelVers = new ModelVers();
+ modelVers.setModelVer(Collections.singletonList(modelVer));
+
+ Model model = new Model();
+ model.setModelType(modelType);
+ model.setModelInvariantId("MODEL_INVARIANT_NAME" + suffix);
+ model.setModelVers(modelVers);
+
+ Result result = new Result();
+ result.setModel(model);
+ return result;
+ }
+
+ @NotNull
+ private ServiceRelationships createServiceRelationships() {
+ RelationshipList relationsList = createRelationshipList(CORRECT_VALUE);
+ ServiceRelationships relationsService = new ServiceRelationships();
+ relationsService.setRelationshipList(relationsList);
+ return relationsService;
+ }
+
+ @NotNull
+ private RelationshipList createRelationshipList(String expectedValue) {
+ List<RelationshipData> relationsDataList = createRelationshipDataList(expectedValue);
+ return createRelationshipList(relationsDataList);
+ }
+
+ @NotNull
+ private RelationshipList createRelationshipList(List<RelationshipData> relationsDataList) {
+ Relationship relation1 = crateRelationship("any", relationsDataList);
+ Relationship relation2 = crateRelationship("zone", relationsDataList);
+ Relationship relation3 = crateRelationship("logical-link", relationsDataList);
+ Relationship relation4 = crateRelationship("lag-interface", relationsDataList);
+ Relationship relation5 = crateRelationship("pnf", relationsDataList);
+
+ RelationshipList relationsList = new RelationshipList();
+ relationsList.setRelationship(Arrays.asList(relation1, relation2, relation3, relation4, relation5));
+ return relationsList;
+ }
+
+ @NotNull
+ private List<RelationshipData> createRelationshipDataList(String expectedValue) {
+ RelationshipData relationData1 = createRelationshipData("any-key", "incorrect_key");
+ RelationshipData relationData2 = createRelationshipData("zone.zone-id", expectedValue);
+ RelationshipData relationData3 = createRelationshipData("logical-link.link-name", expectedValue);
+ RelationshipData relationData4 = createRelationshipData("pnf.pnf-name", expectedValue);
+
+ return Arrays.asList(relationData1, relationData2, relationData3, relationData4);
+ }
+
+ @NotNull
+ private Relationship crateRelationship(String relatedTo, List<RelationshipData> relationsDataList) {
+ Relationship relation = new Relationship();
+ relation.setRelatedTo(relatedTo);
+ relation.setRelationDataList(relationsDataList);
+ return relation;
+ }
+
+ @NotNull
+ private RelationshipData createRelationshipData(String key, String value) {
+ RelationshipData relationData = new RelationshipData();
+ relationData.setRelationshipKey(key);
+ relationData.setRelationshipValue(value);
+ return relationData;
+ }
+
+ private org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.RelationshipList createRelationshipList() {
+ RelatedToProperty property1 =
+ createRelatedToProperty("instance-group.instance-group-name", CORRECT_VALUE);
+ RelatedToProperty property2 =
+ createRelatedToProperty("anything-key", "anything-value");
+ List<RelatedToProperty> properties = Arrays.asList(property1, property2);
+
+ org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.Relationship relationship1 =
+ createRelationship("instance-group", properties);
+ org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.Relationship relationship2 =
+ createRelationship("any-key", properties);
+
+ List<org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.Relationship> relationships =
+ Arrays.asList(relationship1, relationship2);
+
+ org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.RelationshipList relationshipList =
+ new org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.RelationshipList();
+ relationshipList.setRelationship(relationships);
+
+ return relationshipList;
+ }
+
+ @NotNull
+ private org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.Relationship createRelationship(String relatedTo,
+ List<RelatedToProperty> relatedToPropertyList) {
+ org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.Relationship relationship1 =
+ new org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.Relationship();
+ relationship1.setRelatedTo(relatedTo);
+ relationship1.setRelatedToPropertyList(relatedToPropertyList);
+ return relationship1;
+ }
+
+ @NotNull
+ private RelatedToProperty createRelatedToProperty(String key, String value) {
+ RelatedToProperty prop = new RelatedToProperty();
+ prop.setPropertyKey(key);
+ prop.setPropertyValue(value);
+ return prop;
+ }
+
+ @NotNull
+ private AaiResponse<AaiGetVnfResponse> createAaiResponseVnfResponse(List<VnfResult> vnfResults) {
+ AaiGetVnfResponse vnfResponse = new AaiGetVnfResponse();
+ vnfResponse.setResults(vnfResults);
+ return new AaiResponse<>(vnfResponse, null, HttpStatus.SC_OK);
+ }
+
+ private VnfResult createVnfResult(String id, String nodeType) {
+ VnfResult result = new VnfResult();
+ result.setJsonId(id);
+ result.setJsonNodeType(nodeType);
+ return result;
+ }
+
+
+ private org.onap.vid.aai.model.AaiGetServicesRequestModel.Service createService(String serviceId,
+ String resourceVersion,
+ String serviceDescription) {
+ org.onap.vid.aai.model.AaiGetServicesRequestModel.Service service
+ = new org.onap.vid.aai.model.AaiGetServicesRequestModel.Service();
+ service.isPermitted = false;
+ service.resourceVersion = resourceVersion;
+ service.serviceDescription = serviceDescription;
+ service.serviceId = serviceId;
+ return service;
+ }
+
+ @NotNull
+ private Services createAaiResponseServices() {
+ ServiceSubscription sub1 = new ServiceSubscription();
+ sub1.isPermitted = false;
+ sub1.serviceType = "serviceSubsType1";
+
+ ServiceSubscription sub2 = new ServiceSubscription();
+ sub2.isPermitted = true;
+ sub2.serviceType = "serviceSubsType2";
+
+ ServiceSubscriptions serviceSubs = new ServiceSubscriptions();
+ serviceSubs.serviceSubscription = Collections.singletonList(sub2);
+
+ Services services = new Services();
+ services.globalCustomerId = GLOBAL_CUSTOMER_ID;
+ services.resourceVersion = "v-1";
+ services.subscriberName = "name-1";
+ services.subscriberType = "type-1";
+ services.serviceSubscriptions = serviceSubs;
+ return services;
+ }
+
+ @NotNull
+ private Subscriber createSubscriber() {
+ Subscriber subscriber = new Subscriber();
+ subscriber.globalCustomerId = "id-1";
+ subscriber.resourceVersion = "v-1";
+ subscriber.subscriberName = "name-1";
+ subscriber.subscriberType = "type-1";
+ return subscriber;
+ }
+}
diff --git a/vid-app-common/src/test/java/org/onap/vid/services/SchedulerServiceImplTest.java b/vid-app-common/src/test/java/org/onap/vid/services/SchedulerServiceImplTest.java
index b959fa6af..fd562ace1 100644
--- a/vid-app-common/src/test/java/org/onap/vid/services/SchedulerServiceImplTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/services/SchedulerServiceImplTest.java
@@ -123,7 +123,7 @@ public class SchedulerServiceImplTest extends AbstractTestNGSpringContextTests {
restObjectWithRequestInfo
);
- final ExternalComponentStatus schedulerStatus = schedulerService.probeGetSchedulerChangeManagements();
+ final ExternalComponentStatus schedulerStatus = schedulerService.probeComponent();
assertSchedulerStatus(schedulerStatus, true);
assertMetadata(schedulerStatus, 200, startsWith(responseString.substring(0, 400)), "my pretty url", equalTo("OK"));
@@ -142,7 +142,7 @@ public class SchedulerServiceImplTest extends AbstractTestNGSpringContextTests {
restObjectWithRequestInfo
);
- final ExternalComponentStatus schedulerStatus = schedulerService.probeGetSchedulerChangeManagements();
+ final ExternalComponentStatus schedulerStatus = schedulerService.probeComponent();
assertSchedulerStatus(schedulerStatus, true);
@@ -160,7 +160,7 @@ public class SchedulerServiceImplTest extends AbstractTestNGSpringContextTests {
when(changeManagementService.getSchedulerChangeManagementsWithRequestInfo()).thenThrow(new ExceptionWithRequestInfo(HttpMethod.GET,
"my pretty url", responseString, 200, new JsonParseException(null, "Unrecognized token")));
- final ExternalComponentStatus schedulerStatus = schedulerService.probeGetSchedulerChangeManagements();
+ final ExternalComponentStatus schedulerStatus = schedulerService.probeComponent();
assertSchedulerStatus(schedulerStatus, false);
@@ -172,7 +172,7 @@ public class SchedulerServiceImplTest extends AbstractTestNGSpringContextTests {
when(changeManagementService.getSchedulerChangeManagementsWithRequestInfo()).thenThrow(
new GenericUncheckedException(new NotFoundException("Get with status = 400")));
- final ExternalComponentStatus schedulerStatus = schedulerService.probeGetSchedulerChangeManagements();
+ final ExternalComponentStatus schedulerStatus = schedulerService.probeComponent();
assertThat(schedulerStatus.isAvailable(), is(false));
assertThat(schedulerStatus.getComponent(), is(SCHEDULER));
diff --git a/vid-app-common/src/test/java/org/onap/vid/services/VidServiceImplTest.java b/vid-app-common/src/test/java/org/onap/vid/services/VidServiceImplTest.java
index 5dd2bcd19..4f7faab99 100644
--- a/vid-app-common/src/test/java/org/onap/vid/services/VidServiceImplTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/services/VidServiceImplTest.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -21,6 +21,7 @@
package org.onap.vid.services;
import com.google.common.collect.ImmutableMap;
+import io.joshworks.restclient.http.HttpResponse;
import org.apache.commons.lang3.reflect.FieldUtils;
import org.mockito.Answers;
import org.mockito.Mock;
@@ -31,6 +32,8 @@ import org.onap.vid.asdc.AsdcClient;
import org.onap.vid.asdc.beans.Service;
import org.onap.vid.asdc.parser.ToscaParserImpl2;
import org.onap.vid.model.ServiceModel;
+import org.onap.vid.model.probes.ExternalComponentStatus;
+import org.onap.vid.model.probes.HttpRequestMetadata;
import org.onap.vid.properties.Features;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -40,22 +43,31 @@ import java.util.Map;
import java.util.UUID;
import static java.util.stream.Collectors.toMap;
-import static org.hamcrest.CoreMatchers.*;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.Matchers.not;
+import static org.hamcrest.Matchers.nullValue;
+import static org.hamcrest.core.IsSame.sameInstance;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.any;
-import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
public class VidServiceImplTest {
@Mock(answer = Answers.RETURNS_MOCKS)
- AsdcClient asdcClientMock;
+ private AsdcClient asdcClientMock;
@Mock(answer = Answers.RETURNS_MOCKS)
- ToscaParserImpl2 toscaParserMock;
+ private ToscaParserImpl2 toscaParserMock;
@Mock
- FeatureManager featureManager;
+ private FeatureManager featureManager;
+
+ @Mock
+ private HttpResponse<String> httpResponse;
private final UUID uuid1 = UUID.randomUUID();
private final UUID uuid2 = UUID.randomUUID();
@@ -81,13 +93,13 @@ public class VidServiceImplTest {
public void initMocks() throws AsdcCatalogException, SdcToscaParserException, IllegalAccessException {
MockitoAnnotations.initMocks(this);
- vidService = new VidServiceImpl(asdcClientMock, featureManager);
+ vidService = new VidServiceImpl(asdcClientMock, toscaParserMock, featureManager);
FieldUtils.writeField(vidService, "toscaParser", toscaParserMock, true);
when(featureManager.isActive(Features.FLAG_SERVICE_MODEL_CACHE)).thenReturn(true);
- when(asdcClientMock.getService(any())).thenAnswer(invocation -> pseudoServiceByUuid.get(invocation.getArguments()[0]));
- when(toscaParserMock.makeServiceModel(any(), any())).thenAnswer(invocation -> pseudoModelByService.get(invocation.getArguments()[1]));
+ when(asdcClientMock.getService(any())).thenAnswer(invocation -> pseudoServiceByUuid.get(invocation.getArguments()[0]));
+ when(toscaParserMock.makeServiceModel(any(), any())).thenAnswer(invocation -> pseudoModelByService.get(invocation.getArguments()[1]));
}
@Test
@@ -138,5 +150,29 @@ public class VidServiceImplTest {
vidService.getService(uuid1.toString());
}
+ @Test
+ public void shouldCheckConnectionToSdc() {
+ when(asdcClientMock.checkSDCConnectivity()).thenReturn(httpResponse);
+ when(httpResponse.isSuccessful()).thenReturn(true);
+ when(httpResponse.getBody()).thenReturn("sampleBody");
+
+
+ ExternalComponentStatus externalComponentStatus = vidService.probeComponent();
+
+ assertThat(externalComponentStatus.isAvailable(), is(true));
+ assertThat(externalComponentStatus.getComponent(), is(ExternalComponentStatus.Component.SDC));
+ HttpRequestMetadata metadata = (HttpRequestMetadata) externalComponentStatus.getMetadata();
+ assertThat(metadata.getRawData(), is("sampleBody"));
+ }
+
+ @Test
+ public void shouldProperlyHandleNotWorkingSDCConnection(){
+ when(asdcClientMock.checkSDCConnectivity()).thenThrow(new RuntimeException("not working"));
+
+ ExternalComponentStatus externalComponentStatus = vidService.probeComponent();
+
+ assertThat(externalComponentStatus.isAvailable(), is(false));
+ assertThat(externalComponentStatus.getMetadata().getDescription(),containsString("not working"));
+ }
}
diff --git a/vid-ext-services-simulator/pom.xml b/vid-ext-services-simulator/pom.xml
index 8596b973c..56404f876 100644
--- a/vid-ext-services-simulator/pom.xml
+++ b/vid-ext-services-simulator/pom.xml
@@ -28,6 +28,11 @@
<!-- "none" will skip cobertura by default; enable the profile "cobertura" to enable it -->
<coberturaBuildPhase>none</coberturaBuildPhase>
+
+ <!-- will build docker-maven-plugin by default; enable the profile "no-docker" to disable it -->
+ <skipDockerBuild>false</skipDockerBuild>
+ <dockerBuildPhase>package</dockerBuildPhase>
+ <dockerPushPhase>deploy</dockerPushPhase>
</properties>
<profiles>
@@ -38,10 +43,10 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<epsdk.version>1.1.0-SNAPSHOT</epsdk.version>
<nexusproxy>https://nexus.onap.org</nexusproxy>
- <snapshotNexusPath>/content/repositories/snapshots/</snapshotNexusPath>
- <releaseNexusPath>/content/repositories/releases/</releaseNexusPath>
- <stagingNexusPath>/content/repositories/staging/</stagingNexusPath>
- <sitePath>/content/sites/site/org/openecomp/vid/${project.version}</sitePath>
+ <snapshotNexusPath>content/repositories/snapshots/</snapshotNexusPath>
+ <releaseNexusPath>content/repositories/releases/</releaseNexusPath>
+ <stagingNexusPath>content/repositories/staging/</stagingNexusPath>
+ <sitePath>content/sites/site/org/openecomp/vid/${project.version}</sitePath>
</properties>
<repositories>
@@ -85,6 +90,15 @@
</profile>
<profile>
+ <id>no-docker</id>
+ <properties>
+ <skipDockerBuild>true</skipDockerBuild>
+ <dockerBuildPhase>none</dockerBuildPhase>
+ <dockerPushPhase>none</dockerPushPhase>
+ </properties>
+ </profile>
+
+ <profile>
<id>docker-proxy</id>
<!-- activate profile if environment variable `http_proxy` is set -->
<activation>
@@ -177,6 +191,7 @@
<version>0.27.2</version>
<configuration>
+ <skip>${skipDockerBuild}</skip>
<images>
<image>
<name>onap/vid-simulator</name>
@@ -195,7 +210,7 @@
<executions>
<execution>
<id>generate-image</id>
- <phase>package</phase>
+ <phase>${dockerBuildPhase}</phase>
<goals>
<goal>build</goal>
</goals>
@@ -203,7 +218,7 @@
<execution>
<id>push-image</id>
- <phase>deploy</phase>
+ <phase>${dockerPushPhase}</phase>
<goals>
<goal>build</goal>
<goal>push</goal>
diff --git a/vid-webpack-master/pom.xml b/vid-webpack-master/pom.xml
index c86d61308..184f3c99d 100644
--- a/vid-webpack-master/pom.xml
+++ b/vid-webpack-master/pom.xml
@@ -9,7 +9,7 @@
inherit from a parent maven module. -->
<groupId>org.onap.vid</groupId>
<artifactId>vid-webpack-master</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>5.0.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>VID UI</name>
<description>VID UI</description>