Sending workflow data from UI to SO 86/83186/7
authorBartosz Gardziejewski <bartosz.gardziejewski@nokia.com>
Mon, 25 Mar 2019 09:07:38 +0000 (10:07 +0100)
committerBartosz Gardziejewski <bartosz.gardziejewski@nokia.com>
Mon, 1 Apr 2019 13:58:25 +0000 (15:58 +0200)
Change-Id: I39c78584c61eb317d4eaf2861ece810c1b60ab01
Issue-ID: VID-401
Signed-off-by: Bartosz Gardziejewski <bartosz.gardziejewski@nokia.com>
34 files changed:
epsdk-app-onap/src/main/webapp/WEB-INF/conf/system.properties
epsdk-app-onap/src/main/webapp/WEB-INF/conf/system_template.properties
vid-app-common/src/main/java/org/onap/vid/changeManagement/RequestParameters.java [new file with mode: 0644]
vid-app-common/src/main/java/org/onap/vid/changeManagement/UIWorkflowsRequest.java [new file with mode: 0644]
vid-app-common/src/main/java/org/onap/vid/changeManagement/WorkflowRequestDetail.java [new file with mode: 0644]
vid-app-common/src/main/java/org/onap/vid/controller/MsoController.java
vid-app-common/src/main/java/org/onap/vid/controller/WebConfig.java
vid-app-common/src/main/java/org/onap/vid/controller/WorkflowsController.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/services/AaiServiceImpl.java
vid-app-common/src/main/java/org/onap/vid/services/ChangeManagementService.java
vid-app-common/src/main/java/org/onap/vid/services/ChangeManagementServiceImpl.java
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/change-management.service.js
vid-app-common/src/test/java/org/onap/vid/changeManagement/RequestParametersTest.java [new file with mode: 0644]
vid-app-common/src/test/java/org/onap/vid/changeManagement/UIWorkflowsRequestTest.java [new file with mode: 0644]
vid-app-common/src/test/java/org/onap/vid/changeManagement/WorkflowRequestDetailTest.java [new file with mode: 0644]
vid-app-common/src/test/java/org/onap/vid/controller/WorkflowsControllerTest.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/MsoRestClientTest.java
vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTestUtil.java
vid-app-common/src/test/java/org/onap/vid/services/ChangeManagementServiceImplTest.java
vid-app-common/src/test/java/org/onap/vid/services/ChangeManagementServiceUnitTest.java
vid-app-common/src/test/resources/WEB-INF/conf/system.properties
vid-ext-services-simulator/src/main/resources/preset_registration/changeManagement/get_aai_services_by_customer.json
vid-ext-services-simulator/src/main/resources/preset_registration/changeManagement/get_aai_vlb_service_instances.json
vid-ext-services-simulator/src/main/resources/preset_registration/changeManagement/mso_invoke_workflow01.json [new file with mode: 0644]
vid-ext-services-simulator/src/main/resources/preset_registration/changeManagement/mso_invoke_workflow02.json [new file with mode: 0644]
vid-ext-services-simulator/src/main/resources/preset_registration/changeManagement/mso_invoke_workflow03.json [new file with mode: 0644]
vid-ext-services-simulator/src/main/resources/simulator.properties

index 1d0a455..431306d 100755 (executable)
@@ -169,6 +169,7 @@ mso.restapi.vnf.changemanagement.instance=/serviceInstances/v6/<service_instance
 mso.restapi.network.instance=/serviceInstances/v6/<service_instance_id>/networks
 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.workflow.invoke=/onap/so/infra/instanceManagement/v1/serviceInstances/<service_instance_id>/vnfs/<vnf_instance_id>/workflows/<workflow_UUID>
 mso.restapi.volume.group.instance=/serviceInstances/v6/<service_instance_id>/vnfs/<vnf_instance_id>/volumeGroups
 mso.restapi.instance.group=/serviceInstantiation/v7/instanceGroups
 mso.restapi.get.orc.req=/orchestrationRequests/v6
index 5668b78..ac8c393 100755 (executable)
@@ -112,6 +112,7 @@ mso.restapi.vnf.changemanagement.instance=/serviceInstances/v6/<service_instance
 mso.restapi.network.instance=/serviceInstances/v6/<service_instance_id>/networks
 mso.restapi.vf.module.scaleout=/serviceInstantiation/v7/serviceInstances/<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.workflow.invoke=/onap/so/infra/instanceManagement/v1/serviceInstances/<service_instance_id>/vnfs/<vnf_instance_id>/workflows/<workflow_UUID>
 mso.restapi.volume.group.instance=/serviceInstances/v6/<service_instance_id>/vnfs/<vnf_instance_id>/volumeGroups
 mso.restapi.instance.group=/serviceInstantiation/v7/instanceGroups
 mso.restapi.get.orc.req=/orchestrationRequests/v6
