summaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-building-blocks/src/test/java
diff options
context:
space:
mode:
authorBenjamin, Max (mb388a) <mb388a@us.att.com>2019-02-01 18:13:35 -0500
committerBenjamin, Max (mb388a) <mb388a@us.att.com>2019-02-01 18:48:10 -0500
commit4e63348e5b0c9b8df287ee6eba33b69ffd5f2516 (patch)
treea6d806d3185efc62ff8af71bb572c02550aea2a2 /bpmn/so-bpmn-building-blocks/src/test/java
parent62572d10fe5ea77726371c624b6bcbb33ff1707b (diff)
compare resources from openstack to aai
Address Review comments on pull request Update Unit test to have proper variable for testing update logic inside bpmn to reflect proper variable Update unit test to check property for audit Add flag to turn on and off audit behavior Add license headers, remove un-used files Update Building Block Tests and Activity Names Fix additional unit tests in so-bpmn-tasks layer Fix broken Junit Test, and correct Bug in if statement Add annotation to ignore class under test profile Additional bug fixes and unit tests for classes Add Additional JUNITS, add more sample data Add Openstack Audit functionality to Adapter Change-Id: I0492063271e991eefc608b56336a5cdf1d5a7778 Issue-ID: SO-1456 Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'bpmn/so-bpmn-building-blocks/src/test/java')
-rw-r--r--bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/BaseBPMNTest.java9
-rw-r--r--bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/ActivateVfModuleBBTest.java35
2 files changed, 35 insertions, 9 deletions
diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/BaseBPMNTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/BaseBPMNTest.java
index f501151ec9..79bade3cf3 100644
--- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/BaseBPMNTest.java
+++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/BaseBPMNTest.java
@@ -23,7 +23,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-
+import org.camunda.bpm.engine.ExternalTaskService;
import org.camunda.bpm.engine.RepositoryService;
import org.camunda.bpm.engine.RuntimeService;
import org.camunda.bpm.extension.mockito.mock.FluentJavaDelegateMock;
@@ -50,6 +50,7 @@ import org.onap.so.bpmn.infrastructure.adapter.vnf.tasks.VnfAdapterCreateTasks;
import org.onap.so.bpmn.infrastructure.adapter.vnf.tasks.VnfAdapterDeleteTasks;
import org.onap.so.bpmn.infrastructure.adapter.vnf.tasks.VnfAdapterImpl;
import org.onap.so.bpmn.infrastructure.appc.tasks.AppcRunTasks;
+import org.onap.so.bpmn.infrastructure.audit.AuditTasks;
import org.onap.so.bpmn.infrastructure.flowspecific.tasks.ActivateVfModule;
import org.onap.so.bpmn.infrastructure.flowspecific.tasks.AssignNetwork;
import org.onap.so.bpmn.infrastructure.flowspecific.tasks.AssignNetworkBBUtils;
@@ -94,6 +95,9 @@ public abstract class BaseBPMNTest {
protected RuntimeService runtimeService;
@Autowired
+ protected ExternalTaskService externalTaskService;
+
+ @Autowired
private RepositoryService repositoryService;
protected Map<String, Object> variables = new HashMap<>();
@@ -227,6 +231,9 @@ public abstract class BaseBPMNTest {
@MockBean
protected WorkflowActionBBFailure workflowActionBBFailure;
+
+ @MockBean
+ protected AuditTasks auditTasks;
@LocalServerPort
protected int port;
diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/ActivateVfModuleBBTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/ActivateVfModuleBBTest.java
index 1bce605076..9ffcd9d77a 100644
--- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/ActivateVfModuleBBTest.java
+++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/ActivateVfModuleBBTest.java
@@ -21,9 +21,13 @@
package org.onap.so.bpmn.infrastructure.bpmn.subprocess;
import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
import java.io.IOException;
+import java.util.List;
+
import org.camunda.bpm.engine.delegate.BpmnError;
+import org.camunda.bpm.engine.externaltask.LockedExternalTask;
import org.camunda.bpm.engine.runtime.ProcessInstance;
import org.junit.Before;
import org.junit.Test;
@@ -35,17 +39,25 @@ public class ActivateVfModuleBBTest extends BaseBPMNTest{
@Before
public void before() {
variables.put("vfModuleActivateTimerDuration", "PT2S");
+ variables.put("auditInventoryNeeded", "true");
}
@Test
public void sunnyDay() throws InterruptedException, IOException {
mockSubprocess("SDNCHandler", "My Mock Process Name", "GenericStub");
ProcessInstance pi = runtimeService.startProcessInstanceByKey("ActivateVfModuleBB", variables);
- while(runtimeService.createProcessInstanceQuery().processInstanceId(pi.getId()).singleResult() != null) {
- Thread.sleep(1000);
- }
+ List<LockedExternalTask> tasks = externalTaskService.fetchAndLock(100, "externalWorkerId")
+ .topic("InventoryAudit", 60L * 1000L).execute();
+ while (!tasks.isEmpty()) {
+ for (LockedExternalTask task : tasks) {
+ externalTaskService.complete(task.getId(), "externalWorkerId");
+ }
+ tasks = externalTaskService.fetchAndLock(100, "externalWorkerId")
+ .topic("InventoryAudit", 60L * 1000L).execute();
+ }
+
assertThat(pi).isNotNull();
- assertThat(pi).isStarted().hasPassedInOrder("ActivateVfModuleBB_Start", "SetTimerDuration", "Timer", "ActivateVfModule", "CallActivity_sdncHandler",
+ assertThat(pi).isStarted().hasPassedInOrder("ActivateVfModuleBB_Start","ExclusiveGateway_1v8bmbu","Setup_AAI_Inventory_Audit", "Audit_AAI_Inventory", "ActivateVfModule", "CallActivity_sdncHandler",
"UpdateVfModuleActiveStatus", "ActivateVfModuleBB_End");
assertThat(pi).isEnded();
}
@@ -55,11 +67,18 @@ public class ActivateVfModuleBBTest extends BaseBPMNTest{
mockSubprocess("SDNCHandler", "My Mock Process Name", "GenericStub");
doThrow(BpmnError.class).when(aaiUpdateTasks).updateOrchestrationStatusActivateVfModule(any(BuildingBlockExecution.class));
ProcessInstance pi = runtimeService.startProcessInstanceByKey("ActivateVfModuleBB", variables);
- while(runtimeService.createProcessInstanceQuery().processInstanceId(pi.getId()).singleResult() != null) {
- Thread.sleep(1000);
- }
+ List<LockedExternalTask> tasks = externalTaskService.fetchAndLock(100, "externalWorkerId")
+ .topic("InventoryAudit", 60L * 1000L).execute();
+ while (!tasks.isEmpty()) {
+ for (LockedExternalTask task : tasks) {
+ externalTaskService.complete(task.getId(), "externalWorkerId");
+ }
+ tasks = externalTaskService.fetchAndLock(100, "externalWorkerId")
+ .topic("InventoryAudit", 60L * 1000L).execute();
+ }
+
assertThat(pi).isNotNull().isStarted()
- .hasPassedInOrder("ActivateVfModuleBB_Start", "SetTimerDuration", "Timer", "ActivateVfModule", "UpdateVfModuleActiveStatus")
+ .hasPassedInOrder("ActivateVfModuleBB_Start","ExclusiveGateway_1v8bmbu","Setup_AAI_Inventory_Audit", "Audit_AAI_Inventory", "ActivateVfModule", "UpdateVfModuleActiveStatus")
.hasNotPassed("ActivateVfModuleBB_End");
}
}