aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/test')
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java54
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ExternalTicketTasksTest.java75
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasksTest.java33
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java25
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIPnfResourcesTest.java14
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/ServiceMacroAssign.json3
6 files changed, 182 insertions, 22 deletions
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java
index c337f7f1b5..ae6dde6521 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java
@@ -20,21 +20,7 @@
package org.onap.so.bpmn.infrastructure.aai.tasks;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-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.mock;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-import java.util.HashMap;
import org.camunda.bpm.engine.delegate.BpmnError;
-import org.hamcrest.Matchers;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentMatchers;
@@ -48,6 +34,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf;
import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
@@ -56,6 +43,18 @@ import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf;
import org.onap.so.client.exception.BBObjectNotFoundException;
import org.onap.so.db.catalog.beans.OrchestrationStatus;
+import java.util.HashMap;
+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.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
public class AAIUpdateTasksTest extends BaseTaskTest {
@@ -140,6 +139,27 @@ public class AAIUpdateTasksTest extends BaseTaskTest {
aaiUpdateTasks.updateOrchestrationStatusActiveService(execution);
}
+
+ @Test
+ public void updateOrchestrationStatusActivePnfTest() throws Exception {
+ Pnf pnf = preparePnfAndExtractForPnf();
+ doNothing().when(aaiPnfResources).updateOrchestrationStatusPnf(pnf, OrchestrationStatus.ACTIVE);
+
+ aaiUpdateTasks.updateOrchestrationStatusActivePnf(execution);
+
+ verify(aaiPnfResources, times(1)).updateOrchestrationStatusPnf(pnf, OrchestrationStatus.ACTIVE);
+ }
+
+ @Test
+ public void updateOrchestrationStatusActivePnfExceptionTest() throws Exception {
+ Pnf pnf = preparePnfAndExtractForPnf();
+ doThrow(RuntimeException.class).when(aaiPnfResources).updateOrchestrationStatusPnf(pnf,
+ OrchestrationStatus.ACTIVE);
+
+ expectedException.expect(BpmnError.class);
+ aaiUpdateTasks.updateOrchestrationStatusActivePnf(execution);
+ }
+
@Test
public void updateOrchestrationStatusAssignedVnfTest() throws Exception {
doNothing().when(aaiVnfResources).updateOrchestrationStatusVnf(genericVnf, OrchestrationStatus.ASSIGNED);
@@ -743,4 +763,10 @@ public class AAIUpdateTasksTest extends BaseTaskTest {
aaiUpdateTasks.updateOrchestrationStatusConfigDeployConfiguredVnf(execution);
}
+
+ private Pnf preparePnfAndExtractForPnf() throws BBObjectNotFoundException {
+ Pnf pnf = buildPnf();
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.PNF))).thenReturn(pnf);
+ return pnf;
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ExternalTicketTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ExternalTicketTasksTest.java
new file mode 100644
index 0000000000..f8ecf01579
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ExternalTicketTasksTest.java
@@ -0,0 +1,75 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 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.infrastructure.manualhandling.tasks;
+
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.onap.so.bpmn.BaseTaskTest;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.common.DelegateExecutionImpl;
+import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
+import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
+import org.onap.so.client.ticket.ExternalTicket;
+
+public class ExternalTicketTasksTest extends BaseTaskTest {
+
+ @Mock
+ private BuildingBlockExecution buildingBlockExecution;
+
+ @Mock
+ private GeneralBuildingBlock generalBuildingBlock;
+
+ @Mock
+ private RequestContext requestContext;
+
+ @Mock
+ private ExternalTicket MOCK_externalTicket;
+
+ @Before
+ public void before() throws Exception {
+ delegateExecution = new DelegateExecutionFake();
+ buildingBlockExecution = new DelegateExecutionImpl(delegateExecution);
+ generalBuildingBlock = new GeneralBuildingBlock();
+ requestContext = new RequestContext();
+ requestContext.setRequestorId("someRequestorId");
+ generalBuildingBlock.setRequestContext(requestContext);
+ buildingBlockExecution.setVariable("mso-request-id", ("testMsoRequestId"));
+ buildingBlockExecution.setVariable("vnfType", "testVnfType");
+ buildingBlockExecution.setVariable("gBBInput", generalBuildingBlock);
+ buildingBlockExecution.setVariable("rainyDayVnfName", "someVnfName");
+ buildingBlockExecution.setVariable("workStep", "someWorkstep");
+ buildingBlockExecution.setVariable("taskTimeout", "PT5M");
+ }
+
+ @Test
+ public void createExternalTicket_Test() throws Exception {
+ ExternalTicketTasks externalTicketTasksSpy = spy(new ExternalTicketTasks());
+ when(externalTicketTasksSpy.getExternalTicket()).thenReturn(MOCK_externalTicket);
+ externalTicketTasksSpy.createExternalTicket(buildingBlockExecution);
+ verify(MOCK_externalTicket, times(1)).createTicket();
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasksTest.java
index b40195c07b..b6dcd96534 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasksTest.java
@@ -37,9 +37,13 @@ import org.junit.Before;
import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
import org.onap.so.bpmn.BaseTaskTest;
import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.common.DelegateExecutionImpl;
+import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
+import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
+import org.onap.so.client.ticket.ExternalTicket;
import org.onap.so.db.request.beans.InfraActiveRequests;
public class ManualHandlingTasksTest extends BaseTaskTest {
@@ -61,14 +65,36 @@ public class ManualHandlingTasksTest extends BaseTaskTest {
@Mock
private BuildingBlockExecution buildingBlockExecution;
+ @Mock
+ private GeneralBuildingBlock generalBuildingBlock;
+
+ @Mock
+ private RequestContext requestContext;
+
+ @Mock
+ private ExternalTicket MOCK_externalTicket;
+
@Before
public void before() throws Exception {
+ MockitoAnnotations.initMocks(this);
delegateExecution = new DelegateExecutionFake();
buildingBlockExecution = new DelegateExecutionImpl(delegateExecution);
+ generalBuildingBlock = new GeneralBuildingBlock();
+ requestContext = new RequestContext();
+ requestContext.setRequestorId("someRequestorId");
+ generalBuildingBlock.setRequestContext(requestContext);
+ buildingBlockExecution.setVariable("mso-request-id", ("testMsoRequestId"));
+ buildingBlockExecution.setVariable("vnfType", "testVnfType");
+ buildingBlockExecution.setVariable("gBBInput", generalBuildingBlock);
+ buildingBlockExecution.setVariable("rainyDayVnfName", "someVnfName");
+ buildingBlockExecution.setVariable("workStep", "someWorkstep");
+ buildingBlockExecution.setVariable("taskTimeout", "PT5M");
}
@Test
public void setFalloutTaskVariables_Test() {
+ when(mockExecution.getVariable("gBuildingBlockExecution")).thenReturn(buildingBlockExecution);
+ buildingBlockExecution.setVariable("gBBInput", generalBuildingBlock);
when(task.getId()).thenReturn("taskId");
when(task.getExecution()).thenReturn(mockExecution);
when(mockExecution.getProcessEngineServices()).thenReturn(processEngineServices);
@@ -103,7 +129,6 @@ public class ManualHandlingTasksTest extends BaseTaskTest {
@Test
public void updateRequestDbStatus_Test() throws Exception {
InfraActiveRequests mockedRequest = new InfraActiveRequests();
- buildingBlockExecution.setVariable("mso-request-id", "msoRequestId");
when(requestsDbClient.getInfraActiveRequestbyRequestId(any(String.class))).thenReturn(mockedRequest);
doNothing().when(requestsDbClient).updateInfraActiveRequests(any(InfraActiveRequests.class));
manualHandlingTasks.updateRequestDbStatus(buildingBlockExecution, "IN_PROGRESS");
@@ -111,10 +136,4 @@ public class ManualHandlingTasksTest extends BaseTaskTest {
assertEquals(mockedRequest.getRequestStatus(), "IN_PROGRESS");
}
- @Test
- public void createExternalTicket_Test() throws Exception {
- buildingBlockExecution.setVariable("mso-request-id", ("testMsoRequestId"));
- buildingBlockExecution.setVariable("vnfType", "testVnfType");
- manualHandlingTasks.createExternalTicket(buildingBlockExecution);
- }
}
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 cc4a5ce04e..8e47c34cb0 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
@@ -36,8 +36,11 @@ import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.anyObject;
import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.when;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
@@ -224,6 +227,28 @@ public class WorkflowActionTest extends BaseTaskTest {
assertEqualsBulkFlowName(ebbs, "AssignServiceInstanceBB", "ActivateServiceInstanceBB");
}
+ @Test
+ public void selectExecutionListDuplicateNameExceptionTest() throws Exception {
+ String gAction = "createInstance";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ String bpmnRequest =
+ new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroAssign.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
+ execution.setVariable("aLaCarte", true);
+ execution.setVariable("apiVersion", "7");
+ execution.setVariable("requestUri", "v6/serviceInstances");
+ execution.setVariable("requestAction", gAction);
+
+ doThrow(new DuplicateNameException(
+ "serviceInstance with name (instanceName) and different version id (3c40d244-808e-42ca-b09a-256d83d19d0a) already exists. The name must be unique."))
+ .when(SPY_workflowAction).validateResourceIdInAAI(anyString(), eq(WorkflowType.SERVICE),
+ eq("test"), any(RequestDetails.class), any(WorkflowResourceIds.class));
+
+ SPY_workflowAction.selectExecutionList(execution);
+ assertEquals(execution.getVariable("WorkflowActionErrorMessage"),
+ "Exception while setting execution list. serviceInstance with name (instanceName) and different version id (3c40d244-808e-42ca-b09a-256d83d19d0a) already exists. The name must be unique.");
+ }
+
/**
* SERVICE MACRO TESTS
*/
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIPnfResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIPnfResourcesTest.java
index a929f256ac..6d5e6db083 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIPnfResourcesTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIPnfResourcesTest.java
@@ -22,6 +22,7 @@ package org.onap.so.client.orchestration;
import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.argThat;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
@@ -83,4 +84,17 @@ public class AAIPnfResourcesTest extends TestDataSetup {
verify(aaiResourcesClientMock, times(1)).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
}
+ @Test
+ public void updateOrchestrationStatusPnfShouldSetStatusAndUpdatePnfInAAI() {
+ org.onap.aai.domain.yang.Pnf pnfYang = new org.onap.aai.domain.yang.Pnf();
+ doReturn(pnfYang).when(aaiObjectMapperMock).mapPnf(pnf);
+
+ aaiPnfResources.updateOrchestrationStatusPnf(pnf, OrchestrationStatus.ACTIVE);
+
+ assertEquals(OrchestrationStatus.ACTIVE, pnf.getOrchestrationStatus());
+ verify(aaiObjectMapperMock, times(1))
+ .mapPnf(argThat(arg -> OrchestrationStatus.ACTIVE.equals(arg.getOrchestrationStatus())));
+ verify(aaiResourcesClientMock, times(1)).update(any(AAIResourceUri.class), eq(pnfYang));
+ }
+
}
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/ServiceMacroAssign.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/ServiceMacroAssign.json
index 39e87f19f1..1dd475cad4 100644
--- a/bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/ServiceMacroAssign.json
+++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/ServiceMacroAssign.json
@@ -24,7 +24,8 @@
"productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
"source": "VID",
"suppressRollback": true,
- "requestorId": "xxxxxx"
+ "requestorId": "xxxxxx",
+ "instanceName": "test"
},
"requestParameters": {
"subscriptionServiceType": "VMX",