diff options
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/test')
4 files changed, 72 insertions, 17 deletions
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/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java index 24b87277c4..c74f590e6b 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (c) 2019 Samsung + * ================================================================================ * 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 @@ -23,6 +25,7 @@ package org.onap.so.bpmn.infrastructure.workflow.tasks; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.equalTo; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertThat; import static org.mockito.ArgumentMatchers.anyObject; @@ -31,6 +34,7 @@ import static org.mockito.Matchers.isA; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.when; +import com.fasterxml.jackson.databind.ObjectMapper; import java.io.IOException; import java.net.MalformedURLException; import java.nio.file.Files; @@ -40,9 +44,8 @@ import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Optional; -import java.util.UUID; import java.util.Set; - +import java.util.UUID; import org.camunda.bpm.engine.delegate.BpmnError; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake; @@ -90,8 +93,6 @@ import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; import org.onap.so.serviceinstancebeans.SubscriberInfo; import org.springframework.core.env.Environment; -import com.fasterxml.jackson.databind.ObjectMapper; - public class WorkflowActionTest extends BaseTaskTest { @@ -1290,7 +1291,44 @@ public class WorkflowActionTest extends BaseTaskTest { assertEquals("222",result.get(1).getResourceId()); assertEquals("111",result.get(2).getResourceId()); } - + + @Test + public void findCatalogNetworkCollectionTest() { + Service service = new Service(); + NetworkCollectionResourceCustomization networkCustomization = new NetworkCollectionResourceCustomization(); + networkCustomization.setModelCustomizationUUID("123"); + service.getCollectionResourceCustomizations().add(networkCustomization); + doReturn(networkCustomization).when(catalogDbClient).getNetworkCollectionResourceCustomizationByID("123"); + CollectionResourceCustomization customization = workflowAction.findCatalogNetworkCollection(execution, service); + assertNotNull(customization); + } + + @Test + public void findCatalogNetworkCollectionEmptyTest() { + Service service = new Service(); + NetworkCollectionResourceCustomization networkCustomization = new NetworkCollectionResourceCustomization(); + networkCustomization.setModelCustomizationUUID("123"); + service.getCollectionResourceCustomizations().add(networkCustomization); + CollectionResourceCustomization customization = workflowAction.findCatalogNetworkCollection(execution, service); + assertNull(customization); + } + + @Test + public void findCatalogNetworkCollectionMoreThanOneTest() { + Service service = new Service(); + NetworkCollectionResourceCustomization networkCustomization1 = new NetworkCollectionResourceCustomization(); + networkCustomization1.setModelCustomizationUUID("123"); + NetworkCollectionResourceCustomization networkCustomization2 = new NetworkCollectionResourceCustomization(); + networkCustomization2.setModelCustomizationUUID("321"); + service.getCollectionResourceCustomizations().add(networkCustomization1); + service.getCollectionResourceCustomizations().add(networkCustomization2); + doReturn(networkCustomization1).when(catalogDbClient).getNetworkCollectionResourceCustomizationByID("123"); + doReturn(networkCustomization2).when(catalogDbClient).getNetworkCollectionResourceCustomizationByID("321"); + workflowAction.findCatalogNetworkCollection(execution, service); + assertEquals("Found multiple Network Collections in the Service model, only one per Service is supported.", + execution.getVariable("WorkflowActionErrorMessage")); + } + private List<OrchestrationFlow> createFlowList (String... flowNames){ List<OrchestrationFlow> result = new ArrayList<>(); for(String flowName : flowNames){ 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" ] } ] } ], |