summaryrefslogtreecommitdiffstats
path: root/bpmn
diff options
context:
space:
mode:
authorMichal Kabaj <michal.kabaj@nokia.com>2018-08-13 12:21:07 +0200
committerMichal Kabaj <michal.kabaj@nokia.com>2018-08-13 12:47:15 +0200
commit4f2e01ce0175434240f523e9722f1cd236c7afde (patch)
treec4976e6ad86f89983f0d6915e8850c093ecb7c84 /bpmn
parent5bd7a5cb8a769ce7b6fa89d8df1b1863d977666f (diff)
Fix for NullPointerException in Pnf
- Fix: Since lambda expressions are evaluated lazily, Camunda flow results in an NPE being thrown if RuntimeService is not acquired as part of invoking thread. - Modified integration test CreateAndActivatePnfResourceTest to verify the fix. Change-Id: I683a8400c81b2edd9d55f2a1d4121a4fdbdf820c Issue-ID: SO-722 Signed-off-by: Michal Kabaj <michal.kabaj@nokia.com>
Diffstat (limited to 'bpmn')
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/bpmn/CreateAndActivatePnfResourceTest.java16
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClient.java10
2 files changed, 15 insertions, 11 deletions
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/bpmn/CreateAndActivatePnfResourceTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/bpmn/CreateAndActivatePnfResourceTest.java
index d42717f5c1..b514c38d47 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/bpmn/CreateAndActivatePnfResourceTest.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/bpmn/CreateAndActivatePnfResourceTest.java
@@ -30,18 +30,17 @@ import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableName
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-
import org.camunda.bpm.engine.RuntimeService;
import org.camunda.bpm.engine.history.HistoricVariableInstance;
import org.camunda.bpm.engine.runtime.ProcessInstance;
import org.camunda.bpm.engine.test.Deployment;
import org.camunda.bpm.engine.test.ProcessEngineRule;
import org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareTests;
-import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.so.bpmn.infrastructure.pnf.delegate.AaiConnectionTestImpl;
+import org.onap.so.bpmn.infrastructure.pnf.delegate.DmaapClientTestImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
@@ -61,6 +60,9 @@ public class CreateAndActivatePnfResourceTest {
@Autowired
private AaiConnectionTestImpl aaiConnection;
+ @Autowired
+ private DmaapClientTestImpl dmaapClientTestImpl;
+
@Test
@Deployment(resources = {"process/CreateAndActivatePnfResource.bpmn"})
public void shouldSaveCurrentIpToVariableIfItAlreadyExistsInAai() throws Exception {
@@ -96,9 +98,8 @@ public class CreateAndActivatePnfResourceTest {
ProcessInstance instance = runtimeService
.startProcessInstanceByKey("CreateAndActivatePnfResource", "businessKey", variables);
assertThat(instance).isWaitingAt("WaitForDmaapPnfReadyNotification").isWaitingFor("WorkflowMessage");
- runtimeService.createMessageCorrelation("WorkflowMessage")
- .processInstanceBusinessKey("businessKey")
- .correlateWithResult();
+ dmaapClientTestImpl.sendMessage();
+
// then
assertThat(instance).isEnded().hasPassedInOrder(
"CreateAndActivatePnf_StartEvent",
@@ -125,9 +126,8 @@ public class CreateAndActivatePnfResourceTest {
ProcessInstance instance = runtimeService
.startProcessInstanceByKey("CreateAndActivatePnfResource", "businessKey", variables);
assertThat(instance).isWaitingAt("WaitForDmaapPnfReadyNotification").isWaitingFor("WorkflowMessage");
- runtimeService.createMessageCorrelation("WorkflowMessage")
- .processInstanceBusinessKey("businessKey")
- .correlateWithResult();
+ dmaapClientTestImpl.sendMessage();
+
// then
assertThat(instance).isEnded().hasPassedInOrder(
"CreateAndActivatePnf_StartEvent",
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClient.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClient.java
index bb490a06e4..61b1ca4cae 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClient.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClient.java
@@ -20,6 +20,7 @@
package org.onap.so.bpmn.infrastructure.pnf.delegate;
+import org.camunda.bpm.engine.RuntimeService;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.JavaDelegate;
import org.onap.so.bpmn.infrastructure.pnf.dmaap.DmaapClient;
@@ -30,12 +31,15 @@ public class InformDmaapClient implements JavaDelegate {
private DmaapClient dmaapClient;
@Override
- public void execute(DelegateExecution execution) throws Exception {
+ public void execute(DelegateExecution execution) {
String correlationId = (String) execution.getVariable(ExecutionVariableNames.CORRELATION_ID);
- dmaapClient.registerForUpdate(correlationId, () -> execution.getProcessEngineServices().getRuntimeService()
+ RuntimeService runtimeService = execution.getProcessEngineServices().getRuntimeService();
+ dmaapClient.registerForUpdate(correlationId, () ->
+ runtimeService
.createMessageCorrelation("WorkflowMessage")
.processInstanceBusinessKey(execution.getProcessBusinessKey())
- .correlateWithResult());
+ .correlateWithResult()
+ );
}
@Autowired