Merge "Add MaintenanceController JUnits"
authorOfir Sonsino <ofir.sonsino@intl.att.com>
Mon, 29 Oct 2018 13:25:43 +0000 (13:25 +0000)
committerGerrit Code Review <gerrit@onap.org>
Mon, 29 Oct 2018 13:25:43 +0000 (13:25 +0000)
50 files changed:
deliveries/pom.xml
deliveries/src/main/docker/docker-files/Dockerfile
epsdk-app-onap/pom.xml
epsdk-app-onap/src/main/resources/portal.properties
epsdk-app-onap/src/main/resources/portal_template.properties
epsdk-app-onap/src/main/resources/vid-schema.sql
epsdk-app-onap/src/main/webapp/WEB-INF/conf/system.properties
epsdk-app-onap/src/main/webapp/WEB-INF/conf/system_template.properties
epsdk-app-onap/version.properties
pom.xml
version.properties
vid-app-common/pom.xml
vid-app-common/src/main/java/org/onap/vid/client/SyncRestClient.java
vid-app-common/src/main/java/org/onap/vid/job/command/InProgressStatusCommand.java
vid-app-common/src/main/java/org/onap/vid/job/command/ServiceInstantiationCommand.java
vid-app-common/src/main/java/org/onap/vid/job/impl/JobAdapterImpl.java
vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogic.java
vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java
vid-app-common/src/main/java/org/onap/vid/mso/MsoInterface.java
vid-app-common/src/main/java/org/onap/vid/mso/MsoProperties.java
vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java
vid-app-common/src/main/java/org/onap/vid/mso/rest/RequestDetails.java
vid-app-common/src/main/java/org/onap/vid/services/AuditServiceImpl.java
vid-app-common/src/main/java/org/onap/vid/services/CategoryParameterServiceImpl.java
vid-app-common/src/main/java/org/onap/vid/services/ChangeManagementServiceImpl.java
vid-app-common/src/main/java/org/onap/vid/services/PombaServiceImpl.java
vid-app-common/src/main/java/org/onap/vid/services/VidServiceImpl.java
vid-app-common/src/main/webapp/app/vid/scripts/controller/ServiceModelController.js
vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js
vid-app-common/src/main/webapp/app/vid/scripts/services/asdcService.js
vid-app-common/src/test/java/org/onap/vid/job/command/InProgressStatusCommandTest.java [new file with mode: 0644]
vid-app-common/src/test/java/org/onap/vid/job/command/ServiceInstantiationCommandTest.java [new file with mode: 0644]
vid-app-common/src/test/java/org/onap/vid/job/impl/JobAdapterImplTest.java [new file with mode: 0644]
vid-app-common/src/test/java/org/onap/vid/job/impl/JobSchedulerInitializerTest.java [new file with mode: 0644]
vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java
vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientNewTest.java
vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTestUtil.java
vid-app-common/src/test/java/org/onap/vid/services/AuditServiceImplTest.java [new file with mode: 0644]
vid-app-common/src/test/java/org/onap/vid/services/BulkInstantiationServiceImplTest.java [new file with mode: 0644]
vid-app-common/src/test/java/org/onap/vid/services/CategoryParameterServiceImplTest.java
vid-app-common/src/test/java/org/onap/vid/services/PombaServiceImplTest.java [new file with mode: 0644]
vid-app-common/src/test/java/org/onap/vid/services/RoleGenaratorServiceImplTest.java
vid-app-common/src/test/resources/WEB-INF/conf/system.properties
vid-app-common/src/test/resources/payload_jsons/activateOperationalEnvironmentsPayloadToMso.json
vid-app-common/src/test/resources/payload_jsons/deactivateOperationalEnvironmentsPayloadToMso.json
vid-app-common/src/test/resources/payload_jsons/mso_action_scaleout_sample_response.json [new file with mode: 0644]
vid-app-common/src/test/resources/payload_jsons/mso_model_info_sample_response.json [new file with mode: 0644]
vid-app-common/src/test/resources/payload_jsons/scaleOutVfModulePayload.json [new file with mode: 0644]
vid-app-common/src/test/resources/payload_jsons/scaleOutVfModulePayloadToMso.json [new file with mode: 0644]
vid-app-common/version.properties

index 2dad0d4..e366974 100755 (executable)
@@ -62,7 +62,7 @@
                                                                        <descriptor>assembly/assembly-for-plugin.xml</descriptor>\r
                                                                </assembly>\r
                                                                <tags>\r
-                                                                 <tag>3.0-STAGING-latest</tag>\r
+                                                                 <tag>4.0-STAGING-latest</tag>\r
                                                                  <tag>latest</tag>\r
                                                                </tags>\r
                                                                    \r
index ddaa861..8cd2bc7 100755 (executable)
@@ -29,7 +29,7 @@ ENV VID_AAI_HOST aai.api.simpledemo.onap.org
 ENV VID_AAI_PORT 8443\r
 ENV VID_APP_DISPLAY_NAME VID\r
 ENV VID_ECOMP_SHARED_CONTEXT_REST_URL https://portal.api.simpledemo.onap.org:8080/onapportal/context\r
-ENV VID_MSO_SERVER_URL http://vm1.mso.simpledemo.onap.org:8080\r
+ENV VID_MSO_SERVER_URL http://vm1.mso.simpledemo.onap.org:8080/onap/so/infra\r
 ENV VID_MYLOGIN_FEED_DIRECTORY /tmp/MyLogins\r
 ENV VID_MSO_USER InfraPortalClient\r
 ENV VID_MSO_PASS OBF:1ih71i271vny1yf41ymf1ylz1yf21vn41hzj1icz\r
@@ -49,6 +49,7 @@ ENV AAI_VNF_PROV_STATUS PREPROV,NVTPROV,PROV,CAPPED
 ENV VID_ECOMP_REDIRECT_URL  http://portal.api.simpledemo.onap.org:8989/ONAPPORTAL/login.htm\r
 ENV VID_ECOMP_REST_URL http://portal.api.simpledemo.onap.org:8989/ONAPPORTAL/auxapi\r
 ENV VID_ECOMP_SHARED_CONTEXT_REST_URL http://portal.api.simpledemo.onap.org:8989/ONAPPORTAL/context\r
+ENV VID_ROLE_ACCESS_CENTRALIZED local\r
 ENV VID_CONTACT_US_LINK https://todo_contact_us_link.com\r
 \r
 ENV VID_DECRYPTION_KEY AGLDdG4D04BKm2IxIWEr8o=\r
index 025b63a..9b0136f 100755 (executable)
@@ -8,7 +8,7 @@
                the Portal team. -->\r
        <groupId>org.onap.vid</groupId>\r
        <artifactId>epsdk-app-onap</artifactId>\r
-       <version>3.0.0-SNAPSHOT</version>\r
+       <version>4.0.0-SNAPSHOT</version>\r
        <packaging>war</packaging>\r
        <name>ECOMP SDK Webapp for OpenSource</name>\r
        <description>ECOMP SDK Web Application for public release</description>\r
index 104e85d..edb3580 100755 (executable)
@@ -61,6 +61,9 @@ ecomp_redirect_url = http://portal.api.simpledemo.onap.org:8989/ONAPPORTAL/login
 # URL of the ECOMP Portal REST API\r
 ecomp_rest_url = http://portal.api.simpledemo.onap.org:8989/ONAPPORTAL/auxapi\r
 \r
+# Non AAF Mode\r
+role_access_centralized = local\r
+\r
 # Applications do not need to run a UEB listener after 1607.\r
 ueb_listeners_enable = false\r
 \r
index d01413a..51f3949 100755 (executable)
@@ -13,6 +13,9 @@ ecomp_redirect_url    = ${VID_ECOMP_REDIRECT_URL}
 # URL of the ECOMP Portal REST API\r
 ecomp_rest_url = ${VID_ECOMP_REST_URL}\r
 \r
+# AAF Mode\r
+role_access_centralized = ${VID_ROLE_ACCESS_CENTRALIZED}\r
+\r
 # UEB servers\r
 ueb_url_list = ${VID_UEB_URL_LIST}\r
 \r
index 3f15c88..2833cbd 100755 (executable)
@@ -33,6 +33,22 @@ SET FOREIGN_KEY_CHECKS = 0;
 CREATE SCHEMA IF NOT EXISTS `vid_openecomp_epsdk` ;\r
 \r
 USE vid_openecomp_epsdk;\r
+\r
+\r
+CREATE TABLE IF NOT EXISTS `vid_openecomp_epsdk`.`schema_info` (\r
+  `SCHEMA_ID` VARCHAR(25) NOT NULL,\r
+  `SCHEMA_DESC` VARCHAR(75) NOT NULL,\r
+  `DATASOURCE_TYPE` VARCHAR(100) NULL DEFAULT NULL,\r
+  `CONNECTION_URL` VARCHAR(200) NOT NULL,\r
+  `USER_NAME` VARCHAR(45) NOT NULL,\r
+  `PASSWORD` VARCHAR(45) NULL DEFAULT NULL,\r
+  `DRIVER_CLASS` VARCHAR(100) NOT NULL,\r
+  `MIN_POOL_SIZE` INT(11) NOT NULL,\r
+  `MAX_POOL_SIZE` INT(11) NOT NULL,\r
+  `IDLE_CONNECTION_TEST_PERIOD` INT(11) NOT NULL)\r
+ENGINE = InnoDB\r
+DEFAULT CHARACTER SET = utf8;\r
+\r
 -- ----------------------------------------------------------------------------\r
 -- Table vid_openecomp_epsdk.cr_favorite_reports\r
 -- ----------------------------------------------------------------------------\r
index 8834379..049ebf0 100755 (executable)
@@ -166,7 +166,8 @@ mso.restapi.svc.instance.deleteAndUnassign=/serviceInstantiation/v7/serviceInsta
 mso.restapi.vnf.instance=/serviceInstances/v6/<service_instance_id>/vnfs\r
 mso.restapi.vnf.changemanagement.instance=/serviceInstances/v6/<service_instance_id>/vnfs/<vnf_instance_id>/<request_type>\r
 mso.restapi.network.instance=/serviceInstances/v6/<service_instance_id>/networks\r
-mso.restapi.vf.module.instance=/serviceInstantiation/v7/serviceInstances/<service_instance_id>/vnfs/<vnf_instance_id>/vfModules/scaleOut\r
+mso.restapi.vf.module.instance=/serviceInstances/v6/<service_instance_id>/vnfs/<vnf_instance_id>/vfModules\r
+mso.restapi.vf.module.scaleout=/serviceInstantiation/v7/serviceInstances/<service_instance_id>/vnfs/<vnf_instance_id>/vfModules/scaleOut\r
 mso.restapi.volume.group.instance=/serviceInstances/v6/<service_instance_id>/vnfs/<vnf_instance_id>/volumeGroups\r
 mso.restapi.get.orc.req=/orchestrationRequests/v6\r
 mso.restapi.get.orc.reqs=/orchestrationRequests/v6?\r
index c79ae96..06a2e6b 100755 (executable)
@@ -103,16 +103,17 @@ mso.max.polls=10
 mso.user.name=${VID_MSO_USER}\r
 mso.password.x=${VID_MSO_PASS}\r
 #E2E is v3\r
-mso.restapi.svc.e2einstance=/onap/so/infra/e2eServiceInstances/v3\r
+mso.restapi.svc.e2einstance=/e2eServiceInstances/v3\r
 mso.restapi.svc.instance=/serviceInstantiation/v7/serviceInstances\r
 mso.restapi.svc.instance.deleteAndUnassign=/serviceInstantiation/v7/serviceInstances\r
-mso.restapi.vnf.instance=/onap/so/infra/serviceInstances/v6/<service_instance_id>/vnfs\r
-mso.restapi.vnf.changemanagement.instance=/onap/so/infra/serviceInstances/v6/<service_instance_id>/vnfs/<vnf_instance_id>/<request_type>\r
-mso.restapi.network.instance=/onap/so/infra/serviceInstances/v6/<service_instance_id>/networks\r
-mso.restapi.vf.module.instance=/onap/so/infra/serviceInstantiation/v7/serviceInstances/<service_instance_id>/vnfs/<vnf_instance_id>/vfModules/scaleOut\r
-mso.restapi.volume.group.instance=/onap/so/infra/serviceInstances/v6/<service_instance_id>/vnfs/<vnf_instance_id>/volumeGroups\r
-mso.restapi.get.orc.req=/onap/so/infra/orchestrationRequests/v6\r
-mso.restapi.get.orc.reqs=/onap/so/infra/orchestrationRequests/v6?\r
+mso.restapi.vnf.instance=/serviceInstances/v6/<service_instance_id>/vnfs\r
+mso.restapi.vnf.changemanagement.instance=/serviceInstances/v6/<service_instance_id>/vnfs/<vnf_instance_id>/<request_type>\r
+mso.restapi.network.instance=/serviceInstances/v6/<service_instance_id>/networks\r
+mso.restapi.vf.module.scaleout=/serviceInstantiation/v7/serviceInstances/<service_instance_id>/vnfs/<vnf_instance_id>/vfModules/scaleOut\r
+mso.restapi.vf.module.instance=/serviceInstances/v6/<service_instance_id>/vnfs/<vnf_instance_id>/vfModules\r
+mso.restapi.volume.group.instance=/serviceInstances/v6/<service_instance_id>/vnfs/<vnf_instance_id>/volumeGroups\r
+mso.restapi.get.orc.req=/orchestrationRequests/v6\r
+mso.restapi.get.orc.reqs=/orchestrationRequests/v6?\r
 mso.restapi.get.man.tasks=/tasks/v1\r
 mso.restapi.configurations=/serviceInstances/v6/<service_instance_id>/configurations\r
 mso.restapi.configuration.instance=${mso.restapi.configurations}/<configuration_id>\r
@@ -143,4 +144,4 @@ mso.dme2.client.timeout=${MSO_DME2_CLIENT_TIMEOUT}
 mso.dme2.client.read.timeout=${MSO_DME2_CLIENT_READ_TIMEOUT}\r
 mso.dme2.server.url=${MSO_DME2_SERVER_URL}\r
 mso.dme2.enabled=${MSO_DME2_ENABLED}\r
-\r
+scheduler.basic.auth=\r
index 02144f0..9723960 100644 (file)
@@ -2,7 +2,7 @@
 # Note that these variables cannot be structured (e.g. : version.release or version.snapshot etc... )\r
 # because they are used in Jenkins, whose plug-in doesn't support\r
 \r
-major=3\r
+major=4\r
 minor=0\r
 patch=0\r
 \r
diff --git a/pom.xml b/pom.xml
index e34fc4d..7ec5032 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -80,7 +80,7 @@
        <properties>\r
                <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>\r
                <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>\r
-               <build.version>3.0.0-SNAPSHOT</build.version>\r
+               <build.version>4.0.0-SNAPSHOT</build.version>\r
                <nexusproxy>https://nexus.onap.org</nexusproxy>\r
                <snapshotNexusPath>/content/repositories/snapshots/</snapshotNexusPath>\r
                <releaseNexusPath>/content/repositories/releases/</releaseNexusPath>\r
                        <version>4.5.3</version>\r
                </dependency>\r
        </dependencies>\r
-       <version>3.0.0-SNAPSHOT</version>\r
+       <version>4.0.0-SNAPSHOT</version>\r
 </project>\r
index 02144f0..9723960 100644 (file)
@@ -2,7 +2,7 @@
 # Note that these variables cannot be structured (e.g. : version.release or version.snapshot etc... )\r
 # because they are used in Jenkins, whose plug-in doesn't support\r
 \r
-major=3\r
+major=4\r
 minor=0\r
 patch=0\r
 \r
index 5082129..4795103 100755 (executable)
@@ -9,7 +9,7 @@
                inherit from a parent maven module. -->\r
        <groupId>org.onap.vid</groupId>\r
        <artifactId>vid-app-common</artifactId>\r
-       <version>3.0.0-SNAPSHOT</version>\r
+       <version>4.0.0-SNAPSHOT</version>\r
        <packaging>war</packaging>\r
        <name>VID Common</name>\r
        <description>VID Common code for opensource version</description>\r
index 84e83e8..b7f2264 100644 (file)
@@ -23,6 +23,7 @@ package org.onap.vid.client;
 import io.joshworks.restclient.http.HttpResponse;
 import io.joshworks.restclient.http.JsonNode;
 import io.joshworks.restclient.http.RestClient;
+import io.joshworks.restclient.http.exceptions.RestClientException;
 import io.joshworks.restclient.http.mapper.ObjectMapper;
 import org.apache.http.impl.client.CloseableHttpClient;
 import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
@@ -39,7 +40,7 @@ import java.security.UnrecoverableKeyException;
 import java.security.NoSuchAlgorithmException;
 import java.security.KeyManagementException;
 import java.security.cert.CertificateException;
-import javax.net.ssl.SSLHandshakeException;
+import javax.net.ssl.SSLException;
 import java.security.KeyStoreException;
 import java.text.SimpleDateFormat;
 import javax.net.ssl.SSLContext;
