Query CatalogDB for WorkflowSpecifications 75/84775/3
authorElena Kuleshov <evn@att.com>
Tue, 9 Apr 2019 02:08:29 +0000 (22:08 -0400)
committerElena Kuleshov <evn@att.com>
Tue, 9 Apr 2019 06:21:13 +0000 (02:21 -0400)
Query CatalogDB for WorkflowSpecifications fron APIH

Change-Id: I5eef5ba9b49c0a7420ef93a5425121bfe7225b1b
Issue-ID: SO-1727
Signed-off-by: Kuleshov, Elena <evn@att.com>
12 files changed:
adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java
adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql
mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandler.java
mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandlerTest.java
mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowActivitySpecSequence_Response.json [new file with mode: 0644]
mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowSpecifications.json [moved from mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/WorkflowSpecifications.json with 96% similarity]
mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowSpecificationsQuery_Response.json [new file with mode: 0644]
mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java
mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/WorkflowRepository.java
mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/WorkflowRepositoryTest.java
mso-catalog-db/src/test/resources/data.sql
mso-catalog-db/src/test/resources/schema.sql

index e1152ba..51b44b0 100644 (file)
@@ -658,4 +658,19 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest {
         Assert.assertNull(workflow);
     }
 
+    @Test
+    public void getWorkflowByModelUUID_validUuid_expectedOutput() {
+        List<Workflow> workflows = client.findWorkflowByModelUUID("ff2ae348-214a-11e7-93ae-92361f002671");
+        assertTrue(workflows != null);
+        assertTrue(workflows.size() != 0);
+
+        assertEquals("testingWorkflow", workflows.get(0).getArtifactName());
+    }
+
+    @Test
+    public void getWorkflowByModelUUID_invalidUuid_nullOutput() {
+        Workflow workflow = client.findWorkflowByArtifactUUID(UUID.randomUUID().toString());
+        Assert.assertNull(workflow);
+    }
+
 }
