summaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/test/java')
-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/client/orchestration/AAIPnfResourcesTest.java14
2 files changed, 54 insertions, 14 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/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));
+ }
+
}