@@ -150,13 +151,13 @@ public class SyncRestClient implements SyncRestClientInterface {
 
     @SneakyThrows
     private <T> HttpResponse<T> callWithRetryOverHttp(String url,
-        CheckedFunction1<String, HttpResponse<T>> httpRequest) {
+                                                      CheckedFunction1<String, HttpResponse<T>> httpRequest) {
         try {
             return httpRequest.apply(url);
-        } catch (Exception e) {
-            if (e.getCause() instanceof SSLHandshakeException) {
+        } catch (RestClientException e) {
+            if (e.getCause() instanceof SSLException) {
                 logger.warn(EELFLoggerDelegate.debugLogger,
-                    DATE_FORMAT.format(new Date()) + TRY_TO_CALL_OVER_HTTP, e);
+                        DATE_FORMAT.format(new Date()) + TRY_TO_CALL_OVER_HTTP, e);
                 return httpRequest.apply(url.replaceFirst(HTTPS_SCHEMA, HTTP_SCHEMA));
             }
             throw e;
index cee5af6..6685a63 100644 (file)
@@ -23,6 +23,7 @@ package org.onap.vid.job.command;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.google.common.collect.ImmutableMap;
 import io.joshworks.restclient.http.HttpResponse;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
 import org.onap.vid.job.Job.JobStatus;
 import org.onap.vid.job.JobCommand;
 import org.onap.vid.job.NextCommand;
@@ -30,13 +31,13 @@ import org.onap.vid.mso.MsoInterface;
 import org.onap.vid.mso.rest.AsyncRequestStatus;
 import org.onap.vid.services.AsyncInstantiationBusinessLogic;
 import org.onap.vid.services.AuditService;
-import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
 import org.springframework.beans.factory.config.ConfigurableBeanFactory;
 import org.springframework.context.annotation.Scope;
 import org.springframework.stereotype.Component;
 
 import javax.inject.Inject;
 import java.util.Map;
+import java.util.Objects;
 import java.util.UUID;
 
 
@@ -68,33 +69,38 @@ public class InProgressStatusCommand implements JobCommand {
         init(jobUuid, requestId);
     }
 
+    InProgressStatusCommand(AsyncInstantiationBusinessLogic asyncInstantiationBusinessLogic, MsoInterface msoInterface, AuditService auditService, UUID jobUuid, String requestId) {
+        this(jobUuid, requestId);
+        this.asyncInstantiationBL = asyncInstantiationBusinessLogic;
+        this.restMso = msoInterface;
+        this.auditService = auditService;
+    }
+
     @Override
     public NextCommand call() {
 
         try {
-            String path = asyncInstantiationBL.getOrchestrationRequestsPath()+"/"+requestId;
+            String path = asyncInstantiationBL.getOrchestrationRequestsPath() + "/" + requestId;
             HttpResponse<AsyncRequestStatus> msoResponse = restMso.get(path, AsyncRequestStatus.class);
 
 
             JobStatus jobStatus;
             if (msoResponse.getStatus() >= 400 || msoResponse.getBody() == null) {
-                auditService.setFailedAuditStatusFromMso(jobUuid, requestId, msoResponse.getStatus(), msoResponse.getBody().toString());
+                auditService.setFailedAuditStatusFromMso(jobUuid, requestId, msoResponse.getStatus(), Objects.toString(msoResponse.getBody()));
                 LOGGER.error(EELFLoggerDelegate.errorLogger,
                         "Failed to get orchestration status for {}. Status code: {},  Body: {}",
-                        requestId, msoResponse.getStatus(), msoResponse.getRawBody().toString());
+                        requestId, msoResponse.getStatus(), Objects.toString(msoResponse.getRawBody()));
                 return new NextCommand(JobStatus.IN_PROGRESS, this);
-            }
-            else {
+            } else {
                 jobStatus = asyncInstantiationBL.calcStatus(msoResponse.getBody());
             }
 
-            asyncInstantiationBL.auditMsoStatus(jobUuid,msoResponse.getBody().request);
+            asyncInstantiationBL.auditMsoStatus(jobUuid, msoResponse.getBody().request);
 
 
             if (jobStatus == JobStatus.FAILED) {
                 asyncInstantiationBL.handleFailedInstantiation(jobUuid);
-            }
-            else {
+            } else {
                 asyncInstantiationBL.updateServiceInfoAndAuditStatus(jobUuid, jobStatus);
             }
             //in case of JobStatus.PAUSE we leave the job itself as IN_PROGRESS, for keep tracking job progress
@@ -128,5 +134,4 @@ public class InProgressStatusCommand implements JobCommand {
         return ImmutableMap.of("requestId", requestId);
     }
 
-
 }
index 9d22b8b..958fc11 100644 (file)
@@ -42,6 +42,7 @@ import org.springframework.stereotype.Component;
 
 import javax.inject.Inject;
 import java.util.Map;
+import java.util.Objects;
 import java.util.UUID;
 
 
@@ -73,6 +74,14 @@ public class ServiceInstantiationCommand implements JobCommand {
         init(uuid, serviceInstantiationRequest, userId);
     }
 
+    ServiceInstantiationCommand(AsyncInstantiationBusinessLogic asyncInstantiationBL, AuditService auditService, MsoInterface msoInterface,
+                                UUID uuid, ServiceInstantiation serviceInstantiation, String userId) {
+        this(uuid, serviceInstantiation, userId);
+        this.asyncInstantiationBL = asyncInstantiationBL;
+        this.auditService = auditService;
+        this.restMso = msoInterface;
+    }
+
     @Override
     public NextCommand call() {
         RequestDetailsWrapper<ServiceInstantiationRequestDetails> requestDetailsWrapper ;
@@ -81,7 +90,6 @@ public class ServiceInstantiationCommand implements JobCommand {
                     uuid, serviceInstantiationRequest, userId
             );
         }
-
         //Aai return bad response while checking names uniqueness
         catch (InvalidAAIResponseException exception) {
             LOGGER.error("Failed to check name uniqueness in AAI. VID will try again later", exception);
@@ -116,7 +124,7 @@ public class ServiceInstantiationCommand implements JobCommand {
             return new NextCommand(jobStatus, new InProgressStatusCommand(uuid, requestId));
         } else {
             auditService.setFailedAuditStatusFromMso(uuid,null, msoResponse.getStatus(),
-                msoResponse.getBody().toString());
+                    Objects.toString(msoResponse.getBody()));
             return handleCommandFailed();
         }
 
index 77e1dd2..59f12f4 100644 (file)
@@ -33,14 +33,10 @@ public class JobAdapterImpl implements JobAdapter {
     }
 
     @Override
-    public Job createJob(JobType jobType, AsyncJobRequest request, UUID templateId, String userId, Integer indexInBulk){
-        JobDaoImpl job = new JobDaoImpl();
-        job.setStatus(Job.JobStatus.PENDING);
-        job.setTypeAndData(jobType, ImmutableMap.of(
+    public Job createJob(JobType jobType, AsyncJobRequest request, UUID templateId, String userId, Integer indexInBulk) {
+        JobDaoImpl job = createJob(jobType, templateId, indexInBulk, ImmutableMap.of(
                 "request", request,
                 "userId", userId));
-        job.setTemplateId(templateId);
-        job.setIndexInBulk(indexInBulk);
         job.setUserId(userId);
         return job;
     }
@@ -59,14 +55,17 @@ public class JobAdapterImpl implements JobAdapter {
         List<Job> jobList = new ArrayList<>(count + 1);
         UUID templateId = UUID.randomUUID();
         for (int i = 0; i < count; i++) {
-            Job child = new JobDaoImpl();
-            child.setTypeAndData(jobType, bulkRequest);
-            child.setStatus(Job.JobStatus.PENDING);
-            child.setTemplateId(templateId);
-            child.setIndexInBulk(i);
-            jobList.add(child);
+            jobList.add(createJob(jobType, templateId, i, bulkRequest));
         }
         return jobList;
     }
 
+    private JobDaoImpl createJob(JobType jobType, UUID templateId, Integer indexInBulk, Map<String, Object> data) {
+        JobDaoImpl job = new JobDaoImpl();
+        job.setStatus(Job.JobStatus.PENDING);
+        job.setTypeAndData(jobType, data);
+        job.setTemplateId(templateId);
+        job.setIndexInBulk(indexInBulk);
+        return job;
+    }
 }
index 79befe1..0ecb925 100644 (file)
@@ -28,6 +28,8 @@ public interface MsoBusinessLogic {
 
     MsoResponseWrapper createVfModuleInstance(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId);
 
+    MsoResponseWrapper scaleOutVfModuleInstance(org.onap.vid.changeManagement.RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId);
+
     MsoResponseWrapper createConfigurationInstance(org.onap.vid.mso.rest.RequestDetailsWrapper requestDetailsWrapper, String serviceInstanceId);
 
     MsoResponseWrapper deleteSvcInstance(RequestDetails requestDetails, String serviceInstanceId, String serviceStatus);
index 00db464..a6226e0 100644 (file)
@@ -46,7 +46,11 @@ import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
+import static java.util.stream.Collectors.collectingAndThen;
+import static java.util.stream.Collectors.toList;
 import static org.apache.commons.lang.StringUtils.upperCase;
 import static org.onap.vid.changeManagement.ChangeManagementRequest.MsoChangeManagementRequest;
 import static org.onap.vid.controllers.MsoController.*;
@@ -56,10 +60,14 @@ import static org.onap.vid.utils.Logging.debugRequestDetails;
 
 public class MsoBusinessLogicImpl implements MsoBusinessLogic {
 
-    public static final String START = " start";
-    public static final String RESOURCE_TYPE = "resourceType";
-    FeatureManager featureManager;
-
+    static final List<String> DASHBOARD_ALLOWED_TYPES = Stream.of(RequestType.REPLACE_INSTANCE,
+            RequestType.UPDATE_INSTANCE,
+            RequestType.APPLY_UPDATED_CONFIG,
+            RequestType.IN_PLACE_SOFTWARE_UPDATE,
+            RequestType.SCALE_OUT)
+            .map(requestType -> requestType.toString().toUpperCase())
+            .collect(collectingAndThen(toList(), Collections::unmodifiableList));
+    private static final String RESOURCE_TYPE = "resourceType";
     /**
      * The Constant dateFormat.
      */
@@ -73,17 +81,17 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
     private static final String RESOURCE_TYPE_OPERATIONAL_ENVIRONMENT = "operationalEnvironment";
     private static final String SOURCE_OPERATIONAL_ENVIRONMENT = "VID";
     private static final ObjectMapper objectMapper = new ObjectMapper();
+    /**
+     * The logger.
+     */
+    private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MsoBusinessLogicImpl.class);
     /**
      * The Mso REST client
      * This should be replaced with mso client factory.
      */
     private final MsoInterface msoClientInterface;
+    FeatureManager featureManager;
 
-    /**
-     * The logger.
-     */
-    private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MsoBusinessLogicImpl.class);
-    
     @Autowired
     public MsoBusinessLogicImpl(MsoInterface msoClientInterface, FeatureManager featureManager) {
         this.msoClientInterface = msoClientInterface;
@@ -101,34 +109,26 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
     // this function should get params from tosca and send them to instance at mso, then return success response.
     @Override
     public MsoResponseWrapper createSvcInstance(RequestDetails msoRequest) {
-        String methodName = "createSvcInstance ";
-        logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+        logInvocationInDebug("createSvcInstance");
 
-        String endpoint;
-        endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_SVC_INSTANCE);
+        String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_SVC_INSTANCE);
 
         return msoClientInterface.createSvcInstance(msoRequest, endpoint);
     }
 
     @Override
-    public MsoResponseWrapper createE2eSvcInstance(Object msoRequest){
-        String methodName = "createE2eSvcInstance ";
-        logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
-
-        String endpoint;
-        endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_E2E_SVC_INSTANCE);
-
+    public MsoResponseWrapper createE2eSvcInstance(Object msoRequest) {
+        logInvocationInDebug("createE2eSvcInstance");
+        String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_E2E_SVC_INSTANCE);
 
         return msoClientInterface.createE2eSvcInstance(msoRequest, endpoint);
-    } 
+    }
 
     @Override
     public MsoResponseWrapper createVnf(RequestDetails requestDetails, String serviceInstanceId) {
-        String methodName = "createVnf";
-        logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+        logInvocationInDebug("createVnf");
 
-        String endpoint;
-        endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VNF_INSTANCE);
+        String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VNF_INSTANCE);
 
         String vnf_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId);
         return msoClientInterface.createVnf(requestDetails, vnf_endpoint);
@@ -136,11 +136,9 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
 
     @Override
     public MsoResponseWrapper createNwInstance(RequestDetails requestDetails, String serviceInstanceId) {
-        String methodName = "createNwInstance";
-        logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+        logInvocationInDebug("createNwInstance");
 
-        String endpoint;
-        endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_NETWORK_INSTANCE);
+        String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_NETWORK_INSTANCE);
 
         String nw_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId);
         return msoClientInterface.createNwInstance(requestDetails, nw_endpoint);
@@ -148,11 +146,9 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
 
     @Override
     public MsoResponseWrapper createVolumeGroupInstance(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) {
-        String methodName = "createVolumeGroupInstance";
-        logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+        logInvocationInDebug("createVolumeGroupInstance");
 
-        String endpoint;
-        endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VOLUME_GROUP_INSTANCE);
+        String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VOLUME_GROUP_INSTANCE);
 
         String vnf_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId);
         vnf_endpoint = vnf_endpoint.replaceFirst(VNF_INSTANCE_ID, vnfInstanceId);
@@ -162,11 +158,9 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
 
     @Override
     public MsoResponseWrapper createVfModuleInstance(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) {
-        String methodName = "createVfModuleInstance";
-        logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+        logInvocationInDebug("createVfModuleInstance");
 
-        String endpoint;
-        endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VF_MODULE_INSTANCE);
+        String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VF_MODULE_INSTANCE);
 
         String partial_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId);
         String vf_module_endpoint = partial_endpoint.replaceFirst(VNF_INSTANCE_ID, vnfInstanceId);
@@ -174,10 +168,25 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
         return msoClientInterface.createVfModuleInstance(requestDetails, vf_module_endpoint);
     }
 
+    @Override
+    public MsoResponseWrapper scaleOutVfModuleInstance(org.onap.vid.changeManagement.RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) {
+        logInvocationInDebug("scaleOutVfModuleInstance");
+
+        String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VF_MODULE_SCALE_OUT);
+
+        String partial_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId);
+        String vf_module_endpoint = partial_endpoint.replaceFirst(VNF_INSTANCE_ID, vnfInstanceId);
+        RequestDetailsWrapper wrapper = new RequestDetailsWrapper();
+        requestDetails.setVnfName(null);
+        requestDetails.setVnfInstanceId(null);
+        wrapper.requestDetails = requestDetails;
+
+        return msoClientInterface.scaleOutVFModuleInstance(wrapper, vf_module_endpoint);
+    }
+
     @Override
     public MsoResponseWrapper createConfigurationInstance(org.onap.vid.mso.rest.RequestDetailsWrapper requestDetailsWrapper, String serviceInstanceId) {
-        String methodName = "createConfigurationInstance";
-        logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+        logInvocationInDebug("createConfigurationInstance");
 
         String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_CONFIGURATIONS);
         endpoint = endpoint.replace(SVC_INSTANCE_ID, serviceInstanceId);
@@ -187,24 +196,21 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
 
     @Override
     public MsoResponseWrapper deleteE2eSvcInstance(Object requestDetails, String serviceInstanceId) {
-        String methodName = "deleteE2eSvcInstance";
-        logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+        logInvocationInDebug("deleteE2eSvcInstance");
 
-        String endpoint;
-               endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_E2E_SVC_INSTANCE) + "/" + serviceInstanceId;
+        String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_E2E_SVC_INSTANCE) + "/" + serviceInstanceId;
 
         return msoClientInterface.deleteE2eSvcInstance(requestDetails, endpoint);
     }
 
     @Override
     public MsoResponseWrapper deleteSvcInstance(RequestDetails requestDetails, String serviceInstanceId, String serviceStatus) {
-        String methodName = "deleteSvcInstance";
-        logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+        logInvocationInDebug("deleteSvcInstance");
         String endpoint;
 
-        if (featureManager.isActive(FLAG_UNASSIGN_SERVICE)){
+        if (featureManager.isActive(FLAG_UNASSIGN_SERVICE)) {
             endpoint = validateEndpointPath(MsoProperties.MSO_DELETE_OR_UNASSIGN_REST_API_SVC_INSTANCE);
-            if (shouldUnassignService(serviceStatus)){
+            if (shouldUnassignService(serviceStatus)) {
                 logger.debug(EELFLoggerDelegate.debugLogger, "unassign service");
                 String svc_endpoint = endpoint + "/" + serviceInstanceId + "/unassign";
                 return msoClientInterface.unassignSvcInstance(requestDetails, svc_endpoint);
@@ -218,16 +224,14 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
     }
 
     private boolean shouldUnassignService(String serviceStatus) {
-            return ImmutableList.of("created","pendingdelete","pending-delete", "assigned").contains(serviceStatus.toLowerCase());
+        return ImmutableList.of("created", "pendingdelete", "pending-delete", "assigned").contains(serviceStatus.toLowerCase());
     }
 
     @Override
     public MsoResponseWrapper deleteVnf(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) {
-        String methodName = "deleteVnf";
-        logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+        logInvocationInDebug("deleteVnf");
 
-        String endpoint;
-        endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VNF_INSTANCE);
+        String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VNF_INSTANCE);
         String vnf_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId);
         vnf_endpoint = vnf_endpoint + '/' + vnfInstanceId;
 
@@ -236,14 +240,10 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
 
     @Override
     public MsoResponseWrapper deleteVfModule(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId, String vfModuleId) {
-        String methodName = "deleteVfModule";
-        logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
-
-        String endpoint;
-        endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VF_MODULE_INSTANCE);
+        logInvocationInDebug("deleteVfModule");
 
+        String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VF_MODULE_INSTANCE);
         String vf__modules_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId).replaceFirst(VNF_INSTANCE_ID, vnfInstanceId);
-
         String delete_vf_endpoint = vf__modules_endpoint + '/' + vfModuleId;
 
         return msoClientInterface.deleteVfModule(requestDetails, delete_vf_endpoint);
@@ -251,12 +251,9 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
 
     @Override
     public MsoResponseWrapper deleteVolumeGroupInstance(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId, String volumeGroupId) {
-        String methodName = "deleteVolumeGroupInstance";
-        logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
-
-        String endpoint;
-        endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VOLUME_GROUP_INSTANCE);
+        logInvocationInDebug("deleteVolumeGroupInstance");
 
+        String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VOLUME_GROUP_INSTANCE);
         String svc_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId);
         String vnf_endpoint = svc_endpoint.replaceFirst(VNF_INSTANCE_ID, vnfInstanceId);
         String delete_volume_group_endpoint = vnf_endpoint + "/" + volumeGroupId;
@@ -266,12 +263,9 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
 
     @Override
     public MsoResponseWrapper deleteNwInstance(RequestDetails requestDetails, String serviceInstanceId, String networkInstanceId) {
-        String methodName = "deleteNwInstance";
-        logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
-
-        String endpoint;
-        endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_NETWORK_INSTANCE);
+        logInvocationInDebug("deleteNwInstance");
 
+        String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_NETWORK_INSTANCE);
         String svc_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId);
         String delete_nw_endpoint = svc_endpoint + "/" + networkInstanceId;
 
@@ -281,7 +275,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
     @Override
     public MsoResponseWrapper getOrchestrationRequest(String requestId) {
         String methodName = "getOrchestrationRequest";
-        logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+        logInvocationInDebug(methodName);
         try {
             String p = SystemProperties.getProperty(MsoProperties.MSO_REST_API_GET_ORC_REQ);
             String path = p + "/" + requestId;
@@ -289,8 +283,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
             return msoClientInterface.getOrchestrationRequest(path);
 
         } catch (Exception e) {
-            logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
-            logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+            logException(methodName, e);
             throw e;
         }
     }
@@ -298,7 +291,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
     @Override
     public MsoResponseWrapper getOrchestrationRequests(String filterString) {
         String methodName = "getOrchestrationRequest";
-        logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+        logInvocationInDebug(methodName);
         try {
             String p = SystemProperties.getProperty(MsoProperties.MSO_REST_API_GET_ORC_REQS);
             String path = p + filterString;
@@ -306,8 +299,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
             return msoClientInterface.getOrchestrationRequest(path);
 
         } catch (Exception e) {
-            logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
-            logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+            logException(methodName, e);
             throw e;
         }
     }
