aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common
diff options
context:
space:
mode:
authorWojciech Sliwka <wojciech.sliwka@nokia.com>2019-04-02 08:57:15 +0000
committerGerrit Code Review <gerrit@onap.org>2019-04-02 08:57:15 +0000
commit56d27d6651babd9223ee8e3a3deddda9d702dcd1 (patch)
treef763b0edabcadd734707f51e47d2d7ad27b4046c /vid-app-common
parent99f537f2af25e2810ff39077d3d49fadff6272ff (diff)
parent30794f9184dc2220a557ba5610a434c2a2bac801 (diff)
Merge "Sending workflow data from UI to SO"
Diffstat (limited to 'vid-app-common')
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/changeManagement/RequestParameters.java37
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/changeManagement/UIWorkflowsRequest.java35
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/changeManagement/WorkflowRequestDetail.java49
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/MsoController.java1
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/WebConfig.java3
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/WorkflowsController.java17
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogic.java4
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java24
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/MsoInterface.java5
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/MsoProperties.java3
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java16
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/AaiServiceImpl.java2
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/ChangeManagementService.java5
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/ChangeManagementServiceImpl.java14
-rw-r--r--vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js29
-rw-r--r--vid-app-common/src/main/webapp/app/vid/scripts/services/change-management.service.js17
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/changeManagement/RequestParametersTest.java34
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/changeManagement/UIWorkflowsRequestTest.java33
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/changeManagement/WorkflowRequestDetailTest.java33
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/controller/WorkflowsControllerTest.java140
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java48
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTest.java44
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTestUtil.java25
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/ChangeManagementServiceImplTest.java18
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/ChangeManagementServiceUnitTest.java5
-rw-r--r--vid-app-common/src/test/resources/WEB-INF/conf/system.properties1
26 files changed, 630 insertions, 12 deletions
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
index 000000000..dd6923569
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/changeManagement/RequestParameters.java
@@ -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
index 000000000..97eee3045
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/changeManagement/UIWorkflowsRequest.java
@@ -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
index 000000000..2ebebdd68
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/changeManagement/WorkflowRequestDetail.java
@@ -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;
+ }
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/MsoController.java b/vid-app-common/src/main/java/org/onap/vid/controller/MsoController.java
index 290400432..00f9db246 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controller/MsoController.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/MsoController.java
@@ -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;
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/WebConfig.java b/vid-app-common/src/main/java/org/onap/vid/controller/WebConfig.java
index 987bffa34..543aa9432 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controller/WebConfig.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/WebConfig.java
@@ -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());
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/WorkflowsController.java b/vid-app-common/src/main/java/org/onap/vid/controller/WorkflowsController.java
index f413d5658..a6ad92321 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controller/WorkflowsController.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/WorkflowsController.java
@@ -21,18 +21,26 @@
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);
+ }
+
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogic.java b/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogic.java
index 633acbcb8..1ff30f03c 100644
--- a/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogic.java
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogic.java
@@ -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);
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java b/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java
index ec1c5479f..ad07eacae 100644
--- a/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java
@@ -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;
@@ -181,6 +184,27 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
}
@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");
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/MsoInterface.java b/vid-app-common/src/main/java/org/onap/vid/mso/MsoInterface.java
index 31063c62b..904ba13e4 100644
--- a/vid-app-common/src/main/java/org/onap/vid/mso/MsoInterface.java
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/MsoInterface.java
@@ -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,
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/MsoProperties.java b/vid-app-common/src/main/java/org/onap/vid/mso/MsoProperties.java
index 3dc1ddcd3..47cb95f2f 100644
--- a/vid-app-common/src/main/java/org/onap/vid/mso/MsoProperties.java
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/MsoProperties.java
@@ -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";
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java
index 8dac0ce1b..ff7acffcf 100644
--- a/vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java
@@ -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;
@@ -444,6 +446,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;
return client.get(path, commonHeaders, new HashMap<>(), responseClass);
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/AaiServiceImpl.java b/vid-app-common/src/main/java/org/onap/vid/services/AaiServiceImpl.java
index 142bf73ec..83757f2fb 100644
--- a/vid-app-common/src/main/java/org/onap/vid/services/AaiServiceImpl.java
+++ b/vid-app-common/src/main/java/org/onap/vid/services/AaiServiceImpl.java
@@ -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();
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/ChangeManagementService.java b/vid-app-common/src/main/java/org/onap/vid/services/ChangeManagementService.java
index 0047396d1..603e1f7be 100644
--- a/vid-app-common/src/main/java/org/onap/vid/services/ChangeManagementService.java
+++ b/vid-app-common/src/main/java/org/onap/vid/services/ChangeManagementService.java
@@ -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);
+
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/ChangeManagementServiceImpl.java b/vid-app-common/src/main/java/org/onap/vid/services/ChangeManagementServiceImpl.java
index a20164c9e..fc5a85c04 100644
--- a/vid-app-common/src/main/java/org/onap/vid/services/ChangeManagementServiceImpl.java
+++ b/vid-app-common/src/main/java/org/onap/vid/services/ChangeManagementServiceImpl.java
@@ -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;
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js
index a071a58de..f8202fbf2 100644
--- a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js
@@ -380,6 +380,26 @@
});
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?
@@ -406,6 +426,15 @@
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);
+ }
}
};
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/services/change-management.service.js b/vid-app-common/src/main/webapp/app/vid/scripts/services/change-management.service.js
index 4b45b891d..e545aadb1 100644
--- a/vid-app-common/src/main/webapp/app/vid/scripts/services/change-management.service.js
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/services/change-management.service.js
@@ -142,5 +142,22 @@
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
index 000000000..8651981e4
--- /dev/null
+++ b/vid-app-common/src/test/java/org/onap/vid/changeManagement/RequestParametersTest.java
@@ -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
index 000000000..cf2a05377
--- /dev/null
+++ b/vid-app-common/src/test/java/org/onap/vid/changeManagement/UIWorkflowsRequestTest.java
@@ -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
index 000000000..38f15d7e5
--- /dev/null
+++ b/vid-app-common/src/test/java/org/onap/vid/changeManagement/WorkflowRequestDetailTest.java
@@ -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
index 000000000..50f78b23d
--- /dev/null
+++ b/vid-app-common/src/test/java/org/onap/vid/controller/WorkflowsControllerTest.java
@@ -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());
+ }
+}
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java
index 39d777be9..11bf364fb 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java
@@ -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(
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTest.java
index ff71d85fc..839e6e6c1 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTest.java
@@ -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);
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTestUtil.java b/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTestUtil.java
index f10a7f14f..f66235728 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTestUtil.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTestUtil.java
@@ -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),
diff --git a/vid-app-common/src/test/java/org/onap/vid/services/ChangeManagementServiceImplTest.java b/vid-app-common/src/test/java/org/onap/vid/services/ChangeManagementServiceImplTest.java
index d001d566a..621c31327 100644
--- a/vid-app-common/src/test/java/org/onap/vid/services/ChangeManagementServiceImplTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/services/ChangeManagementServiceImplTest.java
@@ -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();
diff --git a/vid-app-common/src/test/java/org/onap/vid/services/ChangeManagementServiceUnitTest.java b/vid-app-common/src/test/java/org/onap/vid/services/ChangeManagementServiceUnitTest.java
index e638605c1..faa7a6a8d 100644
--- a/vid-app-common/src/test/java/org/onap/vid/services/ChangeManagementServiceUnitTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/services/ChangeManagementServiceUnitTest.java
@@ -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);
}
}
}
diff --git a/vid-app-common/src/test/resources/WEB-INF/conf/system.properties b/vid-app-common/src/test/resources/WEB-INF/conf/system.properties
index 6f19eb31e..71f8eac3b 100644
--- a/vid-app-common/src/test/resources/WEB-INF/conf/system.properties
+++ b/vid-app-common/src/test/resources/WEB-INF/conf/system.properties
@@ -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