diff options
Diffstat (limited to 'bpmn')
7 files changed, 103 insertions, 6 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericGetService.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericGetService.groovy index 14f9135826..cfc5171dca 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericGetService.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericGetService.groovy @@ -20,14 +20,14 @@ package org.openecomp.mso.bpmn.common.scripts
-import static org.apache.commons.lang3.StringUtils.*
-
-import org.apache.commons.lang3.*
+import org.apache.commons.lang3.StringEscapeUtils
import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.runtime.Execution
import org.openecomp.mso.rest.APIResponse
import org.springframework.web.util.UriUtils
+import static org.apache.commons.lang3.StringUtils.isBlank
+
/**
* This class supports the GenericGetService Sub Flow.
@@ -301,7 +301,9 @@ class GenericGetService extends AbstractServiceTaskProcessor{ if(responseCode == 200){
utils.log("DEBUG", " Query for Service Instance Url Received a Good Response Code", isDebugEnabled)
execution.setVariable("GENGS_SuccessIndicator", true)
- if(utils.nodeExists(aaiResponse, "result-data")){
+ String globalCustomerId = execution.getVariable("GENGS_globalCustomerId")
+ boolean nodeExists = isBlank(globalCustomerId) ? utils.nodeExists(aaiResponse, "result-data") : hasCustomerServiceInstance(aaiResponse, globalCustomerId)
+ if(nodeExists){
utils.log("DEBUG", "Query for Service Instance Url Response Does Contain Data" , isDebugEnabled)
execution.setVariable("GENGS_FoundIndicator", true)
String resourceLink = utils.getNodeText1(aaiResponse, "resource-link")
@@ -439,4 +441,30 @@ class GenericGetService extends AbstractServiceTaskProcessor{ utils.log("DEBUG", " *** COMPLETED GenericGetService GetServiceObject Process*** ", isDebugEnabled)
}
+ /**
+ * An utility method which check whether a service(by name) is already present within a globalCustomerId or not.
+ * @param jsonResponse raw response received from AAI by searching ServiceInstance by Name.
+ * @param globalCustomerId
+ * @return {@code true} if globalCustomerId is found at 6th position within "resource-link", {@code false} in any other cases.
+ */
+ public boolean hasCustomerServiceInstance(String aaiResponse, final String globalCustomerId) {
+ if (isBlank(aaiResponse)) {
+ return false
+ }
+ aaiResponse = utils.removeXmlNamespaces(aaiResponse)
+ ArrayList<String> linksArray = utils.getMultNodeObjects(aaiResponse, "resource-link")
+ if (linksArray == null || linksArray.size() == 0) {
+ return false
+ }
+ for (String resourceLink : linksArray) {
+ int custStart = resourceLink.indexOf("customer/")
+ int custEnd = resourceLink.indexOf("/service-subscriptions/")
+ String receivedCustomerId = resourceLink.substring(custStart + 9, custEnd)
+ if (globalCustomerId.equals(receivedCustomerId)) {
+ return true
+ }
+ }
+ return false
+ }
+
}
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericGetServiceTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericGetServiceTest.java index b1172837cf..82cceb0b70 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericGetServiceTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericGetServiceTest.java @@ -482,6 +482,61 @@ public class GenericGetServiceTest extends WorkflowTest { assertEquals(expectedWorkflowException, workflowException);
}
+ @Test
+ @Deployment(resources = {"subprocess/GenericGetService.bpmn"})
+ public void testGenericGetService_success_serviceInstance_byNameServicePresent() throws Exception{
+
+ MockNodeQueryServiceInstanceByName("1604-MVM-26", "GenericFlows/getSIUrlByNameMultiCustomer.xml");
+ MockGetServiceInstance("XyCorporation", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getServiceInstance.xml");
+
+ Map<String, String> variables = new HashMap<String, String>();
+ setVariablesInstance(variables, null, "1604-MVM-26", "XyCorporation", null);
+
+ WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables);
+ waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID());
+
+ String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator");
+ String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator");
+ String resourceLink = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_resourceLink");
+ String response = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowResponse");
+ String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException");
+ String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainSIUrlResponseCode");
+
+ assertEquals("true", successIndicator);
+ assertEquals("true", found);
+ assertNotNull(resourceLink);
+ assertNotNull(response);
+ assertEquals("200", siUrlResponseCode);
+ assertEquals(null, workflowException);
+ }
+
+ @Test
+ @Deployment(resources = {"subprocess/GenericGetService.bpmn"})
+ public void testGenericGetService_success_serviceInstance_byNameServiceNotPresent() throws Exception{
+
+ MockNodeQueryServiceInstanceByName("1604-MVM-26", "GenericFlows/getSIUrlByNameMultiCustomer.xml");
+ MockGetServiceInstance("CorporationNotPresent", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getServiceInstance.xml");
+
+ Map<String, String> variables = new HashMap<String, String>();
+ setVariablesInstance(variables, null, "1604-MVM-26", "CorporationNotPresent", null);
+
+ WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables);
+ waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID());
+
+ String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator");
+ String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator");
+ String resourceLink = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_resourceLink");
+ String response = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowResponse");
+ String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException");
+ String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainSIUrlResponseCode");
+
+ assertEquals("true", successIndicator);
+ assertEquals("false", found);
+ assertEquals(null, resourceLink);
+ assertEquals(" ", response);
+ assertEquals("200", siUrlResponseCode);
+ assertEquals(null, workflowException);
+ }
private void setVariablesInstance(Map<String, String> variables, String siId, String siName, String globalCustId, String serviceType) {
variables.put("isDebugLogEnabled", "true");
diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/GenericFlows/getSIUrlByNameMultiCustomer.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/GenericFlows/getSIUrlByNameMultiCustomer.xml new file mode 100644 index 0000000000..fce47fcd0d --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/GenericFlows/getSIUrlByNameMultiCustomer.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?> +<search-results xmlns="http://org.openecomp.aai.inventory/v11"> + <result-data> + <resource-type>service-instance</resource-type> + <resource-link>/aai/v11/business/customers/customer/AbcBank/service-subscriptions/service-subscription/ABC-ST/service-instances/service-instance/MIS%252F1604%252F0026%252FSW_INTERNET</resource-link> + </result-data> + <result-data> + <resource-type>service-instance</resource-type> + <resource-link>/aai/v11/business/customers/customer/XyCorporation/service-subscriptions/service-subscription/XY-ST/service-instances/service-instance/MIS%252F1604%252F0026%252FSW_INTERNET</resource-link> + </result-data> +</search-results>
\ No newline at end of file diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/RollbackData.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/RollbackData.java index 66edaaae3c..7ece05ea9e 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/RollbackData.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/RollbackData.java @@ -89,6 +89,7 @@ public class RollbackData implements Serializable { /** * Returns a string representation of this object. */ + @Override public String toString() { StringBuilder out = new StringBuilder(); out.append(getClass().getSimpleName()); diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/JsonWrapper.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/JsonWrapper.java index ce66e06089..4d895f3279 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/JsonWrapper.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/JsonWrapper.java @@ -142,6 +142,7 @@ public abstract class JsonWrapper implements Serializable { /**
* Returns a string representation of this object.
*/
+ @Override
public String toString() {
return this.toJsonString();
}
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/plugins/LoggingAndURNMappingPlugin.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/plugins/LoggingAndURNMappingPlugin.java index 71ed0eae5e..c346308e2b 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/plugins/LoggingAndURNMappingPlugin.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/plugins/LoggingAndURNMappingPlugin.java @@ -323,6 +323,7 @@ public class LoggingAndURNMappingPlugin extends AbstractProcessEnginePlugin { private void loadFromDB(DelegateExecution execution, ProcessEngineConfigurationImpl processEngineConfiguration) { Command<List<URNMapping>> command = new Command<List<URNMapping>>() { @SuppressWarnings("unchecked") + @Override public List<URNMapping> execute(CommandContext commandContext) { return (List<URNMapping>) commandContext.getDbSqlSession().selectList( "mso.urnMapping.selectAll", null); diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/CreateGenericALaCarteServiceInstanceTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/CreateGenericALaCarteServiceInstanceTest.java index 21c00918d3..571db76399 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/CreateGenericALaCarteServiceInstanceTest.java +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/CreateGenericALaCarteServiceInstanceTest.java @@ -79,8 +79,8 @@ public class CreateGenericALaCarteServiceInstanceTest extends WorkflowTest { MockGetCustomer("MCBH-1610", "CreateServiceInstance/createServiceInstance_queryGlobalCustomerId_AAIResponse_Success.xml"); MockPutServiceInstance("MCBH-1610", "viprsvc", "RaaTest-1-id", ""); MockGetServiceInstance("MCBH-1610", "viprsvc", "RaaTest-1-id", "GenericFlows/getServiceInstance.xml"); - MockNodeQueryServiceInstanceByName("RAATest-1", ""); - MockNodeQueryServiceInstanceById("RaaTest-1-id", ""); + MockNodeQueryServiceInstanceByName("RAATest-1", null); + MockNodeQueryServiceInstanceById("RaaTest-1-id", null); //SDNC mockSDNCAdapter(200); //DB |