@@ -315,48 +307,51 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
     @Override
     public List<Request> getOrchestrationRequestsForDashboard() {
         String methodName = "getOrchestrationRequestsForDashboard";
-        logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
-        List<Request> filteredOrchestrationRequests = new ArrayList<>();
-        try {
-            String path = SystemProperties.getProperty(MsoProperties.MSO_REST_API_GET_ORC_REQS);
-            path += "filter=modelType:EQUALS:vnf";
-            RestObject<String> restObjStr = new RestObject<>();
-            String str = new String();
-            restObjStr.set(str);
+        logInvocationInDebug(methodName);
 
-            MsoResponseWrapper msoResponseWrapper = msoClientInterface.getOrchestrationRequestsForDashboard(str, "", path, restObjStr);
-            List<RequestWrapper> allOrchestrationRequests = deserializeOrchestrationRequestsJson(msoResponseWrapper.getEntity());
-
-            final ImmutableList<String> suppoertedRequestTypes = ImmutableList.of(
-                    RequestType.REPLACE_INSTANCE.toString().toUpperCase(),
-                    RequestType.UPDATE_INSTANCE.toString().toUpperCase(),
-                    RequestType.APPLY_UPDATED_CONFIG.toString().toUpperCase(),
-                    RequestType.IN_PLACE_SOFTWARE_UPDATE.toString().toUpperCase()
-            );
-
-            for (RequestWrapper currentRequest : allOrchestrationRequests) {
-                if (currentRequest.getRequest() != null
-                        && "vnf".equalsIgnoreCase(currentRequest.getRequest().getRequestScope())
-                        && suppoertedRequestTypes.contains(upperCase(currentRequest.getRequest().getRequestType()))
-                ) {
-                    filteredOrchestrationRequests.add(currentRequest.getRequest());
-                }
-            }
+        List<Request> dashboardOrchestrationReqs = new ArrayList<>();
+        try {
+            List<RequestWrapper> vnfOrchestrationReqsWrappers = getOrchestrationRequestsByFilter("modelType", "vnf");
+            dashboardOrchestrationReqs = vnfOrchestrationReqsWrappers.stream()
+                    .filter(reqWrapper -> Objects.nonNull(reqWrapper.getRequest())
+                            && DASHBOARD_ALLOWED_TYPES.contains(upperCase(reqWrapper.getRequest().getRequestType())))
+                    .map(RequestWrapper::getRequest)
+                    .collect(Collectors.toList());
+
+            List<RequestWrapper> scaleOutOrchestrationReqWrappers = getOrchestrationRequestsByFilter("action", "scaleOut");
+            List<Request> scaleoutRequests = scaleOutOrchestrationReqWrappers.stream()
+                    .filter(reqWrapper -> Objects.nonNull(reqWrapper.getRequest()))
+                    .map(RequestWrapper::getRequest)
+                    .collect(Collectors.toList());
+
+            dashboardOrchestrationReqs.addAll(scaleoutRequests);
         } catch (Exception e) {
-            logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
-            logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+            logException(methodName, e);
         }
-        return filteredOrchestrationRequests;
+        return dashboardOrchestrationReqs;
+    }
+
+    private String constructOrchestrationRequestFilter(String filterName, String filterValue) {
+        return String.format("%sfilter=%s:EQUALS:%s",
+                SystemProperties.getProperty(MsoProperties.MSO_REST_API_GET_ORC_REQS), filterName, filterValue);
+    }
+
+    private List<RequestWrapper> getOrchestrationRequestsByFilter(String filterName, String filterValue) {
+        String orchestrationReqPath = constructOrchestrationRequestFilter(filterName, filterValue);
+        RestObject<String> restObjStr = new RestObject<>();
+        String str = new String();
+        restObjStr.set(str);
+        MsoResponseWrapper msoResponseWrapper = msoClientInterface.getOrchestrationRequestsForDashboard(str, "", orchestrationReqPath, restObjStr);
+        return deserializeOrchestrationRequestsJson(msoResponseWrapper.getEntity());
     }
 
     private List<RequestWrapper> deserializeOrchestrationRequestsJson(String orchestrationRequestsJson) {
-        String methodName = "deserializeOrchestrationRequestsJson";
-        logger.debug(dateFormat.format(new Date()) + "<== " + methodName + START);
+        logInvocationInDebug("deserializeOrchestrationRequestsJson");
 
         ObjectMapper mapper = new ObjectMapper();
         mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
         mapper.configure(DeserializationFeature.READ_ENUMS_USING_TO_STRING, true);
-        RequestList requestList = null;
+        RequestList requestList;
         try {
             requestList = mapper.readValue(orchestrationRequestsJson, RequestList.class);
         } catch (IOException e) {
@@ -369,7 +364,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
     @Override
     public List<Task> getManualTasksByRequestId(String originalRequestId) {
         String methodName = "getManualTasksByRequestId";
-        logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+        logInvocationInDebug(methodName);
 
         try {
             String p = SystemProperties.getProperty(MsoProperties.MSO_REST_API_GET_MAN_TASKS);
@@ -383,15 +378,13 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
             return deserializeManualTasksJson(msoResponseWrapper.getEntity());
 
         } catch (Exception e) {
-            logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
-            logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+            logException(methodName, e);
             throw e;
         }
     }
 
     private List<Task> deserializeManualTasksJson(String manualTasksJson) {
-        String methodName = "deserializeManualTasksJson";
-        logger.debug(dateFormat.format(new Date()) + "<== " + methodName + START);
+        logInvocationInDebug("deserializeManualTasksJson");
 
         ObjectMapper mapper = new ObjectMapper();
         try {
@@ -406,7 +399,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
     @Override
     public MsoResponseWrapper completeManualTask(RequestDetails requestDetails, String taskId) {
         String methodName = "completeManualTask";
-        logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+        logInvocationInDebug(methodName);
         try {
             String p = SystemProperties.getProperty(MsoProperties.MSO_REST_API_GET_MAN_TASKS);
             String path = p + "/" + taskId + "/complete";
@@ -420,8 +413,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
             return MsoUtil.wrapResponse(restObjStr);
 
         } catch (Exception e) {
-            logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
-            logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+            logException(methodName, e);
             throw e;
         }
     }
@@ -429,7 +421,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
     @Override
     public MsoResponseWrapper activateServiceInstance(RequestDetails requestDetails, String serviceInstanceId) {
         String methodName = "activateServiceInstance";
-        logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+        logInvocationInDebug(methodName);
         try {
             String serviceEndpoint = SystemProperties.getProperty(MsoProperties.MSO_REST_API_SVC_INSTANCE);
             String activateServicePath = serviceEndpoint + "/" + serviceInstanceId + ACTIVATE;
@@ -443,8 +435,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
             return MsoUtil.wrapResponse(restObjStr);
 
         } catch (Exception e) {
-            logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
-            logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+            logException(methodName, e);
             throw e;
         }
     }
@@ -452,8 +443,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
 
     @Override
     public MsoResponseWrapperInterface updateVnf(org.onap.vid.changeManagement.RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) {
-        String methodName = "updateVnf";
-        logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+        logInvocationInDebug("updateVnf");
 
         String endpoint;
         endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VNF_INSTANCE);
@@ -464,11 +454,9 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
 
     @Override
     public MsoResponseWrapperInterface replaceVnf(org.onap.vid.changeManagement.RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) {
-        String methodName = "replaceVnf";
-        logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+        logInvocationInDebug("replaceVnf");
 
-        String endpoint;
-        endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VNF_CHANGE_MANAGEMENT_INSTANCE);
+        String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VNF_CHANGE_MANAGEMENT_INSTANCE);
         String vnf_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId);
         vnf_endpoint = vnf_endpoint.replace(VNF_INSTANCE_ID, vnfInstanceId);
         vnf_endpoint = vnf_endpoint.replace(REQUEST_TYPE, MsoChangeManagementRequest.REPLACE);
@@ -489,22 +477,17 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
     @Override
     public RequestDetailsWrapper generateConfigMsoRequest(org.onap.vid.changeManagement.RequestDetails requestDetails) {
         validateUpdateVnfConfig(requestDetails);
-        RequestDetails ConfigUpdateRequest = new RequestDetails();
-        ConfigUpdateRequest.setRequestParameters(requestDetails.getRequestParameters());
-        ConfigUpdateRequest.setRequestInfo(requestDetails.getRequestInfo());
+        RequestDetails configUpdateRequest = new RequestDetails();
+        configUpdateRequest.setRequestParameters(requestDetails.getRequestParameters());
+        configUpdateRequest.setRequestInfo(requestDetails.getRequestInfo());
         RequestDetailsWrapper requestDetailsWrapper = new RequestDetailsWrapper();
-        requestDetailsWrapper.requestDetails = ConfigUpdateRequest;
+        requestDetailsWrapper.requestDetails = configUpdateRequest;
         return requestDetailsWrapper;
     }
 
-
-
-
-
     @Override
     public MsoResponseWrapperInterface updateVnfSoftware(org.onap.vid.changeManagement.RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) {
-        String methodName = "updateVnfSoftware";
-        logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+        logInvocationInDebug("updateVnfSoftware");
         String vnf_endpoint = getChangeManagementEndpoint(serviceInstanceId, vnfInstanceId, MsoChangeManagementRequest.SOFTWARE_UPDATE); //workflow name in mso is different than workflow name in vid UI
         RequestDetailsWrapper finalRequestDetails = generateInPlaceMsoRequest(requestDetails);
         return msoClientInterface.changeManagementUpdate(finalRequestDetails, vnf_endpoint);
@@ -512,30 +495,28 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
 
     @Override
     public MsoResponseWrapperInterface updateVnfConfig(org.onap.vid.changeManagement.RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) {
-        String methodName = "updateVnfConfig";
-        logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+        logInvocationInDebug("updateVnfConfig");
         RequestDetailsWrapper finalRequestDetails = generateConfigMsoRequest(requestDetails);
         String vnf_endpoint = getChangeManagementEndpoint(serviceInstanceId, vnfInstanceId, MsoChangeManagementRequest.CONFIG_UPDATE);
         return msoClientInterface.changeManagementUpdate(finalRequestDetails, vnf_endpoint);
     }
 
     private String getChangeManagementEndpoint(String serviceInstanceId, String vnfInstanceId, String vnfRequestType) {
-        String endpoint  = validateEndpointPath(MsoProperties.MSO_REST_API_VNF_CHANGE_MANAGEMENT_INSTANCE);
+        String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VNF_CHANGE_MANAGEMENT_INSTANCE);
         String vnf_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId);
         vnf_endpoint = vnf_endpoint.replace(VNF_INSTANCE_ID, vnfInstanceId);
         vnf_endpoint = vnf_endpoint.replace(REQUEST_TYPE, vnfRequestType);
         return vnf_endpoint;
     }
 
-    private Map getChangeManagementPayload(RequestDetails requestDetails, String message){
-        if(requestDetails.getRequestParameters()==null||requestDetails.getRequestParameters().getAdditionalProperties()==null){
+    private Map getChangeManagementPayload(RequestDetails requestDetails, String message) {
+        if (requestDetails.getRequestParameters() == null || requestDetails.getRequestParameters().getAdditionalProperties() == null) {
             throw new BadRequestException(message);
         }
-        Object payloadRaw=requestDetails.getRequestParameters().getAdditionalProperties().get("payload");
-        try{
-            return objectMapper.readValue((String)payloadRaw,Map.class);
-        }
-        catch(Exception exception){
+        Object payloadRaw = requestDetails.getRequestParameters().getAdditionalProperties().get("payload");
+        try {
+            return objectMapper.readValue((String) payloadRaw, Map.class);
+        } catch (Exception exception) {
             throw new BadRequestException(message);
         }
     }
@@ -564,30 +545,12 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
         }
     }
 
-    private void validateUpdateVnfConfig(RequestDetails requestDetails) {
-        final String noValidPayloadMsg = "No valid payload in " + ChangeManagementRequest.CONFIG_UPDATE + " request";
-
-        Map payload = getChangeManagementPayload(requestDetails, noValidPayloadMsg);
-        validateConfigUpdateVnfPayloadProperty(payload, noValidPayloadMsg, "request-parameters");
-        validateConfigUpdateVnfPayloadProperty(payload, noValidPayloadMsg, "configuration-parameters");
-    }
-
-    private void validateConfigUpdateVnfPayloadProperty(Map payload, String noValidPayloadMsg, String propertyName) {
-        final String noValidPayloadPropertyMsg = noValidPayloadMsg+ ", "+ propertyName + " property is not valid";
-        if(!payload.containsKey(propertyName)) {
-            throw new BadRequestException( noValidPayloadPropertyMsg);
-        }
-    }
-
     @Override
-    public MsoResponseWrapper deleteConfiguration(
-            org.onap.vid.mso.rest.RequestDetailsWrapper requestDetailsWrapper,
-            String serviceInstanceId,
-            String configurationId) {
-
-        String methodName = "deleteConfiguration";
-        logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+    public MsoResponseWrapper deleteConfiguration(org.onap.vid.mso.rest.RequestDetailsWrapper requestDetailsWrapper,
+                                                  String serviceInstanceId,
+                                                  String configurationId) {
 
+        logInvocationInDebug("deleteConfiguration");
         String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_CONFIGURATION_INSTANCE);
         endpoint = endpoint.replace(SVC_INSTANCE_ID, serviceInstanceId);
         endpoint = endpoint.replace(CONFIGURATION_ID, configurationId);
@@ -602,8 +565,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
             String configurationId,
             boolean isActivate) {
 
-        String methodName = "setConfigurationActiveStatus";
-        logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+        logInvocationInDebug("setConfigurationActiveStatus");
 
         String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_CONFIGURATION_INSTANCE);
         endpoint = endpoint.replace(SVC_INSTANCE_ID, serviceInstanceId);
@@ -616,9 +578,9 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
     }
 
     @Override
-    public MsoResponseWrapper setServiceInstanceStatus(RequestDetails requestDetails , String serviceInstanceId, boolean isActivate) {
+    public MsoResponseWrapper setServiceInstanceStatus(RequestDetails requestDetails, String serviceInstanceId, boolean isActivate) {
+        logInvocationInDebug("setServiceInstanceStatus");
         String methodName = "setServiceInstanceStatus";
-        logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
         try {
             String serviceEndpoint = validateEndpointPath(MsoProperties.MSO_REST_API_SVC_INSTANCE);
             String endpoint = serviceEndpoint + "/" + serviceInstanceId;
@@ -631,7 +593,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
             String str = "";
             restObjStr.set(str);
 
-            msoClientInterface.setServiceInstanceStatus(requestDetails , str, "", endpoint, restObjStr);
+            msoClientInterface.setServiceInstanceStatus(requestDetails, str, "", endpoint, restObjStr);
 
             return MsoUtil.wrapResponse(restObjStr);
 
@@ -648,8 +610,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
             String serviceInstanceId,
             String configurationId,
             boolean isEnable) {
-        String methodName = "setPortOnConfigurationStatus";
-        logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+        logInvocationInDebug("setPortOnConfigurationStatus");
 
         String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_CONFIGURATION_INSTANCE);
         endpoint = endpoint.replace(SVC_INSTANCE_ID, serviceInstanceId);
@@ -663,7 +624,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
 
 
     @Override
-    public  RequestDetailsWrapper<RequestDetails> createOperationalEnvironmentActivationRequestDetails(OperationalEnvironmentActivateInfo details) {
+    public RequestDetailsWrapper<RequestDetails> createOperationalEnvironmentActivationRequestDetails(OperationalEnvironmentActivateInfo details) {
         RequestDetails requestDetails = new RequestDetails();
         RequestInfo requestInfo = new RequestInfo();
         requestInfo.setAdditionalProperty(RESOURCE_TYPE, RESOURCE_TYPE_OPERATIONAL_ENVIRONMENT);
@@ -737,7 +698,6 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
     }
 
 
-
     @Override
     public RequestDetailsWrapper<OperationEnvironmentRequestDetails> convertParametersToRequestDetails(OperationalEnvironmentController.OperationalEnvironmentCreateBody input, String userId) {
         OperationEnvironmentRequestDetails.RequestInfo requestInfo = new OperationEnvironmentRequestDetails.RequestInfo(
@@ -766,8 +726,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
 
     @Override
     public MsoResponseWrapper removeRelationshipFromServiceInstance(RequestDetails requestDetails, String serviceInstanceId) {
-        String methodName = "removeRelationshipFromServiceInstance";
-        logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+        logInvocationInDebug("removeRelationshipFromServiceInstance");
 
         String serviceEndpoint = SystemProperties.getProperty(MsoProperties.MSO_REST_API_SVC_INSTANCE);
         String removeRelationshipsPath = serviceEndpoint + "/" + serviceInstanceId + "/removeRelationships";
@@ -777,8 +736,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
 
     @Override
     public MsoResponseWrapper addRelationshipToServiceInstance(RequestDetails requestDetails, String serviceInstanceId) {
-        String methodName = "addRelationshipToServiceInstance";
-        logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+        logInvocationInDebug("addRelationshipToServiceInstance");
 
         String serviceEndpoint = SystemProperties.getProperty(MsoProperties.MSO_REST_API_SVC_INSTANCE);
         String addRelationshipsPath = serviceEndpoint + "/" + serviceInstanceId + "/addRelationships";
@@ -786,8 +744,31 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
         return msoClientInterface.addRelationshipToServiceInstance(requestDetails, addRelationshipsPath);
     }
 
+    private void validateUpdateVnfConfig(RequestDetails requestDetails) {
+        final String noValidPayloadMsg = "No valid payload in " + ChangeManagementRequest.CONFIG_UPDATE + " request";
 
-    public enum RequestType {
+        Map payload = getChangeManagementPayload(requestDetails, noValidPayloadMsg);
+        validateConfigUpdateVnfPayloadProperty(payload, noValidPayloadMsg, "request-parameters");
+        validateConfigUpdateVnfPayloadProperty(payload, noValidPayloadMsg, "configuration-parameters");
+    }
+
+    private void validateConfigUpdateVnfPayloadProperty(Map payload, String noValidPayloadMsg, String propertyName) {
+        final String noValidPayloadPropertyMsg = noValidPayloadMsg + ", " + propertyName + " property is not valid";
+        if (!payload.containsKey(propertyName)) {
+            throw new BadRequestException(noValidPayloadPropertyMsg);
+        }
+    }
+
+    private void logInvocationInDebug(String methodName) {
+        logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + "  start");
+    }
+
+    private void logException(String methodName, Exception e) {
+        logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+        logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+    }
+
+    enum RequestType {
 
         CREATE_INSTANCE("createInstance"),
         DELETE_INSTANCE("deleteInstance"),
@@ -797,27 +778,23 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
         DEACTIVATE_INSTANCE("deactivateInstance"),
         APPLY_UPDATED_CONFIG("applyUpdatedConfig"),
         IN_PLACE_SOFTWARE_UPDATE("inPlaceSoftwareUpdate"),
+        SCALE_OUT("scaleOut"),
         UNKNOWN("unknown"),
         NOT_PROVIDED("not provided");
-        private final String value;
         private static final Map<String, RequestType> CONSTANTS = new HashMap<>();
 
         static {
-            for (RequestType c: values()) {
+            for (RequestType c : values()) {
                 CONSTANTS.put(c.value, c);
             }
         }
 
+        private final String value;
+
         RequestType(String value) {
             this.value = value;
         }
 
-        @JsonValue
-        @Override
-        public String toString() {
-            return this.value;
-        }
-
         @JsonCreator
         public static RequestType fromValue(String value) {
             RequestType constant = CONSTANTS.get(value);
@@ -827,5 +804,11 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
                 return constant;
             }
         }
+
+        @JsonValue
+        @Override
+        public String toString() {
+            return this.value;
+        }
     }
 }
\ No newline at end of file
index 3cba12f..834f808 100644 (file)
@@ -74,6 +74,8 @@ public interface MsoInterface {
 
     MsoResponseWrapper createConfigurationInstance(org.onap.vid.mso.rest.RequestDetailsWrapper requestDetailsWrapper, String endpoint);
 
+    MsoResponseWrapper scaleOutVFModuleInstance(RequestDetailsWrapper requestDetailsWrapper, String endpoint);
+
     MsoResponseWrapper deleteSvcInstance(RequestDetails requestDetails, String endpoint);
 
     MsoResponseWrapper unassignSvcInstance(RequestDetails requestDetails, String endpoint);
index 773b8a8..1d71e9c 100644 (file)
@@ -99,6 +99,8 @@ public class MsoProperties extends SystemProperties {
        /** The Constant MSO_REST_API_VF_MODULE_INSTANCE. */
        public static final String MSO_REST_API_VF_MODULE_INSTANCE = "mso.restapi.vf.module.instance";
 
+       public static final String MSO_REST_API_VF_MODULE_SCALE_OUT = "mso.restapi.vf.module.scaleout";
+
        /** The Constant MSO_REST_API_VOLUME_GROUP_INSTANCE. */
        public static final String MSO_REST_API_VOLUME_GROUP_INSTANCE = "mso.restapi.volume.group.instance"; //serviceInstances/v2/{serviceInstanceId}/volumeGroups
 
index 9cac3e4..59bd667 100644 (file)
@@ -123,6 +123,14 @@ public class MsoRestClientNew implements MsoInterface {
         return createInstance(requestDetails, path);
     }
 
+    @Override
+    public MsoResponseWrapper scaleOutVFModuleInstance(RequestDetailsWrapper requestDetailsWrapper, String endpoint) {
+        String methodName = "scaleOutVFModuleInstance";
+        logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+        String path = baseUrl + endpoint;
+        return createInstance(requestDetailsWrapper, path);
+    }
+
     @Override
     public MsoResponseWrapper createConfigurationInstance(org.onap.vid.mso.rest.RequestDetailsWrapper requestDetailsWrapper, String endpoint) {
         String methodName = "createConfigurationInstance";
index 9d198ad..2b159f8 100644 (file)
 
 package org.onap.vid.mso.rest;
 
-import com.fasterxml.jackson.annotation.*;
-import org.apache.commons.lang.builder.EqualsBuilder;
-import org.apache.commons.lang.builder.HashCodeBuilder;
-import org.apache.commons.lang.builder.ToStringBuilder;
-import org.onap.vid.domain.mso.*;
+import com.fasterxml.jackson.annotation.JsonAnyGetter;
+import com.fasterxml.jackson.annotation.JsonAnySetter;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.onap.vid.domain.mso.CloudConfiguration;
+import org.onap.vid.domain.mso.ModelInfo;
+import org.onap.vid.domain.mso.RequestInfo;
+import org.onap.vid.domain.mso.RequestParameters;
+import org.onap.vid.domain.mso.SubscriberInfo;
 
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -74,7 +82,7 @@ public class RequestDetails{
     private RequestParameters requestParameters;
 
     @JsonProperty("configurationParameters")
-    protected List<Map<String, String>> configurationParameters = new ArrayList<>();
+    protected List<Map<String, String>> configurationParameters;
 
     /** The additional properties. */
     @JsonIgnore
@@ -226,7 +234,7 @@ public class RequestDetails{
                 .append(getRequestParameters())
                 .append(subscriberInfo)
                 .append(additionalProperties)
-                .append(configurationParameters.hashCode())
+                .append(configurationParameters)
                 .toHashCode();
     }
 
index 13db1ae..b4806f1 100644 (file)
@@ -1,3 +1,23 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2018 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
 package org.onap.vid.services;
 
 import com.fasterxml.jackson.core.JsonParseException;
@@ -16,12 +36,12 @@ public class AuditServiceImpl implements AuditService{
 
     @Inject
     private AsyncInstantiationBusinessLogic asyncInstantiationBL;
+    public static final String FAILED_MSO_REQUEST_STATUS = "FAILED";
 
     @Override
     public void setFailedAuditStatusFromMso(UUID jobUuid, String requestId, int statusCode, String msoResponse){
-        final String failedMsoRequestStatus = "FAILED";
         String additionalInfo = formatExceptionAdditionalInfo(statusCode, msoResponse);
-        asyncInstantiationBL.auditMsoStatus(jobUuid, failedMsoRequestStatus, requestId, additionalInfo);
+        asyncInstantiationBL.auditMsoStatus(jobUuid, FAILED_MSO_REQUEST_STATUS, requestId, additionalInfo);
     }
 
     private String formatExceptionAdditionalInfo(int statusCode, String msoResponse) {
index fa531ff..b3d20a6 100644 (file)
@@ -1,3 +1,23 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2018 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
 package org.onap.vid.services;
 
 import org.onap.vid.category.AddCategoryOptionResponse;
@@ -20,6 +40,7 @@ import java.util.stream.Collectors;
 @Service
 public class CategoryParameterServiceImpl implements CategoryParameterService {
 
+    public static final String OPTION_ALREADY_EXIST_FOR_CATEGORY = "Option %s already exist for category %s";
     @Autowired
     private DataAccessService dataAccessService;
 
@@ -68,7 +89,7 @@ public class CategoryParameterServiceImpl implements CategoryParameterService {
         Set<String> categoryOptions = categoryParameter.getOptions().stream().map(CategoryParameterOption::getName).collect(Collectors.toSet());
         for (String optionName : optionsRequest.options) {
             if (categoryOptions.contains(optionName)) {
-                response.getErrors().add(String.format("Option %s already exist for category %s", optionName, categoryName));
+                response.getErrors().add(String.format(OPTION_ALREADY_EXIST_FOR_CATEGORY, optionName, categoryName));
                 continue;
             }
             String appId = categoryParameter.isIdSupported() ? UUID.randomUUID().toString() : optionName;
index 90d1c33..e4a6b39 100644 (file)
@@ -102,7 +102,7 @@ public class ChangeManagementServiceImpl implements ChangeManagementService {
                         break;
                     }
                     case ChangeManagementRequest.SCALE_OUT:{
-                        msoResponseWrapperObject = msoBusinessLogic.createVfModuleInstance(currentRequestDetails, serviceInstanceId, vnfInstanceId);
+                        msoResponseWrapperObject = msoBusinessLogic.scaleOutVfModuleInstance(currentRequestDetails, serviceInstanceId, vnfInstanceId);
                         break;
                     }
                                        default:
index 21b1ec1..231b352 100644 (file)
@@ -1,3 +1,23 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2018 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
 package org.onap.vid.services;
 
 import org.onap.vid.aai.PombaClientInterface;
index dc2541b..1890a5b 100644 (file)
@@ -1,3 +1,23 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2018 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
 package org.onap.vid.services;
 
 import com.google.common.cache.CacheBuilder;
index 89660fb..aee4c05 100755 (executable)
           DataService.setPnf(!angular.equals(serviceModel.pnfs, {}));\r
                                        $scope.createType = COMPONENT.A_LA_CARTE;\r
                                        var broadcastType = COMPONENT.CREATE_COMPONENT;\r
-                    if (AsdcService.isMacro(serviceModel)) {\r
+                    if (AsdcService.isMacro(serviceModel) || DataService.getE2EService()) {\r
                         DataService.setALaCarte(false);\r
                         if(AsdcService.shouldExcludeMacroFromAsyncInstatiationFlow(serviceModel)){\r
                                DataService.setShouldExcludeMacroFromAsyncInstatiationFlow(true);\r
index fca5a7c..6029ed2 100644 (file)
                                var data;
                                if(workflowType=="VNF Scale Out") {
                     data = {
+                        vnfName: vnf.name,
+                        vnfInstanceId: vnf.id,
                         modelInfo: {
                             modelType: 'vfModule',
                             modelInvariantId: moduleToScale.invariantUuid,
                             modelName: moduleToScale.modelCustomizationName,
                             modelVersion: moduleToScale.version,
+                            modelCustomizationName: moduleToScale.modelCustomizationName,
+                            modelCustomizationId: moduleToScale.customizationUuid,
                             modelVersionId: moduleToScale.uuid
                         },
                         cloudConfiguration: vnf.cloudConfiguration,
                         cloudConfiguration: vnf.cloudConfiguration,
                         requestInfo: requestInfoData,
                         relatedInstanceList: [],
-                        requestParameters:requestParametersData,
-                        configurationParameters: []
+                        requestParameters:requestParametersData
                     };
                 }
 
                         var relatedInstance = {
                             instanceId: vnf.id,
                             modelInfo: {
+                                modelCustomizationId: vnf.availableVersions[0].modelInfo.modelCustomizationId,
                                 modelCustomizationName: vnf.availableVersions[0].modelInfo.modelCustomizationName,
                                 modelInvariantId: vnf.availableVersions[0].modelInfo.modelInvariantId,
                                 modelName: vnf.availableVersions[0].modelInfo.modelName,
                                //no scheduling support
                                var dataToSo = extractChangeManagementCallbackDataStr(vm.changeManagement);
                 if(dataToSo) {
-
-                    if(vm.changeManagement.workflow==="VNF Scale Out") {
-                        dataToSo = JSON.parse(dataToSo);
-                        dataToSo = {requestDetails: dataToSo.requestDetails[0]};
-                        changeManagementService.postChangeManagementScaleOutNow(dataToSo,
-                            vm.changeManagement.vnfNames[0]["service-instance-node"][0].properties["service-instance-id"],
-                            vm.changeManagement.vnfNames[0].id);
-                    }else{
-                        //TODO: foreach
-                        var vnfName = vm.changeManagement.vnfNames[0].name;
-                        changeManagementService.postChangeManagementNow(dataToSo, vnfName);
-                    }
+                    var vnfName = vm.changeManagement.vnfNames[0].name;
+                    changeManagementService.postChangeManagementNow(dataToSo, vnfName);
                 }
                        }
         };
index 753f9fd..6bdc0ae 100755 (executable)
@@ -20,7 +20,7 @@
 \r
 "use strict";\r
 \r
-var AsdcService = function ($http, $log, PropertyService, UtilityService, VIDCONFIGURATION, COMPONENT, featureFlags) {\r
+var AsdcService = function ($http, $log, PropertyService, UtilityService, VIDCONFIGURATION, COMPONENT, DataService, featureFlags) {\r
     return {\r
         getModel: function (modelId, successCallbackFunction) {\r
             $log.debug("AsdcService:getModel: modelId: " + modelId);\r
@@ -37,6 +37,8 @@ var AsdcService = function ($http, $log, PropertyService, UtilityService, VIDCON
         shouldExcludeMacroFromAsyncInstatiationFlow: function(serviceModel){\r
             if (!featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_ASYNC_INSTANTIATION))\r
                 return true;\r
+                       if (DataService.getE2EService())\r
+                               return true;\r
             if (!_.isEmpty(serviceModel.pnfs))\r
                 return true;\r
             if (!_.isEmpty(serviceModel.collectionResource))\r
@@ -72,4 +74,4 @@ var AsdcService = function ($http, $log, PropertyService, UtilityService, VIDCON
 }\r
 \r
 appDS2.factory("AsdcService", ["$http", "$log", "PropertyService",\r
-    "UtilityService", "VIDCONFIGURATION","COMPONENT", "featureFlags", AsdcService]);\r
+    "UtilityService", "VIDCONFIGURATION","COMPONENT", "DataService", "featureFlags", AsdcService]);\r
diff --git a/vid-app-common/src/test/java/org/onap/vid/job/command/InProgressStatusCommandTest.java b/vid-app-common/src/test/java/org/onap/vid/job/command/InProgressStatusCommandTest.java
new file mode 100644 (file)
index 0000000..bc62392
--- /dev/null
@@ -0,0 +1,143 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2018 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.job.command;
+
+
+import io.joshworks.restclient.http.HttpResponse;
+import org.mockito.Mock;
+import org.onap.vid.job.Job;
+import org.onap.vid.job.NextCommand;
+import org.onap.vid.mso.MsoInterface;
+import org.onap.vid.mso.rest.AsyncRequestStatus;
+import org.onap.vid.services.AsyncInstantiationBusinessLogic;
+import org.onap.vid.services.AuditService;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import javax.ws.rs.ProcessingException;
+import java.util.UUID;
+
+
+import static org.assertj.core.api.Java6Assertions.assertThat;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import static org.mockito.MockitoAnnotations.initMocks;
+
+public class InProgressStatusCommandTest {
+
+    @Mock
+    private AsyncInstantiationBusinessLogic asyncInstantiationBusinessLogic;
+
+    @Mock
+    private MsoInterface msoInterface;
+
+    @Mock
+    private AuditService auditService;
+
+    @Mock
+    private HttpResponse<AsyncRequestStatus> msoResponse;
+
+    @Mock
+    private AsyncRequestStatus asyncRequestStatus;
+
+    @Mock
+    private AsyncRequestStatus.Request request;
+
+    private UUID uuid = UUID.randomUUID();
+
+    private InProgressStatusCommand inProgressStatusCommand;
+
+    @BeforeMethod
+    public void setUp() {
+        initMocks(this);
+
+        inProgressStatusCommand = new InProgressStatusCommand(asyncInstantiationBusinessLogic, msoInterface, auditService, uuid, "sampleRequestId");
+
+        when(asyncInstantiationBusinessLogic.getOrchestrationRequestsPath()).thenReturn("http://localhost:8080/samplePath");
+        when(msoInterface.get("http://localhost:8080/samplePath/sampleRequestId", AsyncRequestStatus.class)).thenReturn(msoResponse);
+        when(msoResponse.getBody()).thenReturn(asyncRequestStatus);
+    }
+
+
+    @Test
+    public void whenSOReturnsErrorShouldSetProperFailureStateAndReturnRetryCommand() {
+        when(msoResponse.getStatus()).thenReturn(500);
+
+        NextCommand call = inProgressStatusCommand.call();
+
+        assertThat(call.getStatus()).isEqualTo(Job.JobStatus.IN_PROGRESS);
+        assertThat(call.getCommand()).isEqualTo(inProgressStatusCommand);
+
+        verify(auditService).setFailedAuditStatusFromMso(uuid, "sampleRequestId", 500, asyncRequestStatus.toString());
+    }
+
+    @Test
+    public void shouldProperlyHandleFailedInstantiation() {
+        when(msoResponse.getStatus()).thenReturn(200);
+        when(asyncInstantiationBusinessLogic.calcStatus(asyncRequestStatus)).thenReturn(Job.JobStatus.FAILED);
+        asyncRequestStatus.request = request;
+
+        NextCommand call = inProgressStatusCommand.call();
+
+        assertThat(call.getCommand()).isEqualTo(inProgressStatusCommand);
+        assertThat(call.getStatus()).isEqualTo(Job.JobStatus.FAILED);
+
+        verify(asyncInstantiationBusinessLogic).handleFailedInstantiation(uuid);
+        verify(asyncInstantiationBusinessLogic).auditMsoStatus(uuid, request);
+    }
+
+    @Test
+    public void shouldRetryCommandWithPausedState() {
+        when(msoResponse.getStatus()).thenReturn(200);
+        when(asyncInstantiationBusinessLogic.calcStatus(asyncRequestStatus)).thenReturn(Job.JobStatus.PAUSE);
+        asyncRequestStatus.request = request;
+
+        NextCommand call = inProgressStatusCommand.call();
+
+        assertThat(call.getCommand()).isEqualTo(inProgressStatusCommand);
+        assertThat(call.getStatus()).isEqualTo(Job.JobStatus.IN_PROGRESS);
+
+        verify(asyncInstantiationBusinessLogic).auditMsoStatus(uuid, request);
+        verify(asyncInstantiationBusinessLogic).updateServiceInfoAndAuditStatus(uuid, Job.JobStatus.PAUSE);
+    }
+
+    @Test
+    public void shouldRetryCommandExitedWithProcessingException() {
+        when(msoResponse.getStatus()).thenReturn(200);
+        when(asyncInstantiationBusinessLogic.calcStatus(asyncRequestStatus)).thenThrow(new ProcessingException(""));
+
+        NextCommand call = inProgressStatusCommand.call();
+
+        assertThat(call.getCommand()).isEqualTo(inProgressStatusCommand);
+        assertThat(call.getStatus()).isEqualTo(Job.JobStatus.IN_PROGRESS);
+    }
+
+    @Test
+    public void shouldSetStoppedStatusWhenRuntimeExceptionOccurs() {
+        when(msoResponse.getStatus()).thenReturn(200);
+        when(asyncInstantiationBusinessLogic.calcStatus(asyncRequestStatus)).thenThrow(new RuntimeException());
+
+        NextCommand call = inProgressStatusCommand.call();
+
+        assertThat(call.getCommand()).isEqualTo(inProgressStatusCommand);
+        assertThat(call.getStatus()).isEqualTo(Job.JobStatus.STOPPED);
+    }
+}
\ No newline at end of file
diff --git a/vid-app-common/src/test/java/org/onap/vid/job/command/ServiceInstantiationCommandTest.java b/vid-app-common/src/test/java/org/onap/vid/job/command/ServiceInstantiationCommandTest.java
new file mode 100644 (file)
index 0000000..e7ab4f0
--- /dev/null
@@ -0,0 +1,157 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2018 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.job.command;
+
+
+import io.joshworks.restclient.http.HttpResponse;
+import org.mockito.Mock;
+import org.onap.vid.aai.AaiResponse;
+import org.onap.vid.aai.exceptions.InvalidAAIResponseException;
+import org.onap.vid.changeManagement.RequestDetailsWrapper;
+import org.onap.vid.domain.mso.RequestReferences;
+import org.onap.vid.exceptions.MaxRetriesException;
+import org.onap.vid.job.Job;
+import org.onap.vid.job.NextCommand;
+import org.onap.vid.model.RequestReferencesContainer;
+import org.onap.vid.model.serviceInstantiation.ServiceInstantiation;
+import org.onap.vid.mso.MsoInterface;
+import org.onap.vid.mso.model.ServiceInstantiationRequestDetails;
+import org.onap.vid.services.AsyncInstantiationBusinessLogic;
+import org.onap.vid.services.AuditService;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import java.util.UUID;
+
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import static org.mockito.MockitoAnnotations.initMocks;
+
+public class ServiceInstantiationCommandTest {
+    @Mock
+    private AsyncInstantiationBusinessLogic asyncInstantiationBusinessLogic;
+
+    @Mock
+    private MsoInterface msoInterface;
+
+    @Mock
+    private AuditService auditService;
+
+    @Mock
+    private ServiceInstantiation serviceInstantiation;
+
+    @Mock
+    private HttpResponse<RequestReferencesContainer> msoResponse;
+
+    @Mock
+    private RequestDetailsWrapper<ServiceInstantiationRequestDetails> requestDetailsWrapper;
+
+    @Mock
+    private AaiResponse aaiResponse;
+
+    @Mock
+    private RequestReferencesContainer requestReferencesContainer;
+
+
+    private UUID uuid = UUID.randomUUID();
+
+
+    private ServiceInstantiationCommand serviceInstantiationCommand;
+
+    @BeforeMethod
+    public void setUp() {
+        initMocks(this);
+        serviceInstantiationCommand = new ServiceInstantiationCommand(asyncInstantiationBusinessLogic, auditService, msoInterface, uuid, serviceInstantiation, "sampleUserId");
+    }
+
+
+    @Test
+    public void shouldProperlyHandleMaxRetriesException() {
+        when(asyncInstantiationBusinessLogic.generateServiceInstantiationRequest(uuid, serviceInstantiation, "sampleUserId")).thenThrow(new MaxRetriesException("", 2));
+
+        NextCommand call = serviceInstantiationCommand.call();
+
+        assertThat(call.getCommand(), is(nullValue()));
+        assertThat(call.getStatus(), is(equalTo(Job.JobStatus.FAILED)));
+
+        verify(asyncInstantiationBusinessLogic).handleFailedInstantiation(uuid);
+    }
+
+    @Test
+    public void shouldProperlyHandleInvalidAAIResponseException() {
+        doThrow(new InvalidAAIResponseException(aaiResponse)).when(asyncInstantiationBusinessLogic).generateServiceInstantiationRequest(uuid, serviceInstantiation, "sampleUserId");
+
+        NextCommand call = serviceInstantiationCommand.call();
+
+        assertThat(call.getCommand(), is(serviceInstantiationCommand));
+        assertThat(call.getStatus(), is(equalTo(Job.JobStatus.IN_PROGRESS)));
+    }
+
+
+    @Test
+    public void shouldProperlyHandleInvalidSOResponse() {
+        when(asyncInstantiationBusinessLogic.generateServiceInstantiationRequest(uuid, serviceInstantiation, "sampleUserId")).thenReturn(requestDetailsWrapper);
+        when(asyncInstantiationBusinessLogic.getServiceInstantiationPath(serviceInstantiation)).thenReturn("samplePath");
+        when(msoInterface.post("samplePath", requestDetailsWrapper, RequestReferencesContainer.class)).thenReturn(msoResponse);
+        when(msoResponse.getStatus()).thenReturn(500);
+        when(msoResponse.getBody()).thenReturn(requestReferencesContainer);
+
+        NextCommand call = serviceInstantiationCommand.call();
+
+        assertThat(call.getCommand(), is(nullValue()));
+        assertThat(call.getStatus(), is(equalTo(Job.JobStatus.FAILED)));
+
+        verify(auditService).setFailedAuditStatusFromMso(uuid, null, 500, requestReferencesContainer.toString());
+    }
+
+
+    @Test
+    public void shouldProperlyUpdateServiceStatusAndReturnInProgressCommand() {
+        RequestReferences requestReferences = createRequestReferences();
+
+        when(asyncInstantiationBusinessLogic.generateServiceInstantiationRequest(uuid, serviceInstantiation, "sampleUserId")).thenReturn(requestDetailsWrapper);
+        when(asyncInstantiationBusinessLogic.getServiceInstantiationPath(serviceInstantiation)).thenReturn("samplePath");
+        when(msoInterface.post("samplePath", requestDetailsWrapper, RequestReferencesContainer.class)).thenReturn(msoResponse);
+        when(msoResponse.getStatus()).thenReturn(200);
+        when(msoResponse.getBody()).thenReturn(requestReferencesContainer);
+        when(requestReferencesContainer.getRequestReferences()).thenReturn(requestReferences);
+
+
+        NextCommand call = serviceInstantiationCommand.call();
+
+        assertThat(call.getCommand(), instanceOf(InProgressStatusCommand.class));
+        assertThat(call.getStatus(), is(equalTo(Job.JobStatus.IN_PROGRESS)));
+
+    }
+
+    private RequestReferences createRequestReferences() {
+        RequestReferences requestReferences = new RequestReferences();
+        requestReferences.setInstanceId("sampleInstanceId");
+        requestReferences.setRequestId("sampleRequestId");
+        return requestReferences;
+    }
+}
\ No newline at end of file
diff --git a/vid-app-common/src/test/java/org/onap/vid/job/impl/JobAdapterImplTest.java b/vid-app-common/src/test/java/org/onap/vid/job/impl/JobAdapterImplTest.java
new file mode 100644 (file)
index 0000000..dc2eafc
--- /dev/null
@@ -0,0 +1,110 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2018 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.job.impl;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import org.mockito.Mock;
+import org.onap.vid.job.Job;
+import org.onap.vid.job.JobAdapter;
+import org.onap.vid.job.JobType;
+import org.onap.vid.model.JobBulk;
+import org.onap.vid.model.JobModel;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import java.util.List;
+import java.util.UUID;
+import java.util.stream.Stream;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.when;
+import static org.mockito.MockitoAnnotations.initMocks;
+
+public class JobAdapterImplTest {
+
+
+    private static final int SAMPLE_INDEX = 10;
+    private static final String SAMPLE_USER_ID = "sampleUserId";
+
+    @Mock
+    private Job job;
+
+    @Mock
+    private JobAdapter.AsyncJobRequest asyncJobRequest;
+
+    private UUID sampleUuid=UUID.randomUUID();
+
+    private JobAdapterImpl jobAdapter = new JobAdapterImpl();
+
+    @BeforeMethod
+    public void setUp() {
+        initMocks(this);
+
+        when(job.getUuid()).thenReturn(sampleUuid);
+        when(job.getStatus()).thenReturn(Job.JobStatus.IN_PROGRESS);
+        when(job.getTemplateId()).thenReturn(sampleUuid);
+    }
+
+    @Test
+    public void shouldConvertJobToJobModel() {
+
+
+        JobModel convertedJob = jobAdapter.toModel(job);
+
+        assertThat(convertedJob.getUuid()).isEqualByComparingTo(sampleUuid);
+        assertThat(convertedJob.getStatus()).isEqualByComparingTo(Job.JobStatus.IN_PROGRESS);
+        assertThat(convertedJob.getTemplateId()).isEqualByComparingTo(sampleUuid);
+    }
+
+
+    @Test
+    public void shouldProperlyCreateJob() {
+        UUID uuid = UUID.randomUUID();
+
+        Job createdJob = jobAdapter.createJob(JobType.ServiceInstantiation, asyncJobRequest, uuid, SAMPLE_USER_ID, SAMPLE_INDEX);
+
+        assertThat(createdJob.getStatus()).isEqualByComparingTo(Job.JobStatus.PENDING);
+        assertThat(createdJob.getTemplateId()).isEqualByComparingTo(uuid);
+        assertThat(createdJob.getType()).isEqualByComparingTo(JobType.ServiceInstantiation);
+        assertThat(createdJob.getData()).isEqualTo(ImmutableMap.of("request", asyncJobRequest, "userId", SAMPLE_USER_ID));
+    }
+
+    @Test
+    public void shouldProperlyCreateBulkOfJobs(){
+        List<Job> bulkOfJobs = jobAdapter.createBulkOfJobs(ImmutableMap.of("count", 5, "type", JobType.InProgressStatus.name()));
+
+
+        assertThat(bulkOfJobs).hasSize(5);
+
+        Stream<Job> jobStream = bulkOfJobs.stream().filter(x -> JobType.InProgressStatus.equals(x.getType()) && Job.JobStatus.PENDING.equals(x.getStatus()));
+
+        assertThat(jobStream).hasSize(5);
+    }
+
+
+    @Test
+    public void shouldConvertListToBulkJob(){
+        JobBulk jobBulk = jobAdapter.toModelBulk(ImmutableList.of(job, job));
+
+        assertThat(jobBulk.getJobs()).hasSize(2);
+    }
+}
diff --git a/vid-app-common/src/test/java/org/onap/vid/job/impl/JobSchedulerInitializerTest.java b/vid-app-common/src/test/java/org/onap/vid/job/impl/JobSchedulerInitializerTest.java
new file mode 100644 (file)
index 0000000..93afd17
--- /dev/null
@@ -0,0 +1,121 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2018 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.job.impl;
+
+
+import org.mockito.ArgumentCaptor;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.onap.vid.job.JobsBrokerService;
+import org.onap.vid.job.command.JobCommandFactory;
+import org.onap.vid.properties.Features;
+import org.quartz.JobDetail;
+import org.quartz.Scheduler;
+import org.quartz.SchedulerException;
+import org.quartz.Trigger;
+import org.springframework.scheduling.quartz.SchedulerFactoryBean;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+import org.togglz.core.manager.FeatureManager;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.collection.IsIterableContainingInAnyOrder.containsInAnyOrder;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyZeroInteractions;
+import static org.mockito.Mockito.when;
+import static org.mockito.MockitoAnnotations.initMocks;
+
+public class JobSchedulerInitializerTest {
+
+    @Mock
+    private JobsBrokerService brokerService;
+
+    @Mock
+    private SchedulerFactoryBean schedulerFactoryBean;
+
+    @Mock
+    private FeatureManager featureManager;
+
+    @Mock
+    private JobCommandFactory commandFactory;
+
+    @Mock
+    private Scheduler scheduler;
+
+    @InjectMocks
+    private JobSchedulerInitializer jobSchedulerInitializer;
+
+    @BeforeMethod
+    public void setUp() {
+        initMocks(this);
+    }
+
+
+    @Test
+    public void shouldNotInitializeSchedulerWhenAsyncJobsAreDisabled() {
+        when(featureManager.isActive(Features.FLAG_ASYNC_JOBS)).thenReturn(false);
+
+        jobSchedulerInitializer.init();
+
+        verifyZeroInteractions(schedulerFactoryBean);
+    }
+
+
+    @Test
+    public void shouldInitializeSchedulerWhenAsyncJobsAreEnabled() throws SchedulerException {
+        ArgumentCaptor<JobDetail> jobDetailArgumentCaptor = ArgumentCaptor.forClass(JobDetail.class);
+        ArgumentCaptor<Trigger> triggerArgumentCaptor = ArgumentCaptor.forClass(Trigger.class);
+        when(featureManager.isActive(Features.FLAG_ASYNC_JOBS)).thenReturn(true);
+        when(schedulerFactoryBean.getScheduler()).thenReturn(scheduler);
+
+        jobSchedulerInitializer.init();
+
+        verify(scheduler, times(2)).scheduleJob(jobDetailArgumentCaptor.capture(), triggerArgumentCaptor.capture());
+
+        List<Object> topics = extractTopics(jobDetailArgumentCaptor);
+
+        List<String> descriptions = extractDescription(triggerArgumentCaptor);
+
+        assertThat(topics, containsInAnyOrder(org.onap.vid.job.Job.JobStatus.IN_PROGRESS, org.onap.vid.job.Job.JobStatus.PENDING));
+        assertThat(descriptions, containsInAnyOrder("Trigger to run async worker for PENDING", "Trigger to run async worker for IN_PROGRESS"));
+    }
+
+    private List<Object> extractTopics(ArgumentCaptor<JobDetail> jobDetailArgumentCaptor) {
+        return jobDetailArgumentCaptor
+                .getAllValues()
+                .stream()
+                .map(JobDetail::getJobDataMap)
+                .map(x -> x.get("topic"))
+                .collect(Collectors.toList());
+    }
+
+    private List<String> extractDescription(ArgumentCaptor<Trigger> triggerArgumentCaptor) {
+        return triggerArgumentCaptor
+                .getAllValues()
+                .stream()
+                .map(Trigger::getDescription)
+                .collect(Collectors.toList());
+    }
+}
\ No newline at end of file
index 36f4bdd..54e924d 100644 (file)
@@ -1,12 +1,14 @@
 package org.onap.vid.mso;
 
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.mockito.*;
+import org.onap.portalsdk.core.util.SystemProperties;
+import org.onap.vid.changeManagement.RequestDetailsWrapper;
+import org.onap.vid.controllers.MsoController;
+import org.onap.vid.mso.rest.Request;
 import org.onap.vid.mso.rest.RequestDetails;
 import org.onap.vid.properties.Features;
-import org.onap.portalsdk.core.util.SystemProperties;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
 import org.springframework.test.context.web.WebAppConfiguration;
@@ -16,16 +18,32 @@ import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
 import org.togglz.core.manager.FeatureManager;
 
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.*;
 import static org.onap.vid.controllers.MsoController.SVC_INSTANCE_ID;
-import static org.onap.vid.controllers.MsoController.VNF_INSTANCE_ID;
 import static org.onap.vid.mso.MsoBusinessLogicImpl.validateEndpointPath;
 
 @ContextConfiguration(classes = {SystemProperties.class})
 @WebAppConfiguration
 public class MsoBusinessLogicImplTest extends AbstractTestNGSpringContextTests {
 
+    private static final String SERVICE_INSTANCE_ID = "1";
+    private static final String VNF_INSTANCE_ID = "1";
+    private static final String EXPECTED_SCALE_OUT_PATH = "/serviceInstantiation/v7/serviceInstances/1/vnfs/1/vfModules/scaleOut";
+    private static final Path PATH_TO_NOT_PROCESSED_SCALE_OUT_REQUEST = Paths.get("src", "test", "resources", "payload_jsons", "scaleOutVfModulePayload.json");
+    private static final Path PATH_TO_FINAL_SCALE_OUT_REQUEST = Paths.get("src", "test", "resources", "payload_jsons", "scaleOutVfModulePayloadToMso.json");
+    private static final Path PATH_TO_EXPECTED_MSO_MODEL_TYPE_REQ = Paths.get("src", "test", "resources", "payload_jsons", "mso_model_info_sample_response.json");
+    private static final Path PATH_TO_EXPECTED_MSO_SCALEOUT_REQ = Paths.get("src", "test", "resources", "payload_jsons", "mso_action_scaleout_sample_response.json");
+    private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
+
     @InjectMocks
     private MsoBusinessLogicImpl msoBusinessLogic;
 
@@ -37,31 +55,31 @@ public class MsoBusinessLogicImplTest extends AbstractTestNGSpringContextTests {
 
 
     @BeforeTest
-    public void initMocks(){
+    public void initMocks() {
         MockitoAnnotations.initMocks(this);
     }
 
     @Test
-    public void validateEndpointPath_endPointIsNotEmptyAndVaild_returnProperty(){
-        System.setProperty("TestEnv","123");
+    public void validateEndpointPath_endPointIsNotEmptyAndVaild_returnProperty() {
+        System.setProperty("TestEnv", "123");
         String foundEndPoint = validateEndpointPath("TestEnv");
-        Assert.assertEquals("123",foundEndPoint);
+        Assert.assertEquals("123", foundEndPoint);
     }
 
     @Test(expectedExceptions = RuntimeException.class)
-    public void validateEndpointPath_endPointIsNull_throwRuntimeException(){
+    public void validateEndpointPath_endPointIsNull_throwRuntimeException() {
         validateEndpointPath("NotExists");
     }
 
     @Test(expectedExceptions = RuntimeException.class)
-    public void validateEndpointPath_endPointIsNotEmptyButDoesntExists_throwRuntimeException(){
-        System.setProperty("EmptyEndPoint","");
+    public void validateEndpointPath_endPointIsNotEmptyButDoesntExists_throwRuntimeException() {
+        System.setProperty("EmptyEndPoint", "");
         validateEndpointPath("EmptyEndPoint");
     }
 
 
     //@Test(dataProvider = "unAssignOrDeleteParams")
-    public void deleteSvcInstance_verifyEndPointPathConstructing_unAssignFeatureOffOrUnAssignFlagIsFalse(boolean isAssignFlag,String status) {
+    public void deleteSvcInstance_verifyEndPointPathConstructing_unAssignFeatureOffOrUnAssignFlagIsFalse(boolean isAssignFlag, String status) {
         Mockito.reset(msoInterfaceMock);
         String endpoint = validateEndpointPath(isAssignFlag ? MsoProperties.MSO_DELETE_OR_UNASSIGN_REST_API_SVC_INSTANCE : MsoProperties.MSO_REST_API_SVC_INSTANCE);
         RequestDetails requestDetails = new RequestDetails();
@@ -114,7 +132,7 @@ public class MsoBusinessLogicImplTest extends AbstractTestNGSpringContextTests {
 
         String vnf_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, "serviceInstanceTempId");
 
-        msoBusinessLogic.deleteVnf(requestDetails, "serviceInstanceTempId","vnfInstanceTempId");
+        msoBusinessLogic.deleteVnf(requestDetails, "serviceInstanceTempId", "vnfInstanceTempId");
         verify(msoInterfaceMock).deleteVnf(requestDetails, vnf_endpoint + "/vnfInstanceTempId");
     }
 
@@ -123,31 +141,64 @@ public class MsoBusinessLogicImplTest extends AbstractTestNGSpringContextTests {
         String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VF_MODULE_INSTANCE);
         RequestDetails requestDetails = new RequestDetails();
 
-        String vf__modules_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, "serviceInstanceTempId").replaceFirst(VNF_INSTANCE_ID, "vnfInstanceTempId");
+        String vf__modules_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, "serviceInstanceTempId").replaceFirst(MsoController.VNF_INSTANCE_ID, "vnfInstanceTempId");
+
+        msoBusinessLogic.deleteVfModule(requestDetails, "serviceInstanceTempId", "vnfInstanceTempId", "vfModuleTempId");
+        verify(msoInterfaceMock).deleteVfModule(requestDetails, vf__modules_endpoint + "/vfModuleTempId");
+    }
+
+
+    @Test
+    public void shouldSendProperScaleOutRequest() throws IOException {
+        ArgumentCaptor<RequestDetailsWrapper> requestDetailsWrapperArgumentCaptor = ArgumentCaptor.forClass(RequestDetailsWrapper.class);
+        org.onap.vid.changeManagement.RequestDetails requestDetails = getScaleOutRequest();
+        RequestDetailsWrapper expectedRequestWrapper = getExpectedRequestWrapper();
+
+        msoBusinessLogic.scaleOutVfModuleInstance(requestDetails, SERVICE_INSTANCE_ID, VNF_INSTANCE_ID);
+
+        verify(msoInterfaceMock).scaleOutVFModuleInstance(requestDetailsWrapperArgumentCaptor.capture(), eq(EXPECTED_SCALE_OUT_PATH));
+        RequestDetailsWrapper actual = requestDetailsWrapperArgumentCaptor.getAllValues().get(0);
 
-        msoBusinessLogic.deleteVfModule(requestDetails, "serviceInstanceTempId","vnfInstanceTempId", "vfModuleTempId");
-        verify(msoInterfaceMock).deleteVfModule(requestDetails, vf__modules_endpoint + "/vfModuleTempId" );
+        assertThat(expectedRequestWrapper.requestDetails).isEqualTo(actual.requestDetails);
     }
 
     @Test
-    public void insertServiceInstantiationToDB_StartJob() {
-
-//        broker = new JobsBrokerServiceInDatabaseImpl(dataAccessServiceMock, sessionFactory);
-//        ((JobsBrokerServiceInDatabaseImpl)broker).deleteAll();
-//
-////        msoBusinessLogic.setDataAccessService(dataAccessServiceMock);
-////        msoBusinessLogic.setJobsBrokerService(broker);
-////        msoBusinessLogic.setJobAdapter(jobAdapter);
-//
-//        ServiceInstantiation serviceInstantiation = new ServiceInstantiation();
-//        serviceInstantiation.setCount(2);
-//        serviceInstantiation.setInstanceName("TestName");
-//
-//        msoBusinessLogic.pushBulkJob(serviceInstantiation, "testUserId");
-//
-//        List<ServiceInfo> serviceInfoList = dataAccessServiceMock.getList(ServiceInfo.class, null);
-//        int k = 9;
-//        Assert.assertEquals(serviceInstantiation, containsInAnyOrder(serviceInfoList.toArray()));
+    public void shouldFilterOutOrchestrationRequestsNotAllowedInDashboard() throws IOException {
+        String vnfModelTypeOrchestrationRequests = getFileContentAsString(PATH_TO_EXPECTED_MSO_MODEL_TYPE_REQ);
+        String scaleOutActionOrchestrationRequests = getFileContentAsString(PATH_TO_EXPECTED_MSO_SCALEOUT_REQ);
+
+        MsoResponseWrapper msoResponseWrapperMock = mock(MsoResponseWrapper.class);
+        when(msoInterfaceMock.getOrchestrationRequestsForDashboard(any(String.class), any(String.class), any(String.class), any(RestObject.class)))
+                .thenReturn(msoResponseWrapperMock);
+        when(msoResponseWrapperMock.getEntity()).thenReturn(vnfModelTypeOrchestrationRequests, scaleOutActionOrchestrationRequests);
+
+        List<Request> filteredOrchestrationReqs = msoBusinessLogic.getOrchestrationRequestsForDashboard();
+
+        assertThat(filteredOrchestrationReqs).hasSize(3);
+        assertThat(MsoBusinessLogicImpl.DASHBOARD_ALLOWED_TYPES)
+                .containsAll(filteredOrchestrationReqs
+                        .stream()
+                        .map(el -> el.getRequestType().toUpperCase())
+                        .collect(Collectors.toList()));
+        assertThat(filteredOrchestrationReqs
+                .stream()
+                .map(org.onap.vid.domain.mso.Request::getRequestScope)
+                .collect(Collectors.toList()))
+                .containsOnly("vnf", "vfModule");
+    }
+
+
+    private String getFileContentAsString(Path pathToFile) throws IOException {
+        return new String(Files.readAllBytes(pathToFile));
+    }
+
+    private org.onap.vid.changeManagement.RequestDetails getScaleOutRequest() throws IOException {
+        return OBJECT_MAPPER.readValue(PATH_TO_NOT_PROCESSED_SCALE_OUT_REQUEST.toFile(), org.onap.vid.changeManagement.RequestDetails.class);
+    }
+
+    private RequestDetailsWrapper getExpectedRequestWrapper() throws IOException {
+        return OBJECT_MAPPER.readValue(PATH_TO_FINAL_SCALE_OUT_REQUEST.toFile(), new TypeReference<RequestDetailsWrapper<org.onap.vid.changeManagement.RequestDetails>>() {
+        });
     }
 }
 
index 402386a..6996640 100644 (file)
 package org.onap.vid.mso.rest;
 
 import com.xebialabs.restito.server.StubServer;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.Properties;
-import java.util.UUID;
 import org.glassfish.grizzly.http.util.HttpStatus;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
+import org.onap.portalsdk.core.util.SystemProperties;
 import org.onap.vid.client.SyncRestClient;
 import org.onap.vid.controllers.MsoController;
 import org.onap.vid.mso.MsoInterface;
@@ -39,16 +33,30 @@ import org.onap.vid.mso.MsoProperties;
 import org.onap.vid.mso.MsoResponseWrapper;
 import org.onap.vid.mso.MsoResponseWrapperInterface;
 import org.onap.vid.mso.RestObject;
+import org.springframework.test.context.ContextConfiguration;
 
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Properties;
+import java.util.UUID;
+
+import static org.onap.vid.controllers.MsoController.SVC_INSTANCE_ID;
+import static org.onap.vid.controllers.MsoController.VNF_INSTANCE_ID;
+
+@ContextConfiguration(classes = {SystemProperties.class})
 public class MsoRestClientNewTest {
 
     private static StubServer server;
     private static StubServer securedServer;
     private static Properties props = new Properties();
     private static String msoCreateServiceInstanceJson;
+    private static String msoScaleOutVfModule;
     private final static String CREATE_INSTANCE_RESPONSE_STR =
-        "{\"requestReferences\":{\"instanceId\":\"baa13544-0e95-4644-9565-9a198a29a294\","
-            + "\"requestId\":\"a42a1a35-3d63-4629-bbe0-4989fa7414cb\"}}";
+            "{\"requestReferences\":{\"instanceId\":\"baa13544-0e95-4644-9565-9a198a29a294\","
+                    + "\"requestId\":\"a42a1a35-3d63-4629-bbe0-4989fa7414cb\"}}";
     private final static String SERVICE_INSTANCE_ID = "12345";
     private static final String SAMPLE_VNF_INSTANCE_ID = "111";
     private static final String SAMPLE_VNF_MODULE_ID = "987";
@@ -63,15 +71,19 @@ public class MsoRestClientNewTest {
         securedServer = new StubServer().secured().run();
 
         Path resourceDirectory =
-            Paths.get("src", "test", "resources", "WEB-INF", "conf", "system.properties");
-        try(InputStream is = Files.newInputStream(resourceDirectory)) {
+                Paths.get("src", "test", "resources", "WEB-INF", "conf", "system.properties");
+        try (InputStream is = Files.newInputStream(resourceDirectory)) {
             props.load(is);
         }
 
         Path msoServiceInstantiationJsonFilePath =
-            Paths.get("src", "test", "resources", "payload_jsons", "mso_service_instantiation.json");
+                Paths.get("src", "test", "resources", "payload_jsons", "mso_service_instantiation.json");
+
+        Path scaleOutJsonFilePath = Paths.get("src", "test", "resources", "payload_jsons", "scaleOutVfModulePayloadToMso.json");
         msoCreateServiceInstanceJson =
-            String.join("\n", Files.readAllLines(msoServiceInstantiationJsonFilePath));
+                String.join("\n", Files.readAllLines(msoServiceInstantiationJsonFilePath));
+        msoScaleOutVfModule = String.join("\n", Files.readAllLines(scaleOutJsonFilePath));
+
     }
 
     @AfterClass
@@ -89,11 +101,11 @@ public class MsoRestClientNewTest {
     public void testCreateSvcInstance() throws Exception {
         String endpoint = props.getProperty(MsoProperties.MSO_REST_API_CONFIGURATIONS);
         endpoint = endpoint.replace(MsoController.SVC_INSTANCE_ID, SERVICE_INSTANCE_ID);
-        try(MsoRestClientTestUtil closure = new MsoRestClientTestUtil(
-            server,
-            endpoint,
-            HttpStatus.ACCEPTED_202,
-            CREATE_INSTANCE_RESPONSE_STR,CREATE_INSTANCE_RESPONSE_STR)) {
+        try (MsoRestClientTestUtil closure = new MsoRestClientTestUtil(
+                server,
+                endpoint,
+                HttpStatus.ACCEPTED_202,
+                CREATE_INSTANCE_RESPONSE_STR, CREATE_INSTANCE_RESPONSE_STR)) {
             closure.executePost(msoCreateServiceInstanceJson, msoRestClient()::createSvcInstance);
         }
     }
@@ -102,12 +114,12 @@ public class MsoRestClientNewTest {
     public void testCreateVnf() throws Exception {
         String endpoint = props.getProperty(MsoProperties.MSO_REST_API_VNF_INSTANCE);
         endpoint = endpoint.replace(MsoController.SVC_INSTANCE_ID, SERVICE_INSTANCE_ID);
-        try(MsoRestClientTestUtil closure = new MsoRestClientTestUtil(
-            server,
-            endpoint,
-            HttpStatus.ACCEPTED_202,
-            CREATE_INSTANCE_RESPONSE_STR,CREATE_INSTANCE_RESPONSE_STR)) {
-            
+        try (MsoRestClientTestUtil closure = new MsoRestClientTestUtil(
+                server,
+                endpoint,
+                HttpStatus.ACCEPTED_202,
+                CREATE_INSTANCE_RESPONSE_STR, CREATE_INSTANCE_RESPONSE_STR)) {
+
             closure.executePost(msoCreateServiceInstanceJson, msoRestClient()::createVnf);
         }
     }
@@ -116,11 +128,11 @@ public class MsoRestClientNewTest {
     public void testCreateNwInstance() throws Exception {
         String endpoint = props.getProperty(MsoProperties.MSO_REST_API_NETWORK_INSTANCE);
         String nw_endpoint = endpoint.replaceFirst(MsoController.SVC_INSTANCE_ID, SERVICE_INSTANCE_ID);
-        try(MsoRestClientTestUtil closure = new MsoRestClientTestUtil(
-            server,
-            nw_endpoint,
-            HttpStatus.ACCEPTED_202,
-            CREATE_INSTANCE_RESPONSE_STR,CREATE_INSTANCE_RESPONSE_STR)) {
+        try (MsoRestClientTestUtil closure = new MsoRestClientTestUtil(
+                server,
+                nw_endpoint,
+                HttpStatus.ACCEPTED_202,
+                CREATE_INSTANCE_RESPONSE_STR, CREATE_INSTANCE_RESPONSE_STR)) {
             closure.executePost(msoCreateServiceInstanceJson, msoRestClient()::createNwInstance);
         }
     }
@@ -130,11 +142,11 @@ public class MsoRestClientNewTest {
         String endpoint = props.getProperty(MsoProperties.MSO_REST_API_VOLUME_GROUP_INSTANCE);
         String vnf_endpoint = endpoint.replaceFirst(MsoController.SVC_INSTANCE_ID, SERVICE_INSTANCE_ID);
         vnf_endpoint = vnf_endpoint.replaceFirst(MsoController.VNF_INSTANCE_ID, SAMPLE_VNF_INSTANCE_ID);
-        try(MsoRestClientTestUtil closure = new MsoRestClientTestUtil(
-            server,
-            vnf_endpoint,
-            HttpStatus.ACCEPTED_202,
-            CREATE_INSTANCE_RESPONSE_STR,CREATE_INSTANCE_RESPONSE_STR)) {
+        try (MsoRestClientTestUtil closure = new MsoRestClientTestUtil(
+                server,
+                vnf_endpoint,
+                HttpStatus.ACCEPTED_202,
+                CREATE_INSTANCE_RESPONSE_STR, CREATE_INSTANCE_RESPONSE_STR)) {
             closure.executePost(msoCreateServiceInstanceJson, msoRestClient()::createVolumeGroupInstance);
         }
     }
@@ -144,14 +156,14 @@ public class MsoRestClientNewTest {
         String endpoint = props.getProperty(MsoProperties.MSO_REST_API_VF_MODULE_INSTANCE);
         String partial_endpoint = endpoint.replaceFirst(MsoController.SVC_INSTANCE_ID, SERVICE_INSTANCE_ID);
         String vf_module_endpoint =
-            partial_endpoint.replaceFirst(MsoController.VNF_INSTANCE_ID, SAMPLE_VNF_INSTANCE_ID);
+                partial_endpoint.replaceFirst(MsoController.VNF_INSTANCE_ID, SAMPLE_VNF_INSTANCE_ID);
 
 
-        try(MsoRestClientTestUtil closure = new MsoRestClientTestUtil(
-            server,
-            vf_module_endpoint,
-            HttpStatus.ACCEPTED_202,
-            CREATE_INSTANCE_RESPONSE_STR,CREATE_INSTANCE_RESPONSE_STR)) {
+        try (MsoRestClientTestUtil closure = new MsoRestClientTestUtil(
+                server,
+                vf_module_endpoint,
+                HttpStatus.ACCEPTED_202,
+                CREATE_INSTANCE_RESPONSE_STR, CREATE_INSTANCE_RESPONSE_STR)) {
             closure.executePost(msoCreateServiceInstanceJson, msoRestClient()::createVfModuleInstance);
         }
     }
@@ -177,11 +189,11 @@ public class MsoRestClientNewTest {
         endpoint = endpoint.replaceFirst(MsoController.SVC_INSTANCE_ID, SERVICE_INSTANCE_ID);
 
 
-        try(MsoRestClientTestUtil closure = new MsoRestClientTestUtil(
-            server,
-            endpoint,
-            HttpStatus.NO_CONTENT_204,
-            CREATE_INSTANCE_RESPONSE_STR,CREATE_INSTANCE_RESPONSE_STR)) {
+        try (MsoRestClientTestUtil closure = new MsoRestClientTestUtil(
+                server,
+                endpoint,
+                HttpStatus.NO_CONTENT_204,
+                CREATE_INSTANCE_RESPONSE_STR, CREATE_INSTANCE_RESPONSE_STR)) {
             closure.executeDelete(msoCreateServiceInstanceJson, msoRestClient()::deleteSvcInstance);
         }
     }
@@ -191,11 +203,11 @@ public class MsoRestClientNewTest {
         String endpoint = props.getProperty(MsoProperties.MSO_REST_API_VNF_INSTANCE);
         endpoint = endpoint.replaceFirst(MsoController.SVC_INSTANCE_ID, SERVICE_INSTANCE_ID);
 
-        try(MsoRestClientTestUtil closure = new MsoRestClientTestUtil(
-            server,
-            endpoint,
-            HttpStatus.NO_CONTENT_204,
-            CREATE_INSTANCE_RESPONSE_STR,CREATE_INSTANCE_RESPONSE_STR)) {
+        try (MsoRestClientTestUtil closure = new MsoRestClientTestUtil(
+                server,
+                endpoint,
+                HttpStatus.NO_CONTENT_204,
+                CREATE_INSTANCE_RESPONSE_STR, CREATE_INSTANCE_RESPONSE_STR)) {
             closure.executeDelete(msoCreateServiceInstanceJson, msoRestClient()::deleteVnf);
         }
     }
@@ -207,11 +219,11 @@ public class MsoRestClientNewTest {
         String vf_modules_endpoint = part_endpoint.replaceFirst(MsoController.VNF_INSTANCE_ID, SAMPLE_VNF_INSTANCE_ID);
         String delete_vf_endpoint = vf_modules_endpoint + '/' + SAMPLE_VNF_MODULE_ID;
 
-        try(MsoRestClientTestUtil closure = new MsoRestClientTestUtil(
-            server,
-            delete_vf_endpoint,
-            HttpStatus.NO_CONTENT_204,
-            CREATE_INSTANCE_RESPONSE_STR,CREATE_INSTANCE_RESPONSE_STR)) {
+        try (MsoRestClientTestUtil closure = new MsoRestClientTestUtil(
+                server,
+                delete_vf_endpoint,
+                HttpStatus.NO_CONTENT_204,
+                CREATE_INSTANCE_RESPONSE_STR, CREATE_INSTANCE_RESPONSE_STR)) {
             closure.executeDelete(msoCreateServiceInstanceJson, msoRestClient()::deleteVfModule);
         }
     }
@@ -223,11 +235,11 @@ public class MsoRestClientNewTest {
         String vnf_endpoint = svc_endpoint.replaceFirst(MsoController.VNF_INSTANCE_ID, SAMPLE_VNF_INSTANCE_ID);
         String delete_volume_group_endpoint = vnf_endpoint + "/" + SAMPLE_VNF_MODULE_ID;
 
-        try(MsoRestClientTestUtil closure = new MsoRestClientTestUtil(
-            server,
-            delete_volume_group_endpoint,
-            HttpStatus.NO_CONTENT_204,
-            CREATE_INSTANCE_RESPONSE_STR,CREATE_INSTANCE_RESPONSE_STR)) {
+        try (MsoRestClientTestUtil closure = new MsoRestClientTestUtil(
+                server,
+                delete_volume_group_endpoint,
+                HttpStatus.NO_CONTENT_204,
+                CREATE_INSTANCE_RESPONSE_STR, CREATE_INSTANCE_RESPONSE_STR)) {
             closure.executeDelete(msoCreateServiceInstanceJson, msoRestClient()::deleteVolumeGroupInstance);
         }
     }
@@ -410,11 +422,11 @@ public class MsoRestClientNewTest {
         String serviceEndpoint = props.getProperty(MsoProperties.MSO_REST_API_SVC_INSTANCE);
         String removeRelationshipsPath = serviceEndpoint + "/" + SERVICE_INSTANCE_ID + "/removeRelationships";
 
-        try(MsoRestClientTestUtil closure = new MsoRestClientTestUtil(
-            server,
-            removeRelationshipsPath,
-            HttpStatus.ACCEPTED_202,
-            CREATE_INSTANCE_RESPONSE_STR,CREATE_INSTANCE_RESPONSE_STR)) {
+        try (MsoRestClientTestUtil closure = new MsoRestClientTestUtil(
+                server,
+                removeRelationshipsPath,
+                HttpStatus.ACCEPTED_202,
+                CREATE_INSTANCE_RESPONSE_STR, CREATE_INSTANCE_RESPONSE_STR)) {
             closure.executePost(msoCreateServiceInstanceJson, msoRestClient()::removeRelationshipFromServiceInstance);
         }
     }
@@ -433,6 +445,20 @@ public class MsoRestClientNewTest {
         } catch (Exception e) {
         }
     }
+    @Test
+    public void testScaleOutVfModule() throws IOException {
+        String serviceEndpoint = props.getProperty(MsoProperties.MSO_REST_API_VF_MODULE_SCALE_OUT);
+        String partial_endpoint = serviceEndpoint.replaceFirst(SVC_INSTANCE_ID, SERVICE_INSTANCE_ID);
+        String vf_module_endpoint = partial_endpoint.replaceFirst(VNF_INSTANCE_ID, SAMPLE_VNF_INSTANCE_ID);
+        try (MsoRestClientTestUtil closure = new MsoRestClientTestUtil(
+                server,
+                vf_module_endpoint,
+                HttpStatus.ACCEPTED_202,
+                CREATE_INSTANCE_RESPONSE_STR, CREATE_INSTANCE_RESPONSE_STR)) {
+            closure.executePostCall(msoScaleOutVfModule, msoRestClient()::scaleOutVFModuleInstance);
+        }
+
+    }
 
     private MsoRestClientNew msoRestClient() {
         return new MsoRestClientNew(new SyncRestClient(MsoInterface.objectMapper()), baseUrl());
index e8f5569..c81fa16 100644 (file)
@@ -20,11 +20,13 @@ import java.util.function.BiFunction;
 import java.util.function.Function;
 import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.MediaType;
+
 import org.glassfish.grizzly.http.Method;
 import org.glassfish.grizzly.http.util.HttpStatus;
 import org.json.JSONObject;
 import org.junit.Assert;
 import org.onap.portalsdk.core.util.SystemProperties;
+import org.onap.vid.changeManagement.RequestDetailsWrapper;
 import org.onap.vid.mso.MsoResponseWrapper;
 
 class MsoRestClientTestUtil implements AutoCloseable {
@@ -60,6 +62,21 @@ class MsoRestClientTestUtil implements AutoCloseable {
     verifyServer(server, endpoint, Method.POST);
 
   }
+  void executePostCall(String jsonPayload, BiFunction<RequestDetailsWrapper, String, MsoResponseWrapper> func) throws IOException {
+    whenHttp(server)
+            .match(post(endpoint))
+            .then(status(expectedStatus), jsonContent(responsePayload), contentType(MediaType.APPLICATION_JSON));
+
+    RequestDetailsWrapper  sampleRequestDetails =
+            new ObjectMapper().readValue(jsonPayload, RequestDetailsWrapper.class);
+
+    MsoResponseWrapper response = func.apply(sampleRequestDetails, endpoint);
+    JSONObject actualJson = new JSONObject(response.getEntity());
+
+    Assert.assertEquals(expectedStatus.getStatusCode(), response.getStatus());
+    Assert.assertEquals(expectedResponseStr, actualJson.toString());
+    verifyServer(server, endpoint, Method.POST);
+  }
 
   void executeDelete(String jsonPayload, BiFunction<RequestDetails, String, MsoResponseWrapper> func)
       throws IOException {
diff --git a/vid-app-common/src/test/java/org/onap/vid/services/AuditServiceImplTest.java b/vid-app-common/src/test/java/org/onap/vid/services/AuditServiceImplTest.java
new file mode 100644 (file)
index 0000000..3d2a20b
--- /dev/null
@@ -0,0 +1,63 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2018 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.vid.services;
+
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.MockitoAnnotations.initMocks;
+
+import java.util.UUID;
+import org.glassfish.grizzly.http.util.HttpStatus;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+public class AuditServiceImplTest {
+  @Mock
+  private AsyncInstantiationBusinessLogic asyncInstantiationBL;
+
+  @InjectMocks
+  private AuditServiceImpl auditService;
+
+  @BeforeClass
+  public void init() {
+    initMocks(this);
+  }
+
+  @Test
+  public void setFailedAuditStatusFromMsoTest() {
+
+    UUID jobUuid = UUID.randomUUID();
+    String requestId = "1";
+    int statusCode = HttpStatus.OK_200.getStatusCode();
+    String msoResponse = "{}";
+
+    auditService.setFailedAuditStatusFromMso(jobUuid, requestId, statusCode, msoResponse);
+
+    verify(asyncInstantiationBL, times(1))
+        .auditMsoStatus(
+            Mockito.any(UUID.class),
+            Mockito.anyString(),
+            Mockito.anyString(),
+            Mockito.anyString());
+  }
+}
diff --git a/vid-app-common/src/test/java/org/onap/vid/services/BulkInstantiationServiceImplTest.java b/vid-app-common/src/test/java/org/onap/vid/services/BulkInstantiationServiceImplTest.java
new file mode 100644 (file)
index 0000000..6677da3
--- /dev/null
@@ -0,0 +1,135 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2018 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.vid.services;
+
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.reset;
+import static org.mockito.Mockito.when;
+import static org.mockito.MockitoAnnotations.initMocks;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import javax.ws.rs.NotFoundException;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.onap.vid.job.Job;
+import org.onap.vid.job.JobAdapter;
+import org.onap.vid.job.JobsBrokerService;
+import org.onap.vid.job.impl.JobDaoImpl;
+import org.onap.vid.model.JobBulk;
+import org.onap.vid.model.JobModel;
+import org.testng.Assert;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.BeforeSuite;
+import org.testng.annotations.Test;
+
+public class BulkInstantiationServiceImplTest {
+
+  @Mock
+  private JobsBrokerService jobsBrokerService;
+
+  @Mock
+  private JobAdapter jobAdapter;
+
+  @InjectMocks
+  private BulkInstantiationServiceImpl testSubject;
+
+  @BeforeSuite
+  public void before() {
+    initMocks(this);
+  }
+
+  @BeforeMethod
+  public void resetMocks() {
+    reset(jobsBrokerService);
+    reset(jobAdapter);
+  }
+
+  @Test
+  public void saveBulkTest() {
+    UUID uuid = UUID.randomUUID();
+    Map<String, Object> bulkRequest = new HashMap<>();
+    List<Job> jobList = new ArrayList<>();
+    jobList.add(createJob(uuid));
+    when(jobAdapter.createBulkOfJobs(bulkRequest)).thenReturn(jobList);
+
+    JobBulk jobBulk = createJobBulk(jobList);
+    when(jobAdapter.toModelBulk(jobList)).thenReturn(jobBulk);
+
+    JobBulk result = testSubject.saveBulk(bulkRequest);
+
+    Assert.assertEquals(result.getJobs().size(), jobList.size());
+    Assert.assertEquals(result.getJobs().get(0).getUuid(), uuid);
+  }
+
+  @Test
+  public void getJobTest() {
+    UUID uuid = UUID.randomUUID();
+    Job job = createJob(uuid);
+    doReturn(job).when(jobsBrokerService).peek(uuid);
+    JobModel jobModel = createJobModel(uuid);
+    when(jobAdapter.toModel(job)).thenReturn(jobModel);
+
+    JobModel response = testSubject.getJob(uuid);
+    Assert.assertEquals(response.getUuid(), uuid);
+  }
+
+  @Test(expectedExceptions = {NotFoundException.class})
+  public void getJobTest_throwsExceptionOnEmptyUUID() {
+    UUID uuid = null;
+    Job job = createJob(uuid);
+    doReturn(job).when(jobsBrokerService).peek(uuid);
+    JobModel response = testSubject.getJob(uuid);
+    Assert.fail();
+  }
+
+  @Test(expectedExceptions = {NotFoundException.class})
+  public void getJobTest_throwsExceptionCauseJobDoesNotExists() {
+    UUID uuid = UUID.randomUUID();
+    doReturn(null).when(jobsBrokerService).peek(uuid);
+    JobModel response = testSubject.getJob(uuid);
+    Assert.fail();
+  }
+
+  private Job createJob(UUID uuid) {
+    Job job = new JobDaoImpl();
+    job.setUuid(uuid);
+    return job;
+  }
+
+  private JobModel createJobModel(UUID uuid) {
+    JobModel jobModel = new JobModel();
+    jobModel.setUuid(uuid);
+    return jobModel;
+  }
+
+  private JobBulk createJobBulk(List<Job> jobList) {
+    List<JobModel> jobBulkList = new ArrayList<>();
+    jobList.stream().forEach(job -> {
+      JobModel jm = new JobModel();
+      jm.setUuid(job.getUuid());
+      jobBulkList.add(jm);
+    });
+    return new JobBulk(jobBulkList);
+  }
+}
index 440a2a7..04ee464 100644 (file)
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2018 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
 package org.onap.vid.services;
 
-import org.junit.Test;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.reset;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.MockitoAnnotations.initMocks;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import javax.ws.rs.ForbiddenException;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.onap.portalsdk.core.service.DataAccessService;
 import org.onap.vid.category.AddCategoryOptionResponse;
 import org.onap.vid.category.AddCategoryOptionsRequest;
 import org.onap.vid.category.CategoryParameterOptionRep;
 import org.onap.vid.category.CategoryParametersResponse;
+import org.onap.vid.model.CategoryParameter;
+import org.onap.vid.model.CategoryParameter.Family;
 import org.onap.vid.model.CategoryParameterOption;
+import org.onap.vid.services.CategoryParameterServiceImpl.AlreadyExistOptionNameException;
+import org.onap.vid.services.CategoryParameterServiceImpl.UnfoundedCategoryException;
+import org.onap.vid.services.CategoryParameterServiceImpl.UnfoundedCategoryOptionException;
+import org.testng.Assert;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.BeforeSuite;
+import org.testng.annotations.Test;
 
 public class CategoryParameterServiceImplTest {
 
-    private CategoryParameterServiceImpl createTestSubject() {
-        return new CategoryParameterServiceImpl();
+    private static final String CATEGORY_NAME = "SAMPLE_CATEGORY_NAME";
+    private static final String OPTION_NAME = "SAMPLE_OPTION_NAME";
+    private static final String UNIQUE_OPTION_NAME = "UNIQUE_OPTION_NAME";
+    private static final String APP_ID_VID = "VID";
+    private static final String APP_ID_SDC = "SDC";
+    private static final String QUERY_STRING_FOR_CATEGORY_NAME = String.format(" where name = '%s' ", CATEGORY_NAME);
+
+
+    @Mock
+    private DataAccessService dataAccessService;
+
+    @InjectMocks
+    private CategoryParameterServiceImpl testSubject;
+
+    @BeforeSuite
+    public void before() {
+        initMocks(this);
+    }
+
+    @BeforeMethod
+    public void resetMocks() {
+        reset(dataAccessService);
     }
 
     @Test
-    public void testCreateCategoryParameterOptions() throws Exception {
-        CategoryParameterServiceImpl testSubject;
-        String categoryName = "";
-        AddCategoryOptionsRequest optionsRequest = null;
-        AddCategoryOptionResponse result;
-
-        // default test
-        try {
-            testSubject = createTestSubject();
-            result = testSubject.createCategoryParameterOptions(categoryName, optionsRequest);
-        } catch (
-
-        Exception e) {
-        }
+    public void createCategoryParameterOptions_happyPath()  {
+        AddCategoryOptionsRequest optionsRequest = new AddCategoryOptionsRequest();
+        optionsRequest.options.add(UNIQUE_OPTION_NAME);
+        CategoryParameter categoryParameter = createCategoryParameter(CATEGORY_NAME, true);
+        List<CategoryParameter> aList = createCategoryParametersList(categoryParameter);
+
+        doReturn(aList).when(dataAccessService).getList(CategoryParameter.class, QUERY_STRING_FOR_CATEGORY_NAME, null, null);
+
+        AddCategoryOptionResponse result = testSubject.createCategoryParameterOptions(CATEGORY_NAME, optionsRequest);
+
+        Assert.assertTrue(result.getErrors().isEmpty());;
+        verify(dataAccessService, times(1))
+            .saveDomainObject(anyObject(), anyObject());
     }
 
     @Test
-    public void testDeleteCategoryOption() throws Exception {
-        CategoryParameterServiceImpl testSubject;
-        String categoryName = "";
+    public void createCategoryParameterOptions_existingOptionsForCategory()  {
+        AddCategoryOptionsRequest optionsRequest = new AddCategoryOptionsRequest();
+        optionsRequest.options.add(OPTION_NAME);
+        CategoryParameter categoryParameter = createCategoryParameter(CATEGORY_NAME, true);
+        categoryParameter.getOptions().add(new CategoryParameterOption(APP_ID_VID, OPTION_NAME, categoryParameter));
+        List<CategoryParameter> aList = createCategoryParametersList(categoryParameter);
+
+        String expectedError = String.format(CategoryParameterServiceImpl.OPTION_ALREADY_EXIST_FOR_CATEGORY
+            , OPTION_NAME, CATEGORY_NAME);
+
+        doReturn(aList).when(dataAccessService).getList(CategoryParameter.class, QUERY_STRING_FOR_CATEGORY_NAME, null, null);
+
+        AddCategoryOptionResponse result = testSubject.createCategoryParameterOptions(CATEGORY_NAME, optionsRequest);
+
+        Assert.assertFalse(result.getErrors().isEmpty());
+        Assert.assertEquals(result.getErrors().size(), 1);
+        Assert.assertTrue(result.getErrors().stream().allMatch(expectedError::equals));
+    }
+
+    private List<CategoryParameter> createCategoryParametersList(CategoryParameter categoryParameter) {
+        List<CategoryParameter> aList = new ArrayList<>();
+        aList.add(categoryParameter);
+        return aList;
+    }
+
+    @Test
+    public void createCategoryParameterOptions_nonExistingOptionsForCategory()  {
+        AddCategoryOptionsRequest optionsRequest = new AddCategoryOptionsRequest();
+
+        List<CategoryParameter> aList = createCategoryParametersList(new CategoryParameter());
+        doReturn(aList).when(dataAccessService).getList(CategoryParameter.class, QUERY_STRING_FOR_CATEGORY_NAME, null, null);
+
+        AddCategoryOptionResponse result = testSubject.createCategoryParameterOptions(CATEGORY_NAME, optionsRequest);
+
+        Assert.assertTrue(result.getErrors().isEmpty());
+    }
+
+    @Test(expectedExceptions = { UnfoundedCategoryException.class })
+    public void createCategoryParameterOptions_wrongNumberOfCategoryParameters()  {
+        AddCategoryOptionsRequest optionsRequest = new AddCategoryOptionsRequest();
+        List<CategoryParameter> aList = Collections.emptyList();
+
+        doReturn(aList).when(dataAccessService).getList(CategoryParameter.class, QUERY_STRING_FOR_CATEGORY_NAME, null, null);
+
+        AddCategoryOptionResponse result = testSubject.createCategoryParameterOptions(CATEGORY_NAME, optionsRequest);
+
+        Assert.fail();
+    }
+
+    @Test(expectedExceptions = { UnfoundedCategoryException.class })
+    public void deleteCategoryOption_wrongNumberOfParameters() {
         CategoryParameterOption option = null;
+        List<CategoryParameter> aList = Collections.emptyList();
+
+        doReturn(aList).when(dataAccessService).getList(CategoryParameter.class, QUERY_STRING_FOR_CATEGORY_NAME, null, null);
+
+        testSubject.deleteCategoryOption(CATEGORY_NAME, option);
 
-        // default test
-        try {
-            testSubject = createTestSubject();
-            testSubject.deleteCategoryOption(categoryName, option);
-        } catch (
+        Assert.fail();
+    }
+
+    @Test
+    public void deleteCategoryOption_happyPath() {
+        CategoryParameter categoryParameter = createCategoryParameter(CATEGORY_NAME, true);
+        CategoryParameterOption categoryParameterOption =
+            new CategoryParameterOption(APP_ID_VID, OPTION_NAME, categoryParameter);
+        categoryParameter.getOptions().add(categoryParameterOption);
+        List<CategoryParameter> aList = createCategoryParametersList(categoryParameter);
+
+        doReturn(aList).when(dataAccessService).getList(anyObject(), anyString(), anyString(), anyObject());
 
-        Exception e) {
-        }
+        testSubject.deleteCategoryOption(CATEGORY_NAME, categoryParameterOption);
+
+        verify(dataAccessService, times(1))
+            .deleteDomainObject(anyObject(), anyObject());
     }
 
     @Test
-    public void testGetCategoryParameters() throws Exception {
-        CategoryParameterServiceImpl testSubject;
-        CategoryParametersResponse result;
-
-        // default test
-        try {
-            testSubject = createTestSubject();
-            testSubject.getCategoryParameters(null);
-        } catch (
-
-        Exception e) {
-        }
+    public void getCategoryParametersTest() {
+        CategoryParameter categoryParameter = createCategoryParameter(CATEGORY_NAME, true);
+        CategoryParameterOption categoryParameterOption =
+            new CategoryParameterOption(APP_ID_VID, OPTION_NAME, categoryParameter);
+        categoryParameter.getOptions().add(categoryParameterOption);
+        List<CategoryParameter> aList = createCategoryParametersList(categoryParameter);
+
+        doReturn(aList).when(dataAccessService).getList(anyObject(), anyString(), anyString(), anyObject());
+
+        CategoryParametersResponse response = testSubject.getCategoryParameters(Family.PARAMETER_STANDARDIZATION);
+
+        Assert.assertFalse(response.getCategoryParameters().isEmpty());
+        Assert.assertTrue(response.getCategoryParameters().containsKey(CATEGORY_NAME));
+
+        verify(dataAccessService, times(1))
+            .getList(anyObject(), anyString(), anyString(), anyObject());
     }
 
     @Test
-    public void testUpdateCategoryParameterOption() throws Exception {
-        CategoryParameterServiceImpl testSubject;
-        String categoryName = "";
-        CategoryParameterOptionRep option = null;
-        AddCategoryOptionResponse result;
-
-        // default test
-        try {
-            testSubject = createTestSubject();
-            result = testSubject.updateCategoryParameterOption(categoryName, option);
-        } catch (
-
-        Exception e) {
-        }
+    public void updateCategoryParameterOption_domainObjectGetsSavedSuccessfully() {
+        CategoryParameterOptionRep optionRepExisting = new CategoryParameterOptionRep(APP_ID_VID, OPTION_NAME);
+        CategoryParameter categoryParameter = createCategoryParameter(CATEGORY_NAME, true);
+        categoryParameter.getOptions().add(
+            new CategoryParameterOption(APP_ID_VID, UNIQUE_OPTION_NAME, categoryParameter));
+        List<CategoryParameter> aList = createCategoryParametersList(categoryParameter);
+
+        doReturn(aList).when(dataAccessService).getList(CategoryParameter.class, QUERY_STRING_FOR_CATEGORY_NAME, null, null);
+
+        AddCategoryOptionResponse result = testSubject.updateCategoryParameterOption(CATEGORY_NAME, optionRepExisting);
+
+        verify(dataAccessService, times(1))
+            .saveDomainObject(anyObject(), anyObject());
+    }
+
+    @Test(expectedExceptions = { ForbiddenException.class })
+    public void updateCategoryParameterOption_shouldFailUpdateForbidden() {
+        CategoryParameterOptionRep optionRep = new CategoryParameterOptionRep("1", CATEGORY_NAME);
+        CategoryParameter categoryParameter = createCategoryParameter(CATEGORY_NAME, false);
+        categoryParameter.getOptions().add(new CategoryParameterOption(APP_ID_VID, OPTION_NAME, categoryParameter));
+        List<CategoryParameter> aList = createCategoryParametersList(categoryParameter);
+
+        doReturn(aList).when(dataAccessService).getList(CategoryParameter.class, QUERY_STRING_FOR_CATEGORY_NAME, null, null);
+
+        AddCategoryOptionResponse result = testSubject.updateCategoryParameterOption(CATEGORY_NAME, optionRep);
+
+        Assert.fail();
+    }
+
+    @Test(expectedExceptions = { UnfoundedCategoryOptionException.class })
+    public void updateCategoryParameterOption_CategoryNotFound() {
+        CategoryParameterOptionRep optionRep = new CategoryParameterOptionRep("SOME_UNRELATED_ID", CATEGORY_NAME);
+
+        CategoryParameter categoryParameter = createCategoryParameter(CATEGORY_NAME, true);
+        categoryParameter.getOptions().add(new CategoryParameterOption(APP_ID_VID, OPTION_NAME, categoryParameter));
+        List<CategoryParameter> aList = createCategoryParametersList(categoryParameter);
+
+        doReturn(aList).when(dataAccessService).getList(CategoryParameter.class, QUERY_STRING_FOR_CATEGORY_NAME, null, null);
+
+        AddCategoryOptionResponse result = testSubject.updateCategoryParameterOption(CATEGORY_NAME, optionRep);
+
+        Assert.fail();
+    }
+
+    @Test(expectedExceptions = { AlreadyExistOptionNameException.class })
+    public void updateCategoryParameterOption_OptionNameExists() {
+        CategoryParameterOptionRep optionRepExisting = new CategoryParameterOptionRep(APP_ID_VID, OPTION_NAME);
+
+        CategoryParameter categoryParameter = createCategoryParameter(CATEGORY_NAME, true);
+        categoryParameter.getOptions().add(
+            new CategoryParameterOption(APP_ID_VID, UNIQUE_OPTION_NAME, categoryParameter));
+        categoryParameter.getOptions().add(
+            new CategoryParameterOption(APP_ID_SDC, OPTION_NAME, categoryParameter));
+        List<CategoryParameter> aList = createCategoryParametersList(categoryParameter);
+
+        doReturn(aList).when(dataAccessService).getList(CategoryParameter.class, QUERY_STRING_FOR_CATEGORY_NAME, null, null);
+
+        AddCategoryOptionResponse result = testSubject.updateCategoryParameterOption(CATEGORY_NAME, optionRepExisting);
+
+        Assert.fail();
+    }
+
+    private CategoryParameter createCategoryParameter(String categoryName, boolean idSupported) {
+        CategoryParameter categoryParameter = new CategoryParameter();
+        categoryParameter.setName(categoryName);
+        categoryParameter.setIdSupported(idSupported);
+        return categoryParameter;
     }
 }
\ No newline at end of file
diff --git a/vid-app-common/src/test/java/org/onap/vid/services/PombaServiceImplTest.java b/vid-app-common/src/test/java/org/onap/vid/services/PombaServiceImplTest.java
new file mode 100644 (file)
index 0000000..d0eec26
--- /dev/null
@@ -0,0 +1,40 @@
+package org.onap.vid.services;
+
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.MockitoAnnotations.initMocks;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.onap.vid.aai.PombaClientInterface;
+import org.onap.vid.model.PombaInstance.PombaRequest;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+public class PombaServiceImplTest {
+
+  @Mock
+  private PombaClientInterface pombaClientInterface;
+
+  @InjectMocks
+  private PombaServiceImpl testSubject;
+
+  @BeforeClass
+  public void beforeClass() {
+    initMocks(this);
+  }
+
+  @BeforeMethod
+  public void resetMocks() {
+    Mockito.reset(pombaClientInterface);
+  }
+
+  @Test
+  public void testVerify() {
+    PombaRequest pombaRequest = new PombaRequest();
+    testSubject.verify(pombaRequest);
+    verify(pombaClientInterface, times(1))
+        .verify(pombaRequest);
+  }
+}
\ No newline at end of file
index 544a799..d7db495 100644 (file)
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2018 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
 package org.onap.vid.services;
 
-import static org.junit.Assert.*;
-import java.util.*;
-import org.junit.Assert;
-import org.junit.Test;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.MockitoAnnotations.initMocks;
+
+import java.util.ArrayList;
+import org.apache.commons.lang.StringUtils;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.onap.vid.aai.AaiClientInterface;
+import org.onap.vid.aai.AaiResponse;
+import org.onap.vid.aai.ServiceSubscription;
+import org.onap.vid.aai.ServiceSubscriptions;
+import org.onap.vid.aai.Services;
+import org.onap.vid.model.Subscriber;
+import org.onap.vid.model.SubscriberList;
+import org.testng.Assert;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
 
 public class RoleGenaratorServiceImplTest {
 
-    private RoleGenaratorServiceImpl createTestSubject() {
-        return new RoleGenaratorServiceImpl();
+    private static final String GLOBAL_CUSTOMER_ID = "997";
+    private static final String SUBSCRIBER_NAME = "name";
+    private static final String SUBSCRIBER_TYPE = "subscriber_type";
+    private static final String RESOURCE_VERSION = "1";
+    private static final String SERVICE_TYPE = "service_type";
+
+    @Mock
+    private AaiClientInterface aaiClientInterface;
+
+    @InjectMocks
+    private RoleGenaratorServiceImpl testSubject;
+
+    @BeforeClass
+    public void beforeClass() {
+        initMocks(this);
+    }
+
+    @BeforeMethod
+    public void resetMocks() {
+        Mockito.reset(aaiClientInterface);
+    }
+
+    @Test
+    public void tenerateRoleScript_firstRun() {
+        boolean firstRun = true;
+
+        Subscriber subscriber = createSubscriber();
+        AaiResponse<SubscriberList> subscribers = createSubscriberListAaiResponse(subscriber);
+        doReturn(subscribers).when(aaiClientInterface).getAllSubscribers();
+
+        ServiceSubscription serviceSubscription = createServiceSubscription();
+        AaiResponse<Services> subscriberResponse = createServicesAaiResponse(serviceSubscription);
+        doReturn(subscriberResponse).when(aaiClientInterface).getSubscriberData(subscriber.globalCustomerId);
+
+        String result = testSubject.generateRoleScript(firstRun);
+        Assert.assertTrue(StringUtils.isNotBlank(result));
     }
 
     @Test
-    public void testGenerateRoleScript() throws Exception {
-        RoleGenaratorServiceImpl testSubject;
-        Boolean firstRun = null;
-        String result;
-
-        // default test
-        testSubject = createTestSubject();
-        result = testSubject.generateRoleScript(firstRun);
+    public void tenerateRoleScript_notAFirstRun() {
+        boolean firstRun = false;
+
+        Subscriber subscriber = createSubscriber();
+        AaiResponse<SubscriberList> subscribers = createSubscriberListAaiResponse(subscriber);
+        doReturn(subscribers).when(aaiClientInterface).getAllSubscribers();
+
+        ServiceSubscription serviceSubscription = createServiceSubscription();
+        AaiResponse<Services> subscriberResponse = createServicesAaiResponse(serviceSubscription);
+        doReturn(subscriberResponse).when(aaiClientInterface).getSubscriberData(subscriber.globalCustomerId);
+
+        String result = testSubject.generateRoleScript(firstRun);
+        Assert.assertTrue(StringUtils.isNotBlank(result));
+    }
+
+    @Test(expectedExceptions = { Exception.class })
+    public void tenerateRoleScript_errorGettingDataFromAAIClient() {
+        boolean firstRun = false;
+
+        doThrow(new Exception("This is expected.")).when(aaiClientInterface).getAllSubscribers();
+
+        String result = testSubject.generateRoleScript(firstRun);
+        Assert.fail();
+    }
+
+    private ServiceSubscription createServiceSubscription() {
+        ServiceSubscription serviceSubscription = new ServiceSubscription();
+        serviceSubscription.serviceType = SERVICE_TYPE;
+        return serviceSubscription;
+    }
+
+    private AaiResponse<SubscriberList> createSubscriberListAaiResponse(Subscriber subscriber) {
+        AaiResponse<SubscriberList> subscribers = new AaiResponse<>(new SubscriberList(new ArrayList<>()), "", 200);
+        subscribers.getT().customer.add(subscriber);
+        return subscribers;
+    }
+
+    private AaiResponse<Services> createServicesAaiResponse(ServiceSubscription serviceSubscription) {
+        AaiResponse<Services> subscriberResponse = new AaiResponse<>(new Services(), "", 200);
+        subscriberResponse.getT().serviceSubscriptions = new ServiceSubscriptions();
+        subscriberResponse.getT().serviceSubscriptions.serviceSubscription = new ArrayList<>();
+        subscriberResponse.getT().serviceSubscriptions.serviceSubscription.add(serviceSubscription);
+        return subscriberResponse;
+    }
+
+    private Subscriber createSubscriber() {
+        Subscriber subscriber = new Subscriber();
+        subscriber.globalCustomerId = GLOBAL_CUSTOMER_ID;
+        subscriber.subscriberName = SUBSCRIBER_NAME;
+        subscriber.subscriberType = SUBSCRIBER_TYPE;
+        subscriber.resourceVersion = RESOURCE_VERSION;
+        return subscriber;
     }
 
 
index bf0f826..6a8a1a3 100644 (file)
@@ -73,18 +73,12 @@ element_map_icon_path = app/fusionapp/icons/
 
 #aai related properties
 #dev server
-#aai.server.url.base=https://mtanjv9aaas40.aic.cip.att.com:8443/aai/
-#aai.server.url=https://mtanjv9aaas40.aic.cip.att.com:8443/aai/v10/
-#aai.oldserver.url.base=https://mtanjv9aaas40.aic.cip.att.com:8443/aai/servers/
-#aai.oldserver.url=https://mtanjv9aaas40.aic.cip.att.com:8443/aai/servers/v3/
 #ist servers
-aai.server.url.base=https://aai-ext1.test.att.com:8443/aai/
-#aai.server.url=https://aai-ext1.test.att.com:8443/aai/v12/
+aai.server.url.base=http://localhost:8080/vidSimulator/aai/
 aai.server.url=http://localhost:8080/vidSimulator/aai/v12/
 #aai.server.url=http://localhost:1080/aai
-#aai.server.url=https://aai-int2.test.att.com:8443/aai/v12/
-aai.vid.username=VID
-aai.vid.passwd.x=OBF:1jm91i0v1jl9
+aai.vid.username=vid@vid.onap.org
+aai.vid.passwd.x=OBF:1fia1ju61l871lfe18xp18xr18xt1lc41l531jrk1fek
 
 
 
@@ -93,12 +87,10 @@ aai.vid.passwd.x=OBF:1jm91i0v1jl9
 
 
 
-aai.oldserver.url.base=https://aai-ext1.test.att.com:8443/aai/servers/
-aai.oldserver.url=https://aai-ext1.test.att.com:8443/aai/servers/v3/
 aai.truststore.filename=tomcat_keystore
-aai.truststore.passwd.x=OBF:1i9a1u2a1unz1lr61wn51wn11lss1unz1u301i6o
+aai.truststore.passwd.x=OBF:1ks51l8d1o3i1pcc1r2r1e211r391kls1pyj1z7u1njf1lx51go21hnj1y0k1mli1sop1k8o1j651vu91mxw1vun1mze1vv11j8x1k5i1sp11mjc1y161hlr1gm41m111nkj1z781pw31kku1r4p1e391r571pbm1o741l4x1ksp
 aai.keystore.filename=aai-client-cert.p12
-aai.keystore.passwd.x=OBF:1i9a1u2a1unz1lr61wn51wn11lss1unz1u301i6o
+aai.keystore.passwd.x=OBF:1ks51l8d1o3i1pcc1r2r1e211r391kls1pyj1z7u1njf1lx51go21hnj1y0k1mli1sop1k8o1j651vu91mxw1vun1mze1vv11j8x1k5i1sp11mjc1y161hlr1gm41m111nkj1z781pw31kku1r4p1e391r571pbm1o741l4x1ksp
 aai.use.client.cert=false
 aai.vnf.provstatus=PREPROV,NVTPROV,PROV,CAPPED
 
@@ -154,7 +146,8 @@ mso.restapi.svc.instance=/serviceInstances/v5
 mso.restapi.vnf.instance=/serviceInstances/v5/<service_instance_id>/vnfs
 mso.restapi.vnf.changemanagement.instance=/serviceInstances/v5/<service_instance_id>/vnfs/<vnf_instance_id>/<request_type>
 mso.restapi.network.instance=/serviceInstances/v5/<service_instance_id>/networks
-mso.restapi.vf.module.instance=/serviceInstantiation/v7/<service_instance_id>/vnfs/<vnf_instance_id>/vfModules/scaleOut
+mso.restapi.vf.module.instance=/serviceInstances/v6/<service_instance_id>/vnfs/<vnf_instance_id>/vfModules
+mso.restapi.vf.module.scaleout=/serviceInstantiation/v7/serviceInstances/<service_instance_id>/vnfs/<vnf_instance_id>/vfModules/scaleOut
 mso.restapi.volume.group.instance=/serviceInstances/v5/<service_instance_id>/vnfs/<vnf_instance_id>/volumeGroups
 mso.restapi.get.orc.req=/orchestrationRequests/v5
 mso.restapi.get.orc.reqs=/orchestrationRequests/v5?
@@ -166,7 +159,7 @@ vid.truststore.filename=/opt/app/vid/etc/vid_keystore.jks
 mso.dme2.client.timeout=30000
 mso.dme2.client.read.timeout=120000
 
-scheduler.server.url=http://mtanjv9sdlg10.aic.cip.att.com:8989/scheduler
+scheduler.server.url=
 scheduler.create.new.vnf.change.instance=/v1/ChangeManagement/schedules/
 scheduler.get.time.slots=/v1/ChangeManagement/schedules/
 scheduler.get.schedules=/v1/ChangeManagement/schedules/scheduleDetails/
index 7547410..400a55f 100644 (file)
@@ -5,7 +5,6 @@
       "source": "VID",
       "requestorId": "<userId>"
     },
-    "configurationParameters" : [ ],
     "relatedInstanceList": [
       {
         "relatedInstance": {
index c50a66c..b9ff151 100644 (file)
@@ -5,7 +5,6 @@
       "source": "VID",
       "requestorId": "<userId>"
     },
-    "configurationParameters" : [ ],
     "requestParameters": {
       "operationalEnvironmentType": "VNF"
     }
diff --git a/vid-app-common/src/test/resources/payload_jsons/mso_action_scaleout_sample_response.json b/vid-app-common/src/test/resources/payload_jsons/mso_action_scaleout_sample_response.json
new file mode 100644 (file)
index 0000000..d37f6af
--- /dev/null
@@ -0,0 +1,174 @@
+{
+  "requestList": [
+    {
+      "request": {
+        "requestId": "799d7380-60fe-4b64-9d99-82f6ab09163b",
+        "startTime": "Fri, 12 Oct 2018 08:53:07 GMT",
+        "requestScope": "vfModule",
+        "requestType": "scaleOut",
+        "requestDetails": {
+          "modelInfo": {
+            "modelCustomizationName": "WsSp..base_ws..module-0",
+            "modelInvariantId": "763b1172-b5f5-4062-9d79-2459710fa0bc",
+            "modelType": "vfModule",
+            "modelName": "WsSp..base_ws..module-0",
+            "modelVersion": "1",
+            "modelCustomizationUuid": "bfcc8f57-7b56-4be8-a8f1-e44262c83318",
+            "modelVersionId": "53f52586-236b-4d52-a94c-990883e054f0",
+            "modelCustomizationId": "bfcc8f57-7b56-4be8-a8f1-e44262c83318",
+            "modelUuid": "53f52586-236b-4d52-a94c-990883e054f0",
+            "modelInvariantUuid": "763b1172-b5f5-4062-9d79-2459710fa0bc",
+            "modelInstanceName": "WsSp..base_ws..module-0"
+          },
+          "requestInfo": {
+            "source": "VID",
+            "instanceName": "ws-test-0310-8_NaN",
+            "suppressRollback": false,
+            "requestorId": "demo"
+          },
+          "relatedInstanceList": [
+            {
+              "relatedInstance": {
+                "instanceId": "fd84f066-ea75-4b23-acd0-3cf3fce7a99b",
+                "modelInfo": {
+                  "modelInvariantId": "c9817f08-07b2-458b-a02f-cd5407ee7a7b",
+                  "modelType": "service",
+                  "modelName": "ws-service",
+                  "modelVersion": "1.0",
+                  "modelVersionId": "0e0bb964-e687-4439-9a9e-de9cd1ff5367",
+                  "modelUuid": "0e0bb964-e687-4439-9a9e-de9cd1ff5367",
+                  "modelInvariantUuid": "c9817f08-07b2-458b-a02f-cd5407ee7a7b"
+                }
+              }
+            },
+            {
+              "relatedInstance": {
+                "instanceId": "980fe98e-47f8-4164-862d-4ebb026cec75",
+                "modelInfo": {
+                  "modelCustomizationName": "ws-sp 0",
+                  "modelInvariantId": "734f0952-6678-44e7-8918-f9aa4694b687",
+                  "modelType": "vnf",
+                  "modelName": "ws-sp",
+                  "modelVersion": "1.0",
+                  "modelCustomizationUuid": "5815868c-35f8-4c5a-b899-e6eb49f52986",
+                  "modelVersionId": "0e0bb964-e687-4439-9a9e-de9cd1ff5367",
+                  "modelCustomizationId": "5815868c-35f8-4c5a-b899-e6eb49f52986",
+                  "modelUuid": "0e0bb964-e687-4439-9a9e-de9cd1ff5367",
+                  "modelInvariantUuid": "734f0952-6678-44e7-8918-f9aa4694b687",
+                  "modelInstanceName": "ws-sp 0"
+                }
+              }
+            }
+          ],
+          "cloudConfiguration": {
+            "tenantId": "1e097c6713e74fd7ac8e4295e605ee1e",
+            "lcpCloudRegionId": "RegionOne"
+          },
+          "requestParameters": {},
+          "configurationParameters": [
+            {
+              "availability-zone": "$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]",
+              "xtz-123": "$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]"
+            }
+          ]
+        },
+        "instanceReferences": {
+          "serviceInstanceId": "fd84f066-ea75-4b23-acd0-3cf3fce7a99b",
+          "vnfInstanceId": "980fe98e-47f8-4164-862d-4ebb026cec75",
+          "vfModuleInstanceName": "ws-test-0310-8_NaN",
+          "requestorId": "demo"
+        },
+        "requestStatus": {
+          "requestState": "FAILED",
+          "statusMessage": "No valid vfModuleCustomization is specified",
+          "percentProgress": 100,
+          "finishTime": "Fri, 12 Oct 2018 08:53:07 GMT"
+        }
+      }
+    },
+    {
+      "request": {
+        "requestId": "44b534c7-57b5-42ec-85bb-219167021b34",
+        "startTime": "Fri, 12 Oct 2018 09:08:01 GMT",
+        "requestScope": "vfModule",
+        "requestType": "scaleOut",
+        "requestDetails": {
+          "modelInfo": {
+            "modelCustomizationName": "WsSp..base_ws..module-0",
+            "modelInvariantId": "763b1172-b5f5-4062-9d79-2459710fa0bc",
+            "modelType": "vfModule",
+            "modelName": "WsSp..base_ws..module-0",
+            "modelVersion": "1",
+            "modelCustomizationUuid": "bfcc8f57-7b56-4be8-a8f1-e44262c83318",
+            "modelVersionId": "53f52586-236b-4d52-a94c-990883e054f0",
+            "modelCustomizationId": "bfcc8f57-7b56-4be8-a8f1-e44262c83318",
+            "modelUuid": "53f52586-236b-4d52-a94c-990883e054f0",
+            "modelInvariantUuid": "763b1172-b5f5-4062-9d79-2459710fa0bc",
+            "modelInstanceName": "WsSp..base_ws..module-0"
+          },
+          "requestInfo": {
+            "source": "VID",
+            "instanceName": "ws-test-0310-8_NaN",
+            "suppressRollback": false,
+            "requestorId": "demo"
+          },
+          "relatedInstanceList": [
+            {
+              "relatedInstance": {
+                "instanceId": "fd84f066-ea75-4b23-acd0-3cf3fce7a99b",
+                "modelInfo": {
+                  "modelInvariantId": "c9817f08-07b2-458b-a02f-cd5407ee7a7b",
+                  "modelType": "service",
+                  "modelName": "ws-service",
+                  "modelVersion": "1.0",
+                  "modelVersionId": "0e0bb964-e687-4439-9a9e-de9cd1ff5367",
+                  "modelUuid": "0e0bb964-e687-4439-9a9e-de9cd1ff5367",
+                  "modelInvariantUuid": "c9817f08-07b2-458b-a02f-cd5407ee7a7b"
+                }
+              }
+            },
+            {
+              "relatedInstance": {
+                "instanceId": "980fe98e-47f8-4164-862d-4ebb026cec75",
+                "modelInfo": {
+                  "modelCustomizationName": "ws-sp 0",
+                  "modelInvariantId": "734f0952-6678-44e7-8918-f9aa4694b687",
+                  "modelType": "vnf",
+                  "modelName": "ws-sp",
+                  "modelVersion": "1.0",
+                  "modelCustomizationUuid": "5815868c-35f8-4c5a-b899-e6eb49f52986",
+                  "modelVersionId": "0e0bb964-e687-4439-9a9e-de9cd1ff5367",
+                  "modelCustomizationId": "5815868c-35f8-4c5a-b899-e6eb49f52986",
+                  "modelUuid": "0e0bb964-e687-4439-9a9e-de9cd1ff5367",
+                  "modelInvariantUuid": "734f0952-6678-44e7-8918-f9aa4694b687",
+                  "modelInstanceName": "ws-sp 0"
+                }
+              }
+            }
+          ],
+          "cloudConfiguration": {
+            "tenantId": "1e097c6713e74fd7ac8e4295e605ee1e",
+            "lcpCloudRegionId": "RegionOne"
+          },
+          "requestParameters": {},
+          "configurationParameters": [
+            {
+              "availability-zone": "$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]",
+              "xtz-123": "$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]"
+            }
+          ]
+        },
+        "instanceReferences": {
+          "serviceInstanceId": "fd84f066-ea75-4b23-acd0-3cf3fce7a99b",
+          "vnfInstanceId": "980fe98e-47f8-4164-862d-4ebb026cec75",
+          "vfModuleInstanceId": "scaleOut",
+          "vfModuleInstanceName": "ws-test-0310-8_NaN",
+          "requestorId": "demo"
+        },
+        "requestStatus": {
+          "requestState": "FAILED"
+        }
+      }
+    }
+  ]
+}
\ No newline at end of file
diff --git a/vid-app-common/src/test/resources/payload_jsons/mso_model_info_sample_response.json b/vid-app-common/src/test/resources/payload_jsons/mso_model_info_sample_response.json
new file mode 100644 (file)
index 0000000..9dbdfb0
--- /dev/null
@@ -0,0 +1,108 @@
+{
+  "requestList": [
+    {
+      "request": {
+        "requestId": "f8c813a2-b22b-4e3d-9be0-8e2d16b1add3",
+        "startTime": "Wed, 03 Oct 2018 13:13:04 GMT",
+        "requestScope": "vnf",
+        "requestType": "createInstance",
+        "requestDetails": {
+          "modelInfo": {
+            "modelCustomizationName": "ws-sp 0",
+            "modelInvariantId": "734f0952-6678-44e7-8918-f9aa4694b687",
+            "modelType": "vnf",
+            "modelName": "ws-sp",
+            "modelVersion": "1.0",
+            "modelCustomizationUuid": "5815868c-35f8-4c5a-b899-e6eb49f52986",
+            "modelVersionId": "0e0bb964-e687-4439-9a9e-de9cd1ff5367",
+            "modelCustomizationId": "5815868c-35f8-4c5a-b899-e6eb49f52986",
+            "modelUuid": "0e0bb964-e687-4439-9a9e-de9cd1ff5367",
+            "modelInvariantUuid": "734f0952-6678-44e7-8918-f9aa4694b687",
+            "modelInstanceName": "ws-sp 0"
+          },
+          "requestInfo": {
+            "productFamilyId": "61cc3239-5c2e-4762-a281-7422a2e54d5a",
+            "source": "VID",
+            "instanceName": "ws-test-0310-8",
+            "suppressRollback": false,
+            "requestorId": "demo"
+          },
+          "relatedInstanceList": [
+            {
+              "relatedInstance": {
+                "instanceId": "fd84f066-ea75-4b23-acd0-3cf3fce7a99b",
+                "modelInfo": {
+                  "modelInvariantId": "c9817f08-07b2-458b-a02f-cd5407ee7a7b",
+                  "modelType": "service",
+                  "modelName": "ws-service",
+                  "modelVersion": "1.0",
+                  "modelVersionId": "cd3fbd06-6bc8-43a4-b803-933fc2e3cdf7",
+                  "modelUuid": "cd3fbd06-6bc8-43a4-b803-933fc2e3cdf7",
+                  "modelInvariantUuid": "c9817f08-07b2-458b-a02f-cd5407ee7a7b"
+                }
+              }
+            }
+          ],
+          "cloudConfiguration": {
+            "tenantId": "1e097c6713e74fd7ac8e4295e605ee1e",
+            "lcpCloudRegionId": "RegionOne"
+          },
+          "requestParameters": {
+            "testApi": "VNF_API"
+          },
+          "platform": {
+            "platformName": "Demo"
+          },
+          "lineOfBusiness": {
+            "lineOfBusinessName": "Demo"
+          }
+        },
+        "instanceReferences": {
+          "serviceInstanceId": "fd84f066-ea75-4b23-acd0-3cf3fce7a99b",
+          "vnfInstanceId": "980fe98e-47f8-4164-862d-4ebb026cec75",
+          "vnfInstanceName": "ws-test-0310-8",
+          "requestorId": "demo"
+        },
+        "requestStatus": {
+          "requestState": "COMPLETE",
+          "statusMessage": "Vnf has been created successfully.",
+          "percentProgress": 100,
+          "finishTime": "Wed, 03 Oct 2018 13:13:09 GMT"
+        }
+      }
+    },
+    {
+      "request": {
+        "requestId": "3447ba35-015d-4d72-9345-d89b1e35b2d6",
+        "startTime": "Thu, 04 Oct 2018 10:35:17 GMT",
+        "requestScope": "vnf",
+        "requestType": "inPlaceSoftwareUpdate",
+        "requestDetails": {
+          "requestInfo": {
+            "source": "VID",
+            "suppressRollback": false,
+            "requestorId": "demo"
+          },
+          "cloudConfiguration": {
+            "tenantId": "1e097c6713e74fd7ac8e4295e605ee1e",
+            "lcpCloudRegionId": "RegionOne"
+          },
+          "requestParameters": {
+            "payload": "{\"existing_software_version\":\"0.7\",\"new_software_version\":\"1.0\",\"operations_timeout\":\"10\"}"
+          }
+        },
+        "instanceReferences": {
+          "serviceInstanceId": "fd84f066-ea75-4b23-acd0-3cf3fce7a99b",
+          "vnfInstanceId": "980fe98e-47f8-4164-862d-4ebb026cec75",
+          "requestorId": "demo"
+        },
+        "requestStatus": {
+          "requestState": "FAILED",
+          "statusMessage": "Cloud Region with cloudRegionId RegionOne does not exist in A&AI",
+          "percentProgress": 100,
+          "finishTime": "Thu, 04 Oct 2018 10:35:21 GMT"
+        }
+      }
+    }
+  ]
+}
\ No newline at end of file
diff --git a/vid-app-common/src/test/resources/payload_jsons/scaleOutVfModulePayload.json b/vid-app-common/src/test/resources/payload_jsons/scaleOutVfModulePayload.json
new file mode 100644 (file)
index 0000000..c509c62
--- /dev/null
@@ -0,0 +1,67 @@
+{
+    "vnfName":"test",
+    "vnfInstanceId":"123",
+    "relatedInstanceList": [
+      {
+        "relatedInstance": {
+          "instanceId": "fd84f066-ea75-4b23-acd0-3cf3fce7a99b",
+          "modelInfo": {
+            "modelType": "service",
+            "modelInvariantId": "c9817f08-07b2-458b-a02f-cd5407ee7a7b",
+            "modelVersionId": "0e0bb964-e687-4439-9a9e-de9cd1ff5367",
+            "modelName": "ws-service",
+            "modelVersion": "1.0",
+            "additionalProperties": {}
+          }
+        }
+      },
+      {
+        "relatedInstance": {
+          "instanceId": "980fe98e-47f8-4164-862d-4ebb026cec75",
+          "modelInfo": {
+            "modelType": "vnf",
+            "modelInvariantId": "734f0952-6678-44e7-8918-f9aa4694b687",
+            "modelVersionId": "0e0bb964-e687-4439-9a9e-de9cd1ff5367",
+            "modelName": "ws-sp",
+            "modelVersion": "1.0",
+            "modelCustomizationName": "ws-sp 0",
+            "modelCustomizationId": "5815868c-35f8-4c5a-b899-e6eb49f52986",
+            "additionalProperties": {}
+          }
+        }
+      }
+    ],
+    "cloudConfiguration": {
+      "lcpCloudRegionId": "RegionOne",
+      "tenantId": "1e097c6713e74fd7ac8e4295e605ee1e",
+      "additionalProperties": {}
+    },
+    "modelInfo": {
+      "modelCustomizationName": "WsSp..base_ws..module-0",
+      "modelCustomizationId": "bfcc8f57-7b56-4be8-a8f1-e44262c83318",
+      "modelInvariantId": "763b1172-b5f5-4062-9d79-2459710fa0bc",
+      "modelVersionId": "53f52586-236b-4d52-a94c-990883e054f0",
+      "modelName": "WsSp..base_ws..module-0",
+      "modelNameVersionId": null,
+      "modelType": "vfModule",
+      "modelVersion": "1",
+      "additionalProperties": {}
+    },
+    "requestInfo": {
+      "instanceName": "ws-test-0310-8_NaN",
+      "source": "VID",
+      "suppressRollback": false,
+      "requestorId": "demo",
+      "additionalProperties": {}
+    },
+    "requestParameters": {
+      "additionalProperties": {}
+    },
+    "configurationParameters": [
+      {
+        "availability-zone": "$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]",
+        "xtz-123": "$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]"
+      }
+    ]
+  }
+}
\ No newline at end of file
diff --git a/vid-app-common/src/test/resources/payload_jsons/scaleOutVfModulePayloadToMso.json b/vid-app-common/src/test/resources/payload_jsons/scaleOutVfModulePayloadToMso.json
new file mode 100644 (file)
index 0000000..ddbebac
--- /dev/null
@@ -0,0 +1,66 @@
+{
+  "requestDetails": {
+    "relatedInstanceList": [
+      {
+        "relatedInstance": {
+          "instanceId": "fd84f066-ea75-4b23-acd0-3cf3fce7a99b",
+          "modelInfo": {
+            "modelType": "service",
+            "modelInvariantId": "c9817f08-07b2-458b-a02f-cd5407ee7a7b",
+            "modelVersionId": "0e0bb964-e687-4439-9a9e-de9cd1ff5367",
+            "modelName": "ws-service",
+            "modelVersion": "1.0",
+            "additionalProperties": {}
+          }
+        }
+      },
+      {
+        "relatedInstance": {
+          "instanceId": "980fe98e-47f8-4164-862d-4ebb026cec75",
+          "modelInfo": {
+            "modelType": "vnf",
+            "modelInvariantId": "734f0952-6678-44e7-8918-f9aa4694b687",
+            "modelVersionId": "0e0bb964-e687-4439-9a9e-de9cd1ff5367",
+            "modelName": "ws-sp",
+            "modelVersion": "1.0",
+            "modelCustomizationName": "ws-sp 0",
+            "modelCustomizationId": "5815868c-35f8-4c5a-b899-e6eb49f52986",
+            "additionalProperties": {}
+          }
+        }
+      }
+    ],
+    "cloudConfiguration": {
+      "lcpCloudRegionId": "RegionOne",
+      "tenantId": "1e097c6713e74fd7ac8e4295e605ee1e",
+      "additionalProperties": {}
+    },
+    "modelInfo": {
+      "modelCustomizationName": "WsSp..base_ws..module-0",
+      "modelCustomizationId": "bfcc8f57-7b56-4be8-a8f1-e44262c83318",
+      "modelInvariantId": "763b1172-b5f5-4062-9d79-2459710fa0bc",
+      "modelVersionId": "53f52586-236b-4d52-a94c-990883e054f0",
+      "modelName": "WsSp..base_ws..module-0",
+      "modelNameVersionId": null,
+      "modelType": "vfModule",
+      "modelVersion": "1",
+      "additionalProperties": {}
+    },
+    "requestInfo": {
+      "instanceName": "ws-test-0310-8_NaN",
+      "source": "VID",
+      "suppressRollback": false,
+      "requestorId": "demo",
+      "additionalProperties": {}
+    },
+    "requestParameters": {
+      "additionalProperties": {}
+    },
+    "configurationParameters": [
+      {
+        "availability-zone": "$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]",
+        "xtz-123": "$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]"
+      }
+    ]
+  }
+}
\ No newline at end of file
index 02144f0..9723960 100755 (executable)
@@ -2,7 +2,7 @@
 # Note that these variables cannot be structured (e.g. : version.release or version.snapshot etc... )\r
 # because they are used in Jenkins, whose plug-in doesn't support\r
 \r
-major=3\r
+major=4\r
 minor=0\r
 patch=0\r
 \r