diff --git a/vid-app-common/src/main/java/org/onap/vid/changeManagement/RequestParameters.java b/vid-app-common/src/main/java/org/onap/vid/changeManagement/RequestParameters.java
new file mode 100644 (file)
index 0000000..dd69235
--- /dev/null
@@ -0,0 +1,37 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2019 Nokia Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.vid.changeManagement;
+
+import java.util.List;
+import java.util.Map;
+
+public class RequestParameters {
+
+    private List<Map<String,String>> userParams;
+
+
+    public List<Map<String, String>> getUserParams() {
+        return userParams;
+    }
+
+    public void setUserParams(List<Map<String, String>> userParams) {
+        this.userParams = userParams;
+    }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/changeManagement/UIWorkflowsRequest.java b/vid-app-common/src/main/java/org/onap/vid/changeManagement/UIWorkflowsRequest.java
new file mode 100644 (file)
index 0000000..97eee30
--- /dev/null
@@ -0,0 +1,35 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2019 Nokia Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.vid.changeManagement;
+
+public class UIWorkflowsRequest {
+
+    private WorkflowRequestDetail requestDetails;
+
+
+    public WorkflowRequestDetail getRequestDetails() {
+        return requestDetails;
+    }
+
+    public void setRequestDetails(WorkflowRequestDetail requestDetails) {
+        this.requestDetails = requestDetails;
+    }
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/changeManagement/WorkflowRequestDetail.java b/vid-app-common/src/main/java/org/onap/vid/changeManagement/WorkflowRequestDetail.java
new file mode 100644 (file)
index 0000000..2ebebdd
--- /dev/null
@@ -0,0 +1,49 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2019 Nokia Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.vid.changeManagement;
+
+import org.onap.vid.mso.model.CloudConfiguration;
+
+public class WorkflowRequestDetail {
+
+
+    private CloudConfiguration cloudConfiguration;
+
+    private RequestParameters requestParameters;
+
+
+    public CloudConfiguration getCloudConfiguration() {
+        return cloudConfiguration;
+    }
+
+    public void setCloudConfiguration(CloudConfiguration cloudConfiguration) {
+        this.cloudConfiguration = cloudConfiguration;
+    }
+
+
+    public RequestParameters getRequestParameters() {
+        return requestParameters;
+    }
+
+    public void setRequestParameters(RequestParameters requestParameters) {
+        this.requestParameters = requestParameters;
+    }
+
+}
index 2904004..00f9db2 100644 (file)
@@ -74,6 +74,7 @@ public class MsoController extends RestrictedBaseController {
      * The Constant VNF_INSTANCE_ID.
      */
     public static final String VNF_INSTANCE_ID = "<vnf_instance_id>";
+    public static final String WORKFLOW_ID = "<workflow_UUID>";
     public static final String START_LOG = " start";
 
     private final MsoBusinessLogic msoBusinessLogic;
index 987bffa..543aa94 100644 (file)
@@ -24,6 +24,7 @@ package org.onap.vid.controller;
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.module.kotlin.KotlinModule;
 import io.joshworks.restclient.http.mapper.ObjectMapper;
+import org.onap.portalsdk.core.util.SystemProperties;
 import org.onap.vid.aai.*;
 import org.onap.vid.aai.model.PortDetailsTranslator;
 import org.onap.vid.aai.util.*;
@@ -163,7 +164,7 @@ public class WebConfig {
     }
 
     @Bean
-    public AaiOverTLSClientInterface aaiOverTLSClient(ObjectMapper unirestObjectMapper){
+    public AaiOverTLSClientInterface aaiOverTLSClient(ObjectMapper unirestObjectMapper, SystemProperties systemProperties){
         return new AaiOverTLSClient(new SyncRestClient(unirestObjectMapper), new AaiOverTLSPropertySupplier());
     }
 
index f413d56..a6ad923 100644 (file)
 package org.onap.vid.controller;
 
 import java.util.List;
+import java.util.UUID;
+
+import org.onap.vid.changeManagement.UIWorkflowsRequest;
 import org.onap.vid.model.LocalWorkflowParameterDefinitions;
 import org.onap.vid.model.SOWorkflow;
 import org.onap.vid.model.SOWorkflowParameterDefinitions;
+import org.onap.vid.mso.MsoResponseWrapper;
+import org.onap.vid.services.ChangeManagementService;
 import org.onap.vid.services.ExternalWorkflowsService;
 import org.onap.vid.services.LocalWorkflowsService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
+import javax.servlet.http.HttpServletRequest;
+
 @RestController
 @RequestMapping(WorkflowsController.WORKFLOWS_MANAGEMENT)
 public class WorkflowsController extends VidRestrictedBaseController {
@@ -40,11 +48,13 @@ public class WorkflowsController extends VidRestrictedBaseController {
 
     private ExternalWorkflowsService externalWorkflowsService;
     private LocalWorkflowsService localWorkflowsService;
+    private ChangeManagementService changeManagementService;
 
     @Autowired
-    public WorkflowsController(ExternalWorkflowsService externalWorkflowsService, LocalWorkflowsService localWorkflowsService) {
+    public WorkflowsController(ExternalWorkflowsService externalWorkflowsService, LocalWorkflowsService localWorkflowsService,ChangeManagementService changeManagementService) {
         this.externalWorkflowsService = externalWorkflowsService;
         this.localWorkflowsService = localWorkflowsService;
+        this.changeManagementService = changeManagementService;
     }
 
     @RequestMapping(value = "workflows", method = RequestMethod.GET)
@@ -62,5 +72,10 @@ public class WorkflowsController extends VidRestrictedBaseController {
         return localWorkflowsService.getWorkflowParameterDefinitions(name);
     }
 
+    @RequestMapping(value = "{serviceInstanceId}/{vnfInstanceId}/{workflow_UUID}", method = RequestMethod.POST)
+    public MsoResponseWrapper getWorkflowFromUI(HttpServletRequest request, @PathVariable("serviceInstanceId") UUID serviceInstanceId, @PathVariable("vnfInstanceId") UUID vnfInstanceId, @PathVariable("workflow_UUID") UUID workflow_UUID, @RequestBody UIWorkflowsRequest requestBody) {
+        return changeManagementService.invokeVnfWorkflow(request,requestBody.getRequestDetails(), serviceInstanceId, vnfInstanceId, workflow_UUID);
+    }
+
 }
 
index 633acbc..1ff30f0 100644 (file)
@@ -21,6 +21,7 @@
 package org.onap.vid.mso;
 
 import org.onap.vid.changeManagement.RequestDetailsWrapper;
+import org.onap.vid.changeManagement.WorkflowRequestDetail;
 import org.onap.vid.controller.OperationalEnvironmentController;
 import org.onap.vid.model.SoftDeleteRequest;
 import org.onap.vid.mso.model.OperationalEnvironmentActivateInfo;
@@ -31,6 +32,7 @@ import org.onap.vid.mso.rest.RequestDetails;
 import org.onap.vid.mso.rest.Task;
 
 import java.util.List;
+import java.util.UUID;
 
 public interface MsoBusinessLogic {
 
@@ -51,6 +53,8 @@ public interface MsoBusinessLogic {
 
     MsoResponseWrapper scaleOutVfModuleInstance(org.onap.vid.changeManagement.RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId);
 
+    MsoResponseWrapper invokeVnfWorkflow(WorkflowRequestDetail request, String userId, UUID serviceInstanceId, UUID vnfInstanceId, UUID workflow_UUID);
+
     MsoResponseWrapper createConfigurationInstance(org.onap.vid.mso.rest.RequestDetailsWrapper requestDetailsWrapper, String serviceInstanceId);
 
     MsoResponseWrapper deleteSvcInstance(RequestDetails requestDetails, String serviceInstanceId, String serviceStatus);
index ec1c547..ad07eac 100644 (file)
@@ -30,6 +30,9 @@ import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
 import org.onap.portalsdk.core.util.SystemProperties;
 import org.onap.vid.changeManagement.ChangeManagementRequest;
 import org.onap.vid.changeManagement.RequestDetailsWrapper;
+import org.onap.vid.changeManagement.UIWorkflowsRequest;
+import org.onap.vid.changeManagement.WorkflowRequestDetail;
+import org.onap.vid.controller.ControllersUtils;
 import org.onap.vid.controller.OperationalEnvironmentController;
 import org.onap.vid.exceptions.GenericUncheckedException;
 import org.onap.vid.model.RequestReferencesContainer;
@@ -180,6 +183,27 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
         return msoClientInterface.scaleOutVFModuleInstance(wrapper, vf_module_endpoint);
     }
 
+    @Override
+    public MsoResponseWrapper invokeVnfWorkflow(WorkflowRequestDetail request, String userId, UUID serviceInstanceId, UUID vnfInstanceId, UUID workflow_UUID) {
+        logInvocationInDebug("invokeVnfWorkflow");
+
+        String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_WORKFLOW_INSTANCE);
+
+        String final_endpoint = endpoint
+                .replaceFirst(SVC_INSTANCE_ID, serviceInstanceId.toString())
+                .replaceFirst(WORKFLOW_ID, workflow_UUID.toString())
+                .replaceFirst(VNF_INSTANCE_ID, vnfInstanceId.toString());
+
+        Map<String,String> extraHeaders = new HashMap<>();
+
+        UUID requestId = UUID.randomUUID();
+        extraHeaders.put("X-ONAP-RequestID",requestId.toString());
+        extraHeaders.put("X-ONAP-PartnerName","VID");
+        extraHeaders.put("X-RequestorID",userId);
+
+        return msoClientInterface.invokeWorkflow(request,final_endpoint,extraHeaders);
+    }
+
     @Override
     public MsoResponseWrapper createConfigurationInstance(org.onap.vid.mso.rest.RequestDetailsWrapper requestDetailsWrapper, String serviceInstanceId) {
         logInvocationInDebug("createConfigurationInstance");
index 31063c6..904ba13 100644 (file)
@@ -22,8 +22,11 @@ package org.onap.vid.mso;
 
 import io.joshworks.restclient.http.HttpResponse;
 import org.onap.vid.changeManagement.RequestDetailsWrapper;
+import org.onap.vid.changeManagement.WorkflowRequestDetail;
 import org.onap.vid.mso.rest.RequestDetails;
 
+import java.util.Map;
+
 /**
  * Created by pickjonathan on 21/06/2017.
  */
@@ -111,6 +114,8 @@ public interface MsoInterface {
 
     MsoResponseWrapper addRelationshipToServiceInstance(RequestDetails requestDetails, String addRelationshipsPath);
 
+    MsoResponseWrapper invokeWorkflow(WorkflowRequestDetail requestDetails,String invokeWorkflowsPath,  Map<String, String> extraHeaders);
+
     <T> HttpResponse<T> get(String path, Class<T> responseClass);
 
     <T> HttpResponse<T> post(String path, RequestDetailsWrapper<?> requestDetailsWrapper,
index 3dc1ddc..47cb95f 100644 (file)
@@ -97,6 +97,9 @@ public class MsoProperties extends SystemProperties {
 
        public static final String MSO_REST_API_VF_MODULE_SCALE_OUT = "mso.restapi.vf.module.scaleout";
 
+       /** The Constant MSO_REST_API_WORKFLOW_INSTANCE. */
+       public static final String MSO_REST_API_WORKFLOW_INSTANCE = "mso.restapi.workflow.invoke";
+
        /** The Constant MSO_REST_API_VOLUME_GROUP_INSTANCE. */
        public static final String MSO_REST_API_VOLUME_GROUP_INSTANCE = "mso.restapi.volume.group.instance";
 
index 8dac0ce..ff7acff 100644 (file)
@@ -22,6 +22,7 @@ package org.onap.vid.mso.rest;
 
 import com.google.common.collect.ImmutableMap;
 import io.joshworks.restclient.http.HttpResponse;
+import io.joshworks.restclient.http.JsonNode;
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.Date;
@@ -36,6 +37,7 @@ import org.onap.portalsdk.core.util.SystemProperties;
 import org.onap.vid.aai.util.HttpsAuthClient;
 import org.onap.vid.changeManagement.MsoRequestDetails;
 import org.onap.vid.changeManagement.RequestDetailsWrapper;
+import org.onap.vid.changeManagement.WorkflowRequestDetail;
 import org.onap.vid.client.SyncRestClient;
 import org.onap.vid.model.RequestReferencesContainer;
 import org.onap.vid.mso.MsoInterface;
@@ -443,6 +445,20 @@ public class MsoRestClientNew extends RestMsoImplementation implements MsoInterf
         }
     }
 
+    @Override
+    public MsoResponseWrapper invokeWorkflow(WorkflowRequestDetail workflowRequestDetail, String invokeWorkflowsPath, Map<String, String> extraHeaders) {
+        String path = baseUrl + invokeWorkflowsPath;
+        Map<String, String> finalHeader = new HashMap<>();
+
+        finalHeader.putAll(commonHeaders);
+        finalHeader.putAll(extraHeaders);
+
+        RequestDetailsWrapper<WorkflowRequestDetail> requestDetailsWrapper = new RequestDetailsWrapper<>(workflowRequestDetail);
+
+        HttpResponse<JsonNode> response = client.post(path, finalHeader, requestDetailsWrapper);
+        return MsoUtil.wrapResponse(response);
+    }
+
     @Override
     public <T> HttpResponse<T> get(String endpoint, Class<T> responseClass) {
         String path = baseUrl + endpoint;
index 142bf73..83757f2 100644 (file)
@@ -320,6 +320,8 @@ public class AaiServiceImpl implements AaiService {
         return aaiClient.getPNFData(globalCustomerId, serviceType, modelVersionId, modelInvariantId, cloudRegion, equipVendor, equipModel);
     }
 
+
+
     @Override
     public AaiResponse getServices(RoleValidator roleValidator) {
         AaiResponse<GetServicesAAIRespone> subscriberResponse = aaiClient.getServices();
index 0047396..603e1f7 100644 (file)
@@ -23,13 +23,16 @@ package org.onap.vid.services;
 import com.fasterxml.jackson.databind.node.ArrayNode;
 import org.apache.commons.lang3.tuple.Pair;
 import org.onap.vid.changeManagement.*;
+import org.onap.vid.mso.MsoResponseWrapper;
 import org.onap.vid.mso.RestObjectWithRequestInfo;
 import org.onap.vid.mso.rest.Request;
 import org.springframework.http.ResponseEntity;
 import org.springframework.web.multipart.MultipartFile;
 
+import javax.servlet.http.HttpServletRequest;
 import java.util.Collection;
 import java.util.List;
+import java.util.UUID;
 
 public interface ChangeManagementService {
     Collection<Request> getMSOChangeManagements();
@@ -49,4 +52,6 @@ public interface ChangeManagementService {
     VnfWorkflowRelationAllResponse getAllVnfWorkflowRelations();
     String uploadConfigUpdateFile(MultipartFile file);
 
+    MsoResponseWrapper invokeVnfWorkflow(HttpServletRequest request, WorkflowRequestDetail requestBody, UUID serviceInstanceId, UUID vnfInstanceId, UUID workflow_UUID);
+
 }
index a20164c..fc5a85c 100644 (file)
@@ -30,17 +30,20 @@ import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
 import org.onap.portalsdk.core.service.DataAccessService;
 import org.onap.portalsdk.core.util.SystemProperties;
 import org.onap.vid.changeManagement.*;
+import org.onap.vid.controller.ControllersUtils;
 import org.onap.vid.exceptions.GenericUncheckedException;
 import org.onap.vid.exceptions.NotFoundException;
 import org.onap.vid.model.VNFDao;
 import org.onap.vid.model.VidWorkflow;
 import org.onap.vid.mso.MsoBusinessLogic;
+import org.onap.vid.mso.MsoResponseWrapper;
 import org.onap.vid.mso.MsoResponseWrapperInterface;
 import org.onap.vid.mso.RestObject;
 import org.onap.vid.mso.RestObjectWithRequestInfo;
 import org.onap.vid.mso.rest.Request;
 import org.onap.vid.scheduler.SchedulerProperties;
 import org.onap.vid.scheduler.SchedulerRestInterfaceIfc;
+import org.onap.vid.utils.SystemPropertiesWrapper;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
@@ -48,6 +51,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.util.StringUtils;
 import org.springframework.web.multipart.MultipartFile;
 
+import javax.servlet.http.HttpServletRequest;
 import javax.ws.rs.BadRequestException;
 import java.io.IOException;
 import java.util.*;
@@ -64,16 +68,18 @@ public class ChangeManagementServiceImpl implements ChangeManagementService {
     private MsoBusinessLogic msoBusinessLogic;
     private final SchedulerRestInterfaceIfc restClient;
     private final CloudOwnerService cloudOwnerService;
+    private final SystemPropertiesWrapper systemPropertiesWrapper;
 
     @Autowired
     private CsvService csvService;
 
     @Autowired
-    public ChangeManagementServiceImpl(DataAccessService dataAccessService, MsoBusinessLogic msoBusinessLogic, SchedulerRestInterfaceIfc schedulerRestInterface, CloudOwnerService cloudOwnerService) {
+    public ChangeManagementServiceImpl(DataAccessService dataAccessService, MsoBusinessLogic msoBusinessLogic, SchedulerRestInterfaceIfc schedulerRestInterface, CloudOwnerService cloudOwnerService, SystemPropertiesWrapper systemPropertiesWrapper) {
         this.dataAccessService = dataAccessService;
         this.msoBusinessLogic = msoBusinessLogic;
         this.restClient = schedulerRestInterface;
         this.cloudOwnerService = cloudOwnerService;
+        this.systemPropertiesWrapper = systemPropertiesWrapper;
     }
 
     @Override
@@ -327,6 +333,12 @@ public class ChangeManagementServiceImpl implements ChangeManagementService {
         return json.toString();
     }
 
+    @Override
+    public MsoResponseWrapper invokeVnfWorkflow(HttpServletRequest request,WorkflowRequestDetail requestBody, UUID serviceInstanceId, UUID vnfInstanceId, UUID workflow_UUID) {
+        String userId = new ControllersUtils(systemPropertiesWrapper).extractUserId(request);
+        return msoBusinessLogic.invokeVnfWorkflow(requestBody, userId, serviceInstanceId, vnfInstanceId, workflow_UUID);
+    }
+
     private boolean validateJsonOutput(org.json.JSONObject json) {
         if (!json.has(PRIMARY_KEY) || !json.getJSONObject(PRIMARY_KEY).keySet().containsAll(REQUIRED_KEYS))
             return false;
index a071a58..f8202fb 100644 (file)
                        });
                        return JSON.stringify(result);
                }
+
+               function getWorkflowParametersFromForm() {
+            let workflowParameters =
+                {requestDetails:{
+                        cloudConfiguration:{},
+                        requestParameters:{userParams:[{}]}
+                    }};
+            workflowParameters.requestDetails.cloudConfiguration = vm.changeManagement.vnfNames[0].cloudConfiguration;
+
+            let parameters = vm.getRemoteWorkFlowParameters(vm.changeManagement.workflow);
+            let i = 1;
+            parameters.forEach((parameter)=>{
+                let inputField = document.getElementById('so-workflow-parameter-'+i);
+                i++;
+                workflowParameters.requestDetails.requestParameters.userParams[0][parameter.name]=inputField.value;
+            });
+
+            return workflowParameters;
+        }
+
         vm.openModal = function () {
             if(vm.hasScheduler) { //scheduling supported
                                $scope.widgetParameter = ""; // needed by the scheduler?
                     var vnfName = vm.changeManagement.vnfNames[0].name;
                     changeManagementService.postChangeManagementNow(dataToSo, vnfName);
                 }
+
+                let workflowParameters = getWorkflowParametersFromForm();
+                if(workflowParameters){
+                    let servieInstanceId = vm.changeManagement.vnfNames[0]['service-instance-node'][0].properties['service-instance-id'];
+                    let vnfInstanceId = vm.changeManagement.vnfNames[0].id;
+                    let workflow_UUID = vm.changeManagement.fromVNFVersion;
+
+                    changeManagementService.postWorkflowsParametersNow(servieInstanceId,vnfInstanceId,workflow_UUID,workflowParameters);
+                }
                        }
         };
 
index 4b45b89..e545aad 100644 (file)
                     return {data: []};
                 });
         };
+
+        this.postWorkflowsParametersNow = function (serviceInstanceId,vnfInstanceId,workflow_UUID,requestData) {
+            let baseUrl = "workflows-management/{serviceInstanceId}/{vnfInstanceId}/{workflow_UUID}";
+            let url = baseUrl.
+                replace("{serviceInstanceId}",serviceInstanceId).
+                replace("{vnfInstanceId}",vnfInstanceId).
+                replace("{workflow_UUID}",workflow_UUID);
+
+            return $http.post(url, requestData)
+                .success(function (response) {
+                    return {data: response};
+                })
+                .catch(function (err) {
+                    return {data: []};
+                });
+        };
+
     }
 })();
diff --git a/vid-app-common/src/test/java/org/onap/vid/changeManagement/RequestParametersTest.java b/vid-app-common/src/test/java/org/onap/vid/changeManagement/RequestParametersTest.java
new file mode 100644 (file)
index 0000000..8651981
--- /dev/null
@@ -0,0 +1,34 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2019 Nokia Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.vid.changeManagement;
+
+import org.testng.annotations.Test;
+
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+public class RequestParametersTest {
+
+    @Test
+    public void shouldHaveProperSettersAndGetters() {
+        assertThat(RequestParameters.class, hasValidGettersAndSetters());
+    }
+
+}
diff --git a/vid-app-common/src/test/java/org/onap/vid/changeManagement/UIWorkflowsRequestTest.java b/vid-app-common/src/test/java/org/onap/vid/changeManagement/UIWorkflowsRequestTest.java
new file mode 100644 (file)
index 0000000..cf2a053
--- /dev/null
@@ -0,0 +1,33 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2019 Nokia Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.vid.changeManagement;
+
+import org.testng.annotations.Test;
+
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+public class UIWorkflowsRequestTest {
+
+    @Test
+    public void shouldHaveProperSettersAndGetters() {
+        assertThat(UIWorkflowsRequest.class, hasValidGettersAndSetters());
+    }
+}
diff --git a/vid-app-common/src/test/java/org/onap/vid/changeManagement/WorkflowRequestDetailTest.java b/vid-app-common/src/test/java/org/onap/vid/changeManagement/WorkflowRequestDetailTest.java
new file mode 100644 (file)
index 0000000..38f15d7
--- /dev/null
@@ -0,0 +1,33 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2019 Nokia Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.vid.changeManagement;
+
+import org.testng.annotations.Test;
+
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+public class WorkflowRequestDetailTest {
+
+    @Test
+    public void shouldHaveProperSettersAndGetters() {
+        assertThat(WorkflowRequestDetail.class, hasValidGettersAndSetters());
+    }
+}
diff --git a/vid-app-common/src/test/java/org/onap/vid/controller/WorkflowsControllerTest.java b/vid-app-common/src/test/java/org/onap/vid/controller/WorkflowsControllerTest.java
new file mode 100644 (file)
index 0000000..50f78b2
--- /dev/null
@@ -0,0 +1,140 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2019 Nokia Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.vid.controller;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import io.joshworks.restclient.http.HttpResponse;
+import io.joshworks.restclient.http.JsonMapper;
+import org.apache.http.ProtocolVersion;
+import org.apache.http.StatusLine;
+import org.apache.http.message.BasicHttpResponse;
+import org.apache.http.message.BasicStatusLine;
+import org.mockito.Mock;
+import org.onap.vid.changeManagement.UIWorkflowsRequest;
+import org.onap.vid.changeManagement.WorkflowRequestDetail;
+import org.onap.vid.mso.MsoUtil;
+import org.onap.vid.mso.model.CloudConfiguration;
+import org.onap.vid.services.ChangeManagementService;
+import org.onap.vid.services.ExternalWorkflowsService;
+import org.onap.vid.services.LocalWorkflowsService;
+import org.springframework.test.web.servlet.MockMvc;
+import org.springframework.test.web.servlet.ResultActions;
+import org.springframework.test.web.servlet.setup.MockMvcBuilders;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.MediaType;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.BDDMockito.given;
+import static org.mockito.MockitoAnnotations.initMocks;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
+
+public class WorkflowsControllerTest {
+
+    private static final String VID_WORKFLOWS = "/workflows-management/{serviceInstanceId}/{vnfInstanceId}/{workflow_UUID}";
+
+    private MockMvc mockMvc;
+
+    private WorkflowsController workflowsController;
+
+    @Mock
+    private ExternalWorkflowsService externalWorkflowsService;
+
+    @Mock
+    private LocalWorkflowsService localWorkflowsService;
+
+    @Mock
+    private ChangeManagementService changeManagementService;
+
+    @BeforeClass
+    public  void setUp(){
+        initMocks(this);
+        workflowsController = new WorkflowsController(externalWorkflowsService,localWorkflowsService,changeManagementService);
+        mockMvc = MockMvcBuilders.standaloneSetup(workflowsController).build();
+    }
+
+    @Test
+    public void shouldProperlyReceivePostRequestFromUI() throws Exception {
+        //  given
+        HttpResponse<String> expectedResponse = createOkResponse();
+        ObjectMapper objectMapper = new ObjectMapper();
+
+        UIWorkflowsRequest uiWorkflowsRequest = new UIWorkflowsRequest();
+
+        WorkflowRequestDetail workflowRequestDetail = createWorkflowRequestDetail();
+
+        uiWorkflowsRequest.setRequestDetails(workflowRequestDetail);
+
+        UUID serviceInstanceId = new UUID(1,10);
+        UUID vnfInstanceId = new UUID(2,20);
+        UUID workflow_UUID = new UUID(3,30);
+
+        given(changeManagementService.invokeVnfWorkflow(
+                any(HttpServletRequest.class), eq(uiWorkflowsRequest.getRequestDetails()),eq(serviceInstanceId),eq(vnfInstanceId), eq(workflow_UUID)
+                )).willReturn(MsoUtil.wrapResponse(expectedResponse));
+
+        //  when
+        ResultActions response = mockMvc.perform( post(VID_WORKFLOWS,serviceInstanceId,vnfInstanceId,workflow_UUID)
+                .contentType(MediaType.APPLICATION_JSON)
+                .content(objectMapper.writeValueAsString(uiWorkflowsRequest)));
+
+        //then
+        response.andExpect(status().isOk());
+    }
+
+    private WorkflowRequestDetail createWorkflowRequestDetail() {
+        WorkflowRequestDetail workflowRequestDetail = new WorkflowRequestDetail();
+        org.onap.vid.changeManagement.RequestParameters requestParameters = new org.onap.vid.changeManagement.RequestParameters();
+        HashMap<String,String> paramsMap = new HashMap<>();
+        paramsMap.put("testKey1","testValue1");
+        paramsMap.put("testKey2","testValue2");
+
+        List<Map<String,String>> mapArray= new ArrayList<>();
+        mapArray.add(paramsMap);
+        requestParameters.setUserParams(mapArray);
+
+        CloudConfiguration cloudConfiguration = new CloudConfiguration();
+        cloudConfiguration.setCloudOwner("testOwne");
+        cloudConfiguration.setTenantId("testId");
+        cloudConfiguration.setLcpCloudRegionId("testLcpCloudId");
+
+        workflowRequestDetail.setRequestParameters(requestParameters);
+        workflowRequestDetail.setCloudConfiguration(cloudConfiguration);
+        return workflowRequestDetail;
+    }
+
+    private HttpResponse<String> createOkResponse() {
+        StatusLine statusline = new BasicStatusLine(
+                new ProtocolVersion("http",1,1), 200, "acceptResponse");
+
+        org.apache.http.HttpResponse responseBase = new BasicHttpResponse(statusline);
+
+        return new HttpResponse<>(responseBase ,String.class, new JsonMapper());
+    }
+}
index 39d777b..11bf364 100644 (file)
@@ -26,6 +26,9 @@ import com.fasterxml.jackson.databind.ObjectMapper;
 import io.joshworks.restclient.http.HttpResponse;
 import org.apache.commons.io.IOUtils;
 import org.jetbrains.annotations.NotNull;
+import org.mockito.hamcrest.MockitoHamcrest;
+import org.onap.vid.changeManagement.WorkflowRequestDetail;
+import org.onap.vid.controller.ControllersUtils;
 import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
@@ -60,12 +63,18 @@ import java.io.IOException;
 import java.net.URL;
 import java.nio.file.Path;
 import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
+import java.util.UUID;
 import java.util.stream.Collectors;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.tuple;
 import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
+import static org.hamcrest.Matchers.allOf;
+import static org.hamcrest.Matchers.hasEntry;
 import static org.junit.Assert.assertEquals;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anyBoolean;
@@ -1329,6 +1338,45 @@ public class MsoBusinessLogicImplTest extends AbstractTestNGSpringContextTests {
         MsoBusinessLogicImpl.RequestType.fromValue(testValue);
     }
 
+    @Test
+    public void shouldProperlyInvokeVnfWorkflowWithValidParameters() {
+        // given
+        MsoResponseWrapper okResponse = createOkResponse();
+        WorkflowRequestDetail request = createWorkflowRequestDetail();
+        UUID serviceInstanceId = new UUID(1,10);
+        UUID vnfInstanceId = new UUID(2,20);
+        UUID workflow_UUID = new UUID(3,30);
+        String path = "/onap/so/infra/instanceManagement/v1/serviceInstances/"+serviceInstanceId+"/vnfs/"+vnfInstanceId+"/workflows/"+workflow_UUID;
+
+        given(msoInterface.invokeWorkflow(eq(request), eq(path), MockitoHamcrest.argThat(allOf(hasEntry("X-RequestorID", "testRequester"),hasEntry("X-ONAP-PartnerName", "VID"))))).willReturn(okResponse);
+
+        // when
+        MsoResponseWrapper response = msoBusinessLogic.invokeVnfWorkflow(request, "testRequester", serviceInstanceId, vnfInstanceId, workflow_UUID);
+
+        // then
+        assertThat(response).isEqualToComparingFieldByField(okResponse);
+    }
+
+    private WorkflowRequestDetail createWorkflowRequestDetail() {
+        WorkflowRequestDetail workflowRequestDetail = new WorkflowRequestDetail();
+        org.onap.vid.changeManagement.RequestParameters requestParameters = new org.onap.vid.changeManagement.RequestParameters();
+        HashMap<String,String> paramsMap = new HashMap<>();
+        paramsMap.put("testKey1","testValue1");
+        paramsMap.put("testKey2","testValue2");
+
+        List<Map<String,String>> mapArray= new ArrayList<>();
+        mapArray.add(paramsMap);
+        requestParameters.setUserParams(mapArray);
+
+        CloudConfiguration cloudConfiguration = new CloudConfiguration();
+        cloudConfiguration.setCloudOwner("testOwne");
+        cloudConfiguration.setTenantId("testId");
+        cloudConfiguration.setLcpCloudRegionId("testLcpCloudId");
+
+        workflowRequestDetail.setRequestParameters(requestParameters);
+        workflowRequestDetail.setCloudConfiguration(cloudConfiguration);
+        return workflowRequestDetail;
+    }
 
     private OperationalEnvironmentActivateInfo createTestOperationalEnvironmentActivateInfo() {
         OperationalEnvironmentController.OperationalEnvironmentActivateBody operationalEnvironmentActivateBody = new OperationalEnvironmentController.OperationalEnvironmentActivateBody(
index ff71d85..839e6e6 100644 (file)
@@ -21,6 +21,8 @@
 package org.onap.vid.mso.rest;
 
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.hamcrest.Matchers.allOf;
+import static org.hamcrest.Matchers.hasEntry;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anyMap;
 import static org.mockito.ArgumentMatchers.eq;
@@ -33,9 +35,12 @@ import org.apache.http.ProtocolVersion;
 import org.apache.http.StatusLine;
 import org.apache.http.message.BasicHttpResponse;
 import org.apache.http.message.BasicStatusLine;
+import org.jetbrains.annotations.NotNull;
 import org.mockito.Mock;
 import org.onap.portalsdk.core.util.SystemProperties;
 import org.onap.vid.changeManagement.RequestDetailsWrapper;
+import org.onap.vid.changeManagement.RequestParameters;
+import org.onap.vid.changeManagement.WorkflowRequestDetail;
 import org.onap.vid.client.SyncRestClient;
 import org.onap.vid.controller.LocalWebConfig;
 import org.onap.vid.model.RequestReferencesContainer;
@@ -43,12 +48,22 @@ import org.onap.vid.mso.MsoResponseWrapper;
 import org.onap.vid.mso.MsoResponseWrapperInterface;
 import org.onap.vid.mso.MsoUtil;
 import org.onap.vid.mso.RestObject;
+import org.onap.vid.mso.model.CloudConfiguration;
 import org.onap.vid.mso.model.RequestReferences;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.web.WebAppConfiguration;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import static org.mockito.ArgumentMatchers.refEq;
+import static org.mockito.hamcrest.MockitoHamcrest.argThat;
+
 
 @ContextConfiguration(classes = {LocalWebConfig.class, SystemProperties.class})
 @WebAppConfiguration
@@ -60,6 +75,7 @@ public class MsoRestClientTest {
     @Mock
     private SyncRestClient client;
 
+
     private MsoRestClientNew restClient;
 
 
@@ -748,6 +764,34 @@ public class MsoRestClientTest {
         assertThat(expectedResponse).isEqualToComparingFieldByField(response);
     }
 
+    @Test
+    public void shouldProperlyInvokeWorkflows() {
+        //  given
+        String endpoint = "testPath";
+        HttpResponse expectedResponse = createOkResponse();
+
+        WorkflowRequestDetail workflowRequestDetail = MsoRestClientTestUtil.createWorkflowRequestDetail();
+
+        RequestDetailsWrapper<WorkflowRequestDetail> requestDetailsWrapper = new RequestDetailsWrapper<>(workflowRequestDetail);
+
+        UUID requestId = UUID.randomUUID();
+
+        when(client.post(eq(baseUrl + endpoint), argThat(allOf(hasEntry("X-ONAP-RequestID", requestId.toString()),hasEntry("Content-Type", "application/json"))), refEq(requestDetailsWrapper))).
+                thenReturn(expectedResponse);
+
+        Map<String,String> extraHeaders = new HashMap<>();
+        extraHeaders.put("X-ONAP-RequestID",requestId.toString());
+        extraHeaders.put("X-ONAP-PartnerName","VID");
+        extraHeaders.put("X-RequestorID","testRequester");
+
+        //  when
+        MsoResponseWrapper response = restClient.invokeWorkflow(workflowRequestDetail, endpoint, extraHeaders);
+
+        //  then
+        assertThat(response).isEqualToComparingFieldByField(MsoUtil.wrapResponse(expectedResponse));
+
+    }
+
     private class MsoTestException extends RuntimeException{
         MsoTestException(String testException) {
             super(testException);
index f10a7f1..f662357 100644 (file)
@@ -37,8 +37,11 @@ import com.fasterxml.jackson.databind.ObjectMapper;
 import com.xebialabs.restito.semantics.Action;
 import com.xebialabs.restito.server.StubServer;
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
+import java.util.Map;
 import java.util.function.BiFunction;
 import java.util.function.Function;
 import javax.ws.rs.core.HttpHeaders;
@@ -50,6 +53,7 @@ import org.junit.Assert;
 import org.onap.portalsdk.core.util.SystemProperties;
 import org.onap.vid.changeManagement.RelatedInstanceList;
 import org.onap.vid.changeManagement.RequestDetailsWrapper;
+import org.onap.vid.changeManagement.WorkflowRequestDetail;
 import org.onap.vid.mso.MsoResponseWrapper;
 import org.onap.vid.mso.model.CloudConfiguration;
 import org.onap.vid.mso.model.ModelInfo;
@@ -200,6 +204,27 @@ class MsoRestClientTestUtil implements AutoCloseable {
     return requestDetails;
   }
 
+  static WorkflowRequestDetail createWorkflowRequestDetail() {
+    WorkflowRequestDetail workflowRequestDetail = new WorkflowRequestDetail();
+    org.onap.vid.changeManagement.RequestParameters requestParameters = new org.onap.vid.changeManagement.RequestParameters();
+    HashMap<String,String> paramsMap = new HashMap<>();
+    paramsMap.put("testKey1","testValue1");
+    paramsMap.put("testKey2","testValue2");
+
+    List<Map<String,String>> mapArray= new ArrayList<>();
+    mapArray.add(paramsMap);
+    requestParameters.setUserParams(mapArray);
+
+    CloudConfiguration cloudConfiguration = new CloudConfiguration();
+    cloudConfiguration.setCloudOwner("testOwne");
+    cloudConfiguration.setTenantId("testId");
+    cloudConfiguration.setLcpCloudRegionId("testLcpCloudId");
+
+    workflowRequestDetail.setRequestParameters(requestParameters);
+    workflowRequestDetail.setCloudConfiguration(cloudConfiguration);
+    return workflowRequestDetail;
+  }
+
   private void verifyServer(StubServer server, String endpoint, Method httpMethod) {
     verifyHttp(server).once(
         method(httpMethod),
index d001d56..621c313 100644 (file)
@@ -27,6 +27,7 @@ import org.onap.vid.changeManagement.RequestDetails;
 import org.onap.vid.mso.MsoBusinessLogic;
 import org.onap.vid.mso.MsoResponseWrapperInterface;
 import org.onap.vid.scheduler.SchedulerRestInterfaceIfc;
+import org.onap.vid.utils.SystemPropertiesWrapper;
 import org.springframework.http.ResponseEntity;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
@@ -38,16 +39,19 @@ import static org.testng.Assert.assertNull;
 public class ChangeManagementServiceImplTest {
 
     @Mock
-    DataAccessService dataAccessServiceMock;
+    private DataAccessService dataAccessServiceMock;
 
     @Mock
-    MsoBusinessLogic msoBusinessLogicMock;
+    private MsoBusinessLogic msoBusinessLogicMock;
 
     @Mock
-    SchedulerRestInterfaceIfc schedulerRestInterface;
+    private SchedulerRestInterfaceIfc schedulerRestInterface;
 
     @Mock
-    CloudOwnerService cloudOwnerService;
+    private CloudOwnerService cloudOwnerService;
+
+    @Mock
+    private SystemPropertiesWrapper systemPropertiesWrapper;
 
     @BeforeMethod
     public void initMocks(){
@@ -56,14 +60,14 @@ public class ChangeManagementServiceImplTest {
 
     @Test
     public void doChangeManagement_requestIsNull_returnsNull() throws Exception {
-        ChangeManagementServiceImpl changeManagementService = new ChangeManagementServiceImpl(dataAccessServiceMock, msoBusinessLogicMock, schedulerRestInterface, cloudOwnerService);
+        ChangeManagementServiceImpl changeManagementService = new ChangeManagementServiceImpl(dataAccessServiceMock, msoBusinessLogicMock, schedulerRestInterface, cloudOwnerService, systemPropertiesWrapper);
         ResponseEntity<String> result = changeManagementService.doChangeManagement(null,"anyString");
         assertNull(result);
     }
 
     @Test
     public void doChangeManagement_currentRequestDetailsIsNull_returnsNull() throws Exception {
-        ChangeManagementServiceImpl changeManagementService = new ChangeManagementServiceImpl(dataAccessServiceMock, msoBusinessLogicMock, schedulerRestInterface, cloudOwnerService);
+        ChangeManagementServiceImpl changeManagementService = new ChangeManagementServiceImpl(dataAccessServiceMock, msoBusinessLogicMock, schedulerRestInterface, cloudOwnerService,systemPropertiesWrapper);
 
         ChangeManagementServiceImpl changeManagementServiceSpied = Mockito.spy(changeManagementService);
         Mockito.doReturn(null).when(changeManagementServiceSpied).findRequestByVnfName(Matchers.anyList(),Mockito.anyString());
@@ -121,7 +125,7 @@ public class ChangeManagementServiceImplTest {
     }
 
     private RequestDetails callChangeManagement(String requestType) throws Exception {
-        ChangeManagementServiceImpl changeManagementService = new ChangeManagementServiceImpl(dataAccessServiceMock, msoBusinessLogicMock, schedulerRestInterface, cloudOwnerService);
+        ChangeManagementServiceImpl changeManagementService = new ChangeManagementServiceImpl(dataAccessServiceMock, msoBusinessLogicMock, schedulerRestInterface, cloudOwnerService,systemPropertiesWrapper);
         ChangeManagementServiceImpl changeManagementServiceSpied = Mockito.spy(changeManagementService);
         ChangeManagementRequest updateRequest = new ChangeManagementRequest();
 
index e638605..faa7a6a 100644 (file)
@@ -40,6 +40,7 @@ import org.onap.vid.mso.rest.RequestDetails;
 import org.onap.vid.properties.AsdcClientConfiguration;
 import org.onap.vid.scheduler.SchedulerRestInterfaceIfc;
 import org.onap.vid.testUtils.RegExMatcher;
+import org.onap.vid.utils.SystemPropertiesWrapper;
 import org.skyscreamer.jsonassert.JSONAssert;
 import org.skyscreamer.jsonassert.JSONCompareMode;
 import org.springframework.context.annotation.Bean;
@@ -118,8 +119,8 @@ public class ChangeManagementServiceUnitTest extends AbstractTestNGSpringContext
     public static class TestMsoConfig extends MsoConfig {
 
         @Bean
-        public ChangeManagementService getChangeManagementService(DataAccessService dataAccessService, MsoBusinessLogic msoInterface, SchedulerRestInterfaceIfc schedulerRestInterface, CloudOwnerService cloudOwnerService) {
-            return new ChangeManagementServiceImpl(dataAccessService, msoInterface, schedulerRestInterface, cloudOwnerService);
+        public ChangeManagementService getChangeManagementService(DataAccessService dataAccessService, MsoBusinessLogic msoInterface, SchedulerRestInterfaceIfc schedulerRestInterface, CloudOwnerService cloudOwnerService, SystemPropertiesWrapper systemPropertiesWrapper) {
+            return new ChangeManagementServiceImpl(dataAccessService, msoInterface, schedulerRestInterface, cloudOwnerService, systemPropertiesWrapper);
         }
     }
 }
index 6f19eb3..71f8eac 100644 (file)
@@ -150,6 +150,7 @@ mso.restapi.vnf.changemanagement.instance=/serviceInstances/v5/<service_instance
 mso.restapi.network.instance=/serviceInstances/v5/<service_instance_id>/networks
 mso.restapi.vf.module.instance=/serviceInstances/v7/<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.workflow.invoke=/onap/so/infra/instanceManagement/v1/serviceInstances/<service_instance_id>/vnfs/<vnf_instance_id>/workflows/<workflow_UUID>
 mso.restapi.volume.group.instance=/serviceInstances/v5/<service_instance_id>/vnfs/<vnf_instance_id>/volumeGroups
 mso.restapi.instance.group=/serviceInstantiation/v7/instanceGroups
 mso.restapi.get.orc.req=/orchestrationRequests/v5
index cb2dc7c..a780126 100644 (file)
@@ -1,7 +1,7 @@
 {
   "simulatorRequest": {
     "method": "GET",
-    "path": "/aai/v../business/customers/customer/MSO_1610_ST",
+    "path": "/aai/v../business/customers/customer/CAR_2020_ER",
     "queryParams": {
       "depth": [
         "2"
@@ -11,8 +11,8 @@
   "simulatorResponse": {
     "responseCode": 200,
     "body": {
-      "global-customer-id": "MSO_1610_ST",
-      "subscriber-name": "MSO_1610_ST",
+      "global-customer-id": "CAR_2020_ER",
+      "subscriber-name": "CAR_2020_ER",
       "subscriber-type": "INFRA",
       "resource-version": "1549008901724",
       "service-subscriptions": {
index 5e998e3..91a596b 100644 (file)
@@ -5,7 +5,7 @@
     "queryParams": {
       "format": ["simple"]
     },
-    "body": {"start": ["business/customers/customer/MSO_1610_ST/service-subscriptions/service-subscription/vLB/service-instances"], "query": "query/vnf-topology-fromServiceInstance"}
+    "body": {"start": ["business/customers/customer/CAR_2020_ER/service-subscriptions/service-subscription/vLB/service-instances"], "query": "query/vnf-topology-fromServiceInstance"}
   },
   "simulatorResponse": {
     "responseCode": 200,
diff --git a/vid-ext-services-simulator/src/main/resources/preset_registration/changeManagement/mso_invoke_workflow01.json b/vid-ext-services-simulator/src/main/resources/preset_registration/changeManagement/mso_invoke_workflow01.json
new file mode 100644 (file)
index 0000000..94fc543
--- /dev/null
@@ -0,0 +1,27 @@
+{
+  "simulatorRequest": {
+    "method" : "POST",
+    "path" : "/onap/so/infra/instanceManagement/v1/serviceInstances/[a-fA-F0-9-]*/vnfs/[a-fA-F0-9-]*/workflows/[a-fA-F0-9-]*",
+    "body" : {
+      "requestDetails": {
+        "cloudConfiguration": {
+          "lcpCloudRegionId": "RegionOne",
+          "tenantId": "982c540f6e69488eb6be5664255e00c0"
+        },
+        "requestParameters": {
+          "userParams": [
+            {
+              "[FIRST]parameter 1": "011"
+            }
+          ]
+        }
+      }
+    }
+  },
+  "simulatorResponse": {
+    "responseCode": 200,
+    "body": {
+      "inf": "workflow 1 invoked"
+    }
+  }
+}
\ No newline at end of file
diff --git a/vid-ext-services-simulator/src/main/resources/preset_registration/changeManagement/mso_invoke_workflow02.json b/vid-ext-services-simulator/src/main/resources/preset_registration/changeManagement/mso_invoke_workflow02.json
new file mode 100644 (file)
index 0000000..f5018f5
--- /dev/null
@@ -0,0 +1,28 @@
+{
+  "simulatorRequest": {
+    "method" : "POST",
+    "path" : "/onap/so/infra/instanceManagement/v1/serviceInstances/[a-fA-F0-9-]*/vnfs/[a-fA-F0-9-]*/workflows/[a-fA-F0-9-]*",
+    "body" : {
+      "requestDetails": {
+        "cloudConfiguration": {
+          "lcpCloudRegionId": "RegionOne",
+          "tenantId": "982c540f6e69488eb6be5664255e00c0"
+        },
+        "requestParameters": {
+          "userParams": [
+            {
+              "[SECOND] parameter 2": "022",
+              "[SECOND] parameter 1": "021"
+            }
+          ]
+        }
+      }
+    }
+  },
+  "simulatorResponse": {
+    "responseCode": 200,
+    "body": {
+      "inf": "workflow 2 invoked"
+    }
+  }
+}
\ No newline at end of file
diff --git a/vid-ext-services-simulator/src/main/resources/preset_registration/changeManagement/mso_invoke_workflow03.json b/vid-ext-services-simulator/src/main/resources/preset_registration/changeManagement/mso_invoke_workflow03.json
new file mode 100644 (file)
index 0000000..a9daa7c
--- /dev/null
@@ -0,0 +1,29 @@
+{
+  "simulatorRequest": {
+    "method" : "POST",
+    "path" : "/onap/so/infra/instanceManagement/v1/serviceInstances/[a-fA-F0-9-]*/vnfs/[a-fA-F0-9-]*/workflows/[a-fA-F0-9-]*",
+    "body" : {
+      "requestDetails": {
+        "cloudConfiguration": {
+          "lcpCloudRegionId": "RegionOne",
+          "tenantId": "982c540f6e69488eb6be5664255e00c0"
+        },
+        "requestParameters": {
+          "userParams": [
+            {
+              "[THIRD] parameter 3": "033",
+              "[THIRD] parameter 2": "test",
+              "[THIRD] parameter 1": "031"
+            }
+          ]
+        }
+      }
+    }
+  },
+  "simulatorResponse": {
+    "responseCode": 200,
+    "body": {
+      "inf": "workflow 3 invoked"
+    }
+  }
+}
\ No newline at end of file
index 922e7b1..5f1a90c 100644 (file)
@@ -6,4 +6,4 @@ simulator.mockserver.port = 1080
 
 #Simulator proprietary
 simulator.enablePresetRegistration=false
-simulator.enableCentralizedRoleAccess=false
+simulator.enableCentralizedRoleAccess=false
\ No newline at end of file