From 4e63348e5b0c9b8df287ee6eba33b69ffd5f2516 Mon Sep 17 00:00:00 2001 From: "Benjamin, Max (mb388a)" Date: Fri, 1 Feb 2019 18:13:35 -0500 Subject: 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) --- bpmn/so-bpmn-building-blocks/pom.xml | 3 +- .../BuildingBlock/ActivateVfModuleBB.bpmn | 174 +++++++++++++++------ .../subprocess/BuildingBlock/CreateVfModuleBB.bpmn | 56 +++---- .../BuildingBlock/ExecuteBuildingBlock.bpmn | 99 ++++++------ .../test/java/org/onap/so/bpmn/BaseBPMNTest.java | 9 +- .../bpmn/subprocess/ActivateVfModuleBBTest.java | 35 ++++- .../src/test/resources/application-test.yaml | 7 +- .../src/test/resources/logback-test.xml | 2 +- 8 files changed, 248 insertions(+), 137 deletions(-) (limited to 'bpmn/so-bpmn-building-blocks') diff --git a/bpmn/so-bpmn-building-blocks/pom.xml b/bpmn/so-bpmn-building-blocks/pom.xml index 4fe02ee3ac..0971a9d54e 100644 --- a/bpmn/so-bpmn-building-blocks/pom.xml +++ b/bpmn/so-bpmn-building-blocks/pom.xml @@ -147,6 +147,7 @@ mariaDB4j 2.2.3 test - + + diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ActivateVfModuleBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ActivateVfModuleBB.bpmn index 3670676a84..fd24be100b 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ActivateVfModuleBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ActivateVfModuleBB.bpmn @@ -1,16 +1,17 @@ - + SequenceFlow_0ieafii - + SequenceFlow_0xsp0pv - SequenceFlow_0e44ywc - SequenceFlow_1yzril6 + SequenceFlow_07ybdik + SequenceFlow_0ee42yq + SequenceFlow_1a495wm SequenceFlow_1j4x1ej @@ -24,90 +25,167 @@ - SequenceFlow_1yzril6 + SequenceFlow_1a495wm SequenceFlow_1j4x1ej + - + + + SequenceFlow_0ghzwlo + SequenceFlow_0xndboi + + + SequenceFlow_0xndboi + SequenceFlow_0ee42yq + + + SequenceFlow_1t99ceh + + + + + SequenceFlow_1t99ceh + + + SequenceFlow_1xqyur9 + SequenceFlow_07ybdik + SequenceFlow_0ghzwlo + + + + + + + SequenceFlow_0ieafii - SequenceFlow_0qc2sao + SequenceFlow_1xqyur9 - - SequenceFlow_0qc2sao - SequenceFlow_0e44ywc - - ${execution.getVariable("vfModuleActivateTimerDuration")} - - - - - + - + - + - + - - + + - + - + - + - + - + - - + + - + - + + + + + + + + - - + + + + + + + + + + + - + - - + + - - + + + + + - + - - - + + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateVfModuleBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateVfModuleBB.bpmn index bd126de24e..08252f66b8 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateVfModuleBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateVfModuleBB.bpmn @@ -1,5 +1,5 @@ - + SequenceFlow_1xr6chl @@ -10,7 +10,7 @@ - SequenceFlow_1stomxq + SequenceFlow_1vbwdaw SequenceFlow_15hn8si @@ -34,15 +34,13 @@ SequenceFlow_16g4dz0 SequenceFlow_0ecr393 - - SequenceFlow_0qqsilv - SequenceFlow_1stomxq + SequenceFlow_0rds4rj + SequenceFlow_1vbwdaw - SequenceFlow_0ecr393 - SequenceFlow_0qqsilv + SequenceFlow_0rds4rj @@ -55,6 +53,8 @@ + + @@ -75,9 +75,9 @@ - + - + @@ -108,34 +108,20 @@ - - + + - + - - - - - - - - + - - - - - - - - + @@ -159,6 +145,20 @@ + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ExecuteBuildingBlock.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ExecuteBuildingBlock.bpmn index 9be4cd0473..943ce12a8a 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ExecuteBuildingBlock.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ExecuteBuildingBlock.bpmn @@ -1,5 +1,5 @@ - + SequenceFlow_0rq4c5r @@ -37,7 +37,7 @@ SequenceFlow_09synl9 - + @@ -114,6 +114,11 @@ + + + + + @@ -156,63 +161,63 @@ - + - + - + - + - + - + - - + + - + - - + + - + - - + + - + - + - - + + - + - - + + - + - + @@ -238,38 +243,38 @@ - - + + - + - + - + - + - - + + - + - + - + - + - + @@ -312,27 +317,27 @@ - - + + - + - - + + - + - + - + - + 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; @@ -93,6 +94,9 @@ public abstract class BaseBPMNTest { @Autowired protected RuntimeService runtimeService; + @Autowired + protected ExternalTaskService externalTaskService; + @Autowired private RepositoryService repositoryService; @@ -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 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 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"); } } diff --git a/bpmn/so-bpmn-building-blocks/src/test/resources/application-test.yaml b/bpmn/so-bpmn-building-blocks/src/test/resources/application-test.yaml index 1090ab7be4..c36172c3bf 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/resources/application-test.yaml +++ b/bpmn/so-bpmn-building-blocks/src/test/resources/application-test.yaml @@ -31,6 +31,10 @@ log: vnfAdapterCreateV1: 'true' vnfAdapterRestV1: 'true' mso: + infra: + auditInventory: true + customer: + id: testCustIdInfra adapters: completemsoprocess: endpoint: http://localhost:28090/CompleteMsoProcess @@ -96,9 +100,6 @@ mso: healthcheck: log: debug: 'false' - infra: - customer: - id: testCustIdInfra logPath: logs msoKey: 07a7159d3bf51a0e53be7a8f89699be7 po: diff --git a/bpmn/so-bpmn-building-blocks/src/test/resources/logback-test.xml b/bpmn/so-bpmn-building-blocks/src/test/resources/logback-test.xml index 64b6bfc81b..d8f6ba3930 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/resources/logback-test.xml +++ b/bpmn/so-bpmn-building-blocks/src/test/resources/logback-test.xml @@ -26,5 +26,5 @@ - + \ No newline at end of file -- cgit 1.2.3-korg