aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/MSOCommonBPMN/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn/MSOCommonBPMN/src/test')
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcessTest.groovy214
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/FalloutHandlerTest.groovy333
2 files changed, 151 insertions, 396 deletions
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcessTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcessTest.groovy
index 99c351c465..119159f458 100644
--- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcessTest.groovy
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcessTest.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
@@ -24,13 +24,17 @@ import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution
import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
import org.junit.Before
+import org.junit.Ignore
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.ArgumentCaptor
+import org.mockito.Mock
import org.mockito.MockitoAnnotations
+import org.mockito.Spy
import org.mockito.runners.MockitoJUnitRunner
import org.onap.so.bpmn.core.WorkflowException
-
+import org.onap.so.db.request.beans.InfraActiveRequests
+import org.onap.so.db.request.client.RequestsDbClient
import static org.assertj.core.api.Assertions.assertThat
import static org.assertj.core.api.Assertions.assertThatThrownBy
import static org.mockito.ArgumentMatchers.eq
@@ -38,27 +42,20 @@ import static org.mockito.Mockito.*
@RunWith(MockitoJUnitRunner.class)
class CompleteMsoProcessTest {
- @Before
- public void init() {
- MockitoAnnotations.initMocks(this)
- }
-
- private String completeMsoProcessRequest = """
- <sdncadapterworkflow:MsoCompletionRequest xmlns:ns="http://org.onap/so/request/types/v1" xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1">
- <ns:request-information>
- <ns:request-id>uCPE1020_STUW105_5002</ns:request-id>
- <ns:request-action>Layer3ServiceActivateRequest</ns:request-action>
- <ns:request-sub-action>COMPLETE</ns:request-sub-action>
- <ns:source>OMX</ns:source>
- <ns:notification-url>http://localhost:28090/CCD/StatusNotification</ns:notification-url>
- <ns:order-number>10205000</ns:order-number>
- <ns:order-version>1</ns:order-version>
- </ns:request-information>
- <sdncadapterworkflow:mso-bpel-name>UCPELayer3ServiceActivateV1</sdncadapterworkflow:mso-bpel-name>
- </sdncadapterworkflow:MsoCompletionRequest>
- """
-
- private String completeMsoNetworkProcessRequest = """
+
+ @Mock
+ RequestsDbClient requestsDbClient;
+
+ @Spy
+ CompleteMsoProcess completeMsoProcess;
+
+
+ @Before
+ public void init() {
+ MockitoAnnotations.initMocks(this)
+ }
+
+ private String completeMsoNetworkProcessRequest = """
<aetgt:MsoCompletionRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1"
xmlns:ns="http://org.onap/so/request/types/v1">
<request-info xmlns="http://org.onap/so/infra/vnf-request/v1">
@@ -71,104 +68,39 @@ class CompleteMsoProcessTest {
<aetgt:mso-bpel-name>BPMN Network action: CREATE</aetgt:mso-bpel-name>
</aetgt:MsoCompletionRequest>"""
- @Test
- public void testPreProcessRequest() {
-
- ExecutionEntity mockExecution = mock(ExecutionEntity.class)
- when(mockExecution.getVariable("CompleteMsoProcessRequest")).thenReturn(completeMsoProcessRequest)
- when(mockExecution.getVariable("mso.adapters.db.auth")).thenReturn("5E12ACACBD552A415E081E29F2C4772F9835792A51C766CCFDD7433DB5220B59969CB2798C");
- when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7");
-
- CompleteMsoProcess completeMsoProcess = new CompleteMsoProcess()
- completeMsoProcess.preProcessRequest(mockExecution)
-
- /* Initialize all the process request variables in this block */
- verify(mockExecution).setVariable("prefix","CMSO_")
- //verify(mockExecution).setVariable("getLayer3ServiceDetailsV1Response","")
- verify(mockExecution).setVariable("CMSO_request_id","")
- verify(mockExecution).setVariable("CMSO_notification-url","")
- verify(mockExecution).setVariable("CMSO_mso-bpel-name","")
- verify(mockExecution).setVariable("CMSO_request_action","")
-
- verify(mockExecution).setVariable("CMSO_notification-url-Ok", false)
- verify(mockExecution).setVariable("CMSO_request_id-Ok", false)
-
- //updateRequest Adapter process variables
- verify(mockExecution).setVariable("CMSO_updateRequestResponse", "")
- verify(mockExecution).setVariable("CMSO_updateRequestResponseCode", "")
- verify(mockExecution).setVariable("CMSO_updateFinalNotifyAckStatusFailedPayload", "")
-
- //Set DB adapter variables here
- verify(mockExecution).setVariable("CMSO_updateDBStatusToSuccessPayload", "")
- verify(mockExecution).setVariable("CMSO_updateInfraRequestDBPayload", "")
- verify(mockExecution).setVariable("CMSO_setUpdateDBstatustoSuccessPayload", "")
-
- //Auth variables
- verify(mockExecution).setVariable("BasicAuthHeaderValue","")
-
- //Response variables
- verify(mockExecution).setVariable("CompletionHandlerResponse","")
- verify(mockExecution).setVariable("CMSO_ErrorResponse", null)
- verify(mockExecution).setVariable("CMSO_ResponseCode", "")
-
- verify(mockExecution).setVariable("CMSO_notification-url-Ok",true)
- verify(mockExecution).setVariable("CMSO_request_id-Ok",true)
- verify(mockExecution).setVariable("CMSO_notification-url","http://localhost:28090/CCD/StatusNotification")
- verify(mockExecution).setVariable("CMSO_request_id","uCPE1020_STUW105_5002")
- verify(mockExecution).setVariable("CMSO_request_action","Layer3ServiceActivateRequest")
- verify(mockExecution).setVariable("CMSO_source","OMX")
-
- }
-
- private String setUpdateDBstatustoSuccessPayload = """
- <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://org.onap.so/requestsdb">
- <soapenv:Header/>
- <soapenv:Body>
- <req:updateInfraRequest>
- <requestId>testReqId</requestId>
- <lastModifiedBy>BPEL</lastModifiedBy>
- <statusMessage>Resource Completed Successfully</statusMessage>
- <requestStatus>COMPLETE</requestStatus>
- <progress>100</progress>
- <networkId>bd631913-cfc6-488b-ba22-6b98504f703d</networkId>
- </req:updateInfraRequest>
- </soapenv:Body>
- </soapenv:Envelope>"""
-
- @Test
- public void testsetUpdateDBstatustoSuccessPayload(){
-
- ExecutionEntity mockExecution = mock(ExecutionEntity.class)
- when(mockExecution.getVariable("CMSO_request_id")).thenReturn("testReqId")
- when(mockExecution.getVariable("CMSO_mso-bpel-name")).thenReturn("BPEL")
- when(mockExecution.getVariable("mso.adapters.db.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC");
- when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7");
- when(mockExecution.getVariable("CompleteMsoProcessRequest")).thenReturn(completeMsoNetworkProcessRequest);
-
- CompleteMsoProcess completeMsoProcess = new CompleteMsoProcess()
- completeMsoProcess.setUpdateDBstatustoSuccessPayload(mockExecution)
-
- verify(mockExecution).setVariable("CMSO_setUpdateDBstatustoSuccessPayload",setUpdateDBstatustoSuccessPayload)
- }
-
- private String msoCompletionResponse = """onse xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1">
- <sdncadapterworkflow:out>BPEL BPEL-NAME FAILED</sdncadapterworkflow:out>
-</sdncadapterworkflow:MsoCompletionResponse>"""
-
-
- @Test
- void postProcessResponse_successful() {
- DelegateExecution mockExecution = mock(DelegateExecution.class)
- when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
- when(mockExecution.getVariable("CMSO_mso-bpel-name")).thenReturn("mso-bpel-test")
- new CompleteMsoProcess().postProcessResponse(mockExecution)
-
- String expectedResponse = "<sdncadapterworkflow:MsoCompletionResponse xmlns:sdncadapterworkflow=\"http://ecomp.com/mso/workflow/schema/v1\">\n" +
- " <sdncadapterworkflow:out>BPEL mso-bpel-test completed</sdncadapterworkflow:out>\n" +
- "</sdncadapterworkflow:MsoCompletionResponse>"
-
- verify(mockExecution).setVariable("WorkflowResponse", expectedResponse)
- verify(mockExecution).setVariable("CompleteMsoProcessResponse", expectedResponse)
- verify(mockExecution).setVariable("CMSO_ResponseCode", "200")
- }
+ @Test
+ public void testPreProcessRequest() {
+
+ ExecutionEntity mockExecution = mock(ExecutionEntity.class)
+ when(mockExecution.getVariable("CompleteMsoProcessRequest")).thenReturn(completeMsoNetworkProcessRequest)
+
+ completeMsoProcess.preProcessRequest(mockExecution)
+
+ verify(mockExecution).setVariable("CMSO_request_id", "bd631913-cfc6-488b-ba22-6b98504f703d")
+ }
+
+
+ @Test
+ public void testUpdateInfraRequestDB(){
+
+ ExecutionEntity mockExecution = mock(ExecutionEntity.class)
+ when(mockExecution.getVariable("CMSO_request_id")).thenReturn("testReqId")
+ when(mockExecution.getVariable("CompleteMsoProcessRequest")).thenReturn(completeMsoNetworkProcessRequest);
+ when(completeMsoProcess.getDbClient()).thenReturn(requestsDbClient)
+ completeMsoProcess.updateInfraRequestDB(mockExecution)
+
+ InfraActiveRequests request = new InfraActiveRequests()
+ request.setRequestId("testReqId")
+
+ completeMsoProcess.updateInfraRequestDB(mockExecution)
+
+ request.setRequestStatus("COMPLETED")
+ request.setStatusMessage("Resource Completed Successfully")
+ request.setProgress(100)
+ request.setLastModifiedBy("BPMN")
+ request.setNetworkId("bd631913-cfc6-488b-ba22-6b98504f703d")
+
+
+ verify(requestsDbClient, times(2)).updateInfraActiveRequests(request, null, null)
+ }
} \ No newline at end of file
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/FalloutHandlerTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/FalloutHandlerTest.groovy
index 25f62a6555..6cae293971 100644
--- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/FalloutHandlerTest.groovy
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/FalloutHandlerTest.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
@@ -29,31 +29,41 @@ import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.ArgumentCaptor;
+import org.mockito.Mock
import org.mockito.MockitoAnnotations
+import org.mockito.Spy
import org.mockito.runners.MockitoJUnitRunner
import org.onap.so.bpmn.common.scripts.MsoUtils;
+import org.onap.so.db.request.beans.InfraActiveRequests
+import org.onap.so.db.request.client.RequestsDbClient
import org.onap.so.bpmn.common.scripts.FalloutHandler;
@RunWith(MockitoJUnitRunner.class)
class FalloutHandlerTest {
-
- public MsoUtils utils = new MsoUtils()
-
- @Before
- public void init() {
- MockitoAnnotations.initMocks(this)
- }
- private String falloutHandlerRequest = """
+ public MsoUtils utils = new MsoUtils()
+
+ @Spy
+ FalloutHandler falloutHandler = new FalloutHandler()
+
+ @Mock
+ RequestsDbClient requestsDbClient;
+
+ @Before
+ public void init() {
+ MockitoAnnotations.initMocks(this)
+ }
+
+ private String falloutHandlerRequest = """
<sdncadapterworkflow:FalloutHandlerRequest xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1" xmlns:ns7="http://org.onap/so/request/types/v1">
- <ns7:request-information>
+ <ns7:request-info>
<ns7:request-id>uCPE1020_STUW105_5002</ns7:request-id>
<ns7:request-action>Layer3ServiceActivateRequest</ns7:request-action>
<ns7:request-sub-action>CANCEL</ns7:request-sub-action>
<ns7:source>OMX</ns7:source>
<ns7:order-number>10205000</ns7:order-number>
<ns7:order-version>1</ns7:order-version>
- </ns7:request-information>
+ </ns7:request-info>
<sdncadapterworkflow:WorkflowException>
<sdncadapterworkflow:ErrorMessage>Some Error Message - Fallout Handler</sdncadapterworkflow:ErrorMessage>
<sdncadapterworkflow:ErrorCode>Some Error Code - Fallout Handler</sdncadapterworkflow:ErrorCode>
@@ -62,251 +72,64 @@ class FalloutHandlerTest {
</sdncadapterworkflow:FalloutHandlerRequest>
"""
- private String falloutHandlerResponse = """<workflow:FalloutHandlerResponse xmlns:workflow="http://org.onap/so/workflow/schema/v1">
+ private String falloutHandlerResponse = """<workflow:FalloutHandlerResponse xmlns:workflow="http://org.onap/so/workflow/schema/v1">
<workflow:out>Fallout Handler Failed</workflow:out>
</workflow:FalloutHandlerResponse>"""
- @Test
- public void testPreProcessRequest() {
-
- ExecutionEntity mockExecution = mock(ExecutionEntity.class)
-
- when(mockExecution.getVariable("FalloutHandlerRequest")).thenReturn(falloutHandlerRequest)
- when(mockExecution.getVariable("mso.adapters.db.auth")).thenReturn("5E12ACACBD552A415E081E29F2C4772F9835792A51C766CCFDD7433DB5220B59969CB2798C");
- when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7");
-
- FalloutHandler falloutHandler = new FalloutHandler()
- falloutHandler.preProcessRequest(mockExecution)
-
- /* Initialize all the process request variables in this block */
- verify(mockExecution).setVariable("prefix","FH_")
- //verify(mockExecution).setVariable("getLayer3ServiceDetailsV1Response","")
+ @Test
+ public void testPreProcessRequest() {
- //These variables are form the input Message to the BPMN
- verify(mockExecution).setVariable("FH_request_id","")
- verify(mockExecution).setVariable("FH_request_action","")
- verify(mockExecution).setVariable("FH_notification-url","")
- verify(mockExecution).setVariable("FH_mso-bpel-name","")
- verify(mockExecution).setVariable("FH_ErrorCode", "")
- verify(mockExecution).setVariable("FH_ErrorMessage", "")
+ ExecutionEntity mockExecution = mock(ExecutionEntity.class)
- verify(mockExecution).setVariable("FH_notification-url-Ok", false)
- verify(mockExecution).setVariable("FH_request_id-Ok", false)
+ when(mockExecution.getVariable("FalloutHandlerRequest")).thenReturn(falloutHandlerRequest)
- //These variables are for Get Mso Aai Password Adapter
- verify(mockExecution).setVariable("FH_deliveryStatus", true)
+ falloutHandler.preProcessRequest(mockExecution)
- //update Response Status to pending ...Adapter variables
- verify(mockExecution).setVariable("FH_updateResponseStatusPayload", null)
- verify(mockExecution).setVariable("FH_updateResponseStatusResponse", null)
+ verify(mockExecution).setVariable("FH_success", true)
+ verify(mockExecution).setVariable("FH_request_id","uCPE1020_STUW105_5002")
+ verify(mockExecution).setVariable("FH_ErrorCode","Some Error Code - Fallout Handler")
+ verify(mockExecution).setVariable("FH_ErrorMessage","Some Error Message - Fallout Handler")
+ }
- //update Request Gamma ...Adapter variables
- verify(mockExecution).setVariable("FH_updateRequestGammaPayload", "")
- verify(mockExecution).setVariable("FH_updateRequestGammaResponse", null)
- verify(mockExecution).setVariable("FH_updateRequestGammaResponseCode", null)
+ @Test
+ public void testpostProcessResponse(){
- //update Request Infra ...Adapter variables
- verify(mockExecution).setVariable("FH_updateRequestInfraPayload", "")
- verify(mockExecution).setVariable("FH_updateRequestInfraResponse", null)
- verify(mockExecution).setVariable("FH_updateRequestInfraResponseCode", null)
+ ExecutionEntity mockExecution = mock(ExecutionEntity.class)
- //assign False to success variable
- verify(mockExecution).setVariable("FH_success", true)
+ when(mockExecution.getVariable("FH_success")).thenReturn(false)
- //Set notify status to Failed variable
- verify(mockExecution).setVariable("FH_NOTIFY_STATUS", "SUCCESS")
+ falloutHandler.postProcessResponse(mockExecution)
- //Set DB update variable
- verify(mockExecution).setVariable("FH_updateRequestPayload", "")
- verify(mockExecution).setVariable("FH_updateRequestResponse", null)
- verify(mockExecution).setVariable("FH_updateRequestResponseCode", null)
+ // Capture the arguments to setVariable
+ ArgumentCaptor<String> captor1 = ArgumentCaptor.forClass(String.class);
+ ArgumentCaptor<String> captor2 = ArgumentCaptor.forClass(String.class);
- //Auth variables
- verify(mockExecution).setVariable("BasicAuthHeaderValue","")
+ verify(mockExecution, times(4)).setVariable(captor1.capture(), captor2.capture())
+ List<String> arg2List = captor2.getAllValues()
+ String payloadResponseActual = arg2List.get(1)
- //Response variables
- verify(mockExecution).setVariable("FalloutHandlerResponse","")
- verify(mockExecution).setVariable("FH_ErrorResponse", null)
- verify(mockExecution).setVariable("FH_ResponseCode", "")
+ assertEquals(falloutHandlerResponse.replaceAll("\\s+", ""), payloadResponseActual.replaceAll("\\s+", ""))
- verify(mockExecution).setVariable("FH_request_id-Ok",true)
- verify(mockExecution).setVariable("FH_request_id","uCPE1020_STUW105_5002")
- verify(mockExecution).setVariable("FH_request_action","Layer3ServiceActivateRequest")
- verify(mockExecution).setVariable("FH_source","OMX")
- verify(mockExecution).setVariable("FH_ErrorCode","Some Error Code - Fallout Handler")
- verify(mockExecution).setVariable("FH_ErrorMessage","Some Error Message - Fallout Handler")
+ verify(mockExecution).setVariable("FH_ResponseCode","500")
+ }
- }
- @Test
- public void testpostProcessResponse(){
+ @Test
+ public void testUpdateInfraRequestDB(){
- ExecutionEntity mockExecution = mock(ExecutionEntity.class)
+ ExecutionEntity mockExecution = mock(ExecutionEntity.class)
+ when(mockExecution.getVariable("FH_request_id")).thenReturn("testReqId")
+ when(mockExecution.getVariable("FH_ErrorMessage")).thenReturn("ErrorMessage")
+ when(falloutHandler.getDbClient()).thenReturn(requestsDbClient)
- when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
- when(mockExecution.getVariable("FH_success")).thenReturn(false)
-
- FalloutHandler falloutHandler = new FalloutHandler()
- falloutHandler.postProcessResponse(mockExecution)
-
- // Capture the arguments to setVariable
- ArgumentCaptor<String> captor1 = ArgumentCaptor.forClass(String.class);
- ArgumentCaptor<String> captor2 = ArgumentCaptor.forClass(String.class);
-
- verify(mockExecution, times(4)).setVariable(captor1.capture(), captor2.capture())
- List<String> arg2List = captor2.getAllValues()
- String payloadResponseActual = arg2List.get(1)
-
- assertEquals(falloutHandlerResponse.replaceAll("\\s+", ""), payloadResponseActual.replaceAll("\\s+", ""))
-
- verify(mockExecution).setVariable("FH_ResponseCode","500")
- }
-
- private String updateRequestPayload = """
- <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://org.onap.so/requestsdb">
- <soapenv:Header/>
- <soapenv:Body>
- <req:updateRequest>
- <requestId>testReqId</requestId>
- <lastModifiedBy>BPEL</lastModifiedBy>
- <finalErrorMessage>ErrorMessage</finalErrorMessage>
- <finalErrorCode>ErrorCode</finalErrorCode>
- <status>FAILED</status>
- <responseStatus>NotifyStatus</responseStatus>
- </req:updateRequest>
- </soapenv:Body>
- </soapenv:Envelope>
- """
-
- @Test
- public void testupdateRequestPayload(){
-
- ExecutionEntity mockExecution = mock(ExecutionEntity.class)
- when(mockExecution.getVariable("FH_request_id")).thenReturn("testReqId")
- when(mockExecution.getVariable("FH_ErrorMessage")).thenReturn("ErrorMessage")
- when(mockExecution.getVariable("FH_ErrorCode")).thenReturn("ErrorCode")
- when(mockExecution.getVariable("FH_NOTIFY_STATUS")).thenReturn("NotifyStatus")
-
- FalloutHandler falloutHandler = new FalloutHandler()
- falloutHandler.updateRequestPayload(mockExecution)
-
- // Capture the arguments to setVariable
- ArgumentCaptor<String> captor1 = ArgumentCaptor.forClass(String.class);
- ArgumentCaptor<String> captor2 = ArgumentCaptor.forClass(String.class);
-
- verify(mockExecution, times(1)).setVariable(captor1.capture(), captor2.capture())
- List<String> arg2List = captor2.getAllValues()
- String payloadRequestActual = arg2List.get(0)
-
- assertEquals(updateRequestPayload.replaceAll("\\s+", ""), payloadRequestActual.replaceAll("\\s+", ""))
- }
-
- private String updateRequestInfraPayload = """
- <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://org.onap.so/requestsdb">
- <soapenv:Header/>
- <soapenv:Body>
- <req:updateInfraRequest>
- <requestId>testReqId</requestId>
- <lastModifiedBy>BPEL</lastModifiedBy>
- <statusMessage>ErrorMessage</statusMessage>
- <requestStatus>FAILED</requestStatus>
- <progress>100</progress>
- </req:updateInfraRequest>
- </soapenv:Body>
- </soapenv:Envelope>
- """
-
- @Test
- public void testupdateRequestInfraPayload(){
-
- ExecutionEntity mockExecution = mock(ExecutionEntity.class)
- when(mockExecution.getVariable("FH_request_id")).thenReturn("testReqId")
- when(mockExecution.getVariable("FH_ErrorMessage")).thenReturn("ErrorMessage")
-
- FalloutHandler falloutHandler = new FalloutHandler()
- falloutHandler.updateRequestInfraPayload(mockExecution)
-
- // Capture the arguments to setVariable
- ArgumentCaptor<String> captor1 = ArgumentCaptor.forClass(String.class);
- ArgumentCaptor<String> captor2 = ArgumentCaptor.forClass(String.class);
-
- verify(mockExecution, times(1)).setVariable(captor1.capture(), captor2.capture())
- List<String> arg2List = captor2.getAllValues()
- String payloadRequestActual = arg2List.get(0)
-
- assertEquals(updateRequestInfraPayload.replaceAll("\\s+", ""), payloadRequestActual.replaceAll("\\s+", ""))
- }
-
- private String updateRequestGammaPayload = """
- <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://org.onap.so/requestsdb">
- <soapenv:Header/>
- <soapenv:Body>
- <req:updateRequest>
- <requestId>testReqId</requestId>
- <lastModifiedBy>BPEL</lastModifiedBy>
- <finalErrorMessage>ErrorMessage</finalErrorMessage>
- <finalErrorCode>ErrorCode</finalErrorCode>
- <status>FAILED</status>
- </req:updateRequest>
- </soapenv:Body>
- </soapenv:Envelope>
- """
-
- @Test
- public void testupdateRequestGammaPayload(){
-
- ExecutionEntity mockExecution = mock(ExecutionEntity.class)
- when(mockExecution.getVariable("FH_request_id")).thenReturn("testReqId")
- when(mockExecution.getVariable("FH_ErrorMessage")).thenReturn("ErrorMessage")
- when(mockExecution.getVariable("FH_ErrorCode")).thenReturn("ErrorCode")
- when(mockExecution.getVariable("mso.default.adapter.namespace")).thenReturn("http://org.onap.so");
-
- FalloutHandler falloutHandler = new FalloutHandler()
- falloutHandler.updateRequestGammaPayload(mockExecution)
-
- // Capture the arguments to setVariable
- ArgumentCaptor<String> captor1 = ArgumentCaptor.forClass(String.class);
- ArgumentCaptor<String> captor2 = ArgumentCaptor.forClass(String.class);
-
- verify(mockExecution, times(1)).setVariable(captor1.capture(), captor2.capture())
- List<String> arg2List = captor2.getAllValues()
- String payloadRequestActual = arg2List.get(0)
-
- assertEquals(updateRequestGammaPayload.replaceAll("\\s+", ""), payloadRequestActual.replaceAll("\\s+", ""))
- }
-
-
- String updateResponseStatusPayload = """
- <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://org.onap.so/requestsdb">
- <soapenv:Header/>
- <soapenv:Body>
- <req:updateResponseStatus>
- <requestId>testReqId</requestId>
- <lastModifiedBy>BPEL</lastModifiedBy>
- <responseStatus>SENDING_FINAL_NOTIFY</responseStatus>
- </req:updateResponseStatus>
- </soapenv:Body>
- </soapenv:Envelope>
- """
-
- @Test
- public void testupdateResponseStatusPayload(){
-
- ExecutionEntity mockExecution = mock(ExecutionEntity.class)
- when(mockExecution.getVariable("FH_request_id")).thenReturn("testReqId")
+ falloutHandler.updateInfraRequestDB(mockExecution)
- FalloutHandler falloutHandler = new FalloutHandler()
- falloutHandler.updateResponseStatusPayload(mockExecution)
-
- // Capture the arguments to setVariable
- ArgumentCaptor<String> captor1 = ArgumentCaptor.forClass(String.class);
- ArgumentCaptor<String> captor2 = ArgumentCaptor.forClass(String.class);
-
- verify(mockExecution, times(1)).setVariable(captor1.capture(), captor2.capture())
- List<String> arg2List = captor2.getAllValues()
- String payloadResponseActual = arg2List.get(0)
-
- assertEquals(updateResponseStatusPayload.replaceAll("\\s+", ""), payloadResponseActual.replaceAll("\\s+", ""))
- }
+ InfraActiveRequests infraRequest = new InfraActiveRequests();
+ infraRequest.setLastModifiedBy("BPMN")
+ infraRequest.setStatusMessage("ErrorMessage")
+ infraRequest.setRequestStatus("FAILED")
+ infraRequest.setProgress(100)
+ verify(requestsDbClient, times(1)).updateInfraActiveRequests(infraRequest, null, null)
+ }
} \ No newline at end of file