aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xepsdk-app-onap/src/main/webapp/WEB-INF/conf/system.properties4
-rwxr-xr-xepsdk-app-onap/src/main/webapp/WEB-INF/conf/system_template.properties2
-rw-r--r--vid-app-common/jest.config.js4
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/MsoConfig.java5
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/WorkflowsController.java4
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/SOWorkflows.kt60
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogic.java3
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java74
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/MsoInterface.java3
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/MsoProperties.java2
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/rest/MockedWorkflowsRestClient.java72
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java8
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/ExternalWorkflowsService.java6
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/ExternalWorkflowsServiceImpl.java70
-rw-r--r--vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js127
-rw-r--r--vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.test.js68
-rw-r--r--vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.html2
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java29
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/ExternalWorkflowServiceImplTest.java116
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/ExternalWorkflowsServiceImplTest.java80
-rw-r--r--vid-app-common/src/test/resources/WEB-INF/conf/system.properties1
-rw-r--r--vid-ext-services-simulator/src/main/resources/preset_registration/changeManagement/get_workflows_by_model_id.json106
-rw-r--r--vid-ext-services-simulator/src/main/resources/preset_registration/changeManagement/mso_invoke_workflow01.json10
-rw-r--r--vid-ext-services-simulator/src/main/resources/preset_registration/changeManagement/mso_invoke_workflow02.json28
-rw-r--r--vid-ext-services-simulator/src/main/resources/preset_registration/changeManagement/mso_invoke_workflow03.json29
25 files changed, 535 insertions, 378 deletions
diff --git a/epsdk-app-onap/src/main/webapp/WEB-INF/conf/system.properties b/epsdk-app-onap/src/main/webapp/WEB-INF/conf/system.properties
index 431306d8a..9310da082 100755
--- a/epsdk-app-onap/src/main/webapp/WEB-INF/conf/system.properties
+++ b/epsdk-app-onap/src/main/webapp/WEB-INF/conf/system.properties
@@ -191,7 +191,7 @@ mso.restapi.operationalEnvironment.create=${mso.restapi.cloudResourcesApiRoot}/o
mso.restapi.cloudResourcesRequestsApiRoot=/cloudResourcesRequests/v1
mso.restapi.operationalEnvironment.cloudResourcesRequests.status=${mso.restapi.cloudResourcesRequestsApiRoot}?requestId=<request_id>
-
+mso.restapi.changeManagement.workflowSpecifications=/workflowSpecifications/v1/workflows?vnfModelVersionId=<model_version_id>
mso.displayTestAPIOnScreen=true
mso.defaultTestAPI=GR_API
mso.maxOpenedInstantiationRequests=20
@@ -207,4 +207,4 @@ scheduler.get.time.slots=/v1/ChangeManagement/schedules/
scheduler.server.url=http://BYO.scheduler:8989/scheduler
scheduler.submit.new.vnf.change=/v1/ChangeManagement/schedules/{scheduleId}/approvals
-scheduler.get.schedules=/v1/ChangeManagement/schedules/scheduleDetails/ \ No newline at end of file
+scheduler.get.schedules=/v1/ChangeManagement/schedules/scheduleDetails/
diff --git a/epsdk-app-onap/src/main/webapp/WEB-INF/conf/system_template.properties b/epsdk-app-onap/src/main/webapp/WEB-INF/conf/system_template.properties
index ac8c3931b..f5955a50c 100755
--- a/epsdk-app-onap/src/main/webapp/WEB-INF/conf/system_template.properties
+++ b/epsdk-app-onap/src/main/webapp/WEB-INF/conf/system_template.properties
@@ -120,7 +120,7 @@ mso.restapi.get.orc.reqs=/orchestrationRequests/v6?
mso.restapi.get.man.tasks=/tasks/v1
mso.restapi.configurations=/serviceInstances/v6/<service_instance_id>/configurations
mso.restapi.configuration.instance=${mso.restapi.configurations}/<configuration_id>
-
+mso.restapi.changeManagement.workflowSpecifications=/workflowSpecifications/v1/workflows?vnfModelVersionId=<model_version_id>
mso.restapi.serviceInstantiationApiRoot=/serviceInstantiation/v7
mso.restapi.serviceInstanceCreate=${mso.restapi.serviceInstantiationApiRoot}/serviceInstances
mso.restapi.serviceInstanceAssign=${mso.restapi.serviceInstantiationApiRoot}/serviceInstances/assign
diff --git a/vid-app-common/jest.config.js b/vid-app-common/jest.config.js
index e9ca59b11..3f72db3be 100644
--- a/vid-app-common/jest.config.js
+++ b/vid-app-common/jest.config.js
@@ -7,10 +7,10 @@ module.exports = {
"<rootDir>/src/main/webapp/app/vid/external"
],
setupFilesAfterEnv: ["<rootDir>/test-config.js"],
- collectCoverage: true,
+ collectCoverage: false,
collectCoverageFrom: [
"src/**/*.js",
"!**/node_modules/**",
"!**/vendor/**"
]
-}; \ No newline at end of file
+};
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/MsoConfig.java b/vid-app-common/src/main/java/org/onap/vid/controller/MsoConfig.java
index a472268a3..a82dfab75 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controller/MsoConfig.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/MsoConfig.java
@@ -30,7 +30,6 @@ import org.onap.vid.mso.MsoBusinessLogic;
import org.onap.vid.mso.MsoBusinessLogicImpl;
import org.onap.vid.mso.MsoInterface;
import org.onap.vid.mso.MsoProperties;
-import org.onap.vid.mso.rest.MockedWorkflowsRestClient;
import org.onap.vid.mso.rest.MsoRestClientNew;
import org.onap.vid.services.CloudOwnerService;
import org.onap.vid.services.CloudOwnerServiceImpl;
@@ -54,10 +53,6 @@ public class MsoConfig {
MsoProperties.MSO_SERVER_URL),httpsAuthClient);
}
- @Bean
- public MockedWorkflowsRestClient mockedWorkflowsClient(ObjectMapper unirestObjectMapper){
- return new MockedWorkflowsRestClient(new SyncRestClient(unirestObjectMapper), "http://vid-simulator:1080/");
- }
@Bean
public MsoBusinessLogic getMsoBusinessLogic(MsoInterface msoClient, FeatureManager featureManager){
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 a6ad92321..1d0ff95bc 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
@@ -62,10 +62,6 @@ public class WorkflowsController extends VidRestrictedBaseController {
return externalWorkflowsService.getWorkflows(vnfModelId);
}
- @RequestMapping(value = "remote-workflow-parameters/{id}", method = RequestMethod.GET)
- SOWorkflowParameterDefinitions getParameters(@PathVariable Long id) {
- return externalWorkflowsService.getWorkflowParameterDefinitions(id);
- }
@RequestMapping(value = "local-workflow-parameters/{name}", method = RequestMethod.GET)
LocalWorkflowParameterDefinitions getParameters(@PathVariable String name) {
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/SOWorkflows.kt b/vid-app-common/src/main/java/org/onap/vid/model/SOWorkflows.kt
index b88c3f6f6..00cc7b943 100644
--- a/vid-app-common/src/main/java/org/onap/vid/model/SOWorkflows.kt
+++ b/vid-app-common/src/main/java/org/onap/vid/model/SOWorkflows.kt
@@ -20,9 +20,18 @@
package org.onap.vid.model
+import com.google.common.collect.Lists
+
+enum class WorkflowSource(val source: String) {
+ SDC("sdc"), NATIVE("native")
+}
+
data class SOWorkflow constructor(
- val id: Long,
- val name: String) {
+ val id: String,
+ val name: String,
+ val source: WorkflowSource,
+ val workflowInputParameters: List<WorkflowInputParameter>
+) {
fun clone(): SOWorkflow {
return copy()
}
@@ -79,3 +88,50 @@ data class LocalWorkflowParameterDefinitions constructor(
}
}
+
+data class ArtifactInfo constructor(
+ val artifactType: String,
+ val artifactUuid: String,
+ val artifactName: String,
+ val artifactVersion: String,
+ val artifactDescription: String? = null,
+ val workflowName: String,
+ val operationName: String? = null,
+ val workflowSource: String,
+ val workflowResourceTarget: String
+)
+
+data class ActivitySequenceItem constructor(
+ val name: String,
+ val description: String
+)
+
+data class WorkflowInputParameter constructor(
+ val label: String,
+ val inputType: String,
+ val required: Boolean,
+ val validation: List<InputParameterValidation>? = Lists.newArrayList(),
+ val soFieldName: String,
+ val soPayloadLocation: String?,
+ val description: String?
+
+)
+
+data class InputParameterValidation constructor(
+ val maxLength: String?,
+ val allowableChars: String?
+)
+
+data class WorkflowSpecification constructor(
+ val artifactInfo: ArtifactInfo,
+ val activitySequence: List<ActivitySequenceItem>? = Lists.newArrayList(),
+ val workflowInputParameters: List<WorkflowInputParameter>
+)
+
+data class WorkflowSpecificationWrapper constructor(
+ val workflowSpecification: WorkflowSpecification
+)
+
+data class SOWorkflowList constructor(
+ val workflowSpecificationList: List<WorkflowSpecificationWrapper>? = Lists.newArrayList()
+)
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 1ff30f03c..3b2cdb1bf 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
@@ -3,6 +3,7 @@
* VID
* ================================================================================
* Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright 2019 Nokia
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,6 +24,7 @@ package org.onap.vid.mso;
import org.onap.vid.changeManagement.RequestDetailsWrapper;
import org.onap.vid.changeManagement.WorkflowRequestDetail;
import org.onap.vid.controller.OperationalEnvironmentController;
+import org.onap.vid.model.SOWorkflowList;
import org.onap.vid.model.SoftDeleteRequest;
import org.onap.vid.mso.model.OperationalEnvironmentActivateInfo;
import org.onap.vid.mso.model.OperationalEnvironmentDeactivateInfo;
@@ -138,4 +140,5 @@ public interface MsoBusinessLogic {
MsoResponseWrapper2 activateFabricConfiguration(String serviceInstanceId, RequestDetails requestDetails);
+ SOWorkflowList getWorkflowListByModelId(String modelVersionId);
}
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 ad07eacae..64c405a39 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
@@ -8,9 +8,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -26,26 +26,44 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
+import io.joshworks.restclient.http.HttpResponse;
import org.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;
+import org.onap.vid.model.SOWorkflowList;
import org.onap.vid.model.SoftDeleteRequest;
-import org.onap.vid.mso.model.*;
+import org.onap.vid.mso.model.CloudConfiguration;
+import org.onap.vid.mso.model.ModelInfo;
+import org.onap.vid.mso.model.OperationalEnvironmentActivateInfo;
+import org.onap.vid.mso.model.OperationalEnvironmentDeactivateInfo;
+import org.onap.vid.mso.model.RequestInfo;
+import org.onap.vid.mso.model.RequestParameters;
import org.onap.vid.mso.rest.OperationalEnvironment.OperationEnvironmentRequestDetails;
-import org.onap.vid.mso.rest.*;
+import org.onap.vid.mso.rest.RelatedInstance;
+import org.onap.vid.mso.rest.Request;
+import org.onap.vid.mso.rest.RequestDetails;
+import org.onap.vid.mso.rest.RequestList;
+import org.onap.vid.mso.rest.RequestWrapper;
+import org.onap.vid.mso.rest.Task;
+import org.onap.vid.mso.rest.TaskList;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
import org.togglz.core.manager.FeatureManager;
import javax.ws.rs.BadRequestException;
import java.io.IOException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.UUID;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -54,8 +72,16 @@ import static java.util.stream.Collectors.collectingAndThen;
import static java.util.stream.Collectors.toList;
import static org.apache.commons.lang.StringUtils.upperCase;
import static org.onap.vid.changeManagement.ChangeManagementRequest.MsoChangeManagementRequest;
-import static org.onap.vid.controller.MsoController.*;
-import static org.onap.vid.mso.MsoProperties.*;
+import static org.onap.vid.controller.MsoController.CONFIGURATION_ID;
+import static org.onap.vid.controller.MsoController.REQUEST_TYPE;
+import static org.onap.vid.controller.MsoController.SVC_INSTANCE_ID;
+import static org.onap.vid.controller.MsoController.VNF_INSTANCE_ID;
+import static org.onap.vid.controller.MsoController.WORKFLOW_ID;
+import static org.onap.vid.mso.MsoProperties.MSO_REST_API_CLOUD_RESOURCES_REQUEST_STATUS;
+import static org.onap.vid.mso.MsoProperties.MSO_REST_API_OPERATIONAL_ENVIRONMENT_ACTIVATE;
+import static org.onap.vid.mso.MsoProperties.MSO_REST_API_OPERATIONAL_ENVIRONMENT_CREATE;
+import static org.onap.vid.mso.MsoProperties.MSO_REST_API_OPERATIONAL_ENVIRONMENT_DEACTIVATE;
+import static org.onap.vid.mso.MsoProperties.MSO_REST_API_WORKFLOW_SPECIFICATIONS;
import static org.onap.vid.properties.Features.FLAG_UNASSIGN_SERVICE;
import static org.onap.vid.utils.Logging.debugRequestDetails;
@@ -97,7 +123,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
this.featureManager = featureManager;
}
- public static String validateEndpointPath(String endpointEnvVariable) {
+ public static String validateEndpointPath(String endpointEnvVariable) {
String endpoint = SystemProperties.getProperty(endpointEnvVariable);
if (endpoint == null || endpoint.isEmpty()) {
throw new GenericUncheckedException(endpointEnvVariable + " env variable is not defined");
@@ -404,7 +430,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
}
}
- private List<Task> deserializeManualTasksJson(String manualTasksJson) {
+ private List<Task> deserializeManualTasksJson(String manualTasksJson) {
logInvocationInDebug("deserializeManualTasksJson");
ObjectMapper mapper = new ObjectMapper();
@@ -558,6 +584,20 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
return new MsoResponseWrapper2<>(msoClientInterface.post(path, new RequestDetailsWrapper<>(requestDetails), RequestReferencesContainer.class));
}
+ @Override
+ public SOWorkflowList getWorkflowListByModelId(String modelVersionId) {
+ logInvocationInDebug("getWorkflowListByModelId");
+ String pathTemplate = validateEndpointPath(MSO_REST_API_WORKFLOW_SPECIFICATIONS);
+ String path = pathTemplate.replaceFirst("<model_version_id>", modelVersionId);
+
+ HttpResponse<SOWorkflowList> workflowListByModelId = msoClientInterface.getWorkflowListByModelId(path);
+ if (!isSuccessful(workflowListByModelId)) {
+ logger.error(EELFLoggerDelegate.errorLogger, workflowListByModelId.getStatusText());
+ throw new WorkflowListException(String.format("Get worklflow list for id: %s failed due to %s", modelVersionId, workflowListByModelId.getStatusText()));
+ }
+ return workflowListByModelId.getBody();
+ }
+
@Override
public MsoResponseWrapperInterface updateVnfSoftware(org.onap.vid.changeManagement.RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) {
@@ -842,6 +882,18 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
logger.debug(EELFLoggerDelegate.debugLogger, methodName + e.toString());
}
+ private boolean isSuccessful(HttpResponse<SOWorkflowList> workflowListByModelId) {
+ int status = workflowListByModelId.getStatus();
+ return HttpStatus.OK.value() == status || HttpStatus.ACCEPTED.value() == status;
+ }
+
+ static class WorkflowListException extends RuntimeException{
+
+ WorkflowListException(String message) {
+ super(message);
+ }
+ }
+
enum RequestType {
CREATE_INSTANCE("createInstance"),
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 904ba13e4..9befc0f90 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,6 +22,7 @@ package org.onap.vid.mso;
import io.joshworks.restclient.http.HttpResponse;
import org.onap.vid.changeManagement.RequestDetailsWrapper;
+import org.onap.vid.model.SOWorkflowList;
import org.onap.vid.changeManagement.WorkflowRequestDetail;
import org.onap.vid.mso.rest.RequestDetails;
@@ -114,6 +115,8 @@ public interface MsoInterface {
MsoResponseWrapper addRelationshipToServiceInstance(RequestDetails requestDetails, String addRelationshipsPath);
+ HttpResponse<SOWorkflowList> getWorkflowListByModelId(String endpoint);
+
MsoResponseWrapper invokeWorkflow(WorkflowRequestDetail requestDetails,String invokeWorkflowsPath, Map<String, String> extraHeaders);
<T> HttpResponse<T> get(String path, Class<T> responseClass);
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 47cb95f2f..4e6258c16 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
@@ -125,4 +125,6 @@ public class MsoProperties extends SystemProperties {
/** The Constant MSO_REST_API_SERVICE_INSTANCE_ASSIGN */
public static final String MSO_REST_API_SERVICE_INSTANCE_ASSIGN = "mso.restapi.serviceInstanceAssign";
+
+ public static final String MSO_REST_API_WORKFLOW_SPECIFICATIONS= "mso.restapi.changeManagement.workflowSpecifications";
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/MockedWorkflowsRestClient.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/MockedWorkflowsRestClient.java
deleted file mode 100644
index 54ee6464f..000000000
--- a/vid-app-common/src/main/java/org/onap/vid/mso/rest/MockedWorkflowsRestClient.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 - 2019 AT&T 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.mso.rest;
-
-import java.util.Collections;
-import org.jetbrains.annotations.NotNull;
-import org.onap.vid.client.SyncRestClient;
-import org.onap.vid.model.SOWorkflowParameterDefinitions;
-import org.onap.vid.model.SOWorkflows;
-import org.onap.vid.mso.MsoResponseWrapper2;
-
-public class MockedWorkflowsRestClient {
-
- private SyncRestClient syncRestClient;
- private String baseUrl;
-
- public MockedWorkflowsRestClient(SyncRestClient syncRestClient, String baseUrl) {
- this.syncRestClient = syncRestClient;
- this.baseUrl = baseUrl;
- }
-
- public MsoResponseWrapper2<SOWorkflows> getWorkflows(String vnfName) {
- // Temporary skip vnfName and call mocked service
- return new MsoResponseWrapper2<>(syncRestClient
- .get(getWorkflowsUrl(),
- Collections.emptyMap(),
- Collections.emptyMap(),
- SOWorkflows.class));
- }
-
- public MsoResponseWrapper2<SOWorkflowParameterDefinitions> getWorkflowParameterDefinitions(Long workflowId) {
- return new MsoResponseWrapper2<>(syncRestClient
- .get((workflowId <= 3 && workflowId > 0) ? getParametersUrl(workflowId) : getParametersUrl(),
- Collections.emptyMap(),
- Collections.emptyMap(),
- SOWorkflowParameterDefinitions.class));
- }
-
- @NotNull
- private String getWorkflowsUrl() {
- return baseUrl + "so/workflows";
- }
-
-
- @NotNull
- private String getParametersUrl() {
- return baseUrl + "so/workflow-parameters";
- }
-
- @NotNull
- private String getParametersUrl(Long workflowId) {
- return baseUrl + "so/workflow-parameters/" + workflowId;
- }
-}
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 ff7acffcf..0c05b80e2 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
@@ -21,6 +21,7 @@
package org.onap.vid.mso.rest;
import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Maps;
import io.joshworks.restclient.http.HttpResponse;
import io.joshworks.restclient.http.JsonNode;
import java.text.DateFormat;
@@ -40,6 +41,7 @@ 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.model.SOWorkflowList;
import org.onap.vid.mso.MsoInterface;
import org.onap.vid.mso.MsoProperties;
import org.onap.vid.mso.MsoResponseWrapper;
@@ -473,6 +475,12 @@ public class MsoRestClientNew extends RestMsoImplementation implements MsoInterf
}
+ public HttpResponse<SOWorkflowList> getWorkflowListByModelId(String endpoint){
+ String path = baseUrl + endpoint;
+
+ return client.get(path, commonHeaders, Maps.newHashMap(), SOWorkflowList.class);
+ }
+
private MsoResponseWrapper createInstance(Object request, String path) {
String methodName = "createInstance";
logger.debug(methodName + START);
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/ExternalWorkflowsService.java b/vid-app-common/src/main/java/org/onap/vid/services/ExternalWorkflowsService.java
index 2eae52f4f..4620eed34 100644
--- a/vid-app-common/src/main/java/org/onap/vid/services/ExternalWorkflowsService.java
+++ b/vid-app-common/src/main/java/org/onap/vid/services/ExternalWorkflowsService.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* VID
* ================================================================================
- * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * 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.
@@ -22,10 +22,8 @@ package org.onap.vid.services;
import java.util.List;
import org.onap.vid.model.SOWorkflow;
-import org.onap.vid.model.SOWorkflowParameterDefinitions;
+
public interface ExternalWorkflowsService {
List<SOWorkflow> getWorkflows(String vnfModelId);
-
- SOWorkflowParameterDefinitions getWorkflowParameterDefinitions(Long workflowId);
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/ExternalWorkflowsServiceImpl.java b/vid-app-common/src/main/java/org/onap/vid/services/ExternalWorkflowsServiceImpl.java
index e03b5463a..0648b6ac9 100644
--- a/vid-app-common/src/main/java/org/onap/vid/services/ExternalWorkflowsServiceImpl.java
+++ b/vid-app-common/src/main/java/org/onap/vid/services/ExternalWorkflowsServiceImpl.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* VID
* ================================================================================
- * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * 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.
@@ -20,60 +20,48 @@
package org.onap.vid.services;
-import java.util.List;
+import org.onap.vid.model.ArtifactInfo;
import org.onap.vid.model.SOWorkflow;
-import org.onap.vid.model.SOWorkflowParameterDefinitions;
-import org.onap.vid.model.SOWorkflows;
-import org.onap.vid.mso.MsoResponseWrapper2;
-import org.onap.vid.mso.rest.MockedWorkflowsRestClient;
+import org.onap.vid.model.SOWorkflowList;
+import org.onap.vid.model.WorkflowSource;
+import org.onap.vid.model.WorkflowSpecification;
+import org.onap.vid.mso.MsoBusinessLogic;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+
@Service
public class ExternalWorkflowsServiceImpl implements ExternalWorkflowsService {
- private MockedWorkflowsRestClient mockedWorkflowsRestClient;
+ private MsoBusinessLogic msoService;
@Autowired
- public ExternalWorkflowsServiceImpl(MockedWorkflowsRestClient mockedWorkflowsRestClient) {
- this.mockedWorkflowsRestClient = mockedWorkflowsRestClient;
+ public ExternalWorkflowsServiceImpl(MsoBusinessLogic msoService) {
+ this.msoService = msoService;
}
@Override
public List<SOWorkflow> getWorkflows(String vnfModelId) {
- MsoResponseWrapper2<SOWorkflows> msoResponse = mockedWorkflowsRestClient.getWorkflows(vnfModelId);
- validateSOResponse(msoResponse, SOWorkflows.class);
- return convertMsoResponseToWorkflowList(msoResponse);
- }
+ SOWorkflowList workflowListByModelId = msoService.getWorkflowListByModelId(vnfModelId);
+ List<SOWorkflow> soWorkflows = new ArrayList<>();
+ Objects.requireNonNull(workflowListByModelId
+ .getWorkflowSpecificationList())
+ .forEach(
+ workflow -> soWorkflows.add(convertWorkflow(workflow.getWorkflowSpecification()))
+ );
- @Override
- public SOWorkflowParameterDefinitions getWorkflowParameterDefinitions(Long workflowId) {
- MsoResponseWrapper2<SOWorkflowParameterDefinitions> msoResponse = mockedWorkflowsRestClient.getWorkflowParameterDefinitions(workflowId);
- validateSOResponse(msoResponse, SOWorkflowParameterDefinitions.class);
- return (SOWorkflowParameterDefinitions) msoResponse.getEntity();
+ return soWorkflows;
}
- private List<SOWorkflow> convertMsoResponseToWorkflowList(MsoResponseWrapper2<SOWorkflows> msoResponse) {
- SOWorkflows soWorkflows = (SOWorkflows) msoResponse.getEntity();
- return soWorkflows.getWorkflows();
- }
+ private SOWorkflow convertWorkflow(WorkflowSpecification workflow) {
+ ArtifactInfo artifactInfo = workflow.getArtifactInfo();
- private void validateSOResponse(MsoResponseWrapper2 response, Class<?> expectedResponseClass){
- if (response.getStatus() >= 400 || !expectedResponseClass.isInstance(response.getEntity())) {
- throw new BadResponseFromMso(response);
- }
+ return new SOWorkflow(artifactInfo.getArtifactUuid(),
+ artifactInfo.getWorkflowName(),
+ WorkflowSource.valueOf(artifactInfo.getWorkflowSource().toUpperCase()),
+ workflow.getWorkflowInputParameters());
}
-
- public static class BadResponseFromMso extends RuntimeException {
- private final MsoResponseWrapper2<?> msoResponse;
-
- BadResponseFromMso(MsoResponseWrapper2<?> msoResponse) {
- this.msoResponse = msoResponse;
- }
-
- public MsoResponseWrapper2<?> getMsoResponse() {
- return msoResponse;
- }
- }
-
}
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 f8202fbf2..246834cdd 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
@@ -390,11 +390,9 @@
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;
+ let inputField = document.getElementById('so-workflow-parameter-'+parameter.soFieldName);
+ workflowParameters.requestDetails.requestParameters.userParams[0][parameter.soFieldName]=inputField.value;
});
return workflowParameters;
@@ -402,40 +400,60 @@
vm.openModal = function () {
if(vm.hasScheduler) { //scheduling supported
- $scope.widgetParameter = ""; // needed by the scheduler?
-
- // properties needed by the scheduler so it knows whether to show
- // policy or sniro related features on the scheduler UI or not.
- vm.changeManagement.policyYN = "Y";
- vm.changeManagement.sniroYN = "Y";
-
- if (featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_ADD_MSO_TESTAPI_FIELD)) {
- vm.changeManagement.testApi = DataService.getMsoRequestParametersTestApi();
- }
- var data = {
- widgetName: 'Portal-Common-Scheduler',
- widgetData: vm.changeManagement,
- widgetParameter: $scope.widgetParameter
- };
-
- window.parent.postMessage(data, VIDCONFIGURATION.SCHEDULER_PORTAL_URL);
+ vm.scheduleWorkflow();
} else {
- //no scheduling support
- var dataToSo = extractChangeManagementCallbackDataStr(vm.changeManagement);
- if(dataToSo) {
- var vnfName = vm.changeManagement.vnfNames[0].name;
- changeManagementService.postChangeManagementNow(dataToSo, vnfName);
- }
+ //no scheduling support
+ vm.executeWorkflow();
+ }
+ };
+
+ vm.scheduleWorkflow = function () {
+ $scope.widgetParameter = ""; // needed by the scheduler?
+
+ // properties needed by the scheduler so it knows whether to show
+ // policy or sniro related features on the scheduler UI or not.
+ vm.changeManagement.policyYN = "Y";
+ vm.changeManagement.sniroYN = "Y";
+
+ if (featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_ADD_MSO_TESTAPI_FIELD)) {
+ vm.changeManagement.testApi = DataService.getMsoRequestParametersTestApi();
+ }
+ var data = {
+ widgetName: 'Portal-Common-Scheduler',
+ widgetData: vm.changeManagement,
+ widgetParameter: $scope.widgetParameter
+ };
+
+ window.parent.postMessage(data, VIDCONFIGURATION.SCHEDULER_PORTAL_URL);
+ };
+ vm.executeWorkflow = function () {
+ if (vm.localWorkflows && vm.localWorkflows.length > 0) {
+ vm.triggerLocalWorkflow();
+ } else {
+ vm.triggerRemoteWorkflow();
+ }
+ };
+
+ vm.triggerLocalWorkflow = function () {
+ var dataToSo = extractChangeManagementCallbackDataStr(vm.changeManagement);
+ if (dataToSo) {
+ var vnfName = vm.changeManagement.vnfNames[0].name;
+ changeManagementService.postChangeManagementNow(dataToSo, vnfName);
+ }
+ };
+
+ vm.triggerRemoteWorkflow = function () {
+ let cachedWorkflowDetails = vm.getCachedWorkflowDetails(vm.changeManagement.workflow);
+ if (cachedWorkflowDetails.length > 0) {
let workflowParameters = getWorkflowParametersFromForm();
- if(workflowParameters){
+ 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);
+ let workflow_UUID = cachedWorkflowDetails[0].id;
+ changeManagementService.postWorkflowsParametersNow(servieInstanceId, vnfInstanceId, workflow_UUID, workflowParameters);
}
- }
+ }
};
vm.loadSubscribers = function () {
@@ -728,13 +746,37 @@
};
vm.loadRemoteWorkFlowParameters = function (workflow) {
- changeManagementService.getSOWorkflowParameter(workflow.id)
- .then(function (response) {
- vm.remoteWorkflowsParameters.set(workflow.name, response.data.parameterDefinitions);
- })
- .catch(function (error) {
- $log.error(error);
- });
+ let parameters = [];
+ workflow.workflowInputParameters
+ .filter( function (param) {
+ return param.soPayloadLocation === "userParams"
+ })
+ .forEach(function (param) {
+ let workflowParams = vm.repackAttributes(param);
+ if (param.validation.length > 0) {
+ let validation = param.validation[0];
+ if ('maxLength' in validation) {
+ workflowParams.maxLength = validation.maxLength;
+ }
+ if ('allowableChars' in validation) {
+ workflowParams.pattern = validation.allowableChars;
+ }
+ }
+ parameters.push(workflowParams);
+ }
+ );
+ vm.remoteWorkflowsParameters.set(workflow.name, parameters);
+ };
+
+ vm.repackAttributes = function (workflowParam){
+ return {
+ name: workflowParam.label,
+ required: workflowParam.required,
+ id: workflowParam.soFieldName,
+ soFieldName: workflowParam.soFieldName,
+ maxLength: '500',
+ pattern: '.*'
+ }
};
vm.getRemoteWorkFlowParameters = function (workflow) {
@@ -757,6 +799,13 @@
}
};
+ vm.getCachedWorkflowDetails = function (workflow) {
+ return vm.remoteWorkflows.filter( function (remoteWorkflow) {
+ return remoteWorkflow.name === workflow;
+ });
+
+ };
+
//Must be $scope because we bind to the onchange of the html (cannot attached to vm variable).
$scope.selectFileForVNFName = function (fileInput) {
if (fileInput && fileInput.id) {
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.test.js b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.test.js
index 9810c0013..5989ffdd6 100644
--- a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.test.js
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.test.js
@@ -100,32 +100,59 @@ describe('Testing workFlows from SO', () => {
}
],
}});
- let getSOWorkflowsPromiseStub = Promise.resolve({"data": [{"id": "1", "name": "workflow 1"}, {"id": "2", "name": "workflow 2"}]});
- let getSOWorkflowsParametersPromiseStub = Promise.resolve({"data":{"parameterDefinitions": []}});
+ let getSOWorkflowsPromiseStub = Promise.resolve({"data":[{
- $controller.changeManagement.vnfNames = [{name: 'test1'}, {name: "test2"}];
+ "id": "ab6478e4-ea33-3346-ac12-ab121484a333",
+ "workflowName": "inPlaceSoftwareUpdate",
+ "name": "inPlaceSoftwareUpdate",
+ "source": "sdc",
+ "workflowInputParameters": [
+ {
+ "label": "New Software Version",
+ "inputType": "text",
+ "required": true,
+ "soFieldName": "new_software_version",
+ "soPayloadLocation": "userParams",
+ "validation":[]
+ }
+ ]
+ }]
+ });
+
+ $controller.changeManagement.vnfNames = [{modelVersionId: 'test1', name:'test'}];
$changeManagementService.getWorkflows = () => getWorkflowsStub;
$changeManagementService.getLocalWorkflowParameter = () => getLocalWorkflowsParametersStub;
$changeManagementService.getSOWorkflows = () => getSOWorkflowsPromiseStub;
- $changeManagementService.getSOWorkflowParameter = () => getSOWorkflowsParametersPromiseStub;
// when
return $controller.loadWorkFlows().then(() => {
- expect($controller.workflows).toContain('workflow 1');
- expect($controller.workflows).toContain('workflow 2');
+ expect($controller.workflows).toContain('inPlaceSoftwareUpdate');
+ expect($controller.localWorkflowsParameters).toBeUndefined();
});
});
- test('Verify load workflows will call load workflows parameters from SO', () => {
+ test('Verify load workflows will set workflows and parameters', () => {
// given
let getWorkflowsStub = Promise.resolve({"data": {"workflows": ["workflow 0"]}});
let getLocalWorkflowsParametersStub = Promise.resolve({"data": {}});
- let getSOWorkflowsPromiseStub = Promise.resolve({"data": [{"id": "1", "name": "workflow 0"}]});
- let getSOWorkflowsParametersPromiseStub = Promise.resolve({"data":{"parameterDefinitions": [
- {"id": 1, "name": "parameter 1", "required": true, "type": "STRING", "pattern": "[0-9]*"},
- {"id": 2, "name": "parameter 2", "required": true, "type": "STRING", "pattern": ".*"},
- {"id": 3, "name": "parameter 3", "required": false, "type": "STRING", "pattern": "[0-9]*"}]}});
+ let getSOWorkflowsPromiseStub = Promise.resolve({"data":[{
- $controller.changeManagement.vnfNames = [{name: 'test1'}, {name: "test2"}];
+ "id": "ab6478e4-ea33-3346-ac12-ab121484a333",
+ "workflowName": "inPlaceSoftwareUpdate",
+ "name": "inPlaceSoftwareUpdate",
+ "source": "sdc",
+ "workflowInputParameters": [
+ {
+ "label": "New Software Version",
+ "inputType": "text",
+ "required": true,
+ "soFieldName": "new_software_version",
+ "soPayloadLocation": "userParams",
+ "validation":[]
+ }
+ ]
+ }]
+ });
+ $controller.changeManagement.vnfNames = [{modelVersionId: 'test1', name:'test'}];
$changeManagementService.getWorkflows = () => getWorkflowsStub;
$changeManagementService.getLocalWorkflowParameter = () => getLocalWorkflowsParametersStub;
$changeManagementService.getSOWorkflows = () => getSOWorkflowsPromiseStub;
@@ -133,10 +160,17 @@ describe('Testing workFlows from SO', () => {
// when
return $controller.loadWorkFlows()
.then(() => {
- expect($controller.remoteWorkflowsParameters).toEqual(new Map([["workflow 0",
- [{"id": 1, "name": "parameter 1", "pattern": "[0-9]*", "required": true, "type": "STRING"},
- {"id": 2, "name": "parameter 2", "pattern": ".*", "required": true, "type": "STRING"},
- {"id": 3, "name": "parameter 3", "pattern": "[0-9]*", "required": false, "type": "STRING"}]]]));
+ expect($controller.workflows).toEqual(["inPlaceSoftwareUpdate"]);
+ expect($controller.remoteWorkflowsParameters).toEqual(new Map([["inPlaceSoftwareUpdate",
+ [{
+ "name": "New Software Version",
+ "required": true,
+ "id": "new_software_version",
+ "soFieldName": "new_software_version",
+ "maxLength": '500',
+ "pattern": '.*'
+ }]]
+ ]));
});
});
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.html b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.html
index 9fb978c42..a5a6d1610 100644
--- a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.html
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.html
@@ -97,7 +97,7 @@
<div class="form-group" ng-if="vm.changeManagement.workflow" ng-repeat="item in vm.getRemoteWorkFlowParameters(vm.changeManagement.workflow)">
<label for="so-workflow-parameter-{{item.id}}" class="control-label">{{item.name}}</label>
- <input ng-model="item.value" type="text" id="so-workflow-parameter-{{item.id}}" pattern="{{item.pattern}}" ng-required="{{item.required}}">
+ <input ng-model="item.value" type="text" id="so-workflow-parameter-{{item.id}}" pattern="{{item.pattern}}" maxlength="{{item.maxLength}}" ng-required="{{item.required}}" soFieldName="{{item.soFieldName}}">
</div>
</div>
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 11bf364fb..4494f4872 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
@@ -28,7 +28,7 @@ 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.onap.vid.model.SOWorkflowList;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@@ -78,6 +78,7 @@ import static org.hamcrest.Matchers.hasEntry;
import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
+import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.argThat;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.isA;
@@ -103,6 +104,12 @@ public class MsoBusinessLogicImplTest extends AbstractTestNGSpringContextTests {
private MsoInterface msoInterface;
@Mock
+ private SOWorkflowList workflowList;
+
+ @Mock
+ private HttpResponse<SOWorkflowList> workflowListResponse;
+
+ @Mock
private RequestDetails msoRequest;
@@ -1357,6 +1364,26 @@ public class MsoBusinessLogicImplTest extends AbstractTestNGSpringContextTests {
assertThat(response).isEqualToComparingFieldByField(okResponse);
}
+
+ @Test
+ public void shouldReturnWorkflowListForGivenModelId() {
+ given(msoInterface.getWorkflowListByModelId(anyString())).willReturn(workflowListResponse);
+ given(workflowListResponse.getBody()).willReturn(workflowList);
+ given(workflowListResponse.getStatus()).willReturn(HttpStatus.ACCEPTED.value());
+
+ SOWorkflowList workflows = msoBusinessLogic.getWorkflowListByModelId("sampleModelId");
+
+ assertThat(workflows).isEqualTo(workflowList);
+ }
+
+ @Test(expectedExceptions = {MsoBusinessLogicImpl.WorkflowListException.class})
+ public void shouldRaiseExceptionWhenRetrievingWorkflowsFailed() {
+ given(msoInterface.getWorkflowListByModelId(anyString())).willReturn(workflowListResponse);
+ given(workflowListResponse.getStatus()).willReturn(HttpStatus.INTERNAL_SERVER_ERROR.value());
+
+ msoBusinessLogic.getWorkflowListByModelId("sampleModelId");
+ }
+
private WorkflowRequestDetail createWorkflowRequestDetail() {
WorkflowRequestDetail workflowRequestDetail = new WorkflowRequestDetail();
org.onap.vid.changeManagement.RequestParameters requestParameters = new org.onap.vid.changeManagement.RequestParameters();
diff --git a/vid-app-common/src/test/java/org/onap/vid/services/ExternalWorkflowServiceImplTest.java b/vid-app-common/src/test/java/org/onap/vid/services/ExternalWorkflowServiceImplTest.java
deleted file mode 100644
index 160ba97a5..000000000
--- a/vid-app-common/src/test/java/org/onap/vid/services/ExternalWorkflowServiceImplTest.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 - 2019 AT&T 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.services;
-
-
-
-import com.google.common.collect.Lists;
-import io.joshworks.restclient.http.HttpResponse;
-import java.util.Collections;
-import java.util.List;
-
-import org.assertj.core.api.Assertions;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
-import org.onap.vid.model.SOWorkflow;
-import org.onap.vid.model.SOWorkflowParameterDefinition;
-import org.onap.vid.model.SOWorkflowParameterDefinitions;
-import org.onap.vid.model.SOWorkflowType;
-import org.onap.vid.model.SOWorkflows;
-import org.onap.vid.mso.MsoResponseWrapper2;
-import org.onap.vid.mso.rest.MockedWorkflowsRestClient;
-import org.onap.vid.services.ExternalWorkflowsServiceImpl.BadResponseFromMso;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-public class ExternalWorkflowServiceImplTest {
-
- @Mock
- private MockedWorkflowsRestClient client;
- @Mock
- private HttpResponse<SOWorkflows> response;
-
- @Mock
- private HttpResponse<SOWorkflowParameterDefinitions> parameterDefinitionsHttpResponse;
-
-
- @BeforeMethod
- public void init(){
- MockitoAnnotations.initMocks(this);
- }
-
- @Test
- public void shouldReturnWorkflowsOnValidResponse(){
- // given
- ExternalWorkflowsService extWorkflowsService = new ExternalWorkflowsServiceImpl(client);
- Mockito.when(response.getStatus()).thenReturn(200);
- Mockito.when(response.getBody()).thenReturn(new SOWorkflows(Collections.singletonList(new SOWorkflow(1L, "xyz"))));
- MsoResponseWrapper2<SOWorkflows> msoResponseStub = new MsoResponseWrapper2<>(response);
- Mockito.when(client.getWorkflows("test")).thenReturn(msoResponseStub);
- // when
- List<SOWorkflow> workflows = extWorkflowsService.getWorkflows("test");
- // then
- Mockito.verify(client).getWorkflows("test");
- Assertions.assertThat(workflows.get(0).getName()).isEqualTo("xyz");
- }
-
- @Test(expectedExceptions = BadResponseFromMso.class)
- public void shouldThrowBadResponseOnInvalidResponse(){
- // given
- ExternalWorkflowsService extWorkflowsService = new ExternalWorkflowsServiceImpl(client);
- Mockito.when(response.getStatus()).thenReturn(500);
- Mockito.when(response.getBody()).thenReturn(new SOWorkflows(Collections.singletonList(new SOWorkflow(1L, "xyz"))));
- MsoResponseWrapper2<SOWorkflows> msoResponseStub = new MsoResponseWrapper2<>(response);
- Mockito.when(client.getWorkflows("test")).thenReturn(msoResponseStub);
- // when
- extWorkflowsService.getWorkflows("test");
- // then throw exception
- }
- @Test
- public void shouldReturnWorkflowParametersOnValidResponse() {
- SOWorkflowParameterDefinitions parameters = new SOWorkflowParameterDefinitions(Collections.singletonList(new SOWorkflowParameterDefinition(1L, "sample", "[0-9]", SOWorkflowType.STRING, true)));
- ExternalWorkflowsService extWorkflowsService = new ExternalWorkflowsServiceImpl(client);
- Mockito.when(parameterDefinitionsHttpResponse.getStatus()).thenReturn(200);
- Mockito.when(parameterDefinitionsHttpResponse.getBody()).thenReturn(parameters);
- MsoResponseWrapper2<SOWorkflowParameterDefinitions> msoResponseWrapper = new MsoResponseWrapper2<>(parameterDefinitionsHttpResponse);
- Mockito.when(client.getWorkflowParameterDefinitions(1L)).thenReturn(msoResponseWrapper);
-
-
- SOWorkflowParameterDefinitions workflowParameterDefinitions = extWorkflowsService.getWorkflowParameterDefinitions(1L);
-
- Assertions.assertThat(workflowParameterDefinitions).isEqualTo(parameters);
- }
-
- @Test
- public void shouldProperlyHandleEmptyParametersList(){
- ExternalWorkflowsService extWorkflowsService = new ExternalWorkflowsServiceImpl(client);
- Mockito.when(parameterDefinitionsHttpResponse.getStatus()).thenReturn(200);
- Mockito.when(parameterDefinitionsHttpResponse.getBody()).thenReturn(new SOWorkflowParameterDefinitions(Lists.newArrayList()));
-
- MsoResponseWrapper2<SOWorkflowParameterDefinitions> msoResponseWrapper = new MsoResponseWrapper2<>(parameterDefinitionsHttpResponse);
- Mockito.when(client.getWorkflowParameterDefinitions(1L)).thenReturn(msoResponseWrapper);
-
-
- SOWorkflowParameterDefinitions workflowParameterDefinitions = extWorkflowsService.getWorkflowParameterDefinitions(1L);
- Assertions.assertThat(workflowParameterDefinitions.getParameterDefinitions()).isEmpty();
- }
-}
diff --git a/vid-app-common/src/test/java/org/onap/vid/services/ExternalWorkflowsServiceImplTest.java b/vid-app-common/src/test/java/org/onap/vid/services/ExternalWorkflowsServiceImplTest.java
new file mode 100644
index 000000000..94771b29e
--- /dev/null
+++ b/vid-app-common/src/test/java/org/onap/vid/services/ExternalWorkflowsServiceImplTest.java
@@ -0,0 +1,80 @@
+/*-
+ * ============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.services;
+
+
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.onap.vid.model.ArtifactInfo;
+import org.onap.vid.model.SOWorkflow;
+import org.onap.vid.model.SOWorkflowList;
+import org.onap.vid.model.WorkflowInputParameter;
+import org.onap.vid.model.WorkflowSource;
+import org.onap.vid.model.WorkflowSpecification;
+import org.onap.vid.model.WorkflowSpecificationWrapper;
+import org.onap.vid.mso.MsoBusinessLogic;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.UUID;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.when;
+
+public class ExternalWorkflowsServiceImplTest {
+
+ @Mock
+ private MsoBusinessLogic msoBusinessLogic;
+
+
+ private static final UUID SAMPLE_UUID = UUID.randomUUID();
+
+ @BeforeMethod
+ public void init() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void shouldReturnWorkflowsOnValidResponse() {
+ // given
+ ExternalWorkflowsService extWorkflowsService = new ExternalWorkflowsServiceImpl(msoBusinessLogic);
+ WorkflowInputParameter parameter = new WorkflowInputParameter("sampleLabel", "text",
+ true, Collections.EMPTY_LIST, "sampleName", "userParams", "description");
+ SOWorkflowList workflowList = createWorkflowList(parameter);
+ SOWorkflow workflow = new SOWorkflow(SAMPLE_UUID.toString(), "sampleName", WorkflowSource.SDC, Collections.singletonList(parameter));
+ when(msoBusinessLogic.getWorkflowListByModelId("test")).thenReturn(workflowList);
+ // when
+ List<SOWorkflow> workflows = extWorkflowsService.getWorkflows("test");
+ // then
+ assertThat(workflows).hasSize(1).contains(workflow);
+ }
+
+ private SOWorkflowList createWorkflowList(WorkflowInputParameter parameter) {
+ ArtifactInfo artifactInfo = new ArtifactInfo("workflow", SAMPLE_UUID.toString(), "sampleArtifactName",
+ "sampleVersion", "sampleDescription", "sampleName", "sampleOperation", "sdc", "vnf");
+ WorkflowSpecification specification = new WorkflowSpecification(artifactInfo, Collections.EMPTY_LIST, Collections.singletonList(parameter));
+ WorkflowSpecificationWrapper wrapper = new WorkflowSpecificationWrapper(specification);
+ return new SOWorkflowList(Collections.singletonList(wrapper));
+ }
+
+}
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 71f8eac3b..fce0d1aeb 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
@@ -170,6 +170,7 @@ mso.restapi.operationalEnvironment.create=${mso.restapi.cloudResourcesApiRoot}/o
mso.restapi.serviceInstantiationApiRoot=/serviceInstantiation/v7
mso.restapi.serviceInstanceCreate=${mso.restapi.serviceInstantiationApiRoot}/serviceInstances
mso.restapi.serviceInstanceAssign=${mso.restapi.serviceInstantiationApiRoot}/serviceInstances/assign
+mso.restapi.changeManagement.workflowSpecifications=/workflowSpecifications/v1/workflows?vnfModelVersionId=<model_version_id>
vid.truststore.filename=/opt/app/vid/etc/vid_keystore.jks
mso.dme2.client.timeout=30000
diff --git a/vid-ext-services-simulator/src/main/resources/preset_registration/changeManagement/get_workflows_by_model_id.json b/vid-ext-services-simulator/src/main/resources/preset_registration/changeManagement/get_workflows_by_model_id.json
new file mode 100644
index 000000000..d26d07b93
--- /dev/null
+++ b/vid-ext-services-simulator/src/main/resources/preset_registration/changeManagement/get_workflows_by_model_id.json
@@ -0,0 +1,106 @@
+{
+ "simulatorRequest": {
+ "method": "GET",
+ "path": "/workflowSpecifications/v1/workflows",
+ "queryParams" : {
+ "vnfModelVersionId": "103b4a1b-4a15-4559-a019-1ff132180c7c"
+ }
+ } ,
+ "simulatorResponse": {
+ "responseCode": 200,
+ "body": {
+ "workflowSpecificationList": [{
+ "workflowSpecification": {
+ "artifactInfo": {
+ "artifactType": "workflow",
+ "artifactUuid": "ab6478e4-ea33-3346-ac12-ab121484a333",
+ "artifactName": "inPlaceSoftwareUpdate-1_0.bpmn",
+ "artifactVersion": "1.0",
+ "artifactDescription": "xyz xyz",
+ "workflowName": "inPlaceSoftwareUpdate",
+ "operationName": "inPlaceSoftwareUpdate",
+ "workflowSource": "sdc",
+ "workflowResourceTarget": "vnf"
+ },
+ "activitySequence": [{
+ "name": "VNFQuiesceTrafficActivity",
+ "description": "Activity to QuiesceTraffic on VNF"
+ },
+ {
+ "name": "VNFHealthCheckActivity",
+ "description": "Activity to HealthCheck VNF"
+ },
+ {
+ "name": "FlowCompleteActivity",
+ "description": "Activity to Complete the BPMN Flow"
+ }
+ ],
+ "workflowInputParameters": [{
+ "label": "Cloud Owner",
+ "inputType": "text",
+ "required": true,
+ "validation": [{
+ "maxLength": "7",
+ "allowableChars": "[a-zA-Z0-9]*"
+ }],
+ "soFieldName": "cloudOwner",
+ "soPayloadLocation": "cloudConfiguration"
+ },
+ {
+ "label": "Cloud Region ID",
+ "inputType": "text",
+ "required": true,
+ "validation": [{
+ "maxLength": "7",
+ "allowableChars": "[a-zA-Z0-9]*"
+ }],
+ "soFieldName": "lcpCloudRegionId",
+ "soPayloadLocation": "cloudConfiguration"
+ },
+ {
+ "label": "Tenant/Project ID",
+ "inputType": "text",
+ "required": true,
+ "validation": [{
+ "maxLength": "36",
+ "allowableChars": "[a-zA-Z0-9]*"
+ }],
+ "soFieldName": "tenantId",
+ "soPayloadLocation": "cloudConfiguration"
+ },
+ {
+ "label": "Operations Timeout",
+ "inputType": "text",
+ "required": true,
+ "description": "some description",
+ "validation": [{
+ "maxLength": "50",
+ "allowableChars": "[a-zA-Z0-9]*"
+ }],
+ "soFieldName": "operations_timeout",
+ "soPayloadLocation": "userParams"
+ },
+ {
+ "label": "Existing Software Version",
+ "inputType": "text",
+ "required": true,
+ "validation": [{
+ "maxLength": "50",
+ "allowableChars": "[a-zA-Z0-9]*"
+ }],
+ "soFieldName": "existing_software_version",
+ "soPayloadLocation": "userParams"
+ },
+ {
+ "label": "New Software Version",
+ "inputType": "text",
+ "required": true,
+ "soFieldName": "new_software_version",
+ "soPayloadLocation": "userParams"
+ }
+ ]
+ }
+ }]
+ }
+ }
+}
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
index 94fc543b6..afbfde207 100644
--- 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
@@ -11,7 +11,9 @@
"requestParameters": {
"userParams": [
{
- "[FIRST]parameter 1": "011"
+ "operations_timeout": "a",
+ "existing_software_version": "a",
+ "new_software_version": "a"
}
]
}
@@ -21,7 +23,9 @@
"simulatorResponse": {
"responseCode": 200,
"body": {
- "inf": "workflow 1 invoked"
+ "requestId": "ff3514e3-5a33-55df-13ab-12abad84e7ff",
+ "instanceId": "078046c2-d624-4480-a11d-b92f1fb40be5",
+ "requestSelfLink": "https://mso-apih-dev1-s1.ecomp.idns.cip.att.com:30251/onap/so/infra/orchestrationRequests/v7/ff3514e3-5a33-55df-13ab-12abad84e7ff"
}
}
-} \ 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
deleted file mode 100644
index f5018f557..000000000
--- a/vid-ext-services-simulator/src/main/resources/preset_registration/changeManagement/mso_invoke_workflow02.json
+++ /dev/null
@@ -1,28 +0,0 @@
-{
- "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
deleted file mode 100644
index a9daa7cf9..000000000
--- a/vid-ext-services-simulator/src/main/resources/preset_registration/changeManagement/mso_invoke_workflow03.json
+++ /dev/null
@@ -1,29 +0,0 @@
-{
- "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