diff options
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/test')
4 files changed, 48 insertions, 12 deletions
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 index 278afc733a..516c9480ad 100644 --- 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 @@ -20,12 +20,18 @@ package org.onap.so.bpmn.infrastructure.adapter.network.tasks; +import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; +import static org.junit.Assert.assertThat; + import java.io.IOException; +import java.util.HashMap; +import java.util.Map; import javax.xml.bind.JAXBException; import org.junit.Test; import org.onap.so.adapters.nwrest.CreateNetworkResponse; +import org.onap.so.adapters.nwrest.UpdateNetworkResponse; public class NetworkAdapterRestV1Test { @@ -36,4 +42,17 @@ public class NetworkAdapterRestV1Test { String returnedXml = response.toXmlString(); System.out.println(returnedXml); } + + @Test + public void testUnmarshalXmlUpdate() throws IOException, JAXBException { + UpdateNetworkResponse expectedResponse = new UpdateNetworkResponse(); + expectedResponse.setMessageId("ec100bcc-2659-4aa4-b4d8-3255715c2a51"); + expectedResponse.setNetworkId("80de31e3-cc78-4111-a9d3-5b92bf0a39eb"); + Map<String,String>subnetMap = new HashMap<String,String>(); + subnetMap.put("95cd8437-25f1-4238-8720-cbfe7fa81476", "d8d16606-5d01-4822-b160-9a0d257303e0"); + expectedResponse.setSubnetMap(subnetMap); + String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><updateNetworkResponse><messageId>ec100bcc-2659-4aa4-b4d8-3255715c2a51</messageId><networkId>80de31e3-cc78-4111-a9d3-5b92bf0a39eb</networkId><subnetMap><entry><key>95cd8437-25f1-4238-8720-cbfe7fa81476</key><value>d8d16606-5d01-4822-b160-9a0d257303e0</value></entry></subnetMap></updateNetworkResponse>"; + UpdateNetworkResponse response = (UpdateNetworkResponse) new NetworkAdapterRestV1().unmarshalXml(xml, UpdateNetworkResponse.class); + assertThat(expectedResponse, sameBeanAs(response)); + } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java index f3b094f645..2fc62978fb 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java @@ -31,6 +31,7 @@ import static org.mockito.Mockito.when; import java.util.ArrayList; import java.util.List; +import org.camunda.bpm.engine.delegate.BpmnError; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake; import org.junit.Before; @@ -46,6 +47,7 @@ import org.onap.so.bpmn.core.WorkflowException; import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; import org.onap.so.db.request.beans.InfraActiveRequests; +import org.springframework.core.env.Environment; public class WorkflowActionBBTasksTest extends BaseTaskTest { @@ -64,6 +66,9 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { private DelegateExecution execution; + @Mock + protected Environment environment; + @Rule public ExpectedException thrown = ExpectedException.none(); @@ -287,6 +292,7 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { String reqId = "reqId123"; execution.setVariable("mso-request-id", reqId); doNothing().when(workflowActionBBFailure).updateRequestErrorStatusMessage(isA(DelegateExecution.class)); + doReturn("6").when(environment).getProperty("mso.rainyDay.maxRetries"); execution.setVariable("handlingCode","Retry"); execution.setVariable("retryCount", 1); execution.setVariable("gCurrentSequence",1); @@ -297,6 +303,25 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { } @Test + public void checkRetryStatusTestExceededMaxRetries(){ + String reqId = "reqId123"; + execution.setVariable("mso-request-id", reqId); + doNothing().when(workflowActionBBFailure).updateRequestErrorStatusMessage(isA(DelegateExecution.class)); + doReturn("6").when(environment).getProperty("mso.rainyDay.maxRetries"); + execution.setVariable("handlingCode","Retry"); + execution.setVariable("retryCount", 6); + execution.setVariable("gCurrentSequence",1); + InfraActiveRequests req = new InfraActiveRequests(); + doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId(reqId); + try{ + workflowActionBBTasks.checkRetryStatus(execution); + } catch (BpmnError e) { + WorkflowException exception = (WorkflowException) execution.getVariable("WorkflowException"); + assertEquals("Exceeded maximum retries. Ending flow with status Abort",exception.getErrorMessage()); + } + } + + @Test public void checkRetryStatusNoRetryTest(){ String reqId = "reqId123"; execution.setVariable("mso-request-id", reqId); diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest1Vpn.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest1Vpn.json index 83ecd6add1..6713f80ad9 100644 --- a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest1Vpn.json +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest1Vpn.json @@ -42,9 +42,7 @@ "modelInvariantId" : "testProxyModelInvariantUuid2" }, "requiredCandidates" : [ { - "identifierType" : { - "name" : "vnfId" - }, + "identifierType" : "vnfId", "identifiers" : [ "testVnfId" ] } ] } ], diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest3Vpn.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest3Vpn.json index c3c5c0771a..14a89c90fc 100644 --- a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest3Vpn.json +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest3Vpn.json @@ -42,9 +42,7 @@ "modelInvariantId" : "testProxyModelInvariantUuid2" }, "requiredCandidates" : [ { - "identifierType" : { - "name" : "vnfId" - }, + "identifierType" : "vnfId", "identifiers" : [ "testVnfId" ] } ] }, { @@ -66,9 +64,7 @@ "modelInvariantId" : "testProxyModelInvariantUuid2" }, "requiredCandidates" : [ { - "identifierType" : { - "name" : "vnfId" - }, + "identifierType" : "vnfId", "identifiers" : [ "testVnfId" ] } ] }, { @@ -90,9 +86,7 @@ "modelInvariantId" : "testProxyModelInvariantUuid2" }, "requiredCandidates" : [ { - "identifierType" : { - "name" : "vnfId" - }, + "identifierType" : "vnfId", "identifiers" : [ "testVnfId" ] } ] } ], |