index af00732..0229dd0 100644 (file)
@@ -226,3 +226,6 @@ insert into pnf_resource_customization_to_service(service_model_uuid, resource_m
 
 insert into workflow(artifact_uuid, artifact_name, name, operation_name, version, description, body, resource_target, source) values
 ('5b0c4322-643d-4c9f-b184-4516049e99b1', 'testingWorkflow', 'testingWorkflow', 'create', 1, 'Test Workflow', null, 'vnf', 'sdc');
+
+insert into vnf_resource_to_workflow(vnf_resource_model_uuid, workflow_id) values
+('ff2ae348-214a-11e7-93ae-92361f002671', '1');
index bc4f389..c480bdf 100644 (file)
  */
 package org.onap.so.apihandlerinfra;
 
-import java.nio.file.Files;
-import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 import javax.transaction.Transactional;
 import javax.ws.rs.GET;
 import javax.ws.rs.Path;
@@ -32,7 +35,19 @@ import org.onap.so.apihandler.common.ErrorNumbers;
 import org.onap.so.apihandler.common.ResponseBuilder;
 import org.onap.so.apihandlerinfra.exceptions.ValidateException;
 import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo;
+import org.onap.so.apihandlerinfra.workflowspecificationbeans.ActivitySequence;
+import org.onap.so.apihandlerinfra.workflowspecificationbeans.ArtifactInfo;
+import org.onap.so.apihandlerinfra.workflowspecificationbeans.Validation;
+import org.onap.so.apihandlerinfra.workflowspecificationbeans.WorkflowInputParameter;
+import org.onap.so.apihandlerinfra.workflowspecificationbeans.WorkflowSpecification;
+import org.onap.so.apihandlerinfra.workflowspecificationbeans.WorkflowSpecificationList;
 import org.onap.so.apihandlerinfra.workflowspecificationbeans.WorkflowSpecifications;
+import org.onap.so.db.catalog.beans.ActivitySpec;
+import org.onap.so.db.catalog.beans.ActivitySpecUserParameters;
+import org.onap.so.db.catalog.beans.UserParameters;
+import org.onap.so.db.catalog.beans.Workflow;
+import org.onap.so.db.catalog.beans.WorkflowActivitySpecSequence;
+import org.onap.so.db.catalog.client.CatalogDbClient;
 import org.onap.so.logger.ErrorCode;
 import org.onap.so.logger.MessageEnum;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -51,11 +66,17 @@ public class WorkflowSpecificationsHandler {
     @Autowired
     private ResponseBuilder builder;
 
+    @Autowired
+    private CatalogDbClient catalogDbClient;
+
+    private static final String ARTIFACT_TYPE_WORKFLOW = "workflow";
+
     @Path("/{version:[vV]1}/workflows")
     @GET
     @ApiOperation(value = "Finds Workflow Specifications", response = Response.class)
     @Transactional
-    public Response queryFilters(@QueryParam("vnfModelVersionId") String vnfModelVersionId,
+
+    public Response queryWorkflowSpecifications(@QueryParam("vnfModelVersionId") String vnfModelVersionId,
             @PathParam("version") String version) throws Exception {
 
         String apiVersion = version.substring(1);
@@ -63,10 +84,8 @@ public class WorkflowSpecificationsHandler {
         ObjectMapper mapper1 = new ObjectMapper();
         mapper1.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
 
-        // Replace with Catalog DB Query
-        WorkflowSpecifications workflowSpecifications = mapper1.readValue(
-                new String(Files.readAllBytes(Paths.get("src/test/resources/__files/WorkflowSpecifications.json"))),
-                WorkflowSpecifications.class);
+        List<Workflow> workflows = catalogDbClient.findWorkflowByModelUUID(vnfModelVersionId);
+        WorkflowSpecifications workflowSpecifications = mapWorkflowsToWorkflowSpecifications(workflows);
 
         String jsonResponse = null;
         try {
@@ -85,4 +104,119 @@ public class WorkflowSpecificationsHandler {
 
         return builder.buildResponse(HttpStatus.SC_OK, "", jsonResponse, apiVersion);
     }
+
+    protected WorkflowSpecifications mapWorkflowsToWorkflowSpecifications(List<Workflow> workflows) {
+        if (workflows == null || workflows.size() == 0) {
+            return null;
+        }
+        WorkflowSpecifications workflowSpecifications = new WorkflowSpecifications();
+        List<WorkflowSpecificationList> workflowSpecificationList = new ArrayList<WorkflowSpecificationList>();
+
+        for (Workflow workflow : workflows) {
+            WorkflowSpecificationList workflowSpecificationListItem = new WorkflowSpecificationList();
+            WorkflowSpecification workflowSpecification = new WorkflowSpecification();
+            workflowSpecification.setArtifactInfo(buildArtifactInfo(workflow));
+            workflowSpecification.setActivitySequence(buildActivitySequence(workflow));
+            workflowSpecification.setWorkflowInputParameters(buildWorkflowInputParameters(workflow));
+            workflowSpecificationListItem.setWorkflowSpecification(workflowSpecification);
+            workflowSpecificationList.add(workflowSpecificationListItem);
+        }
+        workflowSpecifications.setWorkflowSpecificationList(workflowSpecificationList);
+        return workflowSpecifications;
+    }
+
+    private ArtifactInfo buildArtifactInfo(Workflow workflow) {
+        ArtifactInfo artifactInfo = new ArtifactInfo();
+        artifactInfo.setArtifactType(ARTIFACT_TYPE_WORKFLOW);
+        artifactInfo.setArtifactUuid(workflow.getArtifactUUID());
+        artifactInfo.setArtifactName(workflow.getArtifactName());
+        if (workflow.getVersion() != null) {
+            artifactInfo.setArtifactVersion(workflow.getVersion().toString());
+        }
+        artifactInfo.setArtifactDescription(workflow.getDescription());
+        artifactInfo.setWorkflowName(workflow.getName());
+        artifactInfo.setOperationName(workflow.getOperationName());
+        artifactInfo.setWorkflowSource(workflow.getSource());
+        artifactInfo.setWorkflowResourceTarget(workflow.getResourceTarget());
+        return artifactInfo;
+    }
+
+    private List<ActivitySequence> buildActivitySequence(Workflow workflow) {
+        List<WorkflowActivitySpecSequence> workflowActivitySpecSequences = workflow.getWorkflowActivitySpecSequence();
+        if (workflowActivitySpecSequences == null || workflowActivitySpecSequences.size() == 0) {
+            return null;
+        }
+        List<ActivitySequence> activitySequences = new ArrayList<ActivitySequence>();
+        for (WorkflowActivitySpecSequence workflowActivitySpecSequence : workflowActivitySpecSequences) {
+            if (workflowActivitySpecSequence != null) {
+                ActivitySpec activitySpec = workflowActivitySpecSequence.getActivitySpec();
+                if (activitySpec != null) {
+                    ActivitySequence activitySequence = new ActivitySequence();
+                    activitySequence.setName(activitySpec.getName());
+                    activitySequence.setDescription(activitySpec.getDescription());
+                    activitySequences.add(activitySequence);
+                }
+            }
+        }
+        return activitySequences;
+    }
+
+    private List<WorkflowInputParameter> buildWorkflowInputParameters(Workflow workflow) {
+        List<WorkflowActivitySpecSequence> workflowActivitySpecSequences = workflow.getWorkflowActivitySpecSequence();
+        if (workflowActivitySpecSequences == null || workflowActivitySpecSequences.size() == 0) {
+            return null;
+        }
+        Map<String, WorkflowInputParameter> workflowInputParameterMap = new HashMap<String, WorkflowInputParameter>();
+        for (WorkflowActivitySpecSequence workflowActivitySpecSequence : workflowActivitySpecSequences) {
+            if (workflowActivitySpecSequence != null) {
+                ActivitySpec activitySpec = workflowActivitySpecSequence.getActivitySpec();
+                if (activitySpec != null) {
+                    List<ActivitySpecUserParameters> activitySpecUserParameters =
+                            activitySpec.getActivitySpecUserParameters();
+                    if (activitySpecUserParameters != null && activitySpecUserParameters.size() != 0) {
+                        for (ActivitySpecUserParameters activitySpecUserParameter : activitySpecUserParameters) {
+                            UserParameters userParameter = activitySpecUserParameter.getUserParameters();
+                            if (userParameter != null) {
+                                WorkflowInputParameter workflowInputParameter =
+                                        buildWorkflowInputParameter(userParameter);
+                                workflowInputParameterMap.put(userParameter.getName(), workflowInputParameter);
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        if (workflowInputParameterMap.size() == 0) {
+            return null;
+        }
+        List<WorkflowInputParameter> workflowInputParameterList =
+                workflowInputParameterMap.values().stream().collect(Collectors.toList());
+        return workflowInputParameterList;
+    }
+
+    private WorkflowInputParameter buildWorkflowInputParameter(UserParameters userParameter) {
+        WorkflowInputParameter workflowInputParameter = new WorkflowInputParameter();
+        workflowInputParameter.setLabel(userParameter.getLabel());
+        workflowInputParameter.setInputType(userParameter.getType());
+        workflowInputParameter.setRequired(userParameter.getIsRequried());
+        workflowInputParameter.setSoFieldName(userParameter.getName());
+        workflowInputParameter.setSoPayloadLocation(userParameter.getPayloadLocation());
+        workflowInputParameter.setValidation(buildValidationList(userParameter));
+        return workflowInputParameter;
+    }
+
+    private List<Validation> buildValidationList(UserParameters userParameter) {
+        List<Validation> validationList = null;
+        if (userParameter.getMaxLength() != null || userParameter.getAllowableChars() != null) {
+            validationList = new ArrayList<Validation>();
+            Validation validation = new Validation();
+            if (userParameter.getMaxLength() != null) {
+                validation.setMaxLength(userParameter.getMaxLength().toString());
+            }
+            validation.setAllowableChars(userParameter.getAllowableChars());
+            validationList.add(validation);
+        }
+        return validationList;
+    }
 }
index 7678de1..48abeac 100644 (file)
 
 package org.onap.so.apihandlerinfra;
 
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.get;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
 import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertThat;
+import java.io.File;
 import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Paths;
 import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.List;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 import org.json.JSONException;
 import org.junit.Test;
+import org.onap.so.apihandlerinfra.workflowspecificationbeans.WorkflowInputParameter;
 import org.onap.so.apihandlerinfra.workflowspecificationbeans.WorkflowSpecifications;
+import org.onap.so.db.catalog.beans.ActivitySpec;
+import org.onap.so.db.catalog.beans.ActivitySpecUserParameters;
+import org.onap.so.db.catalog.beans.UserParameters;
+import org.onap.so.db.catalog.beans.Workflow;
+import org.onap.so.db.catalog.beans.WorkflowActivitySpecSequence;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.http.HttpEntity;
 import org.springframework.http.HttpHeaders;
 import org.springframework.http.HttpMethod;
 import org.springframework.http.ResponseEntity;
+import org.springframework.util.ResourceUtils;
 import org.springframework.web.util.UriComponentsBuilder;
 import com.fasterxml.jackson.core.JsonParseException;
 import com.fasterxml.jackson.databind.DeserializationFeature;
@@ -43,11 +59,16 @@ import com.fasterxml.jackson.databind.JsonMappingException;
 import com.fasterxml.jackson.databind.ObjectMapper;
 
 public class WorkflowSpecificationsHandlerTest extends BaseTest {
+    @Autowired
+    WorkflowSpecificationsHandler workflowSpecificationsHandler;
+
+    @Value("${wiremock.server.port}")
+    private String wiremockPort;
 
     private final String basePath = "onap/so/infra/workflowSpecifications/v1/workflows";
 
     @Test
-    public void getTasksTestByOriginalRequestId()
+    public void queryWorkflowSpecifications_Test_Success()
             throws ParseException, JSONException, JsonParseException, JsonMappingException, IOException {
 
         HttpHeaders headers = new HttpHeaders();
@@ -55,26 +76,191 @@ public class WorkflowSpecificationsHandlerTest extends BaseTest {
         headers.set("Content-Type", MediaType.APPLICATION_JSON);
         HttpEntity<String> entity = new HttpEntity<String>(null, headers);
 
+        wireMockServer.stubFor(get(urlMatching(
+                "/workflow/search/findWorkflowByModelUUID[?]vnfResourceModelUUID=b5fa707a-f55a-11e7-a796-005056856d52"))
+                        .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+                                .withBody(getWiremockResponseForCatalogdb("WorkflowSpecificationsQuery_Response.json"))
+                                .withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+        wireMockServer.stubFor(get(urlMatching("/workflow/1/workflowActivitySpecSequence"))
+                .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+                        .withBody(getWiremockResponseForCatalogdb("WorkflowActivitySpecSequence_Response.json"))
+                        .withStatus(org.apache.http.HttpStatus.SC_OK)));
+
         UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(basePath))
                 .queryParam("vnfModelVersionId", "b5fa707a-f55a-11e7-a796-005056856d52");
 
         ResponseEntity<String> response =
                 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
 
-        ObjectMapper mapper = new ObjectMapper();
+        assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
 
+        ObjectMapper mapper = new ObjectMapper();
         mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
 
         WorkflowSpecifications expectedResponse = mapper.readValue(
-                new String(Files.readAllBytes(Paths.get("src/test/resources/__files/WorkflowSpecifications.json"))),
+                new String(Files
+                        .readAllBytes(Paths.get("src/test/resources/__files/catalogdb/WorkflowSpecifications.json"))),
                 WorkflowSpecifications.class);
+        WorkflowSpecifications realResponse = mapper.readValue(response.getBody(), WorkflowSpecifications.class);
 
         assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
-        WorkflowSpecifications realResponse = mapper.readValue(response.getBody(), WorkflowSpecifications.class);
-        assertThat(realResponse, sameBeanAs(expectedResponse));
+        assertThat(expectedResponse, sameBeanAs(realResponse));
         assertEquals("application/json", response.getHeaders().get(HttpHeaders.CONTENT_TYPE).get(0));
         assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0));
         assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0));
         assertEquals("1.0.0", response.getHeaders().get("X-LatestVersion").get(0));
     }
+
+    @Test
+    public void mapWorkflowsToWorkflowSpecifications_Test_Success() throws Exception {
+        List<Workflow> workflows = new ArrayList<Workflow>();
+        Workflow workflow = new Workflow();
+        workflow.setArtifactUUID("ab6478e4-ea33-3346-ac12-ab121484a333");
+        workflow.setArtifactName("inPlaceSoftwareUpdate-1_0.bpmn");
+        workflow.setVersion(1.0);
+        workflow.setDescription("xyz xyz");
+        workflow.setName("inPlaceSoftwareUpdate");
+        workflow.setOperationName("inPlaceSoftwareUpdate");
+        workflow.setSource("sdc");
+        workflow.setResourceTarget("vnf");
+
+        UserParameters userParameter1 = new UserParameters();
+        userParameter1.setLabel("Operations Timeout");
+        userParameter1.setType("text");
+        userParameter1.setIsRequried(true);
+        userParameter1.setMaxLength(50);
+        userParameter1.setAllowableChars("someRegEx");
+        userParameter1.setName("operations_timeout");
+        userParameter1.setPayloadLocation("userParams");
+
+        UserParameters userParameter2 = new UserParameters();
+        userParameter2.setLabel("Existing Software Version");
+        userParameter2.setType("text");
+        userParameter2.setIsRequried(true);
+        userParameter2.setMaxLength(50);
+        userParameter2.setAllowableChars("someRegEx");
+        userParameter2.setName("existing_software_version");
+        userParameter2.setPayloadLocation("userParams");
+
+        UserParameters userParameter3 = new UserParameters();
+        userParameter3.setLabel("Cloud Owner");
+        userParameter3.setType("text");
+        userParameter3.setIsRequried(true);
+        userParameter3.setMaxLength(7);
+        userParameter3.setAllowableChars("someRegEx");
+        userParameter3.setName("cloudOwner");
+        userParameter3.setPayloadLocation("cloudConfiguration");
+
+        UserParameters userParameter4 = new UserParameters();
+        userParameter4.setLabel("Tenant/Project ID");
+        userParameter4.setType("text");
+        userParameter4.setIsRequried(true);
+        userParameter4.setMaxLength(36);
+        userParameter4.setAllowableChars("someRegEx");
+        userParameter4.setName("tenantId");
+        userParameter4.setPayloadLocation("cloudConfiguration");
+
+        UserParameters userParameter5 = new UserParameters();
+        userParameter5.setLabel("New Software Version");
+        userParameter5.setType("text");
+        userParameter5.setIsRequried(true);
+        userParameter5.setMaxLength(50);
+        userParameter5.setAllowableChars("someRegEx");
+        userParameter5.setName("new_software_version");
+        userParameter5.setPayloadLocation("userParams");
+
+        UserParameters userParameter6 = new UserParameters();
+        userParameter6.setLabel("Cloud Region ID");
+        userParameter6.setType("text");
+        userParameter6.setIsRequried(true);
+        userParameter6.setMaxLength(7);
+        userParameter6.setAllowableChars("someRegEx");
+        userParameter6.setName("lcpCloudRegionId");
+        userParameter6.setPayloadLocation("cloudConfiguration");
+
+
+        List<ActivitySpecUserParameters> activitySpecUserParameters = new ArrayList<ActivitySpecUserParameters>();
+
+        ActivitySpecUserParameters activitySpecUserParameter1 = new ActivitySpecUserParameters();
+        activitySpecUserParameter1.setUserParameters(userParameter1);
+        activitySpecUserParameters.add(activitySpecUserParameter1);
+
+        ActivitySpecUserParameters activitySpecUserParameter2 = new ActivitySpecUserParameters();
+        activitySpecUserParameter2.setUserParameters(userParameter2);
+        activitySpecUserParameters.add(activitySpecUserParameter2);
+
+        ActivitySpecUserParameters activitySpecUserParameter3 = new ActivitySpecUserParameters();
+        activitySpecUserParameter3.setUserParameters(userParameter3);
+        activitySpecUserParameters.add(activitySpecUserParameter3);
+
+
+        ActivitySpecUserParameters activitySpecUserParameter4 = new ActivitySpecUserParameters();
+        activitySpecUserParameter4.setUserParameters(userParameter4);
+        activitySpecUserParameters.add(activitySpecUserParameter4);
+
+        ActivitySpecUserParameters activitySpecUserParameter5 = new ActivitySpecUserParameters();
+        activitySpecUserParameter5.setUserParameters(userParameter5);
+        activitySpecUserParameters.add(activitySpecUserParameter5);
+
+        ActivitySpecUserParameters activitySpecUserParameter6 = new ActivitySpecUserParameters();
+        activitySpecUserParameter6.setUserParameters(userParameter6);
+        activitySpecUserParameters.add(activitySpecUserParameter6);
+
+        List<WorkflowActivitySpecSequence> workflowActivitySpecSequences =
+                new ArrayList<WorkflowActivitySpecSequence>();
+
+        ActivitySpec activitySpec1 = new ActivitySpec();
+        activitySpec1.setName("VNFQuiesceTrafficActivity");
+        activitySpec1.setDescription("Activity to QuiesceTraffic on VNF");
+        activitySpec1.setActivitySpecUserParameters(activitySpecUserParameters);
+        WorkflowActivitySpecSequence workflowActivitySpecSequence1 = new WorkflowActivitySpecSequence();
+        workflowActivitySpecSequence1.setActivitySpec(activitySpec1);
+        workflowActivitySpecSequences.add(workflowActivitySpecSequence1);
+
+        ActivitySpec activitySpec2 = new ActivitySpec();
+        activitySpec2.setName("VNFHealthCheckActivity");
+        activitySpec2.setDescription("Activity to HealthCheck VNF");
+        activitySpec2.setActivitySpecUserParameters(activitySpecUserParameters);
+        WorkflowActivitySpecSequence workflowActivitySpecSequence2 = new WorkflowActivitySpecSequence();
+        workflowActivitySpecSequence2.setActivitySpec(activitySpec2);
+        workflowActivitySpecSequences.add(workflowActivitySpecSequence2);
+
+        ActivitySpec activitySpec3 = new ActivitySpec();
+        activitySpec3.setName("FlowCompleteActivity");
+        activitySpec3.setDescription("Activity to Complete the BPMN Flow");
+        activitySpec3.setActivitySpecUserParameters(activitySpecUserParameters);
+        WorkflowActivitySpecSequence workflowActivitySpecSequence3 = new WorkflowActivitySpecSequence();
+        workflowActivitySpecSequence3.setActivitySpec(activitySpec3);
+        workflowActivitySpecSequences.add(workflowActivitySpecSequence3);
+
+        workflow.setWorkflowActivitySpecSequence(workflowActivitySpecSequences);
+        workflows.add(workflow);
+
+        WorkflowSpecifications workflowSpecifications =
+                workflowSpecificationsHandler.mapWorkflowsToWorkflowSpecifications(workflows);
+        ObjectMapper mapper = new ObjectMapper();
+
+        mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+        String workflowSpecificationsJson = mapper.writeValueAsString(workflowSpecifications);
+        WorkflowSpecifications expectedResult = mapper.readValue(
+                new String(Files
+                        .readAllBytes(Paths.get("src/test/resources/__files/catalogdb/WorkflowSpecifications.json"))),
+                WorkflowSpecifications.class);
+        String expectedResultJson = mapper.writeValueAsString(expectedResult);
+
+        JSONAssert.assertEquals(expectedResultJson, workflowSpecificationsJson, false);
+        assertThat(expectedResult, sameBeanAs(workflowSpecifications).ignoring(WorkflowInputParameter.class));
+    }
+
+    private String getWiremockResponseForCatalogdb(String file) {
+        try {
+            File resource = ResourceUtils.getFile("classpath:__files/catalogdb/" + file);
+            return new String(Files.readAllBytes(resource.toPath())).replaceAll("localhost:8090",
+                    "localhost:" + wiremockPort);
+        } catch (IOException e) {
+            e.printStackTrace();
+            return null;
+        }
+    }
 }
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowActivitySpecSequence_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowActivitySpecSequence_Response.json
new file mode 100644 (file)
index 0000000..3192865
--- /dev/null
@@ -0,0 +1,432 @@
+{
+       "_embedded": {
+       
+    "workflowActivitySpecSequence": [
+      {
+        "activitySpecId": null,
+        "workflowId": null,
+        "activitySpec": {
+          "name": "VNFQuiesceTrafficActivity",
+          "description": "Activity to QuiesceTraffic on VNF",
+          "version": null,
+          "created": null,
+          "workflowActivitySpecSequence": null,
+          "activitySpecActivitySpecCategories": null,
+          "activitySpecUserParameters": [
+            {
+              "activitySpecId": null,
+              "userParametersId": null,
+              "activitySpec": null,
+              "userParameters": {
+                "name": "operations_timeout",
+                "payloadLocation": "userParams",
+                "label": "Operations Timeout",
+                "type": "text",
+                "description": null,
+                "isRequried": true,
+                "maxLength": 50,
+                "allowableChars": "someRegEx",
+                "created": null,
+                "activitySpecUserParameters": null,
+                "id": null
+              },
+              "id": null
+            },
+            {
+              "activitySpecId": null,
+              "userParametersId": null,
+              "activitySpec": null,
+              "userParameters": {
+                "name": "existing_software_version",
+                "payloadLocation": "userParams",
+                "label": "Existing Software Version",
+                "type": "text",
+                "description": null,
+                "isRequried": true,
+                "maxLength": 50,
+                "allowableChars": "someRegEx",
+                "created": null,
+                "activitySpecUserParameters": null,
+                "id": null
+              },
+              "id": null
+            },
+            {
+              "activitySpecId": null,
+              "userParametersId": null,
+              "activitySpec": null,
+              "userParameters": {
+                "name": "cloudOwner",
+                "payloadLocation": "cloudConfiguration",
+                "label": "Cloud Owner",
+                "type": "text",
+                "description": null,
+                "isRequried": true,
+                "maxLength": 7,
+                "allowableChars": "someRegEx",
+                "created": null,
+                "activitySpecUserParameters": null,
+                "id": null
+              },
+              "id": null
+            },
+            {
+              "activitySpecId": null,
+              "userParametersId": null,
+              "activitySpec": null,
+              "userParameters": {
+                "name": "tenantId",
+                "payloadLocation": "cloudConfiguration",
+                "label": "Tenant/Project ID",
+                "type": "text",
+                "description": null,
+                "isRequried": true,
+                "maxLength": 36,
+                "allowableChars": "someRegEx",
+                "created": null,
+                "activitySpecUserParameters": null,
+                "id": null
+              },
+              "id": null
+            },
+            {
+              "activitySpecId": null,
+              "userParametersId": null,
+              "activitySpec": null,
+              "userParameters": {
+                "name": "new_software_version",
+                "payloadLocation": "userParams",
+                "label": "New Software Version",
+                "type": "text",
+                "description": null,
+                "isRequried": true,
+                "maxLength": 50,
+                "allowableChars": "someRegEx",
+                "created": null,
+                "activitySpecUserParameters": null,
+                "id": null
+              },
+              "id": null
+            },
+            {
+              "activitySpecId": null,
+              "userParametersId": null,
+              "activitySpec": null,
+              "userParameters": {
+                "name": "lcpCloudRegionId",
+                "payloadLocation": "cloudConfiguration",
+                "label": "Cloud Region ID",
+                "type": "text",
+                "description": null,
+                "isRequried": true,
+                "maxLength": 7,
+                "allowableChars": "someRegEx",
+                "created": null,
+                "activitySpecUserParameters": null,
+                "id": null
+              },
+              "id": null
+            }
+          ],
+          "activitySpecActivitySpecParameters": null,
+          "id": null
+        },
+        "workflow": null,
+        "id": null,
+        "_links": {
+    "self": {
+      "href": "http://localhost:8090/workflow/search/findWorkflowByModelUUID?vnfResourceModelUUID=b5fa707a-f55a-11e7-a796-005056856d52"
+    },    
+    "workflowActivitySpecSequence": {
+      "href": "http://localhost:8090/workflow/b5fa707a-f55a-11e7-a796-005056856d52/workflowActivitySpecSequence"
+    }
+  
+  }
+        
+      },
+      {
+        "activitySpecId": null,
+        "workflowId": null,
+        "activitySpec": {
+          "name": "VNFHealthCheckActivity",
+          "description": "Activity to HealthCheck VNF",
+          "version": null,
+          "created": null,
+          "workflowActivitySpecSequence": null,
+          "activitySpecActivitySpecCategories": null,
+          "activitySpecUserParameters": [
+            {
+              "activitySpecId": null,
+              "userParametersId": null,
+              "activitySpec": null,
+              "userParameters": {
+                "name": "operations_timeout",
+                "payloadLocation": "userParams",
+                "label": "Operations Timeout",
+                "type": "text",
+                "description": null,
+                "isRequried": true,
+                "maxLength": 50,
+                "allowableChars": "someRegEx",
+                "created": null,
+                "activitySpecUserParameters": null,
+                "id": null
+              },
+              "id": null
+            },
+            {
+              "activitySpecId": null,
+              "userParametersId": null,
+              "activitySpec": null,
+              "userParameters": {
+                "name": "existing_software_version",
+                "payloadLocation": "userParams",
+                "label": "Existing Software Version",
+                "type": "text",
+                "description": null,
+                "isRequried": true,
+                "maxLength": 50,
+                "allowableChars": "someRegEx",
+                "created": null,
+                "activitySpecUserParameters": null,
+                "id": null
+              },
+              "id": null
+            },
+            {
+              "activitySpecId": null,
+              "userParametersId": null,
+              "activitySpec": null,
+              "userParameters": {
+                "name": "cloudOwner",
+                "payloadLocation": "cloudConfiguration",
+                "label": "Cloud Owner",
+                "type": "text",
+                "description": null,
+                "isRequried": true,
+                "maxLength": 7,
+                "allowableChars": "someRegEx",
+                "created": null,
+                "activitySpecUserParameters": null,
+                "id": null
+              },
+              "id": null
+            },
+            {
+              "activitySpecId": null,
+              "userParametersId": null,
+              "activitySpec": null,
+              "userParameters": {
+                "name": "tenantId",
+                "payloadLocation": "cloudConfiguration",
+                "label": "Tenant/Project ID",
+                "type": "text",
+                "description": null,
+                "isRequried": true,
+                "maxLength": 36,
+                "allowableChars": "someRegEx",
+                "created": null,
+                "activitySpecUserParameters": null,
+                "id": null
+              },
+              "id": null
+            },
+            {
+              "activitySpecId": null,
+              "userParametersId": null,
+              "activitySpec": null,
+              "userParameters": {
+                "name": "new_software_version",
+                "payloadLocation": "userParams",
+                "label": "New Software Version",
+                "type": "text",
+                "description": null,
+                "isRequried": true,
+                "maxLength": 50,
+                "allowableChars": "someRegEx",
+                "created": null,
+                "activitySpecUserParameters": null,
+                "id": null
+              },
+              "id": null
+            },
+            {
+              "activitySpecId": null,
+              "userParametersId": null,
+              "activitySpec": null,
+              "userParameters": {
+                "name": "lcpCloudRegionId",
+                "payloadLocation": "cloudConfiguration",
+                "label": "Cloud Region ID",
+                "type": "text",
+                "description": null,
+                "isRequried": true,
+                "maxLength": 7,
+                "allowableChars": "someRegEx",
+                "created": null,
+                "activitySpecUserParameters": null,
+                "id": null
+              },
+              "id": null
+            }
+          ],
+          "activitySpecActivitySpecParameters": null,
+          "id": null
+        },
+        "workflow": null,
+        "id": null,
+        "_links": {
+    "self": {
+      "href": "http://localhost:8090/workflow/search/findWorkflowByModelUUID?vnfResourceModelUUID=b5fa707a-f55a-11e7-a796-005056856d52"
+    },    
+    "workflowActivitySpecSequence": {
+      "href": "http://localhost:8090/workflow/b5fa707a-f55a-11e7-a796-005056856d52/workflowActivitySpecSequence"
+    }
+  
+  }
+      },
+      {
+        "activitySpecId": null,
+        "workflowId": null,
+        "activitySpec": {
+          "name": "FlowCompleteActivity",
+          "description": "Activity to Complete the BPMN Flow",
+          "version": null,
+          "created": null,
+          "workflowActivitySpecSequence": null,
+          "activitySpecActivitySpecCategories": null,
+          "activitySpecUserParameters": [
+            {
+              "activitySpecId": null,
+              "userParametersId": null,
+              "activitySpec": null,
+              "userParameters": {
+                "name": "operations_timeout",
+                "payloadLocation": "userParams",
+                "label": "Operations Timeout",
+                "type": "text",
+                "description": null,
+                "isRequried": true,
+                "maxLength": 50,
+                "allowableChars": "someRegEx",
+                "created": null,
+                "activitySpecUserParameters": null,
+                "id": null
+              },
+              "id": null
+            },
+            {
+              "activitySpecId": null,
+              "userParametersId": null,
+              "activitySpec": null,
+              "userParameters": {
+                "name": "existing_software_version",
+                "payloadLocation": "userParams",
+                "label": "Existing Software Version",
+                "type": "text",
+                "description": null,
+                "isRequried": true,
+                "maxLength": 50,
+                "allowableChars": "someRegEx",
+                "created": null,
+                "activitySpecUserParameters": null,
+                "id": null
+              },
+              "id": null
+            },
+            {
+              "activitySpecId": null,
+              "userParametersId": null,
+              "activitySpec": null,
+              "userParameters": {
+                "name": "cloudOwner",
+                "payloadLocation": "cloudConfiguration",
+                "label": "Cloud Owner",
+                "type": "text",
+                "description": null,
+                "isRequried": true,
+                "maxLength": 7,
+                "allowableChars": "someRegEx",
+                "created": null,
+                "activitySpecUserParameters": null,
+                "id": null
+              },
+              "id": null
+            },
+            {
+              "activitySpecId": null,
+              "userParametersId": null,
+              "activitySpec": null,
+              "userParameters": {
+                "name": "tenantId",
+                "payloadLocation": "cloudConfiguration",
+                "label": "Tenant/Project ID",
+                "type": "text",
+                "description": null,
+                "isRequried": true,
+                "maxLength": 36,
+                "allowableChars": "someRegEx",
+                "created": null,
+                "activitySpecUserParameters": null,
+                "id": null
+              },
+              "id": null
+            },
+            {
+              "activitySpecId": null,
+              "userParametersId": null,
+              "activitySpec": null,
+              "userParameters": {
+                "name": "new_software_version",
+                "payloadLocation": "userParams",
+                "label": "New Software Version",
+                "type": "text",
+                "description": null,
+                "isRequried": true,
+                "maxLength": 50,
+                "allowableChars": "someRegEx",
+                "created": null,
+                "activitySpecUserParameters": null,
+                "id": null
+              },
+              "id": null
+            },
+            {
+              "activitySpecId": null,
+              "userParametersId": null,
+              "activitySpec": null,
+              "userParameters": {
+                "name": "lcpCloudRegionId",
+                "payloadLocation": "cloudConfiguration",
+                "label": "Cloud Region ID",
+                "type": "text",
+                "description": null,
+                "isRequried": true,
+                "maxLength": 7,
+                "allowableChars": "someRegEx",
+                "created": null,
+                "activitySpecUserParameters": null,
+                "id": null
+              },
+              "id": null
+            }
+          ],
+          "activitySpecActivitySpecParameters": null,
+          "id": null
+        },
+        "workflow": null,
+        "id": null,
+        "_links": {
+    "self": {
+      "href": "http://localhost:8090/workflow/search/findWorkflowByModelUUID?vnfResourceModelUUID=b5fa707a-f55a-11e7-a796-005056856d52"
+    },    
+    "workflowActivitySpecSequence": {
+      "href": "http://localhost:8090/workflow/b5fa707a-f55a-11e7-a796-005056856d52/workflowActivitySpecSequence"
+    }
+  
+  }
+      }
+    ]
+  
+}
+}
\ No newline at end of file
           }
         ],
         "workflowInputParameters": [
-          {
-            "label": "Cloud Owner",
+               {
+            "label": "Operations Timeout",
             "inputType": "text",
             "required": true,
             "validation": [
               {
-                "maxLength": "7",
+                "maxLength": "50",
                 "allowableChars": "someRegEx"
               }
             ],
-            "soFieldName": "cloudOwner",
-            "soPayloadLocation": "cloudConfiguration"
-          },
+            "soFieldName": "operations_timeout",
+            "soPayloadLocation": "userParams"
+          },             
           {
-            "label": "Cloud Region ID",
+            "label": "Existing Software Version",
             "inputType": "text",
             "required": true,
             "validation": [
               {
-                "maxLength": "7",
+                "maxLength": "50",
                 "allowableChars": "someRegEx"
               }
             ],
-            "soFieldName": "lcpCloudRegionId",
-            "soPayloadLocation": "cloudConfiguration"
-          },
+            "soFieldName": "existing_software_version",
+            "soPayloadLocation": "userParams"
+          },   
           {
-            "label": "Tenant/Project ID",
+            "label": "Cloud Owner",
             "inputType": "text",
             "required": true,
             "validation": [
               {
-                "maxLength": "36",
+                "maxLength": "7",
                 "allowableChars": "someRegEx"
               }
             ],
-            "soFieldName": "tenantId",
+            "soFieldName": "cloudOwner",
             "soPayloadLocation": "cloudConfiguration"
-          },
+          },          
           {
-            "label": "Operations Timeout",
+            "label": "Tenant/Project ID",
             "inputType": "text",
             "required": true,
             "validation": [
               {
-                "maxLength": "50",
+                "maxLength": "36",
                 "allowableChars": "someRegEx"
               }
             ],
-            "soFieldName": "operations_timeout",
-            "soPayloadLocation": "userParams"
-          },
+            "soFieldName": "tenantId",
+            "soPayloadLocation": "cloudConfiguration"
+          },         
           {
-            "label": "Existing Software Version",
+            "label": "New Software Version",
             "inputType": "text",
             "required": true,
             "validation": [
                 "allowableChars": "someRegEx"
               }
             ],
-            "soFieldName": "existing_software_version",
+            "soFieldName": "new_software_version",
             "soPayloadLocation": "userParams"
           },
-          {
-            "label": "New Software Version",
+           {
+            "label": "Cloud Region ID",
             "inputType": "text",
             "required": true,
             "validation": [
               {
-                "maxLength": "50",
+                "maxLength": "7",
                 "allowableChars": "someRegEx"
               }
             ],
-            "soFieldName": "new_software_version",
-            "soPayloadLocation": "userParams"
-          }
+            "soFieldName": "lcpCloudRegionId",
+            "soPayloadLocation": "cloudConfiguration"
+          }      
         ]
       }
-    },
-    {
-      "workflowSpecification": {}
     }
   ]
 }
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowSpecificationsQuery_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowSpecificationsQuery_Response.json
new file mode 100644 (file)
index 0000000..c123656
--- /dev/null
@@ -0,0 +1,468 @@
+{
+       "_embedded": {
+       "workflows" :[
+  {
+    "artifactUUID": "ab6478e4-ea33-3346-ac12-ab121484a333",
+    "artifactName": "inPlaceSoftwareUpdate-1_0.bpmn",
+    "name": "inPlaceSoftwareUpdate",
+    "operationName": "inPlaceSoftwareUpdate",
+    "version": 1,
+    "description": "xyz xyz",
+    "body": null,
+    "resourceTarget": "vnf",
+    "source": "sdc",
+    "timeoutMinutes": null,
+    "artifactChecksum": null,
+    "created": null,
+    "vnfResourceWorkflow": null,
+    "workflowActivitySpecSequence": [
+      {
+        "activitySpecId": null,
+        "workflowId": null,
+        "activitySpec": {
+          "name": "VNFQuiesceTrafficActivity",
+          "description": "Activity to QuiesceTraffic on VNF",
+          "version": null,
+          "created": null,
+          "workflowActivitySpecSequence": null,
+          "activitySpecActivitySpecCategories": null,
+          "activitySpecUserParameters": [
+            {
+              "activitySpecId": null,
+              "userParametersId": null,
+              "activitySpec": null,
+              "userParameters": {
+                "name": "operations_timeout",
+                "payloadLocation": "userParams",
+                "label": "Operations Timeout",
+                "type": "text",
+                "description": null,
+                "isRequried": true,
+                "maxLength": 50,
+                "allowableChars": "someRegEx",
+                "created": null,
+                "activitySpecUserParameters": null,
+                "id": null
+              },
+              "id": null
+            },
+            {
+              "activitySpecId": null,
+              "userParametersId": null,
+              "activitySpec": null,
+              "userParameters": {
+                "name": "existing_software_version",
+                "payloadLocation": "userParams",
+                "label": "Existing Software Version",
+                "type": "text",
+                "description": null,
+                "isRequried": true,
+                "maxLength": 50,
+                "allowableChars": "someRegEx",
+                "created": null,
+                "activitySpecUserParameters": null,
+                "id": null
+              },
+              "id": null
+            },
+            {
+              "activitySpecId": null,
+              "userParametersId": null,
+              "activitySpec": null,
+              "userParameters": {
+                "name": "cloudOwner",
+                "payloadLocation": "cloudConfiguration",
+                "label": "Cloud Owner",
+                "type": "text",
+                "description": null,
+                "isRequried": true,
+                "maxLength": 7,
+                "allowableChars": "someRegEx",
+                "created": null,
+                "activitySpecUserParameters": null,
+                "id": null
+              },
+              "id": null
+            },
+            {
+              "activitySpecId": null,
+              "userParametersId": null,
+              "activitySpec": null,
+              "userParameters": {
+                "name": "tenantId",
+                "payloadLocation": "cloudConfiguration",
+                "label": "Tenant/Project ID",
+                "type": "text",
+                "description": null,
+                "isRequried": true,
+                "maxLength": 36,
+                "allowableChars": "someRegEx",
+                "created": null,
+                "activitySpecUserParameters": null,
+                "id": null
+              },
+              "id": null
+            },
+            {
+              "activitySpecId": null,
+              "userParametersId": null,
+              "activitySpec": null,
+              "userParameters": {
+                "name": "new_software_version",
+                "payloadLocation": "userParams",
+                "label": "New Software Version",
+                "type": "text",
+                "description": null,
+                "isRequried": true,
+                "maxLength": 50,
+                "allowableChars": "someRegEx",
+                "created": null,
+                "activitySpecUserParameters": null,
+                "id": null
+              },
+              "id": null
+            },
+            {
+              "activitySpecId": null,
+              "userParametersId": null,
+              "activitySpec": null,
+              "userParameters": {
+                "name": "lcpCloudRegionId",
+                "payloadLocation": "cloudConfiguration",
+                "label": "Cloud Region ID",
+                "type": "text",
+                "description": null,
+                "isRequried": true,
+                "maxLength": 7,
+                "allowableChars": "someRegEx",
+                "created": null,
+                "activitySpecUserParameters": null,
+                "id": null
+              },
+              "id": null
+            }
+          ],
+          "activitySpecActivitySpecParameters": null,
+          "id": null
+        },
+        "workflow": null,
+        "id": null,
+        "_links": {
+    "self": {
+      "href": "http://localhost:8090/workflow/search/findWorkflowByModelUUID[?]vnfResourceModelUUID=b5fa707a-f55a-11e7-a796-005056856d52"
+    },    
+    "workflowActivitySpecSequence": {
+      "href": "http://localhost:8090/workflow/b5fa707a-f55a-11e7-a796-005056856d52/workflowActivitySpecSequence"
+    }
+  
+  }
+        
+      },
+      {
+        "activitySpecId": null,
+        "workflowId": null,
+        "activitySpec": {
+          "name": "VNFHealthCheckActivity",
+          "description": "Activity to HealthCheck VNF",
+          "version": null,
+          "created": null,
+          "workflowActivitySpecSequence": null,
+          "activitySpecActivitySpecCategories": null,
+          "activitySpecUserParameters": [
+            {
+              "activitySpecId": null,
+              "userParametersId": null,
+              "activitySpec": null,
+              "userParameters": {
+                "name": "operations_timeout",
+                "payloadLocation": "userParams",
+                "label": "Operations Timeout",
+                "type": "text",
+                "description": null,
+                "isRequried": true,
+                "maxLength": 50,
+                "allowableChars": "someRegEx",
+                "created": null,
+                "activitySpecUserParameters": null,
+                "id": null
+              },
+              "id": null
+            },
+            {
+              "activitySpecId": null,
+              "userParametersId": null,
+              "activitySpec": null,
+              "userParameters": {
+                "name": "existing_software_version",
+                "payloadLocation": "userParams",
+                "label": "Existing Software Version",
+                "type": "text",
+                "description": null,
+                "isRequried": true,
+                "maxLength": 50,
+                "allowableChars": "someRegEx",
+                "created": null,
+                "activitySpecUserParameters": null,
+                "id": null
+              },
+              "id": null
+            },
+            {
+              "activitySpecId": null,
+              "userParametersId": null,
+              "activitySpec": null,
+              "userParameters": {
+                "name": "cloudOwner",
+                "payloadLocation": "cloudConfiguration",
+                "label": "Cloud Owner",
+                "type": "text",
+                "description": null,
+                "isRequried": true,
+                "maxLength": 7,
+                "allowableChars": "someRegEx",
+                "created": null,
+                "activitySpecUserParameters": null,
+                "id": null
+              },
+              "id": null
+            },
+            {
+              "activitySpecId": null,
+              "userParametersId": null,
+              "activitySpec": null,
+              "userParameters": {
+                "name": "tenantId",
+                "payloadLocation": "cloudConfiguration",
+                "label": "Tenant/Project ID",
+                "type": "text",
+                "description": null,
+                "isRequried": true,
+                "maxLength": 36,
+                "allowableChars": "someRegEx",
+                "created": null,
+                "activitySpecUserParameters": null,
+                "id": null
+              },
+              "id": null
+            },
+            {
+              "activitySpecId": null,
+              "userParametersId": null,
+              "activitySpec": null,
+              "userParameters": {
+                "name": "new_software_version",
+                "payloadLocation": "userParams",
+                "label": "New Software Version",
+                "type": "text",
+                "description": null,
+                "isRequried": true,
+                "maxLength": 50,
+                "allowableChars": "someRegEx",
+                "created": null,
+                "activitySpecUserParameters": null,
+                "id": null
+              },
+              "id": null
+            },
+            {
+              "activitySpecId": null,
+              "userParametersId": null,
+              "activitySpec": null,
+              "userParameters": {
+                "name": "lcpCloudRegionId",
+                "payloadLocation": "cloudConfiguration",
+                "label": "Cloud Region ID",
+                "type": "text",
+                "description": null,
+                "isRequried": true,
+                "maxLength": 7,
+                "allowableChars": "someRegEx",
+                "created": null,
+                "activitySpecUserParameters": null,
+                "id": null
+              },
+              "id": null
+            }
+          ],
+          "activitySpecActivitySpecParameters": null,
+          "id": null
+        },
+        "workflow": null,
+        "id": null,
+        "_links": {
+    "self": {
+      "href": "http://localhost:8090/workflow/search/findWorkflowByModelUUID?vnfResourceModelUUID=b5fa707a-f55a-11e7-a796-005056856d52"
+    },    
+    "workflowActivitySpecSequence": {
+      "href": "http://localhost:8090/workflow/b5fa707a-f55a-11e7-a796-005056856d52/workflowActivitySpecSequence"
+    }
+  
+  }
+      },
+      {
+        "activitySpecId": null,
+        "workflowId": null,
+        "activitySpec": {
+          "name": "FlowCompleteActivity",
+          "description": "Activity to Complete the BPMN Flow",
+          "version": null,
+          "created": null,
+          "workflowActivitySpecSequence": null,
+          "activitySpecActivitySpecCategories": null,
+          "activitySpecUserParameters": [
+            {
+              "activitySpecId": null,
+              "userParametersId": null,
+              "activitySpec": null,
+              "userParameters": {
+                "name": "operations_timeout",
+                "payloadLocation": "userParams",
+                "label": "Operations Timeout",
+                "type": "text",
+                "description": null,
+                "isRequried": true,
+                "maxLength": 50,
+                "allowableChars": "someRegEx",
+                "created": null,
+                "activitySpecUserParameters": null,
+                "id": null
+              },
+              "id": null
+            },
+            {
+              "activitySpecId": null,
+              "userParametersId": null,
+              "activitySpec": null,
+              "userParameters": {
+                "name": "existing_software_version",
+                "payloadLocation": "userParams",
+                "label": "Existing Software Version",
+                "type": "text",
+                "description": null,
+                "isRequried": true,
+                "maxLength": 50,
+                "allowableChars": "someRegEx",
+                "created": null,
+                "activitySpecUserParameters": null,
+                "id": null
+              },
+              "id": null
+            },
+            {
+              "activitySpecId": null,
+              "userParametersId": null,
+              "activitySpec": null,
+              "userParameters": {
+                "name": "cloudOwner",
+                "payloadLocation": "cloudConfiguration",
+                "label": "Cloud Owner",
+                "type": "text",
+                "description": null,
+                "isRequried": true,
+                "maxLength": 7,
+                "allowableChars": "someRegEx",
+                "created": null,
+                "activitySpecUserParameters": null,
+                "id": null
+              },
+              "id": null
+            },
+            {
+              "activitySpecId": null,
+              "userParametersId": null,
+              "activitySpec": null,
+              "userParameters": {
+                "name": "tenantId",
+                "payloadLocation": "cloudConfiguration",
+                "label": "Tenant/Project ID",
+                "type": "text",
+                "description": null,
+                "isRequried": true,
+                "maxLength": 36,
+                "allowableChars": "someRegEx",
+                "created": null,
+                "activitySpecUserParameters": null,
+                "id": null
+              },
+              "id": null
+            },
+            {
+              "activitySpecId": null,
+              "userParametersId": null,
+              "activitySpec": null,
+              "userParameters": {
+                "name": "new_software_version",
+                "payloadLocation": "userParams",
+                "label": "New Software Version",
+                "type": "text",
+                "description": null,
+                "isRequried": true,
+                "maxLength": 50,
+                "allowableChars": "someRegEx",
+                "created": null,
+                "activitySpecUserParameters": null,
+                "id": null
+              },
+              "id": null
+            },
+            {
+              "activitySpecId": null,
+              "userParametersId": null,
+              "activitySpec": null,
+              "userParameters": {
+                "name": "lcpCloudRegionId",
+                "payloadLocation": "cloudConfiguration",
+                "label": "Cloud Region ID",
+                "type": "text",
+                "description": null,
+                "isRequried": true,
+                "maxLength": 7,
+                "allowableChars": "someRegEx",
+                "created": null,
+                "activitySpecUserParameters": null,
+                "id": null
+              },
+              "id": null
+            }
+          ],
+          "activitySpecActivitySpecParameters": null,
+          "id": null
+        },
+        "workflow": null,
+        "id": null,
+        "_links": {
+    "self": {
+      "href": "http://localhost:8090/workflow/search/findWorkflowByModelUUID?vnfResourceModelUUID=b5fa707a-f55a-11e7-a796-005056856d52"
+    },    
+    "workflowActivitySpecSequence": {
+      "href": "http://localhost:8090/workflow/b5fa707a-f55a-11e7-a796-005056856d52/workflowActivitySpecSequence"
+    }
+  
+  }
+      }
+    ],
+    "id": null,
+  "_links": {
+    "self": {
+      "href": "http://localhost:8090/workflow/search/findWorkflowByModelUUID?vnfResourceModelUUID=b5fa707a-f55a-11e7-a796-005056856d52"
+    },    
+    "workflowActivitySpecSequence": {
+      "href": "http://localhost:8090/workflow/1/workflowActivitySpecSequence"
+    }
+    
+   }
+  
+  }
+]
+},
+"_links": {
+    "self": {
+      "href": "http://localhost:8090/workflow/search/findWorkflowByModelUUID?vnfResourceModelUUID=b5fa707a-f55a-11e7-a796-005056856d52"
+    },    
+    "workflowActivitySpecSequence": {
+      "href": "http://localhost:8090/workflow/b5fa707a-f55a-11e7-a796-005056856d52/workflowActivitySpecSequence"
+    }
+  
+  }
+}
\ No newline at end of file
index f75ccf0..a2ca4a3 100644 (file)
@@ -190,6 +190,7 @@ public class CatalogDbClient {
     private String findServiceByServiceInstanceId = "/findServiceByServiceInstanceId";
     private String findPnfResourceCustomizationByModelUuid = "/findPnfResourceCustomizationByModelUuid";
     private String findWorkflowByArtifactUUID = "/findByArtifactUUID";
+    private String findWorkflowByModelUUID = "/findWorkflowByModelUUID";
 
     private String serviceURI;
     private String vfModuleURI;
@@ -330,6 +331,7 @@ public class CatalogDbClient {
                 endpoint + PNF_RESOURCE_CUSTOMIZATION + SEARCH + findPnfResourceCustomizationByModelUuid;
 
         findWorkflowByArtifactUUID = endpoint + WORKFLOW + SEARCH + findWorkflowByArtifactUUID;
+        findWorkflowByModelUUID = endpoint + WORKFLOW + SEARCH + findWorkflowByModelUUID;
 
         serviceURI = endpoint + SERVICE + URI_SEPARATOR;
         vfModuleURI = endpoint + VFMODULE + URI_SEPARATOR;
@@ -872,4 +874,9 @@ public class CatalogDbClient {
         return this.getSingleResource(workflowClient, getUri(UriBuilder.fromUri(findWorkflowByArtifactUUID)
                 .queryParam(ARTIFACT_UUID, artifactUUID).build().toString()));
     }
+
+    public List<Workflow> findWorkflowByModelUUID(String vnfResourceModelUUID) {
+        return this.getMultipleResources(workflowClient, getUri(UriBuilder.fromUri(findWorkflowByModelUUID)
+                .queryParam(VNF_RESOURCE_MODEL_UUID, vnfResourceModelUUID).build().toString()));
+    }
 }
index b73896a..fb5f202 100644 (file)
 
 package org.onap.so.db.catalog.data.repository;
 
+import java.util.List;
 import org.onap.so.db.catalog.beans.Workflow;
 import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.repository.query.Param;
 import org.springframework.data.rest.core.annotation.RepositoryRestResource;
 
 @RepositoryRestResource(collectionResourceRel = "workflow", path = "workflow")
 public interface WorkflowRepository extends JpaRepository<Workflow, String> {
+
     Workflow findByArtifactUUID(String artifactUUID);
+
+    /**
+     * Used to fetch the @{link Workflow} by the Model UUID.
+     *
+     * This operation is required by {@link org.onap.so.db.catalog.client.CatalogDbClient} to provide Workflow based on
+     * model UUID without projection.
+     *
+     * @param vnfResourceModelUUIDmodel UUID
+     * @return List of Workflow
+     */
+    @Query(value = "select b.* from vnf_resource_to_workflow a join workflow b where a.WORKFLOW_ID = b.ID and a.VNF_RESOURCE_MODEL_UUID = ?1",
+            nativeQuery = true)
+    List<Workflow> findWorkflowByModelUUID(String vnfResourceModelUUID);
 }
index d541627..4f31e4b 100644 (file)
@@ -18,12 +18,10 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import java.util.List;
+import org.junit.Assert;
 import org.junit.Test;
 import org.onap.so.db.catalog.BaseTest;
-import org.onap.so.db.catalog.beans.PnfResource;
-import org.onap.so.db.catalog.beans.PnfResourceCustomization;
 import org.onap.so.db.catalog.beans.Workflow;
-import org.onap.so.db.catalog.exceptions.NoEntityFoundException;
 import org.springframework.beans.factory.annotation.Autowired;
 
 public class WorkflowRepositoryTest extends BaseTest {
@@ -38,4 +36,14 @@ public class WorkflowRepositoryTest extends BaseTest {
         assertEquals("artifactName", "testingWorkflow", workflow.getArtifactName());
     }
 
+    @Test
+    public void findByVnfResourceModelUUIDTest() throws Exception {
+        List<Workflow> workflows = workflowRepository.findWorkflowByModelUUID("ff2ae348-214a-11e7-93ae-92361f002671");
+
+        Assert.assertTrue(workflows != null);
+        Assert.assertTrue(workflows.size() != 0);
+
+        Assert.assertTrue("testingWorkflow".equals(workflows.get(0).getArtifactName()));
+    }
+
 }
index ade183e..825b541 100644 (file)
@@ -741,3 +741,12 @@ insert into pnf_resource_customization_to_service(service_model_uuid, resource_m
 
 insert into workflow(artifact_uuid, artifact_name, name, operation_name, version, description, body, resource_target, source) values
 ('5b0c4322-643d-4c9f-b184-4516049e99b1', 'testingWorkflow', 'testingWorkflow', 'create', 1, 'Test Workflow', null, 'vnf', 'sdc');
+
+insert into vnf_resource_to_workflow(vnf_resource_model_uuid, workflow_id) values
+('ff2ae348-214a-11e7-93ae-92361f002671', '1');
+
+insert into activity_spec(name, description, version) values
+('testActivity1', 'Test Activity 1', 1);
+
+insert into workflow_activity_spec_sequence(workflow_id, activity_spec_id, seq_no) values
+(1, 1, 1);
index d5a73b0..92979f4 100644 (file)
@@ -1234,6 +1234,138 @@ CREATE TABLE IF NOT EXISTS `vnf_resource_to_workflow` (
   CONSTRAINT `fk_vnf_resource_to_workflow__workflow1` FOREIGN KEY (`WORKFLOW_ID`) REFERENCES `workflow` (`ID`) ON DELETE CASCADE ON UPDATE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
 
+CREATE TABLE IF NOT EXISTS `activity_spec` (
+  `ID` INT(11) NOT NULL AUTO_INCREMENT,
+  `NAME` VARCHAR(200) NOT NULL,
+  `DESCRIPTION` VARCHAR(1200) NOT NULL,
+  `VERSION` DOUBLE NOT NULL,
+  `CREATION_TIMESTAMP` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+  PRIMARY KEY (`ID`),
+  UNIQUE INDEX `UK_activity_spec` (`NAME` ASC, `VERSION` ASC))
+ENGINE = InnoDB
+DEFAULT CHARACTER SET = latin1;
+
+CREATE TABLE IF NOT EXISTS `user_parameters` (
+  `ID` INT(11) NOT NULL AUTO_INCREMENT,
+  `NAME` VARCHAR(200) NOT NULL,
+  `PAYLOAD_LOCATION` VARCHAR(500) NULL,
+  `LABEL` VARCHAR(200) NOT NULL,
+  `TYPE` VARCHAR(200) NOT NULL,
+  `DESCRIPTION` VARCHAR(1200) NULL,
+  `IS_REQUIRED` TINYINT(1) NOT NULL,
+  `MAX_LENGTH` INT(11) NULL,
+  `ALLOWABLE_CHARS` VARCHAR(200) NULL,
+  `CREATION_TIMESTAMP` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+  PRIMARY KEY (`ID`),
+  UNIQUE INDEX `UK_user_parameters` (`NAME` ASC))
+ENGINE = InnoDB
+DEFAULT CHARACTER SET = latin1;
+
+CREATE TABLE IF NOT EXISTS `workflow_activity_spec_sequence` (
+  `ID` INT(11) NOT NULL AUTO_INCREMENT,
+  `WORKFLOW_ID` INT(11) NOT NULL,
+  `ACTIVITY_SPEC_ID` INT(11) NOT NULL,
+  `SEQ_NO` INT(11) NOT NULL,
+  PRIMARY KEY (`ID`),
+  UNIQUE INDEX `UK_workflow_activity_spec_sequence` (`WORKFLOW_ID` ASC, `ACTIVITY_SPEC_ID` ASC, `SEQ_NO` ASC),
+  INDEX `fk_workflow_activity_spec_sequence__activity_spec_idx` (`ACTIVITY_SPEC_ID` ASC),
+  INDEX `fk_workflow_activity_spec_sequence__workflow_actifact_uuid_idx` (`WORKFLOW_ID` ASC),
+  CONSTRAINT `fk_workflow_activity_spec_sequence__activity_spec1`
+    FOREIGN KEY (`ACTIVITY_SPEC_ID`)
+    REFERENCES `activity_spec` (`ID`)
+    ON DELETE CASCADE
+    ON UPDATE CASCADE,
+  CONSTRAINT `fk_workflow_activity_spec_sequence__workflow1`
+    FOREIGN KEY (`WORKFLOW_ID`)
+    REFERENCES `workflow` (`ID`)
+    ON DELETE CASCADE
+    ON UPDATE CASCADE)
+ENGINE = InnoDB
+DEFAULT CHARACTER SET = latin1;
+
+CREATE TABLE IF NOT EXISTS `activity_spec_parameters` (
+  `ID` INT(11) NOT NULL AUTO_INCREMENT,
+  `NAME` VARCHAR(200) NOT NULL,
+  `TYPE` VARCHAR(200) NOT NULL,
+  `DIRECTION` VARCHAR(200) NULL,
+  `DESCRIPTION` VARCHAR(1200) NULL,
+  `CREATION_TIMESTAMP` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+  PRIMARY KEY (`ID`),
+  UNIQUE INDEX `UK_activity_spec_parameters` (`NAME` ASC, `DIRECTION` ASC))
+ENGINE = InnoDB
+DEFAULT CHARACTER SET = latin1;
+
+CREATE TABLE IF NOT EXISTS `activity_spec_categories` (
+  `ID` INT(11) NOT NULL,
+  `NAME` VARCHAR(200) NOT NULL,
+  PRIMARY KEY (`ID`),
+  UNIQUE INDEX `UK_activity_spec_categories` (`NAME` ASC))
+ENGINE = InnoDB
+DEFAULT CHARACTER SET = latin1;
+
+CREATE TABLE IF NOT EXISTS `activity_spec_to_activity_spec_categories` (
+  `ID` INT(11) NOT NULL,
+  `ACTIVITY_SPEC_ID` INT(11) NOT NULL,
+  `ACTIVITY_SPEC_CATEGORIES_ID` INT(11) NOT NULL,
+  PRIMARY KEY (`ID`),
+  UNIQUE INDEX `UK_activity_spec_to_activity_spec_categories` (`ACTIVITY_SPEC_ID` ASC, `ACTIVITY_SPEC_CATEGORIES_ID` ASC),
+  INDEX `fk_activity_spec_to_activity_spec_categories__activity_spec_idx` (`ACTIVITY_SPEC_CATEGORIES_ID` ASC),
+  INDEX `fk_activity_spec_to_activity_spec_categories__activity_spec_idx1` (`ACTIVITY_SPEC_ID` ASC),
+  CONSTRAINT `fk_activity_spec_to_activity_spec_categories__activity_spec1`
+    FOREIGN KEY (`ACTIVITY_SPEC_ID`)
+    REFERENCES `activity_spec` (`ID`)
+    ON DELETE CASCADE
+    ON UPDATE CASCADE,
+  CONSTRAINT `fk_activity_spec_to_activity_spec_categories__activity_spec_c1`
+    FOREIGN KEY (`ACTIVITY_SPEC_CATEGORIES_ID`)
+    REFERENCES `activity_spec_categories` (`ID`)
+    ON DELETE CASCADE
+    ON UPDATE CASCADE)
+ENGINE = InnoDB
+DEFAULT CHARACTER SET = latin1;
+
+CREATE TABLE IF NOT EXISTS `activity_spec_to_activity_spec_parameters` (
+  `ID` INT(11) NOT NULL AUTO_INCREMENT,
+  `ACTIVITY_SPEC_ID` INT(11) NOT NULL,
+  `ACTIVITY_SPEC_PARAMETERS_ID` INT(11) NOT NULL,
+  PRIMARY KEY (`ID`),
+  INDEX `fk_activity_spec_to_activity_spec_params__act_sp_param_id_idx` (`ACTIVITY_SPEC_PARAMETERS_ID` ASC),
+  UNIQUE INDEX `UK_activity_spec_to_activity_spec_parameters` (`ACTIVITY_SPEC_ID` ASC, `ACTIVITY_SPEC_PARAMETERS_ID` ASC),
+  INDEX `fk_activity_spec_to_activity_spec_parameters__act_spec_id_idx` (`ACTIVITY_SPEC_ID` ASC),
+  CONSTRAINT `fk_activity_spec_to_activity_spec_parameters__activity_spec_1`
+    FOREIGN KEY (`ACTIVITY_SPEC_ID`)
+    REFERENCES `activity_spec` (`ID`)
+    ON DELETE CASCADE
+    ON UPDATE CASCADE,
+  CONSTRAINT `fk_activity_spec_to_activity_spec_parameters__activ_spec_param1`
+    FOREIGN KEY (`ACTIVITY_SPEC_PARAMETERS_ID`)
+    REFERENCES `activity_spec_parameters` (`ID`)
+    ON DELETE CASCADE
+    ON UPDATE CASCADE)
+ENGINE = InnoDB
+DEFAULT CHARACTER SET = latin1;
+
+CREATE TABLE IF NOT EXISTS `activity_spec_to_user_parameters` (
+  `ID` INT(11) NOT NULL,
+  `ACTIVITY_SPEC_ID` INT(11) NOT NULL,
+  `USER_PARAMETERS_ID` INT(11) NOT NULL,
+  PRIMARY KEY (`ID`),
+  UNIQUE INDEX `UK_activity_spec_to_user_parameters` (`ACTIVITY_SPEC_ID` ASC, `USER_PARAMETERS_ID` ASC),
+  INDEX `fk_activity_spec_to_user_parameters__user_parameters1_idx` (`USER_PARAMETERS_ID` ASC),
+  INDEX `fk_activity_spec_to_user_parameters__activity_spec1_idx` (`ACTIVITY_SPEC_ID` ASC),
+  CONSTRAINT `fk_activity_spec_to_user_parameters__activity_spec1`
+    FOREIGN KEY (`ACTIVITY_SPEC_ID`)
+    REFERENCES `activity_spec` (`ID`)
+    ON DELETE CASCADE
+    ON UPDATE CASCADE,
+  CONSTRAINT `fk_activity_spec_to_user_parameters__user_parameters1`
+    FOREIGN KEY (`USER_PARAMETERS_ID`)
+    REFERENCES `user_parameters` (`ID`)
+    ON DELETE CASCADE
+    ON UPDATE CASCADE)
+ENGINE = InnoDB
+DEFAULT CHARACTER SET = latin1;
+