From 0502c4a725498477338c6c4ba84b6ccf9f6b727a Mon Sep 17 00:00:00 2001 From: c00149107 Date: Thu, 1 Mar 2018 16:01:25 +0800 Subject: Support decompose service by model uuid Support decompose service by model uuid Change-Id: Ib6f751440bc9c60df12e18857f23b4c62181b9c6 Issue-ID: SO-451 Signed-off-by: c00149107 --- .../org/openecomp/mso/bpmn/common/scripts/DecomposeService.groovy | 7 +++++-- .../src/test/java/org/openecomp/mso/bpmn/common/HomingTest.java | 5 +++-- .../java/org/openecomp/mso/bpmn/mock/StubResponseDatabase.java | 8 ++++++++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/DecomposeService.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/DecomposeService.groovy index 2645ea3c02..8d855e9311 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/DecomposeService.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/DecomposeService.groovy @@ -77,6 +77,7 @@ public class DecomposeService extends AbstractServiceTaskProcessor { String serviceInstanceId = execution.getVariable("serviceInstanceId") String serviceModelInfo = execution.getVariable("serviceModelInfo") execution.setVariable("DDS_serviceModelInvariantId", jsonUtils.getJsonValue(serviceModelInfo, "modelInvariantUuid")) + execution.setVariable("DDS_serviceModelUuid", jsonUtils.getJsonValue(serviceModelInfo, "modelUuid")) execution.setVariable("DDS_modelVersion", jsonUtils.getJsonValue(serviceModelInfo, "modelVersion")) } catch (BpmnError e) { throw e; @@ -97,14 +98,16 @@ public class DecomposeService extends AbstractServiceTaskProcessor { // check for input String serviceModelInvariantId = execution.getVariable("DDS_serviceModelInvariantId") + String serviceModelUuid = execution.getVariable("DDS_serviceModelUuid") String modelVersion = execution.getVariable("DDS_modelVersion") utils.log("DEBUG", "serviceModelInvariantId: " + serviceModelInvariantId, isDebugEnabled) utils.log("DEBUG", "modelVersion: " + modelVersion, isDebugEnabled) JSONObject catalogDbResponse = null - - if (modelVersion != null && modelVersion.length() > 0) + if(serviceModelUuid != null && serviceModelUuid.length() > 0) + catalogDbResponse = catalogDbUtils.getServiceResourcesByServiceModelUuid(execution, serviceModelUuid, "v2") + else if (modelVersion != null && modelVersion.length() > 0) catalogDbResponse = catalogDbUtils.getServiceResourcesByServiceModelInvariantUuidAndServiceModelVersion(execution, serviceModelInvariantId, modelVersion, "v2") else catalogDbResponse = catalogDbUtils.getServiceResourcesByServiceModelInvariantUuid(execution, serviceModelInvariantId, "v2") diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/HomingTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/HomingTest.java index 4296c74392..3210fe8fc7 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/HomingTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/HomingTest.java @@ -23,7 +23,7 @@ */ package org.openecomp.mso.bpmn.common; -import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.MockGetServiceResourcesCatalogData; +import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.MockGetServiceResourcesCatalogDataByModelUuid; import static org.openecomp.mso.bpmn.mock.StubResponseSNIRO.*; import static org.junit.Assert.*; @@ -235,7 +235,8 @@ public class HomingTest extends WorkflowTest { // Create a Service Decomposition //System.out.println("At start of testHoming_success_vnfResourceList"); - MockGetServiceResourcesCatalogData("1cc4e2e4-eb6e-404d-a66f-c8733cedcce8", "5.0", "/BuildingBlocks/catalogResp.json"); + MockGetServiceResourcesCatalogDataByModelUuid("2f7f309d-c842-4644-a2e4-34167be5eeb4", "/BuildingBlocks/catalogResp.json"); + //MockGetServiceResourcesCatalogData("1cc4e2e4-eb6e-404d-a66f-c8733cedcce8", "5.0", "/BuildingBlocks/catalogResp.json"); String busKey = UUID.randomUUID().toString(); Map vars = new HashMap<>(); setVariablesForServiceDecomposition(vars, "testRequestId123", "ff5256d2-5a33-55df-13ab-12abad84e7ff"); diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseDatabase.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseDatabase.java index c9f64d9b26..ffa6701a89 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseDatabase.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseDatabase.java @@ -98,5 +98,13 @@ public class StubResponseDatabase { .withBodyFile(responseFile))); } + public static void MockGetServiceResourcesCatalogDataByModelUuid(String serviceModelUuid, String responseFile){ + stubFor(get(urlEqualTo("/v2/serviceResources?serviceModelUuid=" + serviceModelUuid)) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "application/json") + .withBodyFile(responseFile))); + } + } -- cgit 1.2.3-korg