diff options
Diffstat (limited to 'bpmn')
27 files changed, 466 insertions, 255 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/generalobjects/RequestContext.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/generalobjects/RequestContext.java index d37c8d13f3..cd66e512a5 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/generalobjects/RequestContext.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/generalobjects/RequestContext.java @@ -43,7 +43,7 @@ public class RequestContext implements Serializable{ @JsonProperty("subscription-service-type") private String subscriptionServiceType; @JsonProperty("user-params") - private HashMap<String, String> userParams; + private Map<String, Object> userParams = new HashMap<>(); @JsonProperty("action") private String action; @JsonProperty("callback-url") @@ -87,10 +87,10 @@ public class RequestContext implements Serializable{ public void setSubscriptionServiceType(String subscriptionServiceType) { this.subscriptionServiceType = subscriptionServiceType; } - public HashMap<String, String> getUserParams() { + public Map<String, Object> getUserParams() { return userParams; } - public void setUserParams(HashMap<String, String> userParams) { + public void setUserParams(Map<String, Object> userParams) { this.userParams = userParams; } public String getAction() { diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java index d6597ecb1a..81a504da4a 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java @@ -355,8 +355,8 @@ public class BBInputSetupMapperLayer { return requestParams; } - protected HashMap<String,String> mapNameValueUserParams(org.onap.so.serviceinstancebeans.RequestParameters requestParameters) { - HashMap<String,String> userParamsResult = new HashMap<String,String>(); + protected Map<String,Object> mapNameValueUserParams(org.onap.so.serviceinstancebeans.RequestParameters requestParameters) { + Map<String,Object> userParamsResult = new HashMap<String,Object>(); if (requestParameters.getUserParams() != null) { List<Map<String, Object>> userParams = requestParameters.getUserParams(); for (Map<String, Object> userParamsMap : userParams) { diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java index 7e76e52959..753a354d95 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java @@ -643,7 +643,7 @@ public class BBInputSetupMapperLayerTest { @Test public void testMapNameValueUserParams() throws IOException { RequestDetails requestDetails = mapper.readValue(new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"), RequestDetails.class); - HashMap<String,String> actual = bbInputSetupMapperLayer.mapNameValueUserParams(requestDetails.getRequestParameters()); + Map<String,Object> actual = bbInputSetupMapperLayer.mapNameValueUserParams(requestDetails.getRequestParameters()); assertTrue(actual.containsKey("name1")); assertTrue(actual.containsValue("value1")); diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/UpdateNetworkBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/UpdateNetworkBB.bpmn index 1cfb9a3860..1235469b42 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/UpdateNetworkBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/UpdateNetworkBB.bpmn @@ -1,19 +1,18 @@ <?xml version="1.0" encoding="UTF-8"?> -<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_MagIIMOUEeW8asg-vCEgWQ" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.10.0" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"> +<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_MagIIMOUEeW8asg-vCEgWQ" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.7.2" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"> <bpmn2:process id="UpdateNetworkBB" name="UpdateNetworkBB" isExecutable="true"> <bpmn2:startEvent id="UpdateNetworkBB_Start" name="Start"> <bpmn2:outgoing>SequenceFlow_074w2et</bpmn2:outgoing> </bpmn2:startEvent> <bpmn2:serviceTask id="SDNCChangeAssignNetwork" name="SDNC ChangeAssign Network" camunda:expression="${SDNCChangeAssignTasks.changeAssignNetwork(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> <bpmn2:incoming>SequenceFlow_074w2et</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_04yezm3</bpmn2:outgoing> + <bpmn2:outgoing>SequenceFlow_0rvstwt</bpmn2:outgoing> </bpmn2:serviceTask> <bpmn2:sequenceFlow id="SequenceFlow_074w2et" sourceRef="UpdateNetworkBB_Start" targetRef="SDNCChangeAssignNetwork" /> <bpmn2:intermediateThrowEvent id="SDNC_End" name="To AAI"> - <bpmn2:incoming>SequenceFlow_04yezm3</bpmn2:incoming> + <bpmn2:incoming>SequenceFlow_1eacnem</bpmn2:incoming> <bpmn2:linkEventDefinition name="SDNC_to_AAI" /> </bpmn2:intermediateThrowEvent> - <bpmn2:sequenceFlow id="SequenceFlow_04yezm3" sourceRef="SDNCChangeAssignNetwork" targetRef="SDNC_End" /> <bpmn2:intermediateCatchEvent id="AAI_Start" name="To AAI"> <bpmn2:outgoing>SequenceFlow_1trqq6d</bpmn2:outgoing> <bpmn2:linkEventDefinition name="SDNC_to_AAI" /> @@ -38,24 +37,51 @@ <bpmn2:linkEventDefinition name="AAI_to_AIC" /> </bpmn2:intermediateThrowEvent> <bpmn2:sequenceFlow id="SequenceFlow_00xbxe7" sourceRef="QueryNetworkTableRefAAI" targetRef="AAI_End" /> - <bpmn2:intermediateCatchEvent id="AIC_Start" name="To AIC"> - <bpmn2:outgoing>SequenceFlow_196cgux</bpmn2:outgoing> + <bpmn2:intermediateCatchEvent id="IntermediateCatchEvent_0y5f10a" name="To AIC"> + <bpmn2:outgoing>SequenceFlow_0qrtpcy</bpmn2:outgoing> <bpmn2:linkEventDefinition name="AAI_to_AIC" /> </bpmn2:intermediateCatchEvent> - <bpmn2:sequenceFlow id="SequenceFlow_196cgux" sourceRef="AIC_Start" targetRef="UpdateNetworkAdapter" /> - <bpmn2:serviceTask id="UpdateNetworkAdapter" name="Update Network (Network Adapter)" camunda:expression="${NetworkAdapterUpdateTasks.updateNetwork(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> - <bpmn2:incoming>SequenceFlow_196cgux</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_0hsvgje</bpmn2:outgoing> - </bpmn2:serviceTask> - <bpmn2:sequenceFlow id="SequenceFlow_0hsvgje" sourceRef="UpdateNetworkAdapter" targetRef="UpdateNetworkAAI" /> - <bpmn2:serviceTask id="UpdateNetworkAAI" name="Update Network (AAI)" camunda:expression="${AAIUpdateTasks.updateObjectNetwork(execution.getVariable(""))}"> - <bpmn2:incoming>SequenceFlow_0hsvgje</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_0fhfitm</bpmn2:outgoing> + <bpmn2:serviceTask id="Update_Network_AAI_ServiceTask" name="Update Network (AAI)" camunda:expression="${AAIUpdateTasks.updateNetworkUpdated(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn2:incoming>SequenceFlow_001ursg</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_06ei0em</bpmn2:outgoing> </bpmn2:serviceTask> <bpmn2:endEvent id="UpdateNetworkBB_End" name="End"> - <bpmn2:incoming>SequenceFlow_0fhfitm</bpmn2:incoming> + <bpmn2:incoming>SequenceFlow_06ei0em</bpmn2:incoming> </bpmn2:endEvent> - <bpmn2:sequenceFlow id="SequenceFlow_0fhfitm" sourceRef="UpdateNetworkAAI" targetRef="UpdateNetworkBB_End" /> + <bpmn2:callActivity id="CallActivity_NetworkAdapterRestV1" name="Call NetworkAdapterRestV1" calledElement="NetworkAdapterRestV1"> + <bpmn2:extensionElements> + <camunda:in source="networkAdapterRequest" target="networkAdapterRequest" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:out source="updateNetworkResponse" target="updateNetworkResponse" /> + </bpmn2:extensionElements> + <bpmn2:incoming>SequenceFlow_07hq1eg</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_183ph5i</bpmn2:outgoing> + </bpmn2:callActivity> + <bpmn2:serviceTask id="ServiceTask_ProcessResponse" name="Process Response From Openstack" camunda:expression="${NetworkAdapterUpdateTasks.processResponseFromOpenstack(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn2:incoming>SequenceFlow_183ph5i</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_001ursg</bpmn2:outgoing> + </bpmn2:serviceTask> + <bpmn2:serviceTask id="Create_Network_ServiceTask" name=" AIC Update (network) " camunda:expression="${NetworkAdapterUpdateTasks.updateNetwork(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn2:incoming>SequenceFlow_0qrtpcy</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_07hq1eg</bpmn2:outgoing> + </bpmn2:serviceTask> + <bpmn2:sequenceFlow id="SequenceFlow_0qrtpcy" sourceRef="IntermediateCatchEvent_0y5f10a" targetRef="Create_Network_ServiceTask" /> + <bpmn2:sequenceFlow id="SequenceFlow_001ursg" sourceRef="ServiceTask_ProcessResponse" targetRef="Update_Network_AAI_ServiceTask" /> + <bpmn2:sequenceFlow id="SequenceFlow_06ei0em" sourceRef="Update_Network_AAI_ServiceTask" targetRef="UpdateNetworkBB_End" /> + <bpmn2:sequenceFlow id="SequenceFlow_07hq1eg" sourceRef="Create_Network_ServiceTask" targetRef="CallActivity_NetworkAdapterRestV1" /> + <bpmn2:sequenceFlow id="SequenceFlow_183ph5i" sourceRef="CallActivity_NetworkAdapterRestV1" targetRef="ServiceTask_ProcessResponse" /> + <bpmn2:callActivity id="CallActivity_sdncHandlerCallChangeAssign" name="SDNC Change Assign (network)" calledElement="SDNCHandler"> + <bpmn2:extensionElements> + <camunda:in source="SDNCRequest" target="SDNCRequest" /> + <camunda:out source="SDNCResponse" target="SDNCResponse" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="mso-request-id" target="mso-request-id" /> + </bpmn2:extensionElements> + <bpmn2:incoming>SequenceFlow_0rvstwt</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_1eacnem</bpmn2:outgoing> + </bpmn2:callActivity> + <bpmn2:sequenceFlow id="SequenceFlow_0rvstwt" sourceRef="SDNCChangeAssignNetwork" targetRef="CallActivity_sdncHandlerCallChangeAssign" /> + <bpmn2:sequenceFlow id="SequenceFlow_1eacnem" sourceRef="CallActivity_sdncHandlerCallChangeAssign" targetRef="SDNC_End" /> </bpmn2:process> <bpmn2:error id="Error_2" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> <bpmn2:error id="Error_1" name="java.lang.Exception" errorCode="java.lang.Exception" /> @@ -79,18 +105,11 @@ </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="IntermediateThrowEvent_0pce3rm_di" bpmnElement="SDNC_End"> - <dc:Bounds x="487" y="77" width="36" height="36" /> + <dc:Bounds x="665" y="77" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="490" y="117" width="33" height="12" /> + <dc:Bounds x="669" y="117" width="32" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_04yezm3_di" bpmnElement="SequenceFlow_04yezm3"> - <di:waypoint xsi:type="dc:Point" x="378" y="95" /> - <di:waypoint xsi:type="dc:Point" x="487" y="95" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="432.5" y="74" width="0" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="IntermediateCatchEvent_1hbb3j8_di" bpmnElement="AAI_Start"> <dc:Bounds x="144" y="215" width="36" height="36" /> <bpmndi:BPMNLabel> @@ -140,43 +159,82 @@ <dc:Bounds x="755" y="212" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="IntermediateCatchEvent_0sx0nb6_di" bpmnElement="AIC_Start"> - <dc:Bounds x="144" y="332" width="36" height="36" /> + <bpmndi:BPMNShape id="IntermediateCatchEvent_0y5f10a_di" bpmnElement="IntermediateCatchEvent_0y5f10a"> + <dc:Bounds x="144" y="384" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="146" y="372" width="34" height="12" /> + <dc:Bounds x="147" y="424" width="33" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_196cgux_di" bpmnElement="SequenceFlow_196cgux"> - <di:waypoint xsi:type="dc:Point" x="180" y="350" /> - <di:waypoint xsi:type="dc:Point" x="248" y="350" /> + <bpmndi:BPMNShape id="ServiceTask_1ltcf7v_di" bpmnElement="Update_Network_AAI_ServiceTask"> + <dc:Bounds x="806" y="362" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_1nhzcte_di" bpmnElement="UpdateNetworkBB_End"> + <dc:Bounds x="983" y="384" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="169" y="329" width="90" height="12" /> + <dc:Bounds x="992" y="424" width="19" height="12" /> </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ServiceTask_0i66n9g_di" bpmnElement="UpdateNetworkAdapter"> - <dc:Bounds x="248" y="310" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_0hsvgje_di" bpmnElement="SequenceFlow_0hsvgje"> - <di:waypoint xsi:type="dc:Point" x="348" y="350" /> - <di:waypoint xsi:type="dc:Point" x="422" y="350" /> + <bpmndi:BPMNShape id="CallActivity_1jpfzuh_di" bpmnElement="CallActivity_NetworkAdapterRestV1"> + <dc:Bounds x="445" y="362" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_1kgckv9_di" bpmnElement="ServiceTask_ProcessResponse"> + <dc:Bounds x="625" y="362" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_03ywm5v_di" bpmnElement="Create_Network_ServiceTask"> + <dc:Bounds x="278" y="362" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0qrtpcy_di" bpmnElement="SequenceFlow_0qrtpcy"> + <di:waypoint xsi:type="dc:Point" x="180" y="402" /> + <di:waypoint xsi:type="dc:Point" x="229" y="402" /> + <di:waypoint xsi:type="dc:Point" x="229" y="402" /> + <di:waypoint xsi:type="dc:Point" x="278" y="402" /> <bpmndi:BPMNLabel> - <dc:Bounds x="340" y="329" width="90" height="12" /> + <dc:Bounds x="199" y="396" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ServiceTask_1ydm5u9_di" bpmnElement="UpdateNetworkAAI"> - <dc:Bounds x="422" y="310" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="EndEvent_0fsts2w_di" bpmnElement="UpdateNetworkBB_End"> - <dc:Bounds x="637" y="332" width="36" height="36" /> + <bpmndi:BPMNEdge id="SequenceFlow_001ursg_di" bpmnElement="SequenceFlow_001ursg"> + <di:waypoint xsi:type="dc:Point" x="725" y="402" /> + <di:waypoint xsi:type="dc:Point" x="806" y="402" /> <bpmndi:BPMNLabel> - <dc:Bounds x="646" y="372" width="19" height="12" /> + <dc:Bounds x="720.5" y="381" width="0" height="12" /> </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_06ei0em_di" bpmnElement="SequenceFlow_06ei0em"> + <di:waypoint xsi:type="dc:Point" x="906" y="402" /> + <di:waypoint xsi:type="dc:Point" x="983" y="402" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="899.5" y="381" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_07hq1eg_di" bpmnElement="SequenceFlow_07hq1eg"> + <di:waypoint xsi:type="dc:Point" x="378" y="402" /> + <di:waypoint xsi:type="dc:Point" x="445" y="402" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="411.5" y="381" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_183ph5i_di" bpmnElement="SequenceFlow_183ph5i"> + <di:waypoint xsi:type="dc:Point" x="545" y="402" /> + <di:waypoint xsi:type="dc:Point" x="625" y="402" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="585" y="381" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="CallActivity_1da6ys0_di" bpmnElement="CallActivity_sdncHandlerCallChangeAssign"> + <dc:Bounds x="455" y="55" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_0fhfitm_di" bpmnElement="SequenceFlow_0fhfitm"> - <di:waypoint xsi:type="dc:Point" x="522" y="350" /> - <di:waypoint xsi:type="dc:Point" x="637" y="350" /> + <bpmndi:BPMNEdge id="SequenceFlow_0rvstwt_di" bpmnElement="SequenceFlow_0rvstwt"> + <di:waypoint xsi:type="dc:Point" x="378" y="95" /> + <di:waypoint xsi:type="dc:Point" x="455" y="95" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="416.5" y="74" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1eacnem_di" bpmnElement="SequenceFlow_1eacnem"> + <di:waypoint xsi:type="dc:Point" x="555" y="95" /> + <di:waypoint xsi:type="dc:Point" x="665" y="95" /> <bpmndi:BPMNLabel> - <dc:Bounds x="535" y="329" width="90" height="12" /> + <dc:Bounds x="610" y="74" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/UpdateNetworkBBTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/UpdateNetworkBBTest.java index 98e049f440..1bb065ae06 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/UpdateNetworkBBTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/UpdateNetworkBBTest.java @@ -33,22 +33,24 @@ import org.onap.so.bpmn.common.BuildingBlockExecution; public class UpdateNetworkBBTest extends BaseBPMNTest { @Test public void updateNetworkBBTest() throws InterruptedException { + mockSubprocess("SDNCHandler", "My Mock Process Name", "GenericStub"); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("UpdateNetworkBB", variables); assertThat(processInstance).isNotNull(); assertThat(processInstance).isStarted().hasPassedInOrder( - "UpdateNetworkBB_Start", "SDNCChangeAssignNetwork", + "UpdateNetworkBB_Start", "SDNCChangeAssignNetwork", "CallActivity_sdncHandlerCallChangeAssign", "QueryVpnBindingAAI", "QueryNetworkPolicyAAI", "QueryNetworkTableRefAAI", - "UpdateNetworkAdapter", "UpdateNetworkAAI", "UpdateNetworkBB_End"); + "Create_Network_ServiceTask", "CallActivity_NetworkAdapterRestV1", "ServiceTask_ProcessResponse", "Update_Network_AAI_ServiceTask", "UpdateNetworkBB_End"); assertThat(processInstance).isEnded(); } @Test public void updateNetworkBBExceptionTest() throws Exception { + mockSubprocess("SDNCHandler", "My Mock Process Name", "GenericStub"); doThrow(new BpmnError("7000", "TESTING ERRORS")).when(aaiQueryTasks).queryNetworkVpnBinding(any(BuildingBlockExecution.class)); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("UpdateNetworkBB", variables); assertThat(processInstance).isStarted().hasPassedInOrder( - "UpdateNetworkBB_Start", "SDNCChangeAssignNetwork", + "UpdateNetworkBB_Start", "SDNCChangeAssignNetwork", "CallActivity_sdncHandlerCallChangeAssign", "QueryVpnBindingAAI") .hasNotPassed("QueryNetworkPolicyAAI", "QueryNetworkTableRefAAI", "UpdateNetworkAdapter", "UpdateNetworkAAI", "UpdateNetworkBB_End"); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java index 37e1a93044..34598ef00a 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java @@ -26,6 +26,7 @@ import java.util.List; import java.util.Map; import org.onap.so.adapters.nwrest.CreateNetworkResponse; +import org.onap.so.adapters.nwrest.UpdateNetworkResponse; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection; @@ -338,7 +339,7 @@ public class AAIUpdateTasks { } /** - * BPMN access method to update L3Network after it was created in AIC + * BPMN access method to update L3Network after it was created in cloud * @param execution * @throws Exception */ @@ -379,6 +380,34 @@ public class AAIUpdateTasks { } } + /** + * BPMN access method to update L3Network after it was updated in cloud + * @param execution + * @throws Exception + */ + public void updateNetworkUpdated(BuildingBlockExecution execution) throws Exception { + L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID, execution.getLookupMap().get(ResourceKey.NETWORK_ID)); + L3Network copiedl3network = l3network.shallowCopyId(); + UpdateNetworkResponse response = execution.getVariable("updateNetworkResponse"); + try { + copiedl3network.setNeutronNetworkId(response.getNeutronNetworkId()); + aaiNetworkResources.updateNetwork(copiedl3network); + + Map<String, String> subnetMap = response.getSubnetMap(); + List<Subnet> subnets = l3network.getSubnets(); + if (subnets != null && subnetMap != null){ + for (Subnet subnet: subnets){ + Subnet copiedSubnet = subnet.shallowCopyId(); + copiedSubnet.setNeutronSubnetId(subnetMap.get(copiedSubnet.getSubnetId())); + copiedSubnet.setOrchestrationStatus(OrchestrationStatus.CREATED); + aaiNetworkResources.updateSubnet(copiedl3network, copiedSubnet); + } + } + } catch (Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + } + public void updateObjectNetwork(BuildingBlockExecution execution) { try { L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID, execution.getLookupMap().get(ResourceKey.NETWORK_ID)); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterUpdateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterUpdateTasks.java index ee7f3697ae..61687081d9 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterUpdateTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterUpdateTasks.java @@ -22,8 +22,7 @@ package org.onap.so.bpmn.infrastructure.adapter.network.tasks; -import java.util.Optional; - +import org.onap.so.adapters.nwrest.UpdateNetworkRequest; import org.onap.so.adapters.nwrest.UpdateNetworkResponse; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; @@ -31,6 +30,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; +import org.onap.so.client.adapter.network.mapper.NetworkAdapterObjectMapper; import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.client.orchestration.NetworkAdapterResources; import org.slf4j.Logger; @@ -45,7 +45,7 @@ public class NetworkAdapterUpdateTasks { @Autowired private ExtractPojosForBB extractPojosForBB; @Autowired - private NetworkAdapterResources networkAdapterResources; + private NetworkAdapterObjectMapper networkAdapterObjectMapper; @Autowired private ExceptionBuilder exceptionUtil; @@ -54,14 +54,23 @@ public class NetworkAdapterUpdateTasks { GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock(); ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); L3Network l3Network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID, execution.getLookupMap().get(ResourceKey.NETWORK_ID)); - Optional<UpdateNetworkResponse> oUpdateNetworkResponse = networkAdapterResources.updateNetwork(gBBInput.getRequestContext(), gBBInput.getCloudRegion(), gBBInput.getOrchContext(), serviceInstance, l3Network, gBBInput.getUserInput(), gBBInput.getCustomer()); - if(oUpdateNetworkResponse.isPresent()) { - UpdateNetworkResponse updateNetworkResponse = oUpdateNetworkResponse.get(); - execution.setVariable("NetworkAdapterUpdateNetworkResponse", updateNetworkResponse); - } + UpdateNetworkRequest updateNetworkRequest = networkAdapterObjectMapper.createNetworkUpdateRequestMapper(gBBInput.getRequestContext(), gBBInput.getCloudRegion(), gBBInput.getOrchContext(), serviceInstance, l3Network, gBBInput.getUserInput(), gBBInput.getCustomer()); + execution.setVariable("networkAdapterRequest", updateNetworkRequest); + } catch(Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } + + public void processResponseFromOpenstack(BuildingBlockExecution execution) { + try { + UpdateNetworkResponse updateNetworkResponse = execution.getVariable("updateNetworkResponse"); + if(updateNetworkResponse == null) { + throw new Exception("No response was sent back from NetworkAdapterRestV1 subflow."); + } + } catch (Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapper.java index 701817ab58..2559087619 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapper.java @@ -110,8 +110,8 @@ public class VnfAdapterObjectMapper { return deleteVolumeGroupRequest; } - public Map<String, String> createVolumeGroupParams(RequestContext requestContext,GenericVnf genericVnf, VolumeGroup volumeGroup, String sdncVfModuleQueryResponse) throws JsonParseException, JsonMappingException, IOException { - Map<String, String> volumeGroupParams = new HashMap<>(); + public Map<String, Object> createVolumeGroupParams(RequestContext requestContext,GenericVnf genericVnf, VolumeGroup volumeGroup, String sdncVfModuleQueryResponse) throws JsonParseException, JsonMappingException, IOException { + Map<String, Object> volumeGroupParams = new HashMap<>(); final String USER_PARAM_NAME_KEY = "name"; final String USER_PARAM_VALUE_KEY = "value"; // sdncVfModuleQueryResponse will not be available in aLaCarte case @@ -147,7 +147,7 @@ public class VnfAdapterObjectMapper { return msoRequest; } - private void buildParamsMapFromSdncParams(Map<String,String> volumeGroupParams, GenericResourceApiParam sdncParameters) { + private void buildParamsMapFromSdncParams(Map<String,Object> volumeGroupParams, GenericResourceApiParam sdncParameters) { if (sdncParameters != null) { List<GenericResourceApiParamParam> sdncParametersList = sdncParameters.getParam(); if (sdncParametersList != null) { diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java index 352d4ec7d1..98174d59b6 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java @@ -161,7 +161,7 @@ public class VnfAdapterVfModuleObjectMapper { return msoRequest; } - private Map<String,String> buildVfModuleParamsMap(RequestContext requestContext, ServiceInstance serviceInstance, GenericVnf genericVnf, + private Map<String,Object> buildVfModuleParamsMap(RequestContext requestContext, ServiceInstance serviceInstance, GenericVnf genericVnf, VfModule vfModule, String sdncVnfQueryResponse, String sdncVfModuleQueryResponse) throws JsonParseException, JsonMappingException, IOException { @@ -169,7 +169,7 @@ public class VnfAdapterVfModuleObjectMapper { GenericResourceApiVfModuleTopology vfModuleTop = mapper.readValue(sdncVfModuleQueryResponse, GenericResourceApiVfModuleTopology.class); GenericResourceApiVnftopologyVnfTopology vnfTopology = vnfTop.getVnfTopology(); GenericResourceApiVfmoduletopologyVfModuleTopology vfModuleTopology = vfModuleTop.getVfModuleTopology(); - Map<String,String> paramsMap = new HashMap<>(); + Map<String,Object> paramsMap = new HashMap<>(); if( vfModuleTopology.getSdncGeneratedCloudResources()) { buildParamsMapFromVfModuleSdncResponse(paramsMap, vfModuleTopology, true); @@ -184,17 +184,15 @@ public class VnfAdapterVfModuleObjectMapper { buildMandatoryParamsMap(paramsMap, serviceInstance, genericVnf, vfModule); // Parameters received from the request should overwrite any parameters received from SDNC + paramsMap.putAll(requestContext.getUserParams()); - if (requestContext.getUserParams() != null) { - paramsMap.putAll(requestContext.getUserParams()); - } if (vfModule.getCloudParams() != null) { paramsMap.putAll(vfModule.getCloudParams()); } return paramsMap; } - private void buildMandatoryParamsMap(Map<String,String> paramsMap, ServiceInstance serviceInstance, GenericVnf genericVnf, VfModule vfModule) { + private void buildMandatoryParamsMap(Map<String,Object> paramsMap, ServiceInstance serviceInstance, GenericVnf genericVnf, VfModule vfModule) { paramsMap.put("vnf_id", genericVnf.getVnfId()); paramsMap.put("vnf_name", genericVnf.getVnfName()); paramsMap.put("vf_module_id", vfModule.getVfModuleId()); @@ -209,7 +207,7 @@ public class VnfAdapterVfModuleObjectMapper { } } - private void buildParamsMapFromVnfSdncResponse(Map<String,String> paramsMap, GenericResourceApiVnftopologyVnfTopology vnfTopology, Map<String,String> networkRoleMap, boolean skipVnfResourceAssignments) throws JsonParseException, JsonMappingException, IOException { + private void buildParamsMapFromVnfSdncResponse(Map<String,Object> paramsMap, GenericResourceApiVnftopologyVnfTopology vnfTopology, Map<String,String> networkRoleMap, boolean skipVnfResourceAssignments) throws JsonParseException, JsonMappingException, IOException { // Get VNF parameters from SDNC response GenericResourceApiParam vnfParametersData = vnfTopology.getVnfParametersData(); buildParamsMapFromSdncParams(paramsMap, vnfParametersData); @@ -225,7 +223,7 @@ public class VnfAdapterVfModuleObjectMapper { } } - private void buildAvailabilityZones (Map<String,String> paramsMap, GenericResourceApiVnfresourceassignmentsVnfResourceAssignments vnfResourceAssignments) { + private void buildAvailabilityZones (Map<String,Object> paramsMap, GenericResourceApiVnfresourceassignmentsVnfResourceAssignments vnfResourceAssignments) { GenericResourceApiVnfresourceassignmentsVnfresourceassignmentsAvailabilityZones availabilityZones = vnfResourceAssignments.getAvailabilityZones(); if (availabilityZones != null) { List<String> availabilityZonesList = availabilityZones.getAvailabilityZone(); @@ -237,7 +235,7 @@ public class VnfAdapterVfModuleObjectMapper { } } - private void buildVnfNetworks (Map<String,String> paramsMap, GenericResourceApiVnfresourceassignmentsVnfResourceAssignments vnfResourceAssignments, Map<String,String> networkRoleMap) { + private void buildVnfNetworks (Map<String,Object> paramsMap, GenericResourceApiVnfresourceassignmentsVnfResourceAssignments vnfResourceAssignments, Map<String,String> networkRoleMap) { GenericResourceApiVnfresourceassignmentsVnfresourceassignmentsVnfNetworks vnfNetworks = vnfResourceAssignments.getVnfNetworks(); if (vnfNetworks != null) { List<GenericResourceApiVnfNetworkData> vnfNetworksList = vnfNetworks.getVnfNetwork(); @@ -264,7 +262,7 @@ public class VnfAdapterVfModuleObjectMapper { } } - private void buildVnfNetworkSubnets(Map<String,String> paramsMap, GenericResourceApiVnfNetworkData vnfNetwork, String vnfNetworkKey) { + private void buildVnfNetworkSubnets(Map<String,Object> paramsMap, GenericResourceApiVnfNetworkData vnfNetwork, String vnfNetworkKey) { String vnfNetworkString = convertToString(vnfNetwork); Optional<String> ipv4Ips = jsonPath.locateResult(vnfNetworkString, "$.subnets-data.subnet-data[*].[?(@.ip-version == 'ipv4' && @.dhcp-enabled == 'Y')].subnet-id"); if(ipv4Ips.isPresent()) @@ -275,7 +273,7 @@ public class VnfAdapterVfModuleObjectMapper { addPairToMap(paramsMap, vnfNetworkKey, V6_SUBNET_ID, ipv6Ips.get()); } - private void buildParamsMapFromVfModuleSdncResponse(Map<String,String> paramsMap, GenericResourceApiVfmoduletopologyVfModuleTopology vfModuleTopology, boolean skipVfModuleAssignments) throws JsonParseException, JsonMappingException, IOException { + private void buildParamsMapFromVfModuleSdncResponse(Map<String,Object> paramsMap, GenericResourceApiVfmoduletopologyVfModuleTopology vfModuleTopology, boolean skipVfModuleAssignments) throws JsonParseException, JsonMappingException, IOException { // Get VF Module parameters from SDNC response GenericResourceApiParam vfModuleParametersData = vfModuleTopology.getVfModuleParameters(); buildParamsMapFromSdncParams(paramsMap, vfModuleParametersData); @@ -322,7 +320,7 @@ public class VnfAdapterVfModuleObjectMapper { } } - protected void buildVlanInformation(Map<String, String> paramsMap, + protected void buildVlanInformation(Map<String, Object> paramsMap, GenericResourceApiVmNetworkData network, String key, String networkKey) { String networkString = convertToString(network); @@ -352,7 +350,7 @@ public class VnfAdapterVfModuleObjectMapper { } } - private void buildVfModuleVmNames(Map<String,String> paramsMap, GenericResourceApiVmTopologyData vm, String key) { + private void buildVfModuleVmNames(Map<String,Object> paramsMap, GenericResourceApiVmTopologyData vm, String key) { String values = ""; GenericResourceApiVmtopologydataVmNames vmNames = vm.getVmNames(); if (vmNames != null) { @@ -373,7 +371,7 @@ public class VnfAdapterVfModuleObjectMapper { } } - private void buildVfModuleFloatingIps(Map<String,String> paramsMap, GenericResourceApiVmNetworkData network, String key, String networkKey) { + private void buildVfModuleFloatingIps(Map<String,Object> paramsMap, GenericResourceApiVmNetworkData network, String key, String networkKey) { GenericResourceApiVmnetworkdataFloatingIps floatingIps = network.getFloatingIps(); if (floatingIps != null) { List<String> floatingIpV4List = floatingIps.getFloatingIpV4(); @@ -397,7 +395,7 @@ public class VnfAdapterVfModuleObjectMapper { } } - private void buildVfModuleInterfaceRoutePrefixes(Map<String,String> paramsMap, GenericResourceApiVmNetworkData network, String key, String networkKey) { + private void buildVfModuleInterfaceRoutePrefixes(Map<String,Object> paramsMap, GenericResourceApiVmNetworkData network, String key, String networkKey) { GenericResourceApiVmnetworkdataInterfaceRoutePrefixes interfaceRoutePrefixes = network.getInterfaceRoutePrefixes(); if (interfaceRoutePrefixes != null) { List<String> interfaceRoutePrefixesList = interfaceRoutePrefixes.getInterfaceRoutePrefix(); @@ -421,7 +419,7 @@ public class VnfAdapterVfModuleObjectMapper { } } - private void buildVfModuleSriovParameters(Map<String,String> paramsMap, GenericResourceApiVmNetworkData network, String networkKey) { + private void buildVfModuleSriovParameters(Map<String,Object> paramsMap, GenericResourceApiVmNetworkData network, String networkKey) { // SRIOV Parameters GenericResourceApiVmnetworkdataSriovParameters sriovParameters = network.getSriovParameters(); if (sriovParameters != null) { @@ -447,7 +445,7 @@ public class VnfAdapterVfModuleObjectMapper { } } - private void buildVfModuleNetworkInformation(Map<String,String> paramsMap, GenericResourceApiVmNetworkData network, String key, String networkKey) { + private void buildVfModuleNetworkInformation(Map<String,Object> paramsMap, GenericResourceApiVmNetworkData network, String key, String networkKey) { GenericResourceApiVmnetworkdataNetworkInformationItems networkInformationItems = network.getNetworkInformationItems(); StringBuilder sbIpv4Ips = new StringBuilder(); @@ -500,7 +498,7 @@ public class VnfAdapterVfModuleObjectMapper { * Build Count of SubInterfaces, VLAN Tag, network_name, network_id, * ip_address (V4 and V6) and Floating IPs Addresses (V4 and V6) for Heat Template */ - private void buildParamsMapFromVfModuleForHeatTemplate(Map<String,String> paramsMap, GenericResourceApiVmTopologyData vm) { + private void buildParamsMapFromVfModuleForHeatTemplate(Map<String,Object> paramsMap, GenericResourceApiVmTopologyData vm) { GenericResourceApiVmtopologydataVmNames vmNames = vm.getVmNames(); if (vmNames != null) { @@ -520,7 +518,7 @@ public class VnfAdapterVfModuleObjectMapper { /* * Parse vnfcNames data to build Mapping from GenericResourceApi SDNC for Heat Template. */ - private void parseVnfcNamesData(Map<String,String> paramsMap, GenericResourceApiVmtopologydataVmnamesVnfcNames vnfcNames) { + private void parseVnfcNamesData(Map<String,Object> paramsMap, GenericResourceApiVmtopologydataVmnamesVnfcNames vnfcNames) { if (vnfcNames != null) { GenericResourceApiVnfcNetworkData vnfcNetworks = vnfcNames.getVnfcNetworks(); @@ -544,7 +542,7 @@ public class VnfAdapterVfModuleObjectMapper { * Build Count of SubInterfaces, VLAN Tag, network_name, network_id, * ip_address (V4 and V6) and Floating IPs Addresses (V4 and V6) for Heat Template */ - private void parseVnfcNetworkData(Map<String,String> paramsMap, GenericResourceApiVnfcnetworkdataVnfcNetworkData vnfcNetworkdata, int networkDataIdx) { + private void parseVnfcNetworkData(Map<String,Object> paramsMap, GenericResourceApiVnfcnetworkdataVnfcNetworkData vnfcNetworkdata, int networkDataIdx) { String vmTypeKey = vnfcNetworkdata.getVnfcType(); GenericResourceApiVnfcnetworkdataVnfcnetworkdataVnfcPorts vnfcPorts = vnfcNetworkdata.getVnfcPorts(); @@ -588,7 +586,7 @@ public class VnfAdapterVfModuleObjectMapper { * Example: fw_subint_ctrl_port_0_subintcount * */ - private void buildVfModuleSubInterfacesCount(Map<String,String> paramsMap, String keyPrefix, GenericResourceApiSubInterfaceNetworkData vnicSubInterfaces) { + private void buildVfModuleSubInterfacesCount(Map<String,Object> paramsMap, String keyPrefix, GenericResourceApiSubInterfaceNetworkData vnicSubInterfaces) { List<GenericResourceApiSubinterfacenetworkdataSubInterfaceNetworkData> subInterfaceNetworkDataList = vnicSubInterfaces.getSubInterfaceNetworkData(); @@ -614,7 +612,7 @@ public class VnfAdapterVfModuleObjectMapper { * Example: fw_0_subint_ctrl_port_0_vlan_ids * */ - protected void buildVfModuleVlanTag(Map<String,String> paramsMap, String keyPrefix, String vnicSubInterfaces) { + protected void buildVfModuleVlanTag(Map<String,Object> paramsMap, String keyPrefix, String vnicSubInterfaces) { List<String> vlanTagIds = jsonPath.locateResultList(vnicSubInterfaces, "$.sub-interface-network-data[*].vlan-tag-id"); @@ -627,7 +625,7 @@ public class VnfAdapterVfModuleObjectMapper { * Example: fw_0_subint_ctrl_port_0_net_names * */ - protected void buildVfModuleNetworkName(Map<String,String> paramsMap, String keyPrefix, String vnicSubInterfaces) { + protected void buildVfModuleNetworkName(Map<String,Object> paramsMap, String keyPrefix, String vnicSubInterfaces) { List<String> neworkNames = jsonPath.locateResultList(vnicSubInterfaces, "$.sub-interface-network-data[*].network-name"); @@ -641,7 +639,7 @@ public class VnfAdapterVfModuleObjectMapper { * Example: fw_0_subint_ctrl_port_0_net_ids * */ - protected void buildVfModuleNetworkId(Map<String,String> paramsMap, String keyPrefix, String vnicSubInterfaces) { + protected void buildVfModuleNetworkId(Map<String,Object> paramsMap, String keyPrefix, String vnicSubInterfaces) { List<String> neworkIds = jsonPath.locateResultList(vnicSubInterfaces, "$.sub-interface-network-data[*].network-id"); @@ -654,7 +652,7 @@ public class VnfAdapterVfModuleObjectMapper { * {vm-type}_{index}_subint_{network-role}_port_{index}_ip_{index} -- for ipV4 * key = vm-type, networkRoleKey = NetWork-Role */ - protected void buildVfModuleIpV4AddressHeatTemplate(Map<String,String> paramsMap, String keyPrefix, String vnicSubInterfaces) { + protected void buildVfModuleIpV4AddressHeatTemplate(Map<String,Object> paramsMap, String keyPrefix, String vnicSubInterfaces) { List<String> ipv4Ips = jsonPath.locateResultList(vnicSubInterfaces, "$.sub-interface-network-data[*].network-information-items.network-information-item[?(@.ip-version == 'ipv4')].network-ips.network-ip[*]"); @@ -672,7 +670,7 @@ public class VnfAdapterVfModuleObjectMapper { * {vm-type}_{index}_subint_{network-role}_port_{index}_v6_ip_{index} -- for ipV6 * key = vm-type, networkRoleKey = NetWork-Role */ - protected void buildVfModuleIpV6AddressHeatTemplate(Map<String,String> paramsMap, String keyPrefix, String vnicSubInterfaces) { + protected void buildVfModuleIpV6AddressHeatTemplate(Map<String,Object> paramsMap, String keyPrefix, String vnicSubInterfaces) { List<String> ipv6Ips = jsonPath.locateResultList(vnicSubInterfaces, "$.sub-interface-network-data[*].network-information-items.network-information-item[?(@.ip-version == 'ipv6')].network-ips.network-ip[*]"); @@ -688,7 +686,7 @@ public class VnfAdapterVfModuleObjectMapper { * Building Criteria : * {vm-type}_subint_{network-role}_port_{index}_floating_ip -- for ipV4 */ - protected void buildVfModuleFloatingIpV4HeatTemplate(Map<String,String> paramsMap, String keyPrefix, String vnicSubInterfaces) { + protected void buildVfModuleFloatingIpV4HeatTemplate(Map<String,Object> paramsMap, String keyPrefix, String vnicSubInterfaces) { List<String> floatingV4 = jsonPath.locateResultList(vnicSubInterfaces, "$.sub-interface-network-data[*].floating-ips.floating-ip-v4[*]"); @@ -704,7 +702,7 @@ public class VnfAdapterVfModuleObjectMapper { * Building Criteria : * {vm-type}_subint_{network-role}_port_{index}_floating_v6_ip -- for ipV6 */ - protected void buildVfModuleFloatingIpV6HeatTemplate(Map<String,String> paramsMap, String keyPrefix, String vnicSubInterfaces) { + protected void buildVfModuleFloatingIpV6HeatTemplate(Map<String,Object> paramsMap, String keyPrefix, String vnicSubInterfaces) { List<String> floatingV6 = jsonPath.locateResultList(vnicSubInterfaces, "$.sub-interface-network-data[*].floating-ips.floating-ip-v6[*]"); @@ -714,19 +712,19 @@ public class VnfAdapterVfModuleObjectMapper { addPairToMap(paramsMap, keyPrefix, FLOATING_V6_IP, floatingV6); } - protected void addPairToMap(Map<String, String> paramsMap, String keyPrefix, String key, String value) { + protected void addPairToMap(Map<String, Object> paramsMap, String keyPrefix, String key, String value) { addPairToMap(paramsMap, keyPrefix, key, Collections.singletonList(value)); } - protected void addPairToMap(Map<String, String> paramsMap, String keyPrefix, String key, List<String> value) { + protected void addPairToMap(Map<String, Object> paramsMap, String keyPrefix, String key, List<String> value) { if (!value.isEmpty()) { paramsMap.put(keyPrefix + key, Joiner.on(",").join(value)); } } - private void buildParamsMapFromSdncParams(Map<String,String> paramsMap, GenericResourceApiParam parametersData) { + private void buildParamsMapFromSdncParams(Map<String,Object> paramsMap, GenericResourceApiParam parametersData) { if (parametersData != null) { List<GenericResourceApiParamParam> paramsList = parametersData.getParam(); if (paramsList != null) { diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapper.java index 2cd0947fa8..e46c456f88 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapper.java @@ -22,16 +22,27 @@ package org.onap.so.client.sdnc.mapper; import java.net.URI; -import org.onap.sdnc.northbound.client.model.*; -import org.onap.so.bpmn.servicedecomposition.bbobjects.*; +import org.onap.sdnc.northbound.client.model.GenericResourceApiConfigurationinformationConfigurationInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiGcTopologyOperationInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiGcrequestinputGcRequestInput; +import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; +import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestinformationRequestInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiSdncrequestheaderSdncRequestHeader; +import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformationServiceInformation; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; import org.onap.so.client.sdnc.beans.SDNCSvcAction; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @Component(value = "sdncGCTopologyOperationRequestMapper") public class GCTopologyOperationRequestMapper { - private static final GeneralTopologyObjectMapper generalTopologyObjectMapper = new GeneralTopologyObjectMapper(); + @Autowired + private GeneralTopologyObjectMapper generalTopologyObjectMapper; public GenericResourceApiGcTopologyOperationInformation assignOrActivateVnrReqMapper(SDNCSvcAction svcAction, GenericResourceApiRequestActionEnumeration reqAction, @@ -82,5 +93,4 @@ public class GCTopologyOperationRequestMapper { } - } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java index 7632831111..fedbde251e 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java @@ -20,18 +20,42 @@ package org.onap.so.client.sdnc.mapper; -import org.onap.sdnc.northbound.client.model.*; -import org.onap.so.bpmn.servicedecomposition.bbobjects.*; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.onap.sdnc.northbound.client.model.GenericResourceApiConfigurationinformationConfigurationInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiGcrequestinputGcRequestInput; +import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkinformationNetworkInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiOnapmodelinformationOnapModelInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiParam; +import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; +import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestinformationRequestInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiSdncrequestheaderSdncRequestHeader; +import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformationServiceInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVfmoduleinformationVfModuleInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfinformationVnfInformation; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; +import org.onap.so.client.exception.MapperException; import org.onap.so.client.sdnc.beans.SDNCSvcAction; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.env.Environment; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; -import org.onap.so.client.exception.MapperException; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; @Component public class GeneralTopologyObjectMapper { + private static final Logger logger = LoggerFactory.getLogger(GeneralTopologyObjectMapper.class); + private ObjectMapper mapper = new ObjectMapper(); /* * Build GenericResourceApiRequestinformationRequestInformation @@ -194,4 +218,22 @@ public class GeneralTopologyObjectMapper { } return gcRequestInput; } + + + public String mapUserParamValue(Object value) { + if (value == null) { + return null; + } else { + if (value instanceof Map || value instanceof Set || value instanceof List) { + try { + return mapper.writeValueAsString(value); + } catch (JsonProcessingException e) { + logger.error("could not map value to string", e); + throw new IllegalArgumentException(e); + } + } else { + return value.toString(); + } + } + } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapper.java index 2b4834af42..188a228e5d 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapper.java @@ -23,15 +23,6 @@ package org.onap.so.client.sdnc.mapper; import java.util.Map; import java.util.UUID; -import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; -import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; -import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; -import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; -import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; -import org.onap.so.client.sdnc.beans.SDNCSvcAction; -import org.onap.so.client.sdnc.beans.SDNCSvcOperation; -import org.springframework.stereotype.Component; - import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkOperationInformation; import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkinformationNetworkInformation; import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkrequestinputNetworkRequestInput; @@ -41,6 +32,15 @@ import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnum import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestinformationRequestInformation; import org.onap.sdnc.northbound.client.model.GenericResourceApiSdncrequestheaderSdncRequestHeader; import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformationServiceInformation; +import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; +import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; +import org.onap.so.client.sdnc.beans.SDNCSvcAction; +import org.onap.so.client.sdnc.beans.SDNCSvcOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; /** * Mapper creating SDNC request @@ -49,7 +49,8 @@ import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformatio @Component public class NetworkTopologyOperationRequestMapper { - static GeneralTopologyObjectMapper generalTopologyObjectMapper = new GeneralTopologyObjectMapper(); + @Autowired + private GeneralTopologyObjectMapper generalTopologyObjectMapper; public GenericResourceApiNetworkOperationInformation reqMapper(SDNCSvcOperation svcOperation, SDNCSvcAction svcAction, GenericResourceApiRequestActionEnumeration reqAction, L3Network network, ServiceInstance serviceInstance, @@ -68,11 +69,11 @@ public class NetworkTopologyOperationRequestMapper { req.setNetworkInformation(networkInformation); if (requestContext.getUserParams() != null) { - for (Map.Entry<String, String> entry : requestContext.getUserParams().entrySet()) { + for (Map.Entry<String, Object> entry : requestContext.getUserParams().entrySet()) { GenericResourceApiParam networkInputParameters = new GenericResourceApiParam(); GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam(); - paramItem.setName(entry.getKey()); - paramItem.setValue(entry.getValue()); + paramItem.setName(entry.getKey()); + paramItem.setValue(generalTopologyObjectMapper.mapUserParamValue(entry.getValue())); networkInputParameters.addParamItem(paramItem); networkRequestInput.setNetworkInputParameters(networkInputParameters); } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapper.java index 5b23707cb9..505466b22c 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapper.java @@ -23,13 +23,6 @@ package org.onap.so.client.sdnc.mapper; import java.util.Map; import java.util.UUID; -import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; -import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; -import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; -import org.onap.so.client.sdnc.beans.SDNCSvcAction; -import org.onap.so.client.sdnc.beans.SDNCSvcOperation; -import org.springframework.stereotype.Component; - import org.onap.sdnc.northbound.client.model.GenericResourceApiParam; import org.onap.sdnc.northbound.client.model.GenericResourceApiParamParam; import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; @@ -38,11 +31,19 @@ import org.onap.sdnc.northbound.client.model.GenericResourceApiSdncrequestheader import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation; import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformationServiceInformation; import org.onap.sdnc.northbound.client.model.GenericResourceApiServicerequestinputServiceRequestInput; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; +import org.onap.so.client.sdnc.beans.SDNCSvcAction; +import org.onap.so.client.sdnc.beans.SDNCSvcOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; @Component public class ServiceTopologyOperationMapper{ - static GeneralTopologyObjectMapper generalTopologyObjectMapper = new GeneralTopologyObjectMapper(); + @Autowired + public GeneralTopologyObjectMapper generalTopologyObjectMapper; public GenericResourceApiServiceOperationInformation reqMapper (SDNCSvcOperation svcOperation, SDNCSvcAction svcAction, GenericResourceApiRequestActionEnumeration resourceAction,ServiceInstance serviceInstance, Customer customer, RequestContext requestContext) { @@ -62,13 +63,13 @@ public class ServiceTopologyOperationMapper{ servOpInput.setServiceRequestInput(servReqInfo); if(requestContext.getUserParams()!=null){ - for (Map.Entry<String, String> entry : requestContext.getUserParams().entrySet()) { + for (Map.Entry<String, Object> entry : requestContext.getUserParams().entrySet()) { GenericResourceApiServicerequestinputServiceRequestInput serviceRequestInput = new GenericResourceApiServicerequestinputServiceRequestInput(); serviceRequestInput.setServiceInstanceName(serviceInstance.getServiceInstanceName()); GenericResourceApiParam serviceInputParameters = new GenericResourceApiParam(); GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam(); paramItem.setName(entry.getKey()); - paramItem.setValue(entry.getValue()); + paramItem.setValue(generalTopologyObjectMapper.mapUserParamValue(entry.getValue())); serviceInputParameters.addParamItem(paramItem ); serviceRequestInput.serviceInputParameters(serviceInputParameters); servOpInput.setServiceRequestInput(serviceRequestInput ); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java index 8e0072b16c..f70ac8399f 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java @@ -25,13 +25,25 @@ package org.onap.so.client.sdnc.mapper; import java.util.Map; import java.util.UUID; +import org.onap.sdnc.northbound.client.model.GenericResourceApiParam; +import org.onap.sdnc.northbound.client.model.GenericResourceApiParamParam; +import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; +import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestinformationRequestInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiSdncrequestheaderSdncRequestHeader; +import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformationServiceInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiSvcActionEnumeration; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleResponseInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVfmoduleinformationVfModuleInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVfmodulerequestinputVfModuleRequestInput; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfinformationVnfInformation; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; -import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.client.exception.MapperException; import org.onap.so.client.sdnc.beans.SDNCSvcAction; import org.onap.so.client.sdnc.beans.SDNCSvcOperation; @@ -39,27 +51,17 @@ import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import org.onap.sdnc.northbound.client.model.GenericResourceApiParam; -import org.onap.sdnc.northbound.client.model.GenericResourceApiParamParam; -import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; -import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestinformationRequestInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiSdncrequestheaderSdncRequestHeader; -import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformationServiceInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiSvcActionEnumeration; -import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfinformationVnfInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiVfmoduleinformationVfModuleInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiVfmodulerequestinputVfModuleRequestInput; -import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleResponseInformation; - import com.fasterxml.jackson.databind.ObjectMapper; @Component public class VfModuleTopologyOperationRequestMapper { private static final Logger logger = LoggerFactory.getLogger(VfModuleTopologyOperationRequestMapper.class); - static GeneralTopologyObjectMapper generalTopologyObjectMapper = new GeneralTopologyObjectMapper(); + + @Autowired + private GeneralTopologyObjectMapper generalTopologyObjectMapper; public GenericResourceApiVfModuleOperationInformation reqMapper(SDNCSvcOperation svcOperation, SDNCSvcAction svcAction, VfModule vfModule, VolumeGroup volumeGroup, GenericVnf vnf, ServiceInstance serviceInstance, @@ -126,10 +128,10 @@ public class VfModuleTopologyOperationRequestMapper { GenericResourceApiParam vfModuleInputParameters = new GenericResourceApiParam(); if (requestContext != null && requestContext.getUserParams() != null) { - for (Map.Entry<String, String> entry : requestContext.getUserParams().entrySet()) { + for (Map.Entry<String, Object> entry : requestContext.getUserParams().entrySet()) { GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam(); paramItem.setName(entry.getKey()); - paramItem.setValue(entry.getValue()); + paramItem.setValue(generalTopologyObjectMapper.mapUserParamValue(entry.getValue())); vfModuleInputParameters.addParamItem(paramItem); } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java index e860d3cc48..7de393bb2f 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java @@ -26,6 +26,16 @@ import java.util.Map; import java.util.UUID; import org.apache.commons.lang.StringUtils; +import org.onap.sdnc.northbound.client.model.GenericResourceApiParam; +import org.onap.sdnc.northbound.client.model.GenericResourceApiParamParam; +import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; +import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestinformationRequestInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiSdncrequestheaderSdncRequestHeader; +import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformationServiceInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfinformationVnfInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfrequestinputVnfRequestInput; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfrequestinputVnfrequestinputVnfNetworkInstanceGroupIds; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; @@ -36,23 +46,14 @@ import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup; import org.onap.so.client.sdnc.beans.SDNCSvcAction; import org.onap.so.client.sdnc.beans.SDNCSvcOperation; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import org.onap.sdnc.northbound.client.model.GenericResourceApiParam; -import org.onap.sdnc.northbound.client.model.GenericResourceApiParamParam; -import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; -import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestinformationRequestInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiSdncrequestheaderSdncRequestHeader; -import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformationServiceInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfinformationVnfInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfrequestinputVnfRequestInput; -import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfrequestinputVnfrequestinputVnfNetworkInstanceGroupIds; - @Component public class VnfTopologyOperationRequestMapper { - static GeneralTopologyObjectMapper generalTopologyObjectMapper = new GeneralTopologyObjectMapper(); + @Autowired + private GeneralTopologyObjectMapper generalTopologyObjectMapper; public GenericResourceApiVnfOperationInformation reqMapper(SDNCSvcOperation svcOperation, SDNCSvcAction svcAction, GenericResourceApiRequestActionEnumeration requestAction, GenericVnf vnf, ServiceInstance serviceInstance, @@ -84,10 +85,10 @@ public class VnfTopologyOperationRequestMapper { GenericResourceApiParam vnfInputParameters = new GenericResourceApiParam(); if (requestContext.getUserParams() != null) { - for (Map.Entry<String, String> entry : requestContext.getUserParams().entrySet()) { + for (Map.Entry<String, Object> entry : requestContext.getUserParams().entrySet()) { GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam(); paramItem.setName(entry.getKey()); - paramItem.setValue(entry.getValue()); + paramItem.setValue(generalTopologyObjectMapper.mapUserParamValue(entry.getValue())); vnfInputParameters.addParamItem(paramItem); vnfRequestInput.setVnfInputParameters(vnfInputParameters); } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java index 73d7257632..a8a249f386 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java @@ -43,6 +43,7 @@ import org.mockito.ArgumentMatchers; import org.mockito.InjectMocks; import org.mockito.Mockito; import org.onap.so.adapters.nwrest.CreateNetworkResponse; +import org.onap.so.adapters.nwrest.UpdateNetworkResponse; import org.onap.so.bpmn.BaseTaskTest; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; @@ -456,6 +457,29 @@ public class AAIUpdateTasksTest extends BaseTaskTest{ String neutronSubnetId = createNetworkResponse.getSubnetMap().entrySet().iterator().next().getValue(); assertEquals(neutronSubnetId, network.getSubnets().get(0).getNeutronSubnetId()); } + + @Test + public void updateNetworkUpdatedTest() throws Exception { + UpdateNetworkResponse updateNetworkResponse = new UpdateNetworkResponse(); + updateNetworkResponse.setNeutronNetworkId("testNeutronNetworkId"); + HashMap<String, String> subnetMap = new HashMap<>(); + subnetMap.put("testSubnetId", "testNeutronSubnetId"); + updateNetworkResponse.setSubnetMap(subnetMap); + + network.getSubnets().add(subnet); + + execution.setVariable("updateNetworkResponse", updateNetworkResponse); + + doNothing().when(aaiNetworkResources).updateNetwork(network); + doNothing().when(aaiNetworkResources).updateSubnet(network, subnet); + + aaiUpdateTasks.updateNetworkUpdated(execution); + verify(aaiNetworkResources, times(1)).updateNetwork(network); + verify(aaiNetworkResources, times(1)).updateSubnet(network, subnet); + + String neutronSubnetId = updateNetworkResponse.getSubnetMap().entrySet().iterator().next().getValue(); + assertEquals(neutronSubnetId, network.getSubnets().get(0).getNeutronSubnetId()); + } @Test public void updateOrchestrationStatusNetworkTest() { diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterUpdateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterUpdateTasksTest.java index 9f2f2fbdcc..478c512b0a 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterUpdateTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterUpdateTasksTest.java @@ -24,6 +24,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.times; @@ -39,6 +40,8 @@ import org.junit.Before; import org.junit.Test; import org.mockito.ArgumentMatchers; import org.mockito.InjectMocks; +import org.onap.so.adapters.nwrest.CreateNetworkRequest; +import org.onap.so.adapters.nwrest.UpdateNetworkRequest; import org.onap.so.adapters.nwrest.UpdateNetworkResponse; import org.onap.so.bpmn.BaseTaskTest; import org.onap.so.bpmn.common.BuildingBlockExecution; @@ -83,35 +86,15 @@ public class NetworkAdapterUpdateTasksTest extends BaseTaskTest{ @Test public void updateNetworkTest() throws Exception { - UpdateNetworkResponse updateNetworkResponse = new UpdateNetworkResponse(); - updateNetworkResponse.setMessageId("messageId"); - updateNetworkResponse.setNetworkId("networkId"); - Optional<UpdateNetworkResponse> oUpdateNetworkResponse = Optional.of(updateNetworkResponse); - - doReturn(oUpdateNetworkResponse).when(networkAdapterResources).updateNetwork(requestContext, cloudRegion, orchestrationContext, serviceInstance, network, userInput, customer); - - networkAdapterUpdateTasks.updateNetwork(execution); - - verify(networkAdapterResources, times(1)).updateNetwork(requestContext, cloudRegion, orchestrationContext, serviceInstance, network, userInput, customer); - assertEquals(updateNetworkResponse, execution.getVariable("NetworkAdapterUpdateNetworkResponse")); - } - - @Test - public void updateNetworkNoResponseTest() throws Exception { - doReturn(Optional.empty()).when(networkAdapterResources).updateNetwork(requestContext, cloudRegion, orchestrationContext, serviceInstance, network, userInput, customer); - + String cloudRegionPo = "cloudRegionPo"; + UpdateNetworkRequest updateNetworkRequest = new UpdateNetworkRequest(); + execution.setVariable("cloudRegionPo", cloudRegionPo); + + doReturn(updateNetworkRequest).when(networkAdapterObjectMapper).createNetworkUpdateRequestMapper(isA(RequestContext.class), isA(CloudRegion.class), isA(OrchestrationContext.class), isA(ServiceInstance.class), isA(L3Network.class), isA(Map.class), isA(Customer.class)); networkAdapterUpdateTasks.updateNetwork(execution); - - verify(networkAdapterResources, times(1)).updateNetwork(requestContext, cloudRegion, orchestrationContext, serviceInstance, network, userInput, customer); - assertNull(execution.getVariable("NetworkAdapterUpdateNetworkResponse")); + verify(networkAdapterObjectMapper, times(1)).createNetworkUpdateRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, network, userInput, customer); + assertEquals(updateNetworkRequest, execution.getVariable("networkAdapterRequest")); } - @Test - public void updateNetworkExceptionTest() throws UnsupportedEncodingException, NetworkAdapterClientException { - expectedException.expect(BpmnError.class); - doThrow(new NetworkAdapterClientException("ERROR")).when(networkAdapterResources).updateNetwork(any(RequestContext.class),any(CloudRegion.class), - any(OrchestrationContext.class),eq(serviceInstance),eq(network),any(Map.class),any(Customer.class)); - doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class)); - networkAdapterUpdateTasks.updateNetwork(execution); - } + } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapperTest.java index 339e9cbf17..5169663add 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapperTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapperTest.java @@ -72,7 +72,6 @@ public class VnfAdapterObjectMapperTest { } @Test - @Ignore public void test_createVolumeGroupRequestMapper() throws Exception { RequestContext requestContext = new RequestContext(); requestContext.setMsoRequestId("msoRequestId"); @@ -123,7 +122,7 @@ public class VnfAdapterObjectMapperTest { expectedCreateVolumeGroupRequest.setVfModuleType(volumeGroup.getModelInfoVfModule().getModelName()); expectedCreateVolumeGroupRequest.setModelCustomizationUuid(volumeGroup.getModelInfoVfModule().getModelCustomizationUUID()); - Map<String, String> volumeGroupParams = new HashMap<>(); + Map<String, Object> volumeGroupParams = new HashMap<>(); volumeGroupParams.put("vnf_id", genericVnf.getVnfId()); volumeGroupParams.put("vnf_name", genericVnf.getVnfName()); volumeGroupParams.put("vf_module_id", volumeGroup.getVolumeGroupId()); @@ -201,7 +200,7 @@ public class VnfAdapterObjectMapperTest { expectedCreateVolumeGroupRequest.setVfModuleType(volumeGroup.getModelInfoVfModule().getModelName()); expectedCreateVolumeGroupRequest.setModelCustomizationUuid(volumeGroup.getModelInfoVfModule().getModelCustomizationUUID()); - Map<String, String> volumeGroupParams = new HashMap<>(); + Map<String, Object> volumeGroupParams = new HashMap<>(); volumeGroupParams.put("vnf_id", genericVnf.getVnfId()); volumeGroupParams.put("vnf_name", genericVnf.getVnfName()); volumeGroupParams.put("vf_module_id", volumeGroup.getVolumeGroupId()); @@ -285,7 +284,6 @@ public class VnfAdapterObjectMapperTest { } @Test - @Ignore public void test_createVolumeGroupParams() throws Exception { GenericVnf genericVnf = new GenericVnf(); genericVnf.setVnfId("vnfId"); @@ -308,7 +306,7 @@ public class VnfAdapterObjectMapperTest { expectedVolumeGroupParams.put("paramTwo", "paramTwoValue"); expectedVolumeGroupParams.put("paramThree", "paramThreeValue"); - Map<String, String> actualVolumeGroupParams = vnfAdapterObjectMapper.createVolumeGroupParams(requestContext,genericVnf, volumeGroup, sdncVfModuleQueryResponse); + Map<String, Object> actualVolumeGroupParams = vnfAdapterObjectMapper.createVolumeGroupParams(requestContext,genericVnf, volumeGroup, sdncVfModuleQueryResponse); assertEquals(expectedVolumeGroupParams, actualVolumeGroupParams); } @@ -329,13 +327,12 @@ public class VnfAdapterObjectMapperTest { expectedVolumeGroupParams.put("vf_module_id", volumeGroup.getVolumeGroupId()); expectedVolumeGroupParams.put("vf_module_name", volumeGroup.getVolumeGroupName()); RequestContext requestContext = new RequestContext(); - Map<String, String> actualVolumeGroupParams = vnfAdapterObjectMapper.createVolumeGroupParams(requestContext,genericVnf, volumeGroup, null); + Map<String, Object> actualVolumeGroupParams = vnfAdapterObjectMapper.createVolumeGroupParams(requestContext,genericVnf, volumeGroup, null); assertEquals(expectedVolumeGroupParams, actualVolumeGroupParams); } @Test - @Ignore public void test_createVolumeGroupParams_with_user_params() throws Exception { GenericVnf genericVnf = new GenericVnf(); genericVnf.setVnfId("vnfId"); @@ -366,7 +363,7 @@ public class VnfAdapterObjectMapperTest { expectedVolumeGroupParams.put("paramThree", "paramThreeValue"); expectedVolumeGroupParams.put("userParamKey", "userParamValue"); - Map<String, String> actualVolumeGroupParams = vnfAdapterObjectMapper.createVolumeGroupParams(requestContext,genericVnf, volumeGroup, sdncVfModuleQueryResponse); + Map<String, Object> actualVolumeGroupParams = vnfAdapterObjectMapper.createVolumeGroupParams(requestContext,genericVnf, volumeGroup, sdncVfModuleQueryResponse); assertEquals(expectedVolumeGroupParams, actualVolumeGroupParams); } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperPayloadTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperPayloadTest.java index a156c382d1..00e5c10f73 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperPayloadTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperPayloadTest.java @@ -76,7 +76,7 @@ public class VnfAdapterVfModuleObjectMapperPayloadTest { serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance); RequestContext requestContext = new RequestContext(); - HashMap<String, String> userParams = new HashMap<String, String>(); + Map<String, Object> userParams = new HashMap<>(); userParams.put("key1", "value2"); requestContext.setMsoRequestId("requestId"); requestContext.setUserParams(userParams); @@ -150,7 +150,7 @@ public class VnfAdapterVfModuleObjectMapperPayloadTest { serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance); RequestContext requestContext = new RequestContext(); - HashMap<String, String> userParams = new HashMap<String, String>(); + Map<String, Object> userParams = new HashMap<>(); userParams.put("key1", "value2"); requestContext.setMsoRequestId("requestId"); requestContext.setUserParams(userParams); @@ -223,7 +223,7 @@ public class VnfAdapterVfModuleObjectMapperPayloadTest { serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance); RequestContext requestContext = new RequestContext(); - HashMap<String, String> userParams = new HashMap<String, String>(); + Map<String, Object> userParams = new HashMap<>(); userParams.put("key1", "value2"); requestContext.setMsoRequestId("requestId"); requestContext.setUserParams(userParams); @@ -295,7 +295,7 @@ public class VnfAdapterVfModuleObjectMapperPayloadTest { // RequestContext requestContext = new RequestContext(); - HashMap<String, String> userParams = new HashMap<String, String>(); + Map<String, Object> userParams = new HashMap<>(); userParams.put("key1", "value2"); requestContext.setMsoRequestId("requestId"); requestContext.setUserParams(userParams); @@ -375,7 +375,7 @@ public class VnfAdapterVfModuleObjectMapperPayloadTest { // RequestContext requestContext = new RequestContext(); - HashMap<String, String> userParams = new HashMap<String, String>(); + Map<String, Object> userParams = new HashMap<>(); userParams.put("key1", "value2"); requestContext.setMsoRequestId("requestId"); requestContext.setUserParams(userParams); @@ -450,7 +450,7 @@ public class VnfAdapterVfModuleObjectMapperPayloadTest { serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance); RequestContext requestContext = new RequestContext(); - HashMap<String, String> userParams = new HashMap<String, String>(); + Map<String, Object> userParams = new HashMap<>(); userParams.put("key1", "value2"); requestContext.setMsoRequestId("requestId"); requestContext.setUserParams(userParams); @@ -521,7 +521,7 @@ public class VnfAdapterVfModuleObjectMapperPayloadTest { serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance); RequestContext requestContext = new RequestContext(); - HashMap<String, String> userParams = new HashMap<String, String>(); + Map<String, Object> userParams = new HashMap<>(); userParams.put("key1", "value1"); requestContext.setMsoRequestId("requestId"); requestContext.setUserParams(userParams); @@ -591,7 +591,7 @@ public class VnfAdapterVfModuleObjectMapperPayloadTest { serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance); RequestContext requestContext = new RequestContext(); - HashMap<String, String> userParams = new HashMap<String, String>(); + Map<String, Object> userParams = new HashMap<>(); userParams.put("key1", "value1"); requestContext.setMsoRequestId("requestId"); requestContext.setUserParams(userParams); @@ -661,7 +661,7 @@ public class VnfAdapterVfModuleObjectMapperPayloadTest { serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance); RequestContext requestContext = new RequestContext(); - HashMap<String, String> userParams = new HashMap<String, String>(); + Map<String, Object> userParams = new HashMap<>(); userParams.put("key1", "value1"); requestContext.setMsoRequestId("requestId"); requestContext.setUserParams(userParams); @@ -798,7 +798,7 @@ public class VnfAdapterVfModuleObjectMapperPayloadTest { serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance); RequestContext requestContext = new RequestContext(); - HashMap<String, String> userParams = new HashMap<String, String>(); + Map<String, Object> userParams = new HashMap<>(); userParams.put("key1", "value1"); requestContext.setMsoRequestId("requestId"); requestContext.setUserParams(userParams); @@ -853,7 +853,7 @@ public class VnfAdapterVfModuleObjectMapperPayloadTest { String json = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "grApiVmNetworkSubSectionWith5GParams.json"))); GenericResourceApiVmNetworkData network = omapper.readValue(json, GenericResourceApiVmNetworkData.class); - Map<String, String> paramsMap = new HashMap<>(); + Map<String, Object> paramsMap = new HashMap<>(); vfModuleObjectMapper.buildVlanInformation(paramsMap, network, "testKey", "testType"); assertEquals("1,3", paramsMap.get("testKey_testType_private_vlans")); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperTest.java index 160feed426..81d30e33c5 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperTest.java @@ -67,7 +67,7 @@ public class VnfAdapterVfModuleObjectMapperTest { @Test public void addPairToMapTest() { - Map<String, String> map = new HashMap<>(); + Map<String, Object> map = new HashMap<>(); mapper.addPairToMap(map, "test", "_key", Arrays.asList("a", "b")); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCConfigurationResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCConfigurationResourcesTest.java index 4d90a3fcc9..0023066949 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCConfigurationResourcesTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCConfigurationResourcesTest.java @@ -22,9 +22,7 @@ package org.onap.so.client.orchestration; import static org.junit.Assert.assertNotNull; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.isA; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.times; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.verify; import java.net.URI; @@ -35,10 +33,11 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; +import org.onap.sdnc.northbound.client.model.GenericResourceApiGcTopologyOperationInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; import org.onap.so.bpmn.common.data.TestDataSetup; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; @@ -47,19 +46,17 @@ import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; import org.onap.so.client.exception.BadResponseException; import org.onap.so.client.exception.MapperException; import org.onap.so.client.sdnc.SDNCClient; -import org.onap.so.client.sdnc.endpoint.SDNCTopology; +import org.onap.so.client.sdnc.beans.SDNCSvcAction; import org.onap.so.client.sdnc.mapper.GCTopologyOperationRequestMapper; -import org.onap.sdnc.northbound.client.model.GenericResourceApiGcTopologyOperationInformation; - @RunWith(MockitoJUnitRunner.Silent.class) public class SDNCConfigurationResourcesTest extends TestDataSetup{ @InjectMocks private SDNCConfigurationResources sdncConfigurationResources = new SDNCConfigurationResources(); - @Spy - GCTopologyOperationRequestMapper MOCK_gcTopologyMapper ; + @Mock + private GCTopologyOperationRequestMapper MOCK_gcTopologyMapper ; @Mock protected SDNCClient MOCK_sdncClient; @@ -82,24 +79,34 @@ public class SDNCConfigurationResourcesTest extends TestDataSetup{ @Test public void activateVnrConfigurationTest() throws BadResponseException, MapperException, URISyntaxException { GenericResourceApiGcTopologyOperationInformation response = sdncConfigurationResources.activateVnrConfiguration(serviceInstance,requestContext,customer,vpnBondingLink.getVnrConfiguration(),vnf,"uuid",new URI("http://localhost")); - assertNotNull(response); + verify(MOCK_gcTopologyMapper).assignOrActivateVnrReqMapper( + eq(SDNCSvcAction.ACTIVATE), eq(GenericResourceApiRequestActionEnumeration.CREATEGENERICCONFIGURATIONINSTANCE), + eq(serviceInstance), eq(requestContext), eq(customer), any(Configuration.class), any(GenericVnf.class), any(String.class), any(URI.class)); + } @Test public void assignVnrConfigurationTest() throws BadResponseException, MapperException, URISyntaxException { GenericResourceApiGcTopologyOperationInformation response = sdncConfigurationResources.assignVnrConfiguration(serviceInstance,requestContext,customer,vpnBondingLink.getVnrConfiguration(),vnf,"uuid",new URI("http://localhost")); - assertNotNull(response); + verify(MOCK_gcTopologyMapper).assignOrActivateVnrReqMapper( + eq(SDNCSvcAction.ASSIGN), eq(GenericResourceApiRequestActionEnumeration.CREATEGENERICCONFIGURATIONINSTANCE), + eq(serviceInstance), eq(requestContext), eq(customer), any(Configuration.class), any(GenericVnf.class), any(String.class), any(URI.class)); + } @Test public void unAssignVnrConfigurationTest() throws BadResponseException, MapperException , URISyntaxException{ GenericResourceApiGcTopologyOperationInformation response = sdncConfigurationResources.unAssignVnrConfiguration(serviceInstance,requestContext,vpnBondingLink.getVnrConfiguration(),"uuid",new URI("http://localhost")); - assertNotNull(response); + verify(MOCK_gcTopologyMapper).deactivateOrUnassignVnrReqMapper( + eq(SDNCSvcAction.UNASSIGN), eq(serviceInstance), eq(requestContext), any(Configuration.class), any(String.class), any(URI.class)); + } @Test public void deactivateVnrConfigurationTest() throws BadResponseException, MapperException , URISyntaxException{ GenericResourceApiGcTopologyOperationInformation response = sdncConfigurationResources.deactivateVnrConfiguration(serviceInstance,requestContext,vpnBondingLink.getVnrConfiguration(),"uuid",new URI("http://localhost")); - assertNotNull(response); + verify(MOCK_gcTopologyMapper).deactivateOrUnassignVnrReqMapper( + eq(SDNCSvcAction.DEACTIVATE), eq(serviceInstance), eq(requestContext), any(Configuration.class), any(String.class), any(URI.class)); + } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapperTest.java index f01eeaeae8..f4d442bbc3 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapperTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapperTest.java @@ -24,9 +24,15 @@ import java.net.URI; import java.net.URISyntaxException; import java.util.HashMap; import java.util.List; +import java.util.Map; import org.junit.Assert; import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Spy; +import org.mockito.junit.MockitoJUnitRunner; +import org.onap.sdnc.northbound.client.model.GenericResourceApiGcTopologyOperationInformation; import org.onap.so.bpmn.common.data.TestDataSetup; import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; @@ -38,11 +44,14 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBondingLink; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; import org.onap.so.client.sdnc.beans.SDNCSvcAction; -import org.onap.sdnc.northbound.client.model.GenericResourceApiGcTopologyOperationInformation; - - -public class GCTopologyOperationRequestMapperTest extends TestDataSetup{ +@RunWith(MockitoJUnitRunner.Silent.class) +public class GCTopologyOperationRequestMapperTest extends TestDataSetup { + + @Spy + private GeneralTopologyObjectMapper generalTopologyObjectMapper; + + @InjectMocks private GCTopologyOperationRequestMapper genObjMapper = new GCTopologyOperationRequestMapper(); @Test @@ -80,13 +89,13 @@ public class GCTopologyOperationRequestMapperTest extends TestDataSetup{ private RequestContext getRequestContext() { RequestContext requestContext = new RequestContext(); requestContext.setMsoRequestId("MsoRequestId"); - HashMap<String, String> userParams = getUserParams(); + Map<String, Object> userParams = getUserParams(); requestContext.setUserParams(userParams); return requestContext; } - private HashMap<String, String> getUserParams() { - HashMap<String,String> userParams = new HashMap<>(); + private Map<String, Object> getUserParams() { + Map<String,Object> userParams = new HashMap<>(); userParams.put("lppCustomerId","lppCustomerId"); return userParams; } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapperTest.java index bf2cd347c0..3bb54278b6 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapperTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapperTest.java @@ -29,6 +29,7 @@ import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; import java.util.HashMap; +import java.util.Map; import org.junit.After; import org.junit.Before; @@ -104,7 +105,7 @@ public class GeneralTopologyObjectMapperTest extends TestDataSetup { customer.getServiceSubscription().getServiceInstances().add(serviceInstance); // RequestContext requestContext = new RequestContext(); - HashMap<String, String> userParams = new HashMap<String, String>(); + Map<String, Object> userParams = new HashMap<>(); userParams.put("key1", "value1"); requestContext.setUserParams(userParams); requestContext.setProductFamilyId("productFamilyId"); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapperTest.java index 307fe289a1..6a14f8b567 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapperTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapperTest.java @@ -29,9 +29,16 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; import java.util.HashMap; +import java.util.Map; import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Spy; +import org.mockito.junit.MockitoJUnitRunner; +import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkOperationInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; @@ -45,10 +52,9 @@ import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance; import org.onap.so.client.sdnc.beans.SDNCSvcAction; import org.onap.so.client.sdnc.beans.SDNCSvcOperation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkOperationInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; import com.fasterxml.jackson.databind.ObjectMapper; +@RunWith(MockitoJUnitRunner.class) public class NetworkTopologyOperationRequestMapperTest { private final static String JSON_FILE_LOCATION = "src/test/resources/__files/BuildingBlocks/"; @@ -59,6 +65,12 @@ public class NetworkTopologyOperationRequestMapperTest { private RequestContext requestContext; private L3Network network; private CloudRegion cloudRegion; + + @Spy + private GeneralTopologyObjectMapper generalTopologyObjectMapper; + + @InjectMocks + private NetworkTopologyOperationRequestMapper mapper = new NetworkTopologyOperationRequestMapper(); @Before public void before() { @@ -93,7 +105,7 @@ public class NetworkTopologyOperationRequestMapperTest { serviceInstance.setCollection(networkCollection); // requestContext = new RequestContext(); - HashMap<String, String> userParams = new HashMap<String, String>(); + Map<String, Object> userParams = new HashMap<>(); userParams.put("key1", "value1"); requestContext.setUserParams(userParams); requestContext.setProductFamilyId("productFamilyId"); @@ -115,7 +127,6 @@ public class NetworkTopologyOperationRequestMapperTest { @Test public void createGenericResourceApiNetworkOperationInformationTest() throws Exception { - NetworkTopologyOperationRequestMapper mapper = new NetworkTopologyOperationRequestMapper(); GenericResourceApiNetworkOperationInformation networkSDNCrequest = mapper.reqMapper( SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance, customer, requestContext, cloudRegion); @@ -132,7 +143,6 @@ public class NetworkTopologyOperationRequestMapperTest { @Test public void reqMapperTest() throws Exception { - NetworkTopologyOperationRequestMapper mapper = new NetworkTopologyOperationRequestMapper(); GenericResourceApiNetworkOperationInformation networkSDNCrequest = mapper.reqMapper( SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance, customer, requestContext, cloudRegion); @@ -143,7 +153,6 @@ public class NetworkTopologyOperationRequestMapperTest { @Test public void reqMapperNoCollectionTest() throws Exception { - NetworkTopologyOperationRequestMapper mapper = new NetworkTopologyOperationRequestMapper(); GenericResourceApiNetworkOperationInformation networkSDNCrequest = mapper.reqMapper( SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstanceNoCollection, customer, requestContext, cloudRegion); @@ -154,7 +163,7 @@ public class NetworkTopologyOperationRequestMapperTest { @Test public void createGenericResourceApiNetworkOperationInformation_UnassignTest() throws Exception { - NetworkTopologyOperationRequestMapper mapperUnassign = new NetworkTopologyOperationRequestMapper(); + NetworkTopologyOperationRequestMapper mapperUnassign = mapper; GenericResourceApiNetworkOperationInformation networkSDNCrequestUnassign = mapperUnassign.reqMapper( SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN, GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance, customer, requestContext, cloudRegion); @@ -172,7 +181,6 @@ public class NetworkTopologyOperationRequestMapperTest { @Test public void createGenericResourceApiNetworkOperationInformationNoNetworkNameTest() throws Exception { - NetworkTopologyOperationRequestMapper mapper = new NetworkTopologyOperationRequestMapper(); //set network name NULL network.setNetworkName(null); GenericResourceApiNetworkOperationInformation networkSDNCrequest = mapper.reqMapper( diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapperTest.java index 5d8b31b3bf..0bf06a0bb0 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapperTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapperTest.java @@ -26,8 +26,13 @@ import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; import java.nio.file.Files; import java.nio.file.Paths; import java.util.HashMap; +import java.util.Map; import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Spy; +import org.mockito.junit.MockitoJUnitRunner; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription; @@ -41,8 +46,15 @@ import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnum import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation; import com.fasterxml.jackson.databind.ObjectMapper; +@RunWith(MockitoJUnitRunner.class) public class ServiceTopologyOperationMapperTest { + @Spy + private GeneralTopologyObjectMapper generalTopologyObjectMapper; + + @InjectMocks + private ServiceTopologyOperationMapper mapper = new ServiceTopologyOperationMapper(); + @Test public void reqMapperTest() throws Exception { // prepare and set service instance @@ -64,12 +76,11 @@ public class ServiceTopologyOperationMapperTest { //prepare RequestContext RequestContext requestContext = new RequestContext(); - HashMap<String, String> userParams = new HashMap<String, String>(); + Map<String, Object> userParams = new HashMap<>(); userParams.put("key1", "value1"); requestContext.setUserParams(userParams); requestContext.setProductFamilyId("productFamilyId"); - ServiceTopologyOperationMapper mapper = new ServiceTopologyOperationMapper(); GenericResourceApiServiceOperationInformation serviceOpInformation = mapper.reqMapper( SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE, serviceInstance, customer, requestContext); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java index 7d5aa9d1d9..282f23caa7 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java @@ -35,6 +35,10 @@ import java.util.Map; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Spy; +import org.mockito.junit.MockitoJUnitRunner; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; @@ -54,11 +58,18 @@ import org.onap.so.client.sdnc.beans.SDNCSvcOperation; import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation; import com.fasterxml.jackson.databind.ObjectMapper; +@RunWith(MockitoJUnitRunner.class) public class VfModuleTopologyOperationRequestMapperTest { private final static String JSON_FILE_LOCATION = "src/test/resources/__files/BuildingBlocks/"; private final static String ERRORMESSAGE = "VF Module model info is null for testVfModuleId"; + @Spy + private GeneralTopologyObjectMapper generalTopologyObjectMapper; + + @InjectMocks + private VfModuleTopologyOperationRequestMapper mapper = new VfModuleTopologyOperationRequestMapper(); + @Rule public ExpectedException expectedException = ExpectedException.none(); @@ -84,7 +95,7 @@ public class VfModuleTopologyOperationRequestMapperTest { customer.getServiceSubscription().getServiceInstances().add(serviceInstance); // RequestContext requestContext = new RequestContext(); - HashMap<String,String> userParams = new HashMap<String,String>(); + Map<String,Object> userParams = new HashMap<>(); userParams.put("key1", "value1"); requestContext.setUserParams(userParams); requestContext.setProductFamilyId("productFamilyId"); @@ -124,7 +135,6 @@ public class VfModuleTopologyOperationRequestMapperTest { CloudRegion cloudRegion = new CloudRegion(); - VfModuleTopologyOperationRequestMapper mapper = new VfModuleTopologyOperationRequestMapper(); GenericResourceApiVfModuleOperationInformation vfModuleSDNCrequest = mapper.reqMapper( SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, vfModule, volumeGroup, vnf, serviceInstance, customer, cloudRegion, requestContext, null); @@ -159,7 +169,6 @@ public class VfModuleTopologyOperationRequestMapperTest { vfModule.setVfModuleId("testVfModuleId"); vfModule.setVfModuleName("testVfModuleName"); - VfModuleTopologyOperationRequestMapper mapper = new VfModuleTopologyOperationRequestMapper(); GenericResourceApiVfModuleOperationInformation vfModuleSDNCrequest = mapper.reqMapper( SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN, vfModule, null, vnf, serviceInstance, null, null, null, null); @@ -197,9 +206,9 @@ public class VfModuleTopologyOperationRequestMapperTest { // RequestContext requestContext = new RequestContext(); RequestParameters requestParameters = new RequestParameters(); - HashMap<String,Object> userParams1 = new HashMap<String,Object>(); + HashMap<String,Object> userParams1 = new HashMap<>(); userParams1.put("key1", "value1"); - List<Map<String,Object>> userParams = new ArrayList<Map<String,Object>>(); + List<Map<String,Object>> userParams = new ArrayList<>(); userParams.add(userParams1); requestParameters.setUserParams(userParams); @@ -230,7 +239,6 @@ public class VfModuleTopologyOperationRequestMapperTest { CloudRegion cloudRegion = new CloudRegion(); - VfModuleTopologyOperationRequestMapper mapper = new VfModuleTopologyOperationRequestMapper(); GenericResourceApiVfModuleOperationInformation vfModuleSDNCrequest = mapper.reqMapper( SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, vfModule, null, vnf, serviceInstance, customer, cloudRegion, requestContext, null); @@ -261,7 +269,7 @@ public class VfModuleTopologyOperationRequestMapperTest { customer.getServiceSubscription().getServiceInstances().add(serviceInstance); // RequestContext requestContext = new RequestContext(); - HashMap<String, String> userParams = new HashMap<String, String>(); + Map<String, Object> userParams = new HashMap<String, Object>(); userParams.put("key1", "value1"); requestContext.setUserParams(userParams); requestContext.setProductFamilyId("productFamilyId"); @@ -284,7 +292,6 @@ public class VfModuleTopologyOperationRequestMapperTest { CloudRegion cloudRegion = new CloudRegion(); - VfModuleTopologyOperationRequestMapper mapper = new VfModuleTopologyOperationRequestMapper(); expectedException.expect(MapperException.class); expectedException.expectMessage(ERRORMESSAGE); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapperTest.java index 63c3680e8c..229a8cf601 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapperTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapperTest.java @@ -25,9 +25,14 @@ import static org.junit.Assert.assertNull; import java.util.ArrayList; import java.util.HashMap; +import java.util.Map; import java.util.List; import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Spy; +import org.mockito.junit.MockitoJUnitRunner; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; @@ -45,8 +50,15 @@ import org.onap.so.client.sdnc.beans.SDNCSvcOperation; import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation; +@RunWith(MockitoJUnitRunner.class) public class VnfTopologyOperationRequestMapperTest { + @Spy + private GeneralTopologyObjectMapper generalTopologyObjectMapper; + + @InjectMocks + private VnfTopologyOperationRequestMapper mapper = new VnfTopologyOperationRequestMapper(); + @Test public void reqMapperTest() throws Exception { // prepare and set service instance @@ -106,14 +118,13 @@ public class VnfTopologyOperationRequestMapperTest { //prepare RequestContext RequestContext requestContext = new RequestContext(); - HashMap<String, String> userParams = new HashMap<String, String>(); + Map<String, Object> userParams = new HashMap<>(); userParams.put("key1", "value1"); requestContext.setUserParams(userParams); requestContext.setProductFamilyId("productFamilyId"); CloudRegion cloudRegion = new CloudRegion(); - VnfTopologyOperationRequestMapper mapper = new VnfTopologyOperationRequestMapper(); GenericResourceApiVnfOperationInformation vnfOpInformation = mapper.reqMapper( SDNCSvcOperation.VNF_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN,GenericResourceApiRequestActionEnumeration.CREATEVNFINSTANCE, vnf, serviceInstance, customer, cloudRegion, requestContext,true); |