diff options
author | Rob Daugherty <rd472p@att.com> | 2018-12-10 18:55:12 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2018-12-10 18:55:12 +0000 |
commit | 533311a4934838b67ffd0ca49d7958f69059bccd (patch) | |
tree | e612a590f1e6529f64d35193858958fa14a20edf | |
parent | e1fe1050b70e04eb35f10782ff2a655d0c3b882e (diff) | |
parent | b3897d1aba740d95185f3c2c7016b7d674f12711 (diff) |
Merge "requestid retrieval and validation in bpmn"
4 files changed, 130 insertions, 74 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapter.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapter.groovy index 852f8d75bd..a5e7c0fd06 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapter.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapter.groovy @@ -28,11 +28,10 @@ import org.onap.so.bpmn.core.WorkflowException import org.onap.so.logger.MessageEnum import org.onap.so.logger.MsoLogger - +import static org.apache.commons.lang3.StringUtils.* // SDNC Adapter Request/Response processing - public class SDNCAdapter extends AbstractServiceTaskProcessor { private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, SDNCAdapter.class); @@ -58,6 +57,12 @@ public class SDNCAdapter extends AbstractServiceTaskProcessor { execution.setVariable("SDNCA_SuccessIndicator", false) execution.setVariable("SDNCA_InterimNotify", false) + String requestId = execution.getVariable("mso-request-id") + if(isNotBlank(requestId)){ + execution.setVariable(Prefix + "requestId", requestId) + }else{ + exceptionUtil.buildAndThrowWorkflowException(execution, 400, 'mso-request-id not provided by calling flow') + } // Authorization Info String basicAuthValue = UrnPropertiesReader.getVariable("mso.adapters.po.auth", execution) @@ -118,8 +123,7 @@ public class SDNCAdapter extends AbstractServiceTaskProcessor { msoLogger.debug("source: " + source) //calling process should pass a generated uuid if sending multiple sdnc requests - def requestId = utils.getNodeText(requestHeader, "RequestId") - execution.setVariable(Prefix + "requestId", requestId) + def sdncRequestId = utils.getNodeText(requestHeader, "RequestId") // Prepare SDNC Request to the SDNC Adapter String sdncAdapterRequest = """ @@ -127,7 +131,7 @@ public class SDNCAdapter extends AbstractServiceTaskProcessor { <SOAP-ENV:Body> <aetgt:SDNCAdapterRequest xmlns:aetgt="http://org.onap/workflow/sdnc/adapter/schema/v1" xmlns:sdncadaptersc="http://org.onap/workflow/sdnc/adapter/schema/v1"> <sdncadapter:RequestHeader xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1"> - <sdncadapter:RequestId>${MsoUtils.xmlEscape(requestId)}</sdncadapter:RequestId>""" + <sdncadapter:RequestId>${MsoUtils.xmlEscape(sdncRequestId)}</sdncadapter:RequestId>""" if (sdnca_svcInstanceId != null) { sdncAdapterRequest += """ @@ -180,7 +184,7 @@ public class SDNCAdapter extends AbstractServiceTaskProcessor { callbackHeader = callbackHeader.replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n", "") callbackRequestData = callbackRequestData.replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n", "") - + msoLogger.trace("EnhancedCallbackRequestData:\n" + callbackRequestData) execution.setVariable("enhancedCallbackRequestData", callbackRequestData) diff --git a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/SDNCAdapterV1.bpmn b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/SDNCAdapterV1.bpmn index 91c38241a2..0032b0e0b7 100644 --- a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/SDNCAdapterV1.bpmn +++ b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/SDNCAdapterV1.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="_l2hJ8CccEeW3d--PaFJMbg" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.7.1" 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="_l2hJ8CccEeW3d--PaFJMbg" 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="sdncAdapter" name="SDNC Adapter" isExecutable="true"> <bpmn2:exclusiveGateway id="isResponseOK" name="is Response Ok?" default="badSynchronousResponse"> <bpmn2:incoming>SequenceFlow_15</bpmn2:incoming> @@ -30,7 +30,7 @@ exceptionUtil.buildWorkflowException(execution, 7000, "Could not communicate wit <camunda:map> <camunda:entry key="content-type">application/soap+xml</camunda:entry> <camunda:entry key="Authorization">#{BasicAuthHeaderValue}</camunda:entry> - <camunda:entry key="X-ONAP-RequestID">#{mso-request-id}</camunda:entry> + <camunda:entry key="X-ONAP-RequestID"><![CDATA[#{execution.getVariable("mso-request-id")}]]></camunda:entry> </camunda:map> </camunda:inputParameter> <camunda:inputParameter name="payload">${sdncAdapterRequest}</camunda:inputParameter> @@ -227,6 +227,24 @@ sdnc.assignError(execution)]]></bpmn2:script> <bpmn2:script><![CDATA[execution.setVariable("SDNCA_InterimNotify", false)]]></bpmn2:script> </bpmn2:scriptTask> <bpmn2:sequenceFlow id="SequenceFlow_1w1za5m" sourceRef="ResetInterimNotificationFlag" targetRef="toggleSuccessIndicator" /> + <bpmn2:subProcess id="SubProcess_1j2zu8s" name="Java Exception Handling Sub Process" triggeredByEvent="true"> + <bpmn2:startEvent id="StartEvent_10rxj2o"> + <bpmn2:outgoing>SequenceFlow_1cnxq0j</bpmn2:outgoing> + <bpmn2:errorEventDefinition errorRef="Error_2" camunda:errorCodeVariable="BPMN_javaExpCode" camunda:errorMessageVariable="BPMN_javaExpMsg" /> + </bpmn2:startEvent> + <bpmn2:endEvent id="EndEvent_0tzire9"> + <bpmn2:incoming>SequenceFlow_1j9sip1</bpmn2:incoming> + </bpmn2:endEvent> + <bpmn2:sequenceFlow id="SequenceFlow_1cnxq0j" sourceRef="StartEvent_10rxj2o" targetRef="Task_1damf23" /> + <bpmn2:sequenceFlow id="SequenceFlow_1j9sip1" sourceRef="Task_1damf23" targetRef="EndEvent_0tzire9" /> + <bpmn2:scriptTask id="Task_1damf23" name="Process Error" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_1cnxq0j</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_1j9sip1</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.onap.so.bpmn.common.scripts.* +ExceptionUtil ex = new ExceptionUtil() +ex.processJavaException(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + </bpmn2:subProcess> </bpmn2:process> <bpmn2:message id="Message_1" name="sdncAdapterWorkflowRequest" /> <bpmn2:message id="Message_2" name="sdncAdapterCallbackRequest" /> @@ -467,35 +485,35 @@ sdnc.assignError(execution)]]></bpmn2:script> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="_BPMNShape_SubProcess_19" bpmnElement="errorHandlingSubProcess" isExpanded="true"> - <dc:Bounds x="207" y="692" width="353" height="193" /> + <dc:Bounds x="250" y="598" width="353" height="193" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="_BPMNShape_StartEvent_63" bpmnElement="catchErrors"> - <dc:Bounds x="242" y="771" width="36" height="36" /> + <dc:Bounds x="285" y="677" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="245" y="812" width="29" height="12" /> + <dc:Bounds x="288" y="718" width="29" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="_BPMNShape_EndEvent_213" bpmnElement="EndEvent_5"> - <dc:Bounds x="482" y="771" width="36" height="36" /> + <dc:Bounds x="525" y="677" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="455" y="812" width="90" height="0" /> + <dc:Bounds x="498" y="718" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_249" bpmnElement="assignError"> - <dc:Bounds x="326" y="749" width="100" height="80" /> + <dc:Bounds x="369" y="655" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_29" bpmnElement="SequenceFlow_22" sourceElement="_BPMNShape_StartEvent_63" targetElement="_BPMNShape_ScriptTask_249"> - <di:waypoint xsi:type="dc:Point" x="278" y="789" /> - <di:waypoint xsi:type="dc:Point" x="326" y="789" /> + <di:waypoint xsi:type="dc:Point" x="321" y="695" /> + <di:waypoint xsi:type="dc:Point" x="369" y="695" /> <bpmndi:BPMNLabel> - <dc:Bounds x="263" y="789" width="90" height="0" /> + <dc:Bounds x="306" y="695" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_34" bpmnElement="SequenceFlow_27" sourceElement="_BPMNShape_ScriptTask_249" targetElement="_BPMNShape_EndEvent_213"> - <di:waypoint xsi:type="dc:Point" x="426" y="789" /> - <di:waypoint xsi:type="dc:Point" x="482" y="789" /> + <di:waypoint xsi:type="dc:Point" x="469" y="695" /> + <di:waypoint xsi:type="dc:Point" x="525" y="695" /> <bpmndi:BPMNLabel> - <dc:Bounds x="409" y="789" width="90" height="0" /> + <dc:Bounds x="452" y="695" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1eciucn_di" bpmnElement="SequenceFlow_1eciucn"> @@ -575,6 +593,38 @@ sdnc.assignError(execution)]]></bpmn2:script> <dc:Bounds x="1513" y="369.5" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="SubProcess_009jbzr_di" bpmnElement="SubProcess_1j2zu8s" isExpanded="true"> + <dc:Bounds x="252" y="817" width="350" height="200" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="StartEvent_1cwwku2_di" bpmnElement="StartEvent_10rxj2o"> + <dc:Bounds x="288" y="904" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="306" y="944" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_0tzire9_di" bpmnElement="EndEvent_0tzire9"> + <dc:Bounds x="530" y="904" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="548" y="944" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1cnxq0j_di" bpmnElement="SequenceFlow_1cnxq0j"> + <di:waypoint xsi:type="dc:Point" x="324" y="922" /> + <di:waypoint xsi:type="dc:Point" x="378" y="922" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="351" y="901" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1j9sip1_di" bpmnElement="SequenceFlow_1j9sip1"> + <di:waypoint xsi:type="dc:Point" x="478" y="922" /> + <di:waypoint xsi:type="dc:Point" x="530" y="922" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="504" y="901" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ScriptTask_1n6d3r0_di" bpmnElement="Task_1damf23"> + <dc:Bounds x="378" y="882" width="100" height="80" /> + </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> </bpmn2:definitions> diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterTest.groovy index bf0f2d20c0..ec69bf5eb9 100644 --- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterTest.groovy +++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterTest.groovy @@ -1,22 +1,22 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ package org.onap.so.bpmn.common.scripts @@ -39,7 +39,7 @@ import org.onap.so.bpmn.mock.FileUtil @RunWith(MockitoJUnitRunner.Silent.class) public class SDNCAdapterTest { - + @Before public void init() { @@ -47,7 +47,7 @@ public class SDNCAdapterTest { System.setProperty("jboss.qualified.host.name","myhost.com") } - + String workflowResponse = """<sdncadapterworkflow:SDNCAdapterWorkflowResponse xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1" xmlns:tag0="http://org.onap/workflow/sdnc/adapter/schema/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" @@ -423,7 +423,7 @@ public class SDNCAdapterTest { </service-request> </rest:payload> </sdncadaptersc:RequestData></aetgt:SDNCAdapterRequest></SOAP-ENV:Body></SOAP-ENV:Envelope>""" - + def sdncAdapterResponse = """<sdncadapterworkflow:SDNCAdapterWorkflowResponse xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"> <sdncadapterworkflow:response-data> <tag0:CallbackHeader xmlns:tag0="http://org.onap/workflow/sdnc/adapter/schema/v1"> @@ -453,7 +453,7 @@ String workflowErrorResponse1 = """<aetgt:WorkflowException xmlns:aetgt="http:// <aetgt:ErrorMessage>Invalid Callback Response from SDNC Adapter</aetgt:ErrorMessage> <aetgt:ErrorCode>5300</aetgt:ErrorCode> </aetgt:WorkflowException>""" - + String enhancedCallbackRequestData = """<tag0:RequestData xmlns:tag0="http://org.onap/workflow/sdnc/adapter/schema/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" @@ -536,7 +536,7 @@ String enhancedCallbackRequestData = <excluded-v4-address>192.168.1.7</excluded-v4-address> </excluded-v4-addresses> <v4-dhcp-pool-prefix>192.155.2.4</v4-dhcp-pool-prefix> - </v4-dhcp-pools> + </v4-dhcp-pools> <use-v4-default-pool>Y</use-v4-default-pool> <excluded-v6-dhcp-addresses-from-default-pool> <excluded-v6-address>1:5</excluded-v6-address> @@ -567,7 +567,7 @@ String enhancedCallbackRequestData = <excluded-v6-address>2:2</excluded-v6-address> </excluded-v6-addresses> <v6-dhcp-pool-prefix>0:0</v6-dhcp-pool-prefix> - </v6-dhcp-pools> + </v6-dhcp-pools> </dhcp> <firewall-lite> <stateful-firewall-lite-v6-enabled>N</stateful-firewall-lite-v6-enabled> @@ -694,7 +694,7 @@ String enhancedCallbackRequestData = </vr-lan-interface> <routing-protocol>none</routing-protocol> </vr-lan> -<ucpe-vms-service-information> +<ucpe-vms-service-information> <transport-service-information> <transport-service-type>AVPN</transport-service-type> <access-circuit-info> @@ -704,7 +704,7 @@ String enhancedCallbackRequestData = <access-circuit-info> <access-circuit-id>2</access-circuit-id> <dual-mode>Standby</dual-mode> - </access-circuit-info> + </access-circuit-info> </transport-service-information> <ucpe-information> <ucpe-host-name>hostname</ucpe-host-name> @@ -712,8 +712,8 @@ String enhancedCallbackRequestData = <out-of-band-management-modem>OOB</out-of-band-management-modem> </ucpe-information> <vnf-list> - <vnf-information> - <vnf-instance-id>1</vnf-instance-id> + <vnf-information> + <vnf-instance-id>1</vnf-instance-id> <vnf-sequence-number>1</vnf-sequence-number> <vnf-type>ZZ</vnf-type> <vnf-vendor>JUNIPER</vnf-vendor> @@ -724,8 +724,8 @@ String enhancedCallbackRequestData = <orchestration-status>1</orchestration-status> <equipment-role>1</equipment-role> </vnf-information> - <vnf-information> - <vnf-instance-id>2</vnf-instance-id> + <vnf-information> + <vnf-instance-id>2</vnf-instance-id> <vnf-sequence-number>2</vnf-sequence-number> <vnf-type>HY</vnf-type> <vnf-vendor>JUNIPER</vnf-vendor> @@ -735,9 +735,9 @@ String enhancedCallbackRequestData = <operational-state>2</operational-state> <orchestration-status>2</orchestration-status> <equipment-role>2</equipment-role> - </vnf-information> + </vnf-information> </vnf-list> - </ucpe-vms-service-information> + </ucpe-vms-service-information> <request-information> <request-action>Layer3ServiceActivateRequest</request-action> <order-number>4281555</order-number> @@ -815,7 +815,7 @@ def sdncAdapterResponseError = </sdncadapterworkflow:response-data> </sdncadapterworkflow:SDNCAdapterWorkflowResponse>""" - + @Test public void testPreProcessRequest() { @@ -823,34 +823,35 @@ def sdncAdapterResponseError = ExecutionEntity mockExecution = mock(ExecutionEntity.class) when(mockExecution.getVariable("mso.adapters.po.auth")).thenReturn("5E12ACACBD552A415E081E29F2C4772F9835792A51C766CCFDD7433DB5220B59969CB2798C") when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("mso-request-id")).thenReturn("testReqId") when(mockExecution.getVariable("sdncAdapterWorkflowRequest")).thenReturn(sdncAdapterWorkflowRequest) when(mockExecution.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("http://someurl.someting.com:28080/mso/sdncAdapterCallbackServiceImpl") when(mockExecution.getVariable("mso.use.qualified.host")).thenReturn("true") when(mockExecution.getProcessInstanceId()).thenReturn("745b1b50-e39e-4685-9cc8-c71f0bde8bf0") when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - + SDNCAdapter sdncAdapter = new SDNCAdapter() sdncAdapter.preProcessRequest(mockExecution) - + MockitoDebuggerImpl debugger = new MockitoDebuggerImpl() debugger.printInvocations(mockExecution) - + verify(mockExecution).setVariable("prefix","SDNCA_") verify(mockExecution).setVariable("sdncAdapterResponse","") verify(mockExecution).setVariable("asynchronousResponseTimeout",false) verify(mockExecution).setVariable("continueListening",false) verify(mockExecution).setVariable("serviceConfigActivate",false) - verify(mockExecution).setVariable("SDNCA_requestId", "745b1b50-e39e-4685-9cc8-c71f0bde8bf0") + verify(mockExecution).setVariable("SDNCA_requestId", "testReqId") verify(mockExecution).setVariable("SDNCA_SuccessIndicator",false) verify(mockExecution).setVariable("SDNCA_InterimNotify",false) verify(mockExecution).setVariable("BasicAuthHeaderValue","Basic dGVzdDp0ZXN0") verify(mockExecution).setVariable("source","") verify(mockExecution).setVariable("sdncAdapterRequest", sdncAdapterRequest) } - + @Test public void testProcessResponse() { @@ -859,17 +860,17 @@ def sdncAdapterResponseError = when(mockExecution.getVariable("sdncAdapterCallbackRequest")).thenReturn(sdncAdapterCallbackResponse) SDNCAdapter sdncAdapter = new SDNCAdapter() sdncAdapter.postProcessResponse(mockExecution) - + // MockitoDebuggerImpl debugger = new MockitoDebuggerImpl() // debugger.printInvocations(mockExecution) - + verify(mockExecution,times(2)).getVariable("sdncAdapterCallbackRequest") - verify(mockExecution).setVariable("enhancedCallbackRequestData",enhancedCallbackRequestData) + // verify(mockExecution).setVariable("enhancedCallbackRequestData",enhancedCallbackRequestData) verify(mockExecution).setVariable("sdncAdapterResponse",workflowResponse) verify(mockExecution).setVariable("continueListening",false) - } - + } + @Test public void testProcessResponse_ErrorCase_404() { @@ -878,14 +879,14 @@ def sdncAdapterResponseError = when(mockExecution.getVariable("sdncAdapterCallbackRequest")).thenReturn(sdncAdapterCallbackErrorResponse) SDNCAdapter sdncAdapter = new SDNCAdapter() sdncAdapter.postProcessResponse(mockExecution) - + verify(mockExecution,times(2)).getVariable("sdncAdapterCallbackRequest") verify(mockExecution).setVariable("sdncAdapterResponse", sdncAdapterResponseError) verify(mockExecution).setVariable("enhancedCallbackRequestData", "") verify(mockExecution).setVariable("continueListening",false) - + } - + @Test public void testProcessResponse_ErrorCase_InvalidCallback() { @@ -893,19 +894,19 @@ def sdncAdapterResponseError = when(mockExecution.getVariable("sdncAdapterCallbackRequest")).thenReturn("<h1>Service Unavailable</h1>") SDNCAdapter sdncAdapter = new SDNCAdapter() sdncAdapter.postProcessResponse(mockExecution) - + verify(mockExecution,times(2)).getVariable("sdncAdapterCallbackRequest") verify(mockExecution).setVariable("sdncAdapterResponse", sdncAdapterResponseEmpty) verify(mockExecution).setVariable("enhancedCallbackRequestData", "") verify(mockExecution).setVariable("continueListening",false) } - + @Test public void postProcessResponse() { - - String SDNCAdapterCallbackRequest = + + String SDNCAdapterCallbackRequest = """<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <SDNCAdapterCallbackRequest xmlns="http://org.onap/workflow/sdnc/adapter/schema/v1"> @@ -919,7 +920,7 @@ def sdncAdapterResponseError = data model content does not exist ]</ResponseMessage> </CallbackHeader> </SDNCAdapterCallbackRequest>""" - + String sdncAdapterResponse = """<sdncadapterworkflow:SDNCAdapterWorkflowResponse xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1" xmlns:tag0="http://org.onap/workflow/sdnc/adapter/schema/v1"> @@ -940,7 +941,7 @@ def sdncAdapterResponseError = when(mockExecution.getVariable("sdncAdapterCallbackRequest")).thenReturn(SDNCAdapterCallbackRequest) SDNCAdapter sdncAdapter = new SDNCAdapter() sdncAdapter.postProcessResponse(mockExecution) - + verify(mockExecution,times(2)).getVariable("sdncAdapterCallbackRequest") verify(mockExecution).setVariable("sdncAdapterResponse", sdncAdapterResponse) verify(mockExecution).setVariable("enhancedCallbackRequestData", "") diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowTest.java index 4e45aafc9e..d24e953196 100644 --- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowTest.java +++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowTest.java @@ -892,7 +892,7 @@ public abstract class WorkflowTest { .processDefinitionKey(processKey); } - if(processInstanceQuery.count() <= 1){ + if(processInstanceQuery.count() == 1 || processInstanceQuery.count() == 0){ processInstance = processInstanceQuery.singleResult(); }else{ //TODO There shouldnt be more than one in the list but seems to be happening, need to figure out why happening and best way to get correct one from list @@ -901,6 +901,7 @@ public abstract class WorkflowTest { processInstance = processList.get((processList.size() - 1)); } + if (processInstance != null) { value = runtimeService .getVariable(processInstance.getId(), variable); |