diff options
author | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2019-01-20 18:30:39 -0500 |
---|---|---|
committer | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2019-01-20 21:44:23 -0500 |
commit | e8df6b72e12189ff3d3ad81237deb8c8760aed1b (patch) | |
tree | aedd75dbbd2df1d5d03abacca735c7b3e1a4aa5f | |
parent | 9756b9992858a5f513953f1d16b4d9b396a8397a (diff) |
convert from sync to async
fixed network adapter object mapper test issues
fixed all test issues and compilation issues
remove setting of notification url for rollback
covert sync calls for create and delete network to async
removed async after from invoke sdnc adapter task
remove unwanted changes that were committed earlier
fix unmarshalling of response back from openstack adap
added in code to throw an error when AIC issue
Change-Id: Ic9fa39584ed2bcb70804fbd74586f1cc119c7d8b
Issue-ID: SO-1404
Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
15 files changed, 617 insertions, 105 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/SDNCAdapterV1.bpmn b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/SDNCAdapterV1.bpmn index 0032b0e0b7..0ef6c84494 100644 --- a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/SDNCAdapterV1.bpmn +++ b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/SDNCAdapterV1.bpmn @@ -20,7 +20,7 @@ ExceptionUtil exceptionUtil = new ExceptionUtil() exceptionUtil.buildWorkflowException(execution, 7000, "Could not communicate with the SDNC Adapter" )]]></bpmn2:script> </bpmn2:scriptTask> <bpmn2:sequenceFlow id="Exception" name="Exception" sourceRef="setBadResponse" targetRef="badResponseEndFlow" /> - <bpmn2:serviceTask id="invokeSDNCAdapter" name="Invoke SDNC Adapter" camunda:asyncAfter="true" camunda:class=""> + <bpmn2:serviceTask id="invokeSDNCAdapter" name="Invoke SDNC Adapter" camunda:class=""> <bpmn2:extensionElements> <camunda:connector> <camunda:inputOutput> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateNetworkBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateNetworkBB.bpmn index 21f2fbeeb9..52b9249468 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateNetworkBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateNetworkBB.bpmn @@ -1,5 +1,5 @@ <?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.9.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.10.0" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"> <bpmn2:process id="CreateNetworkBB" name="CreateNetworkBB" isExecutable="true"> <bpmn2:startEvent id="createNetwork_startEvent"> <bpmn2:outgoing>SequenceFlow_1maepy7</bpmn2:outgoing> @@ -13,7 +13,7 @@ </bpmn2:serviceTask> <bpmn2:serviceTask id="Create_Network_ServiceTask" name=" AIC Create (network) " camunda:expression="${NetworkAdapterCreateTasks.createNetwork(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> <bpmn2:incoming>SequenceFlow_1eqfh23</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_0innva6</bpmn2:outgoing> + <bpmn2:outgoing>SequenceFlow_1fm99t6</bpmn2:outgoing> </bpmn2:serviceTask> <bpmn2:serviceTask id="QueryNetworkPolicy_ServiceTask" name=" AAI Query (net policy) " camunda:expression="${AAIQueryTasks.queryNetworkPolicy(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> <bpmn2:incoming>SequenceFlow_0n42zi5</bpmn2:incoming> @@ -24,12 +24,11 @@ <bpmn2:outgoing>SequenceFlow_1h9kkhb</bpmn2:outgoing> </bpmn2:serviceTask> <bpmn2:serviceTask id="Update_Network_AAI_ServiceTask" name=" AAI Update (network) " camunda:expression="${AAIUpdateTasks.updateNetworkCreated(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> - <bpmn2:incoming>SequenceFlow_0innva6</bpmn2:incoming> + <bpmn2:incoming>SequenceFlow_16152be</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_0sissul</bpmn2:outgoing> </bpmn2:serviceTask> <bpmn2:sequenceFlow id="SequenceFlow_0n42zi5" sourceRef="QueryVpnBinding_ServiceTask" targetRef="QueryNetworkPolicy_ServiceTask" /> <bpmn2:sequenceFlow id="SequenceFlow_1yy4aik" sourceRef="QueryNetworkPolicy_ServiceTask" targetRef="QueryNetworkTableRef_ServiceTask" /> - <bpmn2:sequenceFlow id="SequenceFlow_0innva6" sourceRef="Create_Network_ServiceTask" targetRef="Update_Network_AAI_ServiceTask" /> <bpmn2:sequenceFlow id="SequenceFlow_0sissul" sourceRef="Update_Network_AAI_ServiceTask" targetRef="createNetwork_EndEvent" /> <bpmn2:sequenceFlow id="SequenceFlow_1maepy7" sourceRef="createNetwork_startEvent" targetRef="ServiceTask_get_cloud_region" /> <bpmn2:intermediateThrowEvent id="ThrowEvent_ToCollectAAIData" name="ThrowEvent_ToCollectAAIData"> @@ -45,7 +44,7 @@ <bpmn2:linkEventDefinition name="CatchEvent_Create_Network" /> </bpmn2:intermediateCatchEvent> <bpmn2:intermediateThrowEvent id="ThrowEvent_ToCreateNetwork" name="ThrowEvent_ToCreateNetwork"> - <bpmn2:incoming>SequenceFlow_04w6hdq</bpmn2:incoming> + <bpmn2:incoming>SequenceFlow_0y0w60u</bpmn2:incoming> <bpmn2:linkEventDefinition name="CatchEvent_Create_Network" /> </bpmn2:intermediateThrowEvent> <bpmn2:sequenceFlow id="SequenceFlow_1h9kkhb" sourceRef="QueryNetworkTableRef_ServiceTask" targetRef="QueryNetworkSubnet_ServiceTask" /> @@ -56,11 +55,27 @@ <bpmn2:outgoing>SequenceFlow_03ebe6c</bpmn2:outgoing> </bpmn2:serviceTask> <bpmn2:sequenceFlow id="SequenceFlow_03ebe6c" sourceRef="ServiceTask_get_cloud_region" targetRef="ThrowEvent_ToCollectAAIData" /> + <bpmn2:callActivity id="CallActivity_0aj19il" name="Call NetworkAdapterRestV1" calledElement="NetworkAdapterRestV1"> + <bpmn2:extensionElements> + <camunda:in source="networkAdapterRequest" target="networkAdapterRequest" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:out source="createNetworkResponse" target="createNetworkResponse" /> + </bpmn2:extensionElements> + <bpmn2:incoming>SequenceFlow_1fm99t6</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_0qpu80i</bpmn2:outgoing> + </bpmn2:callActivity> + <bpmn2:serviceTask id="ServiceTask_1k8gsz5" name="Process Response From Openstack" camunda:expression="${NetworkAdapterCreateTasks.processResponseFromOpenstack(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn2:incoming>SequenceFlow_0qpu80i</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_16152be</bpmn2:outgoing> + </bpmn2:serviceTask> + <bpmn2:sequenceFlow id="SequenceFlow_0qpu80i" sourceRef="CallActivity_0aj19il" targetRef="ServiceTask_1k8gsz5" /> + <bpmn2:sequenceFlow id="SequenceFlow_16152be" sourceRef="ServiceTask_1k8gsz5" targetRef="Update_Network_AAI_ServiceTask" /> + <bpmn2:sequenceFlow id="SequenceFlow_1fm99t6" sourceRef="Create_Network_ServiceTask" targetRef="CallActivity_0aj19il" /> <bpmn2:serviceTask id="QueryNetworkSubnet_ServiceTask" name=" AAI Query (subnet) " camunda:expression="${AAIQueryTasks.querySubnet(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> <bpmn2:incoming>SequenceFlow_1h9kkhb</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_04w6hdq</bpmn2:outgoing> + <bpmn2:outgoing>SequenceFlow_0y0w60u</bpmn2:outgoing> </bpmn2:serviceTask> - <bpmn2:sequenceFlow id="SequenceFlow_04w6hdq" sourceRef="QueryNetworkSubnet_ServiceTask" targetRef="ThrowEvent_ToCreateNetwork" /> + <bpmn2:sequenceFlow id="SequenceFlow_0y0w60u" sourceRef="QueryNetworkSubnet_ServiceTask" targetRef="ThrowEvent_ToCreateNetwork" /> </bpmn2:process> <bpmn2:error id="Error_2" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> <bpmn2:error id="Error_1" name="java.lang.Exception" errorCode="java.lang.Exception" /> @@ -73,9 +88,9 @@ </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="EndEvent_10l9a3s_di" bpmnElement="createNetwork_EndEvent"> - <dc:Bounds x="656" y="326" width="36" height="36" /> + <dc:Bounds x="997" y="326" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="652" y="362" width="46" height="12" /> + <dc:Bounds x="971" y="362" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ServiceTask_1k7d8ih_di" bpmnElement="QueryVpnBinding_ServiceTask"> @@ -91,7 +106,7 @@ <dc:Bounds x="663" y="91" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ServiceTask_0q51h0f_di" bpmnElement="Update_Network_AAI_ServiceTask"> - <dc:Bounds x="499" y="304" width="100" height="80" /> + <dc:Bounds x="836" y="304" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0n42zi5_di" bpmnElement="SequenceFlow_0n42zi5"> <di:waypoint xsi:type="dc:Point" x="440" y="131" /> @@ -107,18 +122,11 @@ <dc:Bounds x="633" y="106" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0innva6_di" bpmnElement="SequenceFlow_0innva6"> - <di:waypoint xsi:type="dc:Point" x="446" y="344" /> - <di:waypoint xsi:type="dc:Point" x="499" y="344" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="473" y="319" width="0" height="0" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0sissul_di" bpmnElement="SequenceFlow_0sissul"> - <di:waypoint xsi:type="dc:Point" x="599" y="344" /> - <di:waypoint xsi:type="dc:Point" x="656" y="344" /> + <di:waypoint xsi:type="dc:Point" x="936" y="344" /> + <di:waypoint xsi:type="dc:Point" x="997" y="344" /> <bpmndi:BPMNLabel> - <dc:Bounds x="628" y="319" width="0" height="0" /> + <dc:Bounds x="921.5" y="329" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1maepy7_di" bpmnElement="SequenceFlow_1maepy7"> @@ -147,16 +155,16 @@ </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="IntermediateThrowEvent_04qwhex_di" bpmnElement="ThrowEvent_ToCreateNetwork"> - <dc:Bounds x="972" y="113" width="36" height="36" /> + <dc:Bounds x="962" y="113" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1015" y="125" width="86" height="24" /> + <dc:Bounds x="1005" y="125" width="86" height="24" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1h9kkhb_di" bpmnElement="SequenceFlow_1h9kkhb"> <di:waypoint xsi:type="dc:Point" x="763" y="131" /> - <di:waypoint xsi:type="dc:Point" x="818" y="131" /> + <di:waypoint xsi:type="dc:Point" x="817" y="131" /> <bpmndi:BPMNLabel> - <dc:Bounds x="745.5" y="116" width="90" height="0" /> + <dc:Bounds x="745" y="116" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1oc7wcr_di" bpmnElement="SequenceFlow_1oc7wcr"> @@ -183,14 +191,41 @@ <dc:Bounds x="551" y="-52" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ServiceTask_0j3odqk_di" bpmnElement="QueryNetworkSubnet_ServiceTask"> - <dc:Bounds x="818" y="91" width="100" height="80" /> + <bpmndi:BPMNShape id="CallActivity_0aj19il_di" bpmnElement="CallActivity_0aj19il"> + <dc:Bounds x="503" y="304" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_1k8gsz5_di" bpmnElement="ServiceTask_1k8gsz5"> + <dc:Bounds x="663" y="304" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0qpu80i_di" bpmnElement="SequenceFlow_0qpu80i"> + <di:waypoint xsi:type="dc:Point" x="603" y="344" /> + <di:waypoint xsi:type="dc:Point" x="663" y="344" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="633" y="323" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_16152be_di" bpmnElement="SequenceFlow_16152be"> + <di:waypoint xsi:type="dc:Point" x="763" y="344" /> + <di:waypoint xsi:type="dc:Point" x="836" y="344" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="799.5" y="323" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1fm99t6_di" bpmnElement="SequenceFlow_1fm99t6"> + <di:waypoint xsi:type="dc:Point" x="446" y="344" /> + <di:waypoint xsi:type="dc:Point" x="503" y="344" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="474.5" y="323" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_0u4ie2q_di" bpmnElement="QueryNetworkSubnet_ServiceTask"> + <dc:Bounds x="817" y="91" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_04w6hdq_di" bpmnElement="SequenceFlow_04w6hdq"> - <di:waypoint xsi:type="dc:Point" x="918" y="131" /> - <di:waypoint xsi:type="dc:Point" x="972" y="131" /> + <bpmndi:BPMNEdge id="SequenceFlow_0y0w60u_di" bpmnElement="SequenceFlow_0y0w60u"> + <di:waypoint xsi:type="dc:Point" x="917" y="131" /> + <di:waypoint xsi:type="dc:Point" x="962" y="131" /> <bpmndi:BPMNLabel> - <dc:Bounds x="945" y="110" width="0" height="12" /> + <dc:Bounds x="939.5" y="110" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteNetworkBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteNetworkBB.bpmn index 95e481db4f..74b78ef735 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteNetworkBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteNetworkBB.bpmn @@ -5,19 +5,29 @@ <bpmn:outgoing>SequenceFlow_1mc3d3f</bpmn:outgoing> </bpmn:startEvent> <bpmn:serviceTask id="updateNetworkAAI" name=" AAI Update (network) " camunda:expression="${AAIUpdateTasks.updateOrchestrationStatusAssignedNetwork(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> - <bpmn:incoming>SequenceFlow_1c906im</bpmn:incoming> + <bpmn:incoming>SequenceFlow_0gnafn2</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0nhd7b7</bpmn:outgoing> </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_1mc3d3f" sourceRef="deleteNetwork_startEvent" targetRef="deleteNetworkAIC" /> - <bpmn:sequenceFlow id="SequenceFlow_1c906im" sourceRef="deleteNetworkAIC" targetRef="updateNetworkAAI" /> <bpmn:serviceTask id="deleteNetworkAIC" name=" AIC Delete (network) " camunda:expression="${NetworkAdapterDeleteTasks.deleteNetwork(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> <bpmn:incoming>SequenceFlow_1mc3d3f</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_1c906im</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_16ti327</bpmn:outgoing> </bpmn:serviceTask> <bpmn:endEvent id="deleteNetwork_endEvent"> <bpmn:incoming>SequenceFlow_0nhd7b7</bpmn:incoming> </bpmn:endEvent> <bpmn:sequenceFlow id="SequenceFlow_0nhd7b7" sourceRef="updateNetworkAAI" targetRef="deleteNetwork_endEvent" /> + <bpmn:callActivity id="CallActivity_1a77pxk" name="Call NetworkAdapterRestV1" calledElement="NetworkAdapterRestV1"> + <bpmn:extensionElements> + <camunda:in source="networkAdapterRequest" target="networkAdapterRequest" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:out source="deleteNetworkResponse" target="deleteNetworkResponse" /> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_16ti327</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0gnafn2</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="SequenceFlow_16ti327" sourceRef="deleteNetworkAIC" targetRef="CallActivity_1a77pxk" /> + <bpmn:sequenceFlow id="SequenceFlow_0gnafn2" sourceRef="CallActivity_1a77pxk" targetRef="updateNetworkAAI" /> </bpmn:process> <bpmn:error id="Error_1l8dsnn" name="Error_31mlvpb" /> <bpmn:error id="Error_0wyyz4k" name="Error_0v8f773" /> @@ -38,24 +48,17 @@ </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ServiceTask_0zd65z2_di" bpmnElement="updateNetworkAAI"> - <dc:Bounds x="530" y="80" width="100" height="80" /> + <dc:Bounds x="644" y="80" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1mc3d3f_di" bpmnElement="SequenceFlow_1mc3d3f"> <di:waypoint xsi:type="dc:Point" x="209" y="120" /> - <di:waypoint xsi:type="dc:Point" x="370" y="120" /> + <di:waypoint xsi:type="dc:Point" x="317" y="120" /> <bpmndi:BPMNLabel> - <dc:Bounds x="244.5" y="99" width="90" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1c906im_di" bpmnElement="SequenceFlow_1c906im"> - <di:waypoint xsi:type="dc:Point" x="470" y="120" /> - <di:waypoint xsi:type="dc:Point" x="530" y="120" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="455" y="99" width="90" height="12" /> + <dc:Bounds x="218" y="99" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_1gcfuzf_di" bpmnElement="deleteNetworkAIC"> - <dc:Bounds x="370" y="80" width="100" height="80" /> + <dc:Bounds x="317" y="80" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="EndEvent_02vxchc_di" bpmnElement="deleteNetwork_endEvent"> <dc:Bounds x="806" y="102" width="36" height="36" /> @@ -64,10 +67,27 @@ </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0nhd7b7_di" bpmnElement="SequenceFlow_0nhd7b7"> - <di:waypoint xsi:type="dc:Point" x="630" y="120" /> + <di:waypoint xsi:type="dc:Point" x="744" y="120" /> <di:waypoint xsi:type="dc:Point" x="806" y="120" /> <bpmndi:BPMNLabel> - <dc:Bounds x="673" y="99" width="90" height="12" /> + <dc:Bounds x="730" y="99" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="CallActivity_1a77pxk_di" bpmnElement="CallActivity_1a77pxk"> + <dc:Bounds x="481" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_16ti327_di" bpmnElement="SequenceFlow_16ti327"> + <di:waypoint xsi:type="dc:Point" x="417" y="120" /> + <di:waypoint xsi:type="dc:Point" x="481" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="449" y="99" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0gnafn2_di" bpmnElement="SequenceFlow_0gnafn2"> + <di:waypoint xsi:type="dc:Point" x="581" y="120" /> + <di:waypoint xsi:type="dc:Point" x="644" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="612.5" y="99" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/NetworkAdapterRestV1.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/NetworkAdapterRestV1.bpmn new file mode 100644 index 0000000000..583ec9444e --- /dev/null +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/NetworkAdapterRestV1.bpmn @@ -0,0 +1,198 @@ +<?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="_GraPIIyxEeWmdMDkx6Uftw" 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:process id="NetworkAdapterRestV1" name="NetworkAdapterRestV1" isExecutable="true"> + <bpmn2:boundaryEvent id="BoundaryEvent_1" name="Timeout" attachedToRef="waitForAsyncMessage"> + <bpmn2:outgoing>SequenceFlow_27</bpmn2:outgoing> + <bpmn2:timerEventDefinition id="TimerEventDefinition_1"> + <bpmn2:timeDuration xsi:type="bpmn2:tFormalExpression"><![CDATA[${UrnPropertiesReader.getVariable("mso.po.timeout", execution)}]]></bpmn2:timeDuration> + </bpmn2:timerEventDefinition> + </bpmn2:boundaryEvent> + <bpmn2:subProcess id="waitForAsyncMessage" name="Wait for Callback"> + <bpmn2:incoming>SequenceFlow_1286mqm</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_28</bpmn2:outgoing> + <bpmn2:intermediateCatchEvent id="IntermediateCatchEvent_1" name="Catch Event"> + <bpmn2:incoming>SequenceFlow_25</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_26</bpmn2:outgoing> + <bpmn2:messageEventDefinition id="MessageEventDefinition_1" messageRef="Message_1" /> + </bpmn2:intermediateCatchEvent> + <bpmn2:sequenceFlow id="SequenceFlow_26" name="" sourceRef="IntermediateCatchEvent_1" targetRef="EndEvent_2" /> + <bpmn2:startEvent id="StartEvent_3"> + <bpmn2:outgoing>SequenceFlow_25</bpmn2:outgoing> + </bpmn2:startEvent> + <bpmn2:sequenceFlow id="SequenceFlow_25" name="" sourceRef="StartEvent_3" targetRef="IntermediateCatchEvent_1" /> + <bpmn2:endEvent id="EndEvent_2"> + <bpmn2:incoming>SequenceFlow_26</bpmn2:incoming> + </bpmn2:endEvent> + </bpmn2:subProcess> + <bpmn2:sequenceFlow id="SequenceFlow_27" name="" sourceRef="BoundaryEvent_1" targetRef="ScriptTask_5" /> + <bpmn2:sequenceFlow id="SequenceFlow_28" name="" sourceRef="waitForAsyncMessage" targetRef="ServiceTask_6" /> + <bpmn2:sequenceFlow id="SequenceFlow_34" name="" sourceRef="ScriptTask_5" targetRef="EndEvent_8" /> + <bpmn2:endEvent id="EndEvent_8"> + <bpmn2:incoming>SequenceFlow_34</bpmn2:incoming> + <bpmn2:errorEventDefinition id="_ErrorEventDefinition_21" errorRef="Error_1" /> + </bpmn2:endEvent> + <bpmn2:endEvent id="EndEvent_6" name="End Flow"> + <bpmn2:incoming>SequenceFlow_06donih</bpmn2:incoming> + </bpmn2:endEvent> + <bpmn2:startEvent id="StartEvent_1" name="Start"> + <bpmn2:outgoing>SequenceFlow_9</bpmn2:outgoing> + </bpmn2:startEvent> + <bpmn2:sequenceFlow id="SequenceFlow_9" name="" sourceRef="StartEvent_1" targetRef="Call_NetworkAdapter" /> + <bpmn2:serviceTask id="Call_NetworkAdapter" name="Call Network Adapter" camunda:expression="${NetworkAdapterRestV1.callNetworkAdapter(execution)}"> + <bpmn2:incoming>SequenceFlow_9</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_1286mqm</bpmn2:outgoing> + </bpmn2:serviceTask> + <bpmn2:serviceTask id="ServiceTask_4" name="Workflow Exception (bad response)" camunda:expression="${NetworkAdapterRestV1.handleSyncError(execution)}"> + <bpmn2:incoming>SequenceFlow_1qckanf</bpmn2:incoming> + </bpmn2:serviceTask> + <bpmn2:serviceTask id="ScriptTask_5" name="Workflow Exception (timeout)" camunda:expression="${NetworkAdapterRestV1.handleTimeOutException(execution)}"> + <bpmn2:incoming>SequenceFlow_27</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_34</bpmn2:outgoing> + </bpmn2:serviceTask> + <bpmn2:serviceTask id="ServiceTask_6" name="Process Callback" camunda:expression="${NetworkAdapterRestV1.processCallback(execution)}"> + <bpmn2:incoming>SequenceFlow_28</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_06donih</bpmn2:outgoing> + </bpmn2:serviceTask> + <bpmn2:sequenceFlow id="SequenceFlow_06donih" sourceRef="ServiceTask_6" targetRef="EndEvent_6" /> + <bpmn2:boundaryEvent id="BoundaryEvent_1edt16j" attachedToRef="Call_NetworkAdapter"> + <bpmn2:outgoing>SequenceFlow_1qckanf</bpmn2:outgoing> + <bpmn2:errorEventDefinition /> + </bpmn2:boundaryEvent> + <bpmn2:sequenceFlow id="SequenceFlow_1qckanf" sourceRef="BoundaryEvent_1edt16j" targetRef="ServiceTask_4" /> + <bpmn2:sequenceFlow id="SequenceFlow_1286mqm" sourceRef="Call_NetworkAdapter" targetRef="waitForAsyncMessage" /> + </bpmn2:process> + <bpmn2:error id="Error_1" name="MSO Workflow Exception" errorCode="MSOWorkflowException" /> + <bpmn2:message id="Message_1" name="WorkflowMessage" /> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="NetworkAdapterRestV1"> + <bpmndi:BPMNShape id="_BPMNShape_SubProcess_14" bpmnElement="waitForAsyncMessage" isExpanded="true"> + <dc:Bounds x="685" y="110" width="265" height="154" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_BoundaryEvent_24" bpmnElement="BoundaryEvent_1"> + <dc:Bounds x="800" y="246" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="841" y="276" width="41" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_IntermediateCatchEvent_20" bpmnElement="IntermediateCatchEvent_1"> + <dc:Bounds x="804" y="165" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="792" y="206" width="61" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_54" bpmnElement="StartEvent_1"> + <dc:Bounds x="340" y="169" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="346" y="210" width="24" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_2" bpmnElement="SequenceFlow_9" sourceElement="_BPMNShape_StartEvent_54" targetElement="ServiceTask_1tl2aox_di"> + <di:waypoint xsi:type="dc:Point" x="376" y="187" /> + <di:waypoint xsi:type="dc:Point" x="453" y="187" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="369.5" y="169" width="90" height="6" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_55" bpmnElement="StartEvent_3"> + <dc:Bounds x="709" y="165" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="682" y="206" width="90" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_27" bpmnElement="SequenceFlow_25" sourceElement="_BPMNShape_StartEvent_55" targetElement="_BPMNShape_IntermediateCatchEvent_20"> + <di:waypoint xsi:type="dc:Point" x="745" y="183" /> + <di:waypoint xsi:type="dc:Point" x="804" y="183" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="732" y="183" width="90" height="6" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_156" bpmnElement="EndEvent_2"> + <dc:Bounds x="889" y="165" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="862" y="206" width="90" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_28" bpmnElement="SequenceFlow_26" sourceElement="_BPMNShape_IntermediateCatchEvent_20" targetElement="_BPMNShape_EndEvent_156"> + <di:waypoint xsi:type="dc:Point" x="840" y="183" /> + <di:waypoint xsi:type="dc:Point" x="870" y="183" /> + <di:waypoint xsi:type="dc:Point" x="870" y="182" /> + <di:waypoint xsi:type="dc:Point" x="889" y="183" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="825" y="183" width="90" height="6" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_29" bpmnElement="SequenceFlow_27" sourceElement="_BPMNShape_BoundaryEvent_24" targetElement="ServiceTask_1y9aa0r_di"> + <di:waypoint xsi:type="dc:Point" x="818" y="282" /> + <di:waypoint xsi:type="dc:Point" x="818" y="327" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="788" y="302" width="90" height="6" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_30" bpmnElement="SequenceFlow_28" sourceElement="_BPMNShape_SubProcess_14" targetElement="ServiceTask_1s8txq3_di"> + <di:waypoint xsi:type="dc:Point" x="950" y="186" /> + <di:waypoint xsi:type="dc:Point" x="992" y="186" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="926" y="168" width="90" height="6" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_158" bpmnElement="EndEvent_6"> + <dc:Bounds x="1131" y="168" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1126" y="209" width="46" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_160" bpmnElement="EndEvent_8"> + <dc:Bounds x="915" y="349" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="888" y="390" width="90" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_36" bpmnElement="SequenceFlow_34" sourceElement="ServiceTask_1y9aa0r_di" targetElement="_BPMNShape_EndEvent_160"> + <di:waypoint xsi:type="dc:Point" x="868" y="367" /> + <di:waypoint xsi:type="dc:Point" x="915" y="367" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="847" y="349" width="90" height="6" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_1tl2aox_di" bpmnElement="Call_NetworkAdapter"> + <dc:Bounds x="453" y="147" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_0rll4jo_di" bpmnElement="ServiceTask_4"> + <dc:Bounds x="503" y="327" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_1y9aa0r_di" bpmnElement="ScriptTask_5"> + <dc:Bounds x="768" y="327" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_1s8txq3_di" bpmnElement="ServiceTask_6"> + <dc:Bounds x="992" y="146" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_06donih_di" bpmnElement="SequenceFlow_06donih"> + <di:waypoint xsi:type="dc:Point" x="1092" y="186" /> + <di:waypoint xsi:type="dc:Point" x="1131" y="186" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1111.5" y="165" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="BoundaryEvent_0ubdwuw_di" bpmnElement="BoundaryEvent_1edt16j"> + <dc:Bounds x="535" y="209" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="553" y="249" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1qckanf_di" bpmnElement="SequenceFlow_1qckanf"> + <di:waypoint xsi:type="dc:Point" x="553" y="245" /> + <di:waypoint xsi:type="dc:Point" x="553" y="327" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="568" y="280" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1286mqm_di" bpmnElement="SequenceFlow_1286mqm"> + <di:waypoint xsi:type="dc:Point" x="553" y="187" /> + <di:waypoint xsi:type="dc:Point" x="685" y="187" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="619" y="166" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn2:definitions> diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterCreateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterCreateTasks.java index bc3845d760..4c531d46f9 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterCreateTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterCreateTasks.java @@ -21,8 +21,8 @@ package org.onap.so.bpmn.infrastructure.adapter.network.tasks; import java.util.Map; -import java.util.Optional; +import org.onap.so.adapters.nwrest.CreateNetworkRequest; import org.onap.so.adapters.nwrest.CreateNetworkResponse; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; @@ -30,24 +30,23 @@ 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.onap.so.logger.MsoLogger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @Component public class NetworkAdapterCreateTasks { - private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, NetworkAdapterCreateTasks.class); @Autowired private ExtractPojosForBB extractPojosForBB; @Autowired - private NetworkAdapterResources networkAdapterResources; - @Autowired private ExceptionBuilder exceptionUtil; - - + @Autowired + private NetworkAdapterObjectMapper networkAdapterObjectMapper; + @Autowired + private NetworkAdapterResources networkAdapterResources; public void createNetwork(BuildingBlockExecution execution) { execution.setVariable("networkAdapterCreateRollback", false); @@ -59,18 +58,29 @@ public class NetworkAdapterCreateTasks { Map<String, String> userInput = gBBInput.getUserInput(); String cloudRegionPo = execution.getVariable("cloudRegionPo"); - Optional<CreateNetworkResponse> oCreateNetworkResponse = networkAdapterResources.createNetwork(gBBInput.getRequestContext(), gBBInput.getCloudRegion(), gBBInput.getOrchContext(), serviceInstance, l3Network, userInput, cloudRegionPo, gBBInput.getCustomer()); - if (oCreateNetworkResponse.isPresent()){ - CreateNetworkResponse createNetworkResponse = oCreateNetworkResponse.get(); + CreateNetworkRequest createNetworkRequest = networkAdapterObjectMapper.createNetworkRequestMapper(gBBInput.getRequestContext(), gBBInput.getCloudRegion(), gBBInput.getOrchContext(), serviceInstance, l3Network, userInput, cloudRegionPo, gBBInput.getCustomer()); + + execution.setVariable("networkAdapterRequest", createNetworkRequest); + } catch (Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + } + + public void processResponseFromOpenstack(BuildingBlockExecution execution) { + try { + L3Network l3Network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID, execution.getLookupMap().get(ResourceKey.NETWORK_ID)); + + CreateNetworkResponse createNetworkResponse = execution.getVariable("createNetworkResponse"); + if(createNetworkResponse != null) { l3Network.setHeatStackId(createNetworkResponse.getNetworkStackId()); if (createNetworkResponse.getNetworkCreated()){ //setting rollback TRUE only if network was actually created (not a silent success OP) - execution.setVariable("createNetworkResponse", createNetworkResponse); execution.setVariable("networkAdapterCreateRollback", true); } + } else { + 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/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterDeleteTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterDeleteTasks.java index 1baa3f5dc9..41dabf9302 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterDeleteTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterDeleteTasks.java @@ -20,18 +20,15 @@ package org.onap.so.bpmn.infrastructure.adapter.network.tasks; -import java.util.Optional; - -import org.onap.so.adapters.nwrest.DeleteNetworkResponse; +import org.onap.so.adapters.nwrest.DeleteNetworkRequest; import org.onap.so.bpmn.common.BuildingBlockExecution; -import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; 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.onap.so.logger.MsoLogger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -42,7 +39,7 @@ public class NetworkAdapterDeleteTasks { @Autowired private ExtractPojosForBB extractPojosForBB; @Autowired - private NetworkAdapterResources networkAdapterResources; + private NetworkAdapterObjectMapper networkAdapterObjectMapper; @Autowired private ExceptionBuilder exceptionUtil; @@ -53,14 +50,9 @@ public class NetworkAdapterDeleteTasks { L3Network l3Network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID, execution.getLookupMap().get(ResourceKey.NETWORK_ID)); ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); - Optional<DeleteNetworkResponse> oDeleteNetworkResponse = networkAdapterResources.deleteNetwork(gBBInput.getRequestContext(), gBBInput.getCloudRegion(), serviceInstance, l3Network); + DeleteNetworkRequest deleteNetworkRequest = networkAdapterObjectMapper.deleteNetworkRequestMapper(gBBInput.getRequestContext(), gBBInput.getCloudRegion(), serviceInstance, l3Network); - if (oDeleteNetworkResponse.isPresent()){ - DeleteNetworkResponse deleteNetworkResponse = oDeleteNetworkResponse.get(); - if (deleteNetworkResponse.getNetworkDeleted()) { - execution.setVariable("deleteNetworkResponse", deleteNetworkResponse); - } - } + execution.setVariable("networkAdapterRequest", deleteNetworkRequest); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1.java new file mode 100644 index 0000000000..d821223507 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1.java @@ -0,0 +1,123 @@ +package org.onap.so.bpmn.infrastructure.adapter.network.tasks; + +import java.io.StringReader; +import java.util.Optional; + +import javax.ws.rs.core.Response; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Unmarshaller; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.onap.so.adapters.nwrest.CreateNetworkError; +import org.onap.so.adapters.nwrest.CreateNetworkRequest; +import org.onap.so.adapters.nwrest.CreateNetworkResponse; +import org.onap.so.adapters.nwrest.DeleteNetworkError; +import org.onap.so.adapters.nwrest.DeleteNetworkRequest; +import org.onap.so.adapters.nwrest.DeleteNetworkResponse; +import org.onap.so.client.exception.ExceptionBuilder; +import org.onap.so.client.orchestration.NetworkAdapterResources; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class NetworkAdapterRestV1 { + + private static final Logger logger = LoggerFactory.getLogger(NetworkAdapterRestV1.class); + + private static final String NETWORK_REQUEST = "networkAdapterRequest"; + private static final String NETWORK_MESSAGE = "NetworkAResponse_MESSAGE"; + private static final String NETWORK_SYNC_CODE = "NETWORKREST_networkAdapterStatusCode"; + private static final String NETWORK_SYNC_RESPONSE = "NETWORKREST_networkAdapterResponse"; + private static final String NETWORK_CORRELATOR = "NetworkAResponse_CORRELATOR"; + + @Autowired + private ExceptionBuilder exceptionBuilder; + + @Autowired + private NetworkAdapterResources networkAdapterResources; + + public void callNetworkAdapter (DelegateExecution execution) { + try { + Object networkAdapterRequest = execution.getVariable(NETWORK_REQUEST); + if (networkAdapterRequest != null) { + Optional<Response> response = Optional.empty(); + if (networkAdapterRequest instanceof CreateNetworkRequest) { + CreateNetworkRequest createNetworkRequest = (CreateNetworkRequest) networkAdapterRequest; + execution.setVariable(NETWORK_CORRELATOR, createNetworkRequest.getMessageId()); + response = networkAdapterResources.createNetworkAsync(createNetworkRequest); + } else if (networkAdapterRequest instanceof DeleteNetworkRequest) { + DeleteNetworkRequest deleteNetworkRequest = (DeleteNetworkRequest) networkAdapterRequest; + execution.setVariable(NETWORK_CORRELATOR, deleteNetworkRequest.getMessageId()); + response = networkAdapterResources.deleteNetworkAsync(deleteNetworkRequest); + } + if(response.isPresent()) { + String statusCode = Integer.toString(response.get().getStatus()); + String responseString = ""; + if(response.get().getEntity() != null) { + responseString = (String) response.get().getEntity(); + } + execution.setVariable(NETWORK_SYNC_CODE, statusCode); + execution.setVariable(NETWORK_SYNC_RESPONSE, responseString); + } else { + throw new Exception("No Ack response from Openstack Adapter"); + } + } else { + throw new Exception("No Network Request was created. networkAdapterRequest was null."); + } + } catch (Exception ex) { + exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, ex.getStackTrace().toString()); + } + } + + public void processCallback (DelegateExecution execution) { + try { + Object networkAdapterRequest = execution.getVariable(NETWORK_REQUEST); + String callback = (String) execution.getVariable(NETWORK_MESSAGE); + String logCallbackMessage = "Callback from OpenstackAdapter: " + callback; + logger.debug(logCallbackMessage); + if (networkAdapterRequest != null) { + if (networkAdapterRequest instanceof CreateNetworkRequest) { + if(callback.contains("createNetworkError")) { + CreateNetworkError createNetworkError = (CreateNetworkError) unmarshalXml(callback, CreateNetworkError.class); + throw new Exception(createNetworkError.getMessage()); + } else { + CreateNetworkResponse createNetworkResponse = (CreateNetworkResponse) unmarshalXml(callback, CreateNetworkResponse.class); + execution.setVariable("createNetworkResponse", createNetworkResponse); + } + } else if (networkAdapterRequest instanceof DeleteNetworkRequest) { + if(callback.contains("deleteNetworkError")) { + DeleteNetworkError deleteNetworkError = (DeleteNetworkError) unmarshalXml(callback, DeleteNetworkError.class); + throw new Exception(deleteNetworkError.getMessage()); + } else { + DeleteNetworkResponse deleteNetworkResponse = (DeleteNetworkResponse) unmarshalXml(callback, DeleteNetworkResponse.class); + execution.setVariable("deleteNetworkResponse", deleteNetworkResponse); + } + } + } + } catch (Exception e) { + logger.error("Error in Openstack Adapter callback", e); + exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, e.getMessage()); + } + } + + protected <T> Object unmarshalXml(String xmlString, Class<T> resultClass) throws JAXBException { + StringReader reader = new StringReader(xmlString); + JAXBContext context = JAXBContext.newInstance(resultClass); + Unmarshaller unmarshaller = context.createUnmarshaller(); + return unmarshaller.unmarshal(reader); + } + + public void handleTimeOutException (DelegateExecution execution) { + exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, "Error timed out waiting on Openstack Async-Response"); + } + + public void handleSyncError (DelegateExecution execution) { + String statusCode = (String) execution.getVariable(NETWORK_SYNC_CODE); + String responseString = (String) execution.getVariable(NETWORK_SYNC_RESPONSE); + String errorMessage = "Error with Openstack Adapter Sync Request: StatusCode = " + statusCode + " Response = " + responseString; + exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, errorMessage); + } +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/NetworkAdapterClient.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/NetworkAdapterClient.java index 45f28df756..cdb24401b3 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/NetworkAdapterClient.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/NetworkAdapterClient.java @@ -20,6 +20,8 @@ package org.onap.so.client.adapter.network; +import javax.ws.rs.core.Response; + import org.onap.so.adapters.nwrest.CreateNetworkRequest; import org.onap.so.adapters.nwrest.CreateNetworkResponse; import org.onap.so.adapters.nwrest.DeleteNetworkRequest; @@ -44,4 +46,10 @@ public interface NetworkAdapterClient { UpdateNetworkResponse updateNetwork(String aaiNetworkId, UpdateNetworkRequest req) throws NetworkAdapterClientException; + + Response createNetworkAsync(CreateNetworkRequest req) throws NetworkAdapterClientException; + + Response deleteNetworkAsync(String aaiNetworkId, DeleteNetworkRequest req) throws NetworkAdapterClientException; + + Response rollbackNetworkAsync(String aaiNetworkId, RollbackNetworkRequest req) throws NetworkAdapterClientException; } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/NetworkAdapterClientImpl.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/NetworkAdapterClientImpl.java index 9b052b4484..7092fe04c6 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/NetworkAdapterClientImpl.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/NetworkAdapterClientImpl.java @@ -22,6 +22,7 @@ package org.onap.so.client.adapter.network; import javax.ws.rs.InternalServerErrorException; import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; import javax.ws.rs.core.UriBuilder; import org.onap.so.adapters.nwrest.CreateNetworkRequest; @@ -54,6 +55,15 @@ public class NetworkAdapterClientImpl implements NetworkAdapterClient { throw new NetworkAdapterClientException(e.getMessage()); } } + + @Override + public Response createNetworkAsync(CreateNetworkRequest req) throws NetworkAdapterClientException{ + try { + return new AdapterRestClient(this.props, this.getUri("").build()).post(req); + } catch (InternalServerErrorException e) { + throw new NetworkAdapterClientException(e.getMessage()); + } + } @Override public DeleteNetworkResponse deleteNetwork(String aaiNetworkId, DeleteNetworkRequest req) throws NetworkAdapterClientException { @@ -64,6 +74,15 @@ public class NetworkAdapterClientImpl implements NetworkAdapterClient { throw new NetworkAdapterClientException(e.getMessage()); } } + + @Override + public Response deleteNetworkAsync(String aaiNetworkId, DeleteNetworkRequest req) throws NetworkAdapterClientException { + try { + return new AdapterRestClient(this.props, this.getUri("/" + aaiNetworkId).build()).delete(req); + } catch (InternalServerErrorException e) { + throw new NetworkAdapterClientException(e.getMessage()); + } + } @Override public RollbackNetworkResponse rollbackNetwork(String aaiNetworkId, RollbackNetworkRequest req) throws NetworkAdapterClientException { @@ -74,6 +93,15 @@ public class NetworkAdapterClientImpl implements NetworkAdapterClient { throw new NetworkAdapterClientException(e.getMessage()); } } + + @Override + public Response rollbackNetworkAsync(String aaiNetworkId, RollbackNetworkRequest req) throws NetworkAdapterClientException { + try { + return new AdapterRestClient(this.props, this.getUri("/" + aaiNetworkId).build()).delete(req); + } catch (InternalServerErrorException e) { + throw new NetworkAdapterClientException(e.getMessage()); + } + } @Override public QueryNetworkResponse queryNetwork(String aaiNetworkId, String cloudSiteId, String tenantId, diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java index 3081ab86d8..794314bf8c 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java @@ -27,6 +27,7 @@ import java.util.Map; import java.util.Optional; import java.util.UUID; +import org.apache.commons.lang3.StringUtils; import org.modelmapper.ModelMapper; import org.modelmapper.PropertyMap; import org.onap.so.adapters.nwrest.ContrailNetwork; @@ -106,8 +107,7 @@ public class NetworkAdapterObjectMapper { String messageId = getRandomUuid(); createNetworkRequest.setMessageId(messageId); - //TODO clarify callback URL build process - //createNetworkRequest.setNotificationUrl(createCallbackUrl("NetworkAResponse", messageId)); + createNetworkRequest.setNotificationUrl(createCallbackUrl("NetworkAResponse", messageId)); return createNetworkRequest; } @@ -137,11 +137,18 @@ public class NetworkAdapterObjectMapper { deleteNetworkRequest.setMsoRequest(createMsoRequest(requestContext, serviceInstance)); deleteNetworkRequest.setNetworkId(l3Network.getNetworkId()); - deleteNetworkRequest.setNetworkStackId(l3Network.getHeatStackId()); + if (!StringUtils.isEmpty(l3Network.getHeatStackId())){ + deleteNetworkRequest.setNetworkStackId(l3Network.getHeatStackId()); + } + else { + deleteNetworkRequest.setNetworkStackId(l3Network.getNetworkName()); + } deleteNetworkRequest.setNetworkType(l3Network.getNetworkType()); deleteNetworkRequest.setSkipAAI(true); deleteNetworkRequest.setTenantId(cloudRegion.getTenantId()); + deleteNetworkRequest.setNotificationUrl(createCallbackUrl("NetworkAResponse", messageId)); + return deleteNetworkRequest; } @@ -187,11 +194,10 @@ public class NetworkAdapterObjectMapper { return updateNetworkRequest; } - private RollbackNetworkRequest setCommonRollbackRequestFields(RollbackNetworkRequest request,RequestContext requestContext){ - //TODO confirm flag value + private RollbackNetworkRequest setCommonRollbackRequestFields(RollbackNetworkRequest request,RequestContext requestContext) throws UnsupportedEncodingException{ request.setSkipAAI(true); - request.setMessageId(requestContext.getMsoRequestId()); - //TODO clarify callback URL build process. This will also set SYNC flag + String messageId = requestContext.getMsoRequestId(); + request.setMessageId(messageId); //request.setNotificationUrl(createCallbackUrl("NetworkAResponse", messageId)); return request; } @@ -365,4 +371,4 @@ public class NetworkAdapterObjectMapper { updateNetworkRequest.setBackout(Boolean.TRUE.equals(orchestrationContext.getIsRollbackEnabled())); //NetworkTechnology(NetworkTechnology.NEUTRON); NOOP - default } -} +}
\ No newline at end of file diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/NetworkAdapterResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/NetworkAdapterResources.java index 64a86fc731..feb6ed4013 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/NetworkAdapterResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/NetworkAdapterResources.java @@ -24,6 +24,8 @@ import java.io.UnsupportedEncodingException; import java.util.Map; import java.util.Optional; +import javax.ws.rs.core.Response; + import org.onap.so.adapters.nwrest.CreateNetworkRequest; import org.onap.so.adapters.nwrest.CreateNetworkResponse; import org.onap.so.adapters.nwrest.DeleteNetworkRequest; @@ -79,4 +81,29 @@ public class NetworkAdapterResources { DeleteNetworkRequest deleteNetworkRequest = networkAdapterObjectMapper.deleteNetworkRequestMapper(requestContext, cloudRegion, serviceInstance, l3Network); return Optional.of(networkAdapterClient.deleteNetwork(l3Network.getNetworkId(), deleteNetworkRequest)); } + + public Optional<Response> createNetworkAsync(CreateNetworkRequest createNetworkRequest) throws UnsupportedEncodingException, NetworkAdapterClientException { + + return Optional.of(networkAdapterClient.createNetworkAsync(createNetworkRequest)); + } + + public Optional<Response> deleteNetworkAsync(DeleteNetworkRequest deleteNetworkRequest) throws UnsupportedEncodingException, NetworkAdapterClientException { + + return Optional.of(networkAdapterClient.deleteNetworkAsync(deleteNetworkRequest.getNetworkId(), deleteNetworkRequest)); + } + + public Optional<RollbackNetworkResponse> rollbackCreateNetwork(String networkId, RollbackNetworkRequest rollbackNetworkRequest) throws UnsupportedEncodingException, NetworkAdapterClientException { + + return Optional.of(networkAdapterClient.rollbackNetwork(networkId, rollbackNetworkRequest)); + } + + public Optional<UpdateNetworkResponse> updateNetwork(UpdateNetworkRequest updateNetworkRequest) throws UnsupportedEncodingException, NetworkAdapterClientException { + + return Optional.of(networkAdapterClient.updateNetwork(updateNetworkRequest.getNetworkId(), updateNetworkRequest)); + } + + public Optional<DeleteNetworkResponse> deleteNetwork(DeleteNetworkRequest deleteNetworkRequest) throws UnsupportedEncodingException, NetworkAdapterClientException { + + return Optional.of(networkAdapterClient.deleteNetwork(deleteNetworkRequest.getNetworkId(), deleteNetworkRequest)); + } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterCreateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterCreateTasksTest.java index 3dc03b2988..3034f0bd67 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterCreateTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterCreateTasksTest.java @@ -20,7 +20,9 @@ package org.onap.so.bpmn.infrastructure.adapter.network.tasks; +import static org.junit.Assert.assertEquals; 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.Mockito.verify; @@ -33,6 +35,7 @@ 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.CreateNetworkResponse; import org.onap.so.bpmn.BaseTaskTest; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; @@ -76,17 +79,14 @@ public class NetworkAdapterCreateTasksTest extends BaseTaskTest{ @Test public void createNetworkTest() throws Exception { - CreateNetworkResponse createNetworkResponse = new CreateNetworkResponse(); - createNetworkResponse.setNetworkStackId("networkStackId"); - createNetworkResponse.setNetworkCreated(true); - Optional<CreateNetworkResponse> oCreateNetworkResponse = Optional.of(createNetworkResponse); - String cloudRegionPo = "cloudRegionPo"; + CreateNetworkRequest createNetworkRequest = new CreateNetworkRequest(); execution.setVariable("cloudRegionPo", cloudRegionPo); - doReturn(oCreateNetworkResponse).when(networkAdapterResources).createNetwork(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo,customer); + doReturn(createNetworkRequest).when(networkAdapterObjectMapper).createNetworkRequestMapper(isA(RequestContext.class), isA(CloudRegion.class), isA(OrchestrationContext.class), isA(ServiceInstance.class), isA(L3Network.class), isA(Map.class), isA(String.class), isA(Customer.class)); networkAdapterCreateTasks.createNetwork(execution); - verify(networkAdapterResources, times(1)).createNetwork(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo,customer); + verify(networkAdapterObjectMapper, times(1)).createNetworkRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo, customer); + assertEquals(createNetworkRequest, execution.getVariable("networkAdapterRequest")); } @Test diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterDeleteTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterDeleteTasksTest.java index 33a2e6a7a8..5b534e00e7 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterDeleteTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterDeleteTasksTest.java @@ -20,10 +20,8 @@ package org.onap.so.bpmn.infrastructure.adapter.network.tasks; -import static org.junit.Assert.assertEquals; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.times; @@ -31,7 +29,6 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import java.io.UnsupportedEncodingException; -import java.util.Optional; import org.camunda.bpm.engine.delegate.BpmnError; import org.junit.Before; @@ -39,17 +36,16 @@ import org.junit.Test; import org.mockito.ArgumentMatchers; import org.mockito.InjectMocks; import org.mockito.Mock; -import org.onap.so.adapters.nwrest.DeleteNetworkResponse; +import org.onap.so.adapters.nwrest.DeleteNetworkRequest; import org.onap.so.bpmn.BaseTaskTest; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; -import org.onap.so.client.adapter.network.NetworkAdapterClientException; -import org.onap.so.client.exception.BBObjectNotFoundException; -import org.onap.so.client.orchestration.NetworkAdapterResources; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; +import org.onap.so.client.adapter.network.NetworkAdapterClientException; +import org.onap.so.client.exception.BBObjectNotFoundException; public class NetworkAdapterDeleteTasksTest extends BaseTaskTest{ @@ -77,25 +73,19 @@ public class NetworkAdapterDeleteTasksTest extends BaseTaskTest{ @Test public void test_deleteNetwork() throws UnsupportedEncodingException, NetworkAdapterClientException { - DeleteNetworkResponse deleteNetworkResponse = new DeleteNetworkResponse(); - deleteNetworkResponse.setNetworkDeleted(true); - deleteNetworkResponse.setNetworkId(l3Network.getNetworkId()); - Optional<DeleteNetworkResponse> oDeleteNetworkResponse = Optional.of(deleteNetworkResponse); - - when(networkAdapterResources.deleteNetwork(any(RequestContext.class), any(CloudRegion.class), eq(serviceInstance), eq(l3Network))).thenReturn(oDeleteNetworkResponse); + DeleteNetworkRequest deleteNetworkRequest = new DeleteNetworkRequest(); + doReturn(deleteNetworkRequest).when(networkAdapterObjectMapper).deleteNetworkRequestMapper(requestContext, cloudRegion, serviceInstance, l3Network); networkAdapterDeleteTasks.deleteNetwork(execution); - - verify(networkAdapterResources, times(1)).deleteNetwork(requestContext, cloudRegion, serviceInstance, l3Network); - assertEquals(deleteNetworkResponse, execution.getVariable("deleteNetworkResponse")); + verify(networkAdapterObjectMapper, times(1)).deleteNetworkRequestMapper(requestContext, cloudRegion, serviceInstance, l3Network); } @Test public void test_deleteNetwork_exception() throws UnsupportedEncodingException, NetworkAdapterClientException { expectedException.expect(BpmnError.class); - doThrow(NetworkAdapterClientException.class).when(networkAdapterResources). - deleteNetwork(any(RequestContext.class), any(CloudRegion.class), any(ServiceInstance.class), eq(l3Network)); + doThrow(RuntimeException.class).when(networkAdapterObjectMapper). + deleteNetworkRequestMapper(any(RequestContext.class), any(CloudRegion.class), any(ServiceInstance.class), eq(l3Network)); networkAdapterDeleteTasks.deleteNetwork(execution); } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1Test.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1Test.java new file mode 100644 index 0000000000..2ba8cb4b57 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1Test.java @@ -0,0 +1,19 @@ +package org.onap.so.bpmn.infrastructure.adapter.network.tasks; + +import java.io.IOException; + +import javax.xml.bind.JAXBException; + +import org.junit.Test; +import org.onap.so.adapters.nwrest.CreateNetworkResponse; + +public class NetworkAdapterRestV1Test { + + @Test + public void testUnmarshalXml() throws IOException, JAXBException { + String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><createNetworkResponse><messageId>ec37c121-e3ec-4697-8adf-2d7dca7044fc</messageId><networkCreated>true</networkCreated><networkFqdn>someNetworkFqdn</networkFqdn><networkId>991ec7bf-c9c4-4ac1-bb9c-4b61645bddb3</networkId><networkStackId>someStackId</networkStackId><neutronNetworkId>9c47521a-2916-4018-b2bc-71ab767497e3</neutronNetworkId><rollback><cloudId>someCloudId</cloudId><modelCustomizationUuid>b7171cdd-8b05-459b-80ef-2093150e8983</modelCustomizationUuid><msoRequest><requestId>90b32315-176e-4dab-bcf1-80eb97a1c4f4</requestId><serviceInstanceId>71e7db22-7907-4d78-8fcc-8d89d28e90be</serviceInstanceId></msoRequest><networkCreated>true</networkCreated><networkStackId>someStackId</networkStackId><networkType>SomeNetworkType</networkType><neutronNetworkId>9c47521a-2916-4018-b2bc-71ab767497e3</neutronNetworkId><tenantId>b60da4f71c1d4b35b8113d4eca6deaa1</tenantId></rollback><subnetMap><entry><key>6b381fa9-48ce-4e16-9978-d75309565bb6</key><value>bc1d5537-860b-4894-8eba-6faff41e648c</value></entry></subnetMap></createNetworkResponse>"; + CreateNetworkResponse response = (CreateNetworkResponse) new NetworkAdapterRestV1().unmarshalXml(xml, CreateNetworkResponse.class); + String returnedXml = response.toXmlString(); + System.out.println(returnedXml); + } +} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapperTest.java index 6f353fa622..1a86d713a2 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapperTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapperTest.java @@ -22,6 +22,7 @@ package org.onap.so.client.adapter.network.mapper; import static com.shazam.shazamcrest.MatcherAssert.assertThat; import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; import static org.junit.Assert.*; +import static org.mockito.Matchers.isA; import static org.mockito.Mockito.doReturn; import java.io.UnsupportedEncodingException; @@ -135,6 +136,8 @@ public class NetworkAdapterObjectMapperTest extends TestDataSetup{ expectedCreateNetworkRequest.setMsoRequest(msoRequest); expectedCreateNetworkRequest.setSkipAAI(true); + expectedCreateNetworkRequest.setNotificationUrl("endpoint/NetworkAResponse/messageId"); + Subnet openstackSubnet = new Subnet(); HostRoute hostRoute = new HostRoute(); hostRoute.setHostRouteId("hostRouteId"); @@ -146,6 +149,9 @@ public class NetworkAdapterObjectMapperTest extends TestDataSetup{ l3Network.getSubnets().add(openstackSubnet); l3Network.setNetworkTechnology("Contrail"); + doReturn("endpoint/").when(SPY_networkAdapterObjectMapper).getEndpoint(); + doReturn("messageId").when(SPY_networkAdapterObjectMapper).getRandomUuid(); + CreateNetworkRequest createNetworkRequest = SPY_networkAdapterObjectMapper.createNetworkRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo, customer); assertThat(createNetworkRequest, sameBeanAs(expectedCreateNetworkRequest).ignoring("contrailRequest").ignoring("contrailNetwork").ignoring("providerVlanNetwork").ignoring("subnets").ignoring("networkParams").ignoring("messageId")); @@ -295,6 +301,51 @@ public class NetworkAdapterObjectMapperTest extends TestDataSetup{ expectedDeleteNetworkRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId()); + expectedDeleteNetworkRequest.setNotificationUrl("endpoint/NetworkAResponse/messageId"); + + doReturn("endpoint/").when(SPY_networkAdapterObjectMapper).getEndpoint(); + doReturn("messageId").when(SPY_networkAdapterObjectMapper).getRandomUuid(); + + DeleteNetworkRequest deleteNetworkRequest = SPY_networkAdapterObjectMapper.deleteNetworkRequestMapper(requestContext, cloudRegion, serviceInstance, l3Network); + + assertThat(expectedDeleteNetworkRequest, sameBeanAs(deleteNetworkRequest)); + } + + @Test + public void deleteNetworkRequestNoHeatIdMapperTest() throws Exception { + DeleteNetworkRequest expectedDeleteNetworkRequest = new DeleteNetworkRequest(); + + String messageId = "messageId"; + expectedDeleteNetworkRequest.setMessageId(messageId); + doReturn(messageId).when(SPY_networkAdapterObjectMapper).getRandomUuid(); + + ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork(); + l3Network.setModelInfoNetwork(modelInfoNetwork); + modelInfoNetwork.setModelCustomizationUUID("modelCustomizationUuid"); + expectedDeleteNetworkRequest.setModelCustomizationUuid(modelInfoNetwork.getModelCustomizationUUID()); + + MsoRequest msoRequest = new MsoRequest(); + msoRequest.setRequestId(requestContext.getMsoRequestId()); + msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId()); + expectedDeleteNetworkRequest.setMsoRequest(msoRequest); + + expectedDeleteNetworkRequest.setNetworkId(l3Network.getNetworkId()); + + l3Network.setNetworkName("heatStackId"); + expectedDeleteNetworkRequest.setNetworkStackId("heatStackId"); + + expectedDeleteNetworkRequest.setNetworkType(l3Network.getNetworkType()); + + expectedDeleteNetworkRequest.setSkipAAI(true); + + expectedDeleteNetworkRequest.setTenantId(cloudRegion.getTenantId()); + + expectedDeleteNetworkRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId()); + + expectedDeleteNetworkRequest.setNotificationUrl("endpoint/NetworkAResponse/messageId"); + + doReturn("endpoint/").when(SPY_networkAdapterObjectMapper).getEndpoint(); + doReturn("messageId").when(SPY_networkAdapterObjectMapper).getRandomUuid(); DeleteNetworkRequest deleteNetworkRequest = SPY_networkAdapterObjectMapper.deleteNetworkRequestMapper(requestContext, cloudRegion, serviceInstance, l3Network); assertThat(expectedDeleteNetworkRequest, sameBeanAs(deleteNetworkRequest)); @@ -316,6 +367,11 @@ public class NetworkAdapterObjectMapperTest extends TestDataSetup{ org.onap.so.adapters.nwrest.CreateNetworkRequest.class); String cloudRegionPo = "cloudRegionPo"; + + expectedCreateNetworkRequest.setNotificationUrl("endpoint/NetworkAResponse/messageId"); + + doReturn("endpoint/").when(SPY_networkAdapterObjectMapper).getEndpoint(); + doReturn("messageId").when(SPY_networkAdapterObjectMapper).getRandomUuid(); CreateNetworkRequest createNetworkRequest = SPY_networkAdapterObjectMapper.createNetworkRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, myNetwork, userInput, cloudRegionPo, customer); //ignoring dynamic fields and networkParams that throws parsing exception on json file load assertThat(createNetworkRequest, sameBeanAs(expectedCreateNetworkRequest).ignoring("messageId").ignoring("msoRequest.requestId").ignoring("networkParams")); |