aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/test')
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasksTest.java25
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java129
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/configurationResponse.json8
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/vnfcResponse.json29
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/__files/SDNC_Async_Request2.xml11
5 files changed, 201 insertions, 1 deletions
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasksTest.java
index f1779cf119..043aad43b1 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasksTest.java
@@ -27,9 +27,13 @@ import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import java.io.IOException;
+import java.io.StringReader;
import java.nio.file.Files;
import java.nio.file.Paths;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
import org.camunda.bpm.engine.delegate.BpmnError;
import org.camunda.bpm.engine.delegate.DelegateExecution;
@@ -51,6 +55,8 @@ import org.onap.so.client.exception.MapperException;
import org.onap.so.client.sdnc.SDNCClient;
import org.onap.so.client.sdnc.beans.SDNCRequest;
import org.onap.so.client.sdnc.endpoint.SDNCTopology;
+import org.w3c.dom.Document;
+import org.xml.sax.InputSource;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
@@ -131,12 +137,29 @@ public class SDNCRequestTasksTest extends SDNCRequestTasks{
@Test
public void processCallBack_Final_Test() throws MapperException, BadResponseException, IOException{
- final String sdncResponse = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/SDNC_ASYNC_Request.json")));
+ final String sdncResponse = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/SDNC_Async_Request2.xml")));
delegateExecution.setVariable("correlationName_MESSAGE", sdncResponse);
sndcRequestTasks.processCallback(delegateExecution);
assertEquals(true,delegateExecution.getVariable(IS_CALLBACK_COMPLETED));
}
+ @Test
+ public void getXmlElementTest() throws Exception {
+ final String sdncResponse = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/SDNC_Async_Request2.xml")));
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance ();
+ DocumentBuilder db;
+ db = dbf.newDocumentBuilder ();
+ Document doc = db.parse (new InputSource(new StringReader(sdncResponse)));
+
+ String finalMessageIndicator = getXmlElement(doc, "/input/ack-final-indicator");
+ String responseCode = getXmlElement(doc, "/input/response-code");
+ String responseMessage = getXmlElement(doc, "/input/response-message");
+
+ assertEquals("Y", finalMessageIndicator);
+ assertEquals("200", responseCode);
+ assertEquals("Success", responseMessage);
+ }
+
public SDNCRequest createSDNCRequest(){
SDNCRequest request = new SDNCRequest();
request.setCorrelationName("correlationName");
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java
index 0bc20c16f7..87e6daa58a 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java
@@ -53,6 +53,7 @@ import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.mockito.InjectMocks;
import org.mockito.Mock;
+import org.mockito.Spy;
import org.onap.aai.domain.yang.GenericVnf;
import org.onap.aai.domain.yang.L3Network;
import org.onap.aai.domain.yang.Relationship;
@@ -60,6 +61,7 @@ import org.onap.aai.domain.yang.RelationshipList;
import org.onap.aai.domain.yang.ServiceInstance;
import org.onap.aai.domain.yang.VfModule;
import org.onap.aai.domain.yang.VfModules;
+import org.onap.aai.domain.yang.Vnfc;
import org.onap.aai.domain.yang.VolumeGroup;
import org.onap.so.bpmn.BaseTaskTest;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection;
@@ -67,7 +69,11 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock;
import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds;
+import org.onap.so.client.aai.AAIObjectType;
+import org.onap.so.client.aai.entities.AAIResultWrapper;
import org.onap.so.client.aai.entities.Relationships;
+import org.onap.so.client.aai.entities.uri.AAIResourceUri;
+import org.onap.so.client.aai.entities.uri.AAIUriFactory;
import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization;
import org.onap.so.db.catalog.beans.CollectionResource;
import org.onap.so.db.catalog.beans.CollectionResourceCustomization;
@@ -100,9 +106,15 @@ public class WorkflowActionTest extends BaseTaskTest {
private DelegateExecution execution;
+ @InjectMocks
+ @Spy
+ protected WorkflowAction SPY_workflowAction;
+
@Rule
public ExpectedException thrown = ExpectedException.none();
+ private String RESOURCE_PATH = "src/test/resources/__files/";
+
@Before
public void before() throws Exception {
execution = new DelegateExecutionFake();
@@ -930,6 +942,123 @@ public class WorkflowActionTest extends BaseTaskTest {
assertEqualsBulkFlowName(ebbs,"AssignVfModuleBB","CreateVfModuleBB","ActivateVfModuleBB","AssignFabricConfigurationBB","ActivateFabricConfigurationBB", "AssignFabricConfigurationBB","ActivateFabricConfigurationBB");
}
+ @Test
+ public void selectExecutionListALaCarteVfModuleFabricDeleteTest() throws Exception{
+ String gAction = "deleteInstance";
+ String resource = "VfModule";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
+ execution.setVariable("aLaCarte", true);
+ execution.setVariable("apiVersion", "7");
+ execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules");
+
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB","DeleteVfModuleBB","UnassignVfModuleBB","DeactivateFabricConfigurationBB","UnassignFabricConfigurationBB");
+ northBoundRequest.setOrchestrationFlowList(orchFlows);
+
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,true,"my-custom-cloud-owner")).thenReturn(northBoundRequest);
+
+ org.onap.aai.domain.yang.GenericVnf vnf = new org.onap.aai.domain.yang.GenericVnf();
+ vnf.setVnfId("vnf0");
+ vnf.setModelCustomizationId("modelCustomizationId");
+ when(bbSetupUtils.getAAIGenericVnf(anyObject())).thenReturn(vnf);
+
+ org.onap.aai.domain.yang.VfModule vfModule = new org.onap.aai.domain.yang.VfModule();
+ vfModule.setModelCustomizationId("modelCustomizationId");
+ when(bbSetupUtils.getAAIVfModule(anyObject(), anyObject())).thenReturn(vfModule);
+
+ List<org.onap.aai.domain.yang.Vnfc> vnfcs = new ArrayList<org.onap.aai.domain.yang.Vnfc>();
+ org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc();
+ vnfc.setModelInvariantId("modelInvariantId");
+ vnfc.setVnfcName("testVnfcName");
+ vnfcs.add(vnfc);
+ doReturn(vnfcs).when(SPY_workflowAction).getRelatedResourcesInVfModule(anyObject(), anyObject(), anyObject(), anyObject());
+
+ List<org.onap.aai.domain.yang.Configuration> configurations = new ArrayList<org.onap.aai.domain.yang.Configuration>();
+ org.onap.aai.domain.yang.Configuration configuration = new org.onap.aai.domain.yang.Configuration();
+ configuration.setConfigurationId("configurationId");
+ configuration.setModelCustomizationId("modelCustimizationId");
+ configuration.setConfigurationName("testConfigurationName");
+ configurations.add(configuration);
+ doReturn(configurations).when(SPY_workflowAction).getRelatedResourcesInVnfc(anyObject(), anyObject(), anyObject());
+
+ doReturn("testName").when(SPY_workflowAction).getVnfcNameForConfiguration(anyObject());
+
+ SPY_workflowAction.selectExecutionList(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEqualsBulkFlowName(ebbs,"DeactivateFabricConfigurationBB","UnassignFabricConfigurationBB","DeactivateVfModuleBB","DeleteVfModuleBB","UnassignVfModuleBB");
+ }
+
+ @Test
+ public void selectExecutionListALaCarteVfModuleNoFabricDeleteTest() throws Exception{
+ String gAction = "deleteInstance";
+ String resource = "VfModule";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
+ execution.setVariable("aLaCarte", true);
+ execution.setVariable("apiVersion", "7");
+ execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules");
+
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB","DeleteVfModuleBB","UnassignVfModuleBB","DeactivateFabricConfigurationBB","UnassignFabricConfigurationBB");
+ northBoundRequest.setOrchestrationFlowList(orchFlows);
+
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,true,"my-custom-cloud-owner")).thenReturn(northBoundRequest);
+
+ org.onap.aai.domain.yang.GenericVnf vnf = new org.onap.aai.domain.yang.GenericVnf();
+ vnf.setVnfId("vnf0");
+ vnf.setModelCustomizationId("modelCustomizationId");
+ when(bbSetupUtils.getAAIGenericVnf(anyObject())).thenReturn(vnf);
+
+ org.onap.aai.domain.yang.VfModule vfModule = new org.onap.aai.domain.yang.VfModule();
+ vfModule.setModelCustomizationId("modelCustomizationId");
+ when(bbSetupUtils.getAAIVfModule(anyObject(), anyObject())).thenReturn(vfModule);
+
+ List<org.onap.aai.domain.yang.Vnfc> vnfcs = new ArrayList<org.onap.aai.domain.yang.Vnfc>();
+ org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc();
+ vnfc.setModelInvariantId("modelInvariantId");
+ vnfc.setVnfcName("testVnfcName");
+ vnfcs.add(vnfc);
+ doReturn(vnfcs).when(SPY_workflowAction).getRelatedResourcesInVfModule(anyObject(), anyObject(), anyObject(), anyObject());
+
+ List<org.onap.aai.domain.yang.Configuration> configurations = new ArrayList<org.onap.aai.domain.yang.Configuration>();
+ org.onap.aai.domain.yang.Configuration configuration = new org.onap.aai.domain.yang.Configuration();
+ doReturn(configurations).when(SPY_workflowAction).getRelatedResourcesInVnfc(anyObject(), anyObject(), anyObject());
+
+ doReturn("testName").when(SPY_workflowAction).getVnfcNameForConfiguration(anyObject());
+
+ SPY_workflowAction.selectExecutionList(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEqualsBulkFlowName(ebbs,"DeactivateVfModuleBB","DeleteVfModuleBB","UnassignVfModuleBB");
+ }
+
+ @Test
+ public void getRelatedResourcesInVfModuleTest() throws Exception{
+ org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc();
+ vnfc.setModelInvariantId("modelInvariantId");
+ vnfc.setVnfcName("testVnfcName");
+
+ String vfncPayload = new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "/BuildingBlocks/vnfcResponse.json")));
+ AAIResultWrapper vfncWrapper = new AAIResultWrapper(vfncPayload);
+
+ String configurationPayload = new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "/BuildingBlocks/configurationResponse.json")));
+ AAIResultWrapper configurationWrapper = new AAIResultWrapper(configurationPayload);
+ List<AAIResultWrapper> configurationResultWrappers = new ArrayList<AAIResultWrapper>();
+ configurationResultWrappers.add(configurationWrapper);
+
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VNFC, vnfc.getVnfcName());
+ when(bbSetupUtils.getAAIResourceDepthOne(uri)).thenReturn(vfncWrapper);
+
+ doReturn(configurationResultWrappers).when(SPY_workflowAction).getResultWrappersFromRelationships(anyObject(),anyObject());
+ List<org.onap.aai.domain.yang.Configuration> configurationsList = SPY_workflowAction.getRelatedResourcesInVnfc(vnfc, org.onap.aai.domain.yang.Configuration.class, AAIObjectType.CONFIGURATION);
+ assertEquals(1,configurationsList.size());
+ assertEquals("testConfigurationId",configurationsList.get(0).getConfigurationId());
+ }
+
/**
* WorkflowActionBB Tests
*/
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/configurationResponse.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/configurationResponse.json
new file mode 100644
index 0000000000..c8420a5fab
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/configurationResponse.json
@@ -0,0 +1,8 @@
+{
+ "configuration-id": "testConfigurationId",
+ "configuration-type": "...",
+ "orchestration-status": "...",
+ "tunnel-bandwidth": "100",
+ "vendor-allowed-max-bandwidth": "90",
+ "resource-version": "1234"
+} \ No newline at end of file
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/vnfcResponse.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/vnfcResponse.json
new file mode 100644
index 0000000000..0b2d847e03
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/vnfcResponse.json
@@ -0,0 +1,29 @@
+{
+ "vnfc-name": "vnfcName",
+ "nfc-naming-code": "oamfw",
+ "nfc-function": "FIREWALL",
+ "prov-status": "PREPROV",
+ "orchestration-status": "Active",
+ "in-maint": false,
+ "is-closed-loop-disabled": false,
+ "model-invariant-id": "9dae8bb5-0709-4c0e-8f5b-6448232510ea",
+ "model-version-id": "b4e05ccb-01d0-4176-90ae-380308a35e5f",
+ "model-customization-id": "abf73d38-9da2-47af-bd53-26954318449f",
+ "resource-version": "1552319567126",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "generic-vnf",
+ "related-link": "/aai/v11/network/generic-vnfs/generic-vnf/testGenericVnfId",
+ "relationship-data": {
+ "relationship-key": "generic-vnf",
+ "relationship-value": "4a9184ac-5fad-44a1-b224-289bb490eaa9"
+ },
+ "related-to-property": {
+ "property-key": "generic-vnf.vnf-name",
+ "property-value": "USBBBBmtwnjVVHP047"
+ }
+ }
+ ]
+ }
+} \ No newline at end of file
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/SDNC_Async_Request2.xml b/bpmn/so-bpmn-tasks/src/test/resources/__files/SDNC_Async_Request2.xml
new file mode 100644
index 0000000000..aa69dba803
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/SDNC_Async_Request2.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<input>
+ <service-information>
+ <service-type>MY-SERVICE-TYPE</service-type>
+ <service-instance-id>b8308928-de76-4ce6-9e58-ec6033ff43b3</service-instance-id>
+ </service-information>
+ <svc-request-id>aa243891-4575-4040-bceb-25d5b7bc8c61</svc-request-id>
+ <response-code>200</response-code>
+ <response-message>Success</response-message>
+ <ack-final-indicator>Y</ack-final-indicator>
+</input>