aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn')
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionTestImpl.java17
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateAndActivatePnfResourceTest.java29
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/aai/AaiConnectionImpl.java12
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateRelation.java58
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/implementation/AaiConnection.java2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionTestImpl.java6
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionThrowingException.java6
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateRelationTest.java67
-rw-r--r--bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateAndActivatePnfResource.bpmn114
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java15
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java25
11 files changed, 284 insertions, 67 deletions
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionTestImpl.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionTestImpl.java
index 70d94052e1..4e0bf02685 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionTestImpl.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionTestImpl.java
@@ -20,12 +20,10 @@
package org.onap.so.bpmn.infrastructure.pnf.delegate;
-import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
-
import org.onap.aai.domain.yang.Pnf;
import org.onap.so.bpmn.infrastructure.pnf.implementation.AaiConnection;
import org.springframework.context.annotation.Primary;
@@ -39,9 +37,10 @@ public class AaiConnectionTestImpl implements AaiConnection {
public static final String ID_WITH_ENTRY = "idWithEntryNoIp";
private Map<String, Pnf> created = new HashMap<>();
+ private Map<String, String> serviceAndPnfRelationMap = new HashMap<>();
@Override
- public Optional<Pnf> getEntryFor(String correlationId) throws IOException {
+ public Optional<Pnf> getEntryFor(String correlationId) {
if (Objects.equals(correlationId, ID_WITH_ENTRY)) {
return Optional.of(new Pnf());
} else {
@@ -50,15 +49,25 @@ public class AaiConnectionTestImpl implements AaiConnection {
}
@Override
- public void createEntry(String correlationId, Pnf entry) throws IOException {
+ public void createEntry(String correlationId, Pnf entry) {
created.put(correlationId, entry);
}
+ @Override
+ public void createRelation(String serviceInstanceId, String pnfName) {
+ serviceAndPnfRelationMap.put(serviceInstanceId, pnfName);
+ }
+
public Map<String, Pnf> getCreated() {
return created;
}
+ public Map<String, String> getServiceAndPnfRelationMap() {
+ return serviceAndPnfRelationMap;
+ }
+
public void reset() {
created.clear();
+ serviceAndPnfRelationMap.clear();
}
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateAndActivatePnfResourceTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateAndActivatePnfResourceTest.java
index 2d0d4b51a9..db6cbe06ae 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateAndActivatePnfResourceTest.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateAndActivatePnfResourceTest.java
@@ -31,15 +31,19 @@ import java.util.Map;
import java.util.UUID;
import org.assertj.core.api.Assertions;
+import org.assertj.core.data.MapEntry;
import org.camunda.bpm.engine.runtime.ProcessInstance;
+import org.junit.Before;
import org.junit.Test;
import org.onap.so.BaseIntegrationTest;
import org.springframework.beans.factory.annotation.Autowired;
public class CreateAndActivatePnfResourceTest extends BaseIntegrationTest {
- private static final String TIMEOUT_10_S = "PT10S";
private static final String VALID_UUID = UUID.nameUUIDFromBytes("testUuid".getBytes()).toString();
+ private static final String SERVICE_INSTANCE_ID = "serviceForInstance";
+
+ private Map<String, Object> variables;
@Autowired
private AaiConnectionTestImpl aaiConnection;
@@ -47,14 +51,18 @@ public class CreateAndActivatePnfResourceTest extends BaseIntegrationTest {
@Autowired
private DmaapClientTestImpl dmaapClientTestImpl;
+ @Before
+ public void setup() {
+ aaiConnection.reset();
+ variables = new HashMap<>();
+ variables.put("serviceInstanceId", SERVICE_INSTANCE_ID);
+ variables.put(PNF_UUID, VALID_UUID);
+ }
+
@Test
public void shouldWaitForMessageFromDmaapAndUpdateAaiEntryWhenAaiEntryExists() {
// given
- aaiConnection.reset();
- Map<String, Object> variables = new HashMap<>();
- variables.put("timeoutForPnfEntryNotification", TIMEOUT_10_S);
variables.put(CORRELATION_ID, AaiConnectionTestImpl.ID_WITH_ENTRY);
- variables.put(PNF_UUID, VALID_UUID);
// when
ProcessInstance instance = runtimeService
.startProcessInstanceByKey("CreateAndActivatePnfResource", "businessKey", variables);
@@ -70,19 +78,17 @@ public class CreateAndActivatePnfResourceTest extends BaseIntegrationTest {
"AaiEntryExists",
"InformDmaapClient",
"WaitForDmaapPnfReadyNotification",
+ "CreateRelationId",
"AaiEntryUpdated"
);
+ Assertions.assertThat(aaiConnection.getServiceAndPnfRelationMap()).
+ containsOnly(MapEntry.entry(SERVICE_INSTANCE_ID,AaiConnectionTestImpl.ID_WITH_ENTRY));
}
@Test
public void shouldCreateAaiEntryWaitForMessageFromDmaapAndUpdateAaiEntryWhenNoAaiEntryExists() {
// given
- aaiConnection.reset();
-
- Map<String, Object> variables = new HashMap<>();
- variables.put("timeoutForPnfEntryNotification", TIMEOUT_10_S);
variables.put(CORRELATION_ID, AaiConnectionTestImpl.ID_WITHOUT_ENTRY);
- variables.put(PNF_UUID, VALID_UUID);
// when
ProcessInstance instance = runtimeService
.startProcessInstanceByKey("CreateAndActivatePnfResource", "businessKey", variables);
@@ -99,8 +105,11 @@ public class CreateAndActivatePnfResourceTest extends BaseIntegrationTest {
"AaiEntryExists",
"InformDmaapClient",
"WaitForDmaapPnfReadyNotification",
+ "CreateRelationId",
"AaiEntryUpdated"
);
Assertions.assertThat(aaiConnection.getCreated()).containsOnlyKeys(AaiConnectionTestImpl.ID_WITHOUT_ENTRY);
+ Assertions.assertThat(aaiConnection.getServiceAndPnfRelationMap()).
+ containsOnly(MapEntry.entry(SERVICE_INSTANCE_ID,AaiConnectionTestImpl.ID_WITHOUT_ENTRY));
}
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/aai/AaiConnectionImpl.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/aai/AaiConnectionImpl.java
index d57e48781d..1bf2a290cb 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/aai/AaiConnectionImpl.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/aai/AaiConnectionImpl.java
@@ -23,7 +23,11 @@ package org.onap.so.bpmn.infrastructure.pnf.aai;
import java.util.Optional;
import org.onap.aai.domain.yang.Pnf;
import org.onap.so.bpmn.infrastructure.pnf.implementation.AaiConnection;
+import org.onap.so.client.aai.AAIObjectType;
+import org.onap.so.client.aai.AAIResourcesClient;
import org.onap.so.client.aai.AAIRestClientImpl;
+import org.onap.so.client.aai.entities.uri.AAIResourceUri;
+import org.onap.so.client.aai.entities.uri.AAIUriFactory;
import org.springframework.stereotype.Component;
@Component
@@ -40,4 +44,12 @@ public class AaiConnectionImpl implements AaiConnection {
AAIRestClientImpl restClient = new AAIRestClientImpl();
restClient.createPnf(correlationId, entry);
}
+
+ @Override
+ public void createRelation(String serviceInstanceId, String pnfName) {
+ AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,
+ serviceInstanceId);
+ AAIResourceUri pnfUri = AAIUriFactory.createResourceUri(AAIObjectType.PNF, pnfName);
+ new AAIResourcesClient().connect(serviceInstanceURI, pnfUri);
+ }
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateRelation.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateRelation.java
new file mode 100644
index 0000000000..21d43964f8
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateRelation.java
@@ -0,0 +1,58 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 Nokia.
+ * ================================================================================
+ * 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.pnf.delegate;
+
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.camunda.bpm.engine.delegate.JavaDelegate;
+import org.onap.so.bpmn.common.scripts.ExceptionUtil;
+import org.onap.so.bpmn.infrastructure.pnf.implementation.AaiConnection;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class CreateRelation implements JavaDelegate {
+
+ private static final Logger logger = LoggerFactory.getLogger(CreateRelation.class);
+
+ private AaiConnection aaiConnectionImpl;
+
+ @Autowired
+ public CreateRelation(AaiConnection aaiConnectionImpl) {
+ this.aaiConnectionImpl = aaiConnectionImpl;
+ }
+
+ @Override
+ public void execute(DelegateExecution delegateExecution) {
+ String serviceInstanceId = (String) delegateExecution.getVariable("serviceInstanceId");
+ String pnfName = (String) delegateExecution.getVariable("correlationId");
+ try {
+ aaiConnectionImpl.createRelation(serviceInstanceId, pnfName);
+ } catch (Exception e) {
+ new ExceptionUtil().buildAndThrowWorkflowException(delegateExecution, 9999,
+ "An exception occurred when making service and pnf relation. Exception: " + e.getMessage());
+ }
+ logger.debug("The relation has been made between service with id: {} and pnf with name: {}",
+ serviceInstanceId, pnfName);
+ }
+
+}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/implementation/AaiConnection.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/implementation/AaiConnection.java
index 5165912653..eaabb2bfbb 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/implementation/AaiConnection.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/implementation/AaiConnection.java
@@ -29,4 +29,6 @@ public interface AaiConnection {
Optional<Pnf> getEntryFor(String correlationId) throws IOException;
void createEntry(String correlationId, Pnf entry) throws IOException;
+
+ void createRelation(String serviceInstanceId, String pnfName) throws IOException;
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionTestImpl.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionTestImpl.java
index 201e791a24..76b62a9cea 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionTestImpl.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionTestImpl.java
@@ -37,7 +37,7 @@ public class AaiConnectionTestImpl implements AaiConnection {
private Map<String, Pnf> created = new HashMap<>();
@Override
- public Optional<Pnf> getEntryFor(String correlationId) throws IOException {
+ public Optional<Pnf> getEntryFor(String correlationId) {
if (Objects.equals(correlationId, ID_WITH_ENTRY)) {
return Optional.of(new Pnf());
} else {
@@ -50,6 +50,10 @@ public class AaiConnectionTestImpl implements AaiConnection {
created.put(correlationId, entry);
}
+ @Override
+ public void createRelation(String serviceInstanceId, String pnfName) {
+ }
+
public Map<String, Pnf> getCreated() {
return created;
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionThrowingException.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionThrowingException.java
index 7df6757817..300d1e4c9b 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionThrowingException.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionThrowingException.java
@@ -36,4 +36,10 @@ public class AaiConnectionThrowingException implements AaiConnection {
public void createEntry(String correlationId, Pnf entry) throws IOException {
throw new IOException();
}
+
+ @Override
+ public void createRelation(String serviceInstanceId, String pnfName) throws IOException {
+ throw new IOException();
+ }
+
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateRelationTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateRelationTest.java
new file mode 100644
index 0000000000..2dd3e23828
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateRelationTest.java
@@ -0,0 +1,67 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 Nokia.
+ * ================================================================================
+ * 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.pnf.delegate;
+
+import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+
+import java.io.IOException;
+import org.camunda.bpm.engine.delegate.BpmnError;
+import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.so.bpmn.infrastructure.pnf.aai.AaiConnectionImpl;
+import org.onap.so.bpmn.infrastructure.pnf.implementation.AaiConnection;
+
+public class CreateRelationTest {
+
+ private static final String SERVICE_INSTANCE_ID = "serviceTest";
+ private static final String PNF_NAME = "pnfNameTest";
+
+ private DelegateExecutionFake executionFake;
+
+ @Before
+ public void setUp() {
+ executionFake = new DelegateExecutionFake();
+ executionFake.setVariable("serviceInstanceId", SERVICE_INSTANCE_ID);
+ executionFake.setVariable("correlationId", PNF_NAME);
+ }
+
+ @Test
+ public void createRelationSuccessful() throws IOException {
+ // given
+ AaiConnection aaiConnectionMock = mock(AaiConnectionImpl.class);
+ CreateRelation testedObject = new CreateRelation(aaiConnectionMock);
+ // when
+ testedObject.execute(executionFake);
+ // then
+ verify(aaiConnectionMock).createRelation(SERVICE_INSTANCE_ID, PNF_NAME);
+ }
+
+ @Test
+ public void shouldThrowBpmnErrorWhenExceptionOccurred() {
+ CreateRelation testedObject = new CreateRelation(new AaiConnectionThrowingException());
+ executionFake.setVariable("testProcessKey", "testProcessKeyValue");
+
+ assertThatThrownBy(() -> testedObject.execute(executionFake)).isInstanceOf(BpmnError.class);
+ }
+}
diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateAndActivatePnfResource.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateAndActivatePnfResource.bpmn
index d8079174c1..5defe2121b 100644
--- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateAndActivatePnfResource.bpmn
+++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateAndActivatePnfResource.bpmn
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="2.0.3">
+<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.11.3">
<bpmn:collaboration id="Collaboration_1d0w8lf">
<bpmn:participant id="Participant_1egg397" name="SO&#10;Create and Activate Pnf Resource" processRef="CreateAndActivatePnfResource" />
<bpmn:participant id="Participant_0atuyq0" name="AAI" />
@@ -17,7 +17,7 @@
<bpmn:sequenceFlow id="SequenceFlow_0v5ffpe" name="No" sourceRef="DoesAaiContainInfoAboutPnf" targetRef="CreatePnfEntryInAai">
<bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{!aaiContainsInfoAboutPnf}</bpmn:conditionExpression>
</bpmn:sequenceFlow>
- <bpmn:sequenceFlow id="SequenceFlow_0p09qgm" sourceRef="WaitForDmaapPnfReadyNotification" targetRef="AaiEntryUpdated" />
+ <bpmn:sequenceFlow id="SequenceFlow_0p09qgm" sourceRef="WaitForDmaapPnfReadyNotification" targetRef="CreateRelationId" />
<bpmn:sequenceFlow id="SequenceFlow_17s9025" sourceRef="AaiEntryExists" targetRef="InformDmaapClient" />
<bpmn:sequenceFlow id="SequenceFlow_1qr6cmf" sourceRef="CreatePnfEntryInAai" targetRef="AaiEntryExists" />
<bpmn:sequenceFlow id="SequenceFlow_1j4r3zt" sourceRef="CheckAiiForCorrelationId" targetRef="DoesAaiContainInfoAboutPnf" />
@@ -59,9 +59,6 @@
<bpmn:incoming>SequenceFlow_1miyzfe</bpmn:incoming>
<bpmn:errorEventDefinition errorRef="Error_1" />
</bpmn:endEvent>
- <bpmn:endEvent id="AaiEntryUpdated" name="AAI entry updated">
- <bpmn:incoming>SequenceFlow_0p09qgm</bpmn:incoming>
- </bpmn:endEvent>
<bpmn:receiveTask id="WaitForDmaapPnfReadyNotification" name="Wait for DMAAP pnf-ready notification" messageRef="Message_13h1tlo">
<bpmn:incoming>SequenceFlow_1o8od8e</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_0p09qgm</bpmn:outgoing>
@@ -77,13 +74,20 @@
<bpmn:incoming>SequenceFlow_1qr6cmf</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_17s9025</bpmn:outgoing>
</bpmn:exclusiveGateway>
+ <bpmn:sequenceFlow id="SequenceFlow_0o6zhjk" sourceRef="CreateRelationId" targetRef="AaiEntryUpdated" />
+ <bpmn:endEvent id="AaiEntryUpdated" name="AAI entry updated">
+ <bpmn:incoming>SequenceFlow_0o6zhjk</bpmn:incoming>
+ </bpmn:endEvent>
+ <bpmn:serviceTask id="CreateRelationId" name="Create Relation" camunda:delegateExpression="${CreateRelation}">
+ <bpmn:incoming>SequenceFlow_0p09qgm</bpmn:incoming>
+ <bpmn:outgoing>SequenceFlow_0o6zhjk</bpmn:outgoing>
+ </bpmn:serviceTask>
<bpmn:association id="Association_0d7oxnz" sourceRef="CreateAndActivatePnf_StartEvent" targetRef="TextAnnotation_1eyzes8" />
<bpmn:textAnnotation id="TextAnnotation_1eyzes8">
- <bpmn:text>Inputs:
+ <bpmn:text><![CDATA[Inputs:
 - timeoutForPnfEntryNotification - String
- correlationId - String
- - uuid - String
-</bpmn:text>
+ - uuid - String]]></bpmn:text>
</bpmn:textAnnotation>
</bpmn:process>
<bpmn:error id="Error_1" name="MSO Workflow Exception" errorCode="MSOWorkflowException" />
@@ -100,9 +104,9 @@
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="EndEvent_0k52gr7_di" bpmnElement="AaiEntryUpdated">
- <dc:Bounds x="1312" y="189" width="36" height="36" />
+ <dc:Bounds x="1364" y="189" width="36" height="36" />
<bpmndi:BPMNLabel>
- <dc:Bounds x="1287" y="230" width="88" height="14" />
+ <dc:Bounds x="1339" y="230" width="89" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="StartEvent_0j5ok9h_di" bpmnElement="CreateAndActivatePnf_StartEvent">
@@ -118,38 +122,38 @@
<dc:Bounds x="511" y="167" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_1j4r3zt_di" bpmnElement="SequenceFlow_1j4r3zt">
- <di:waypoint x="319" y="207" />
- <di:waypoint x="390" y="207" />
+ <di:waypoint xsi:type="dc:Point" x="319" y="207" />
+ <di:waypoint xsi:type="dc:Point" x="390" y="207" />
<bpmndi:BPMNLabel>
<dc:Bounds x="309.5" y="187" width="90" height="10" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_1l1t6ak_di" bpmnElement="SequenceFlow_1l1t6ak">
- <di:waypoint x="415" y="182" />
- <di:waypoint x="415" y="66" />
- <di:waypoint x="711" y="66" />
- <di:waypoint x="711" y="182" />
+ <di:waypoint xsi:type="dc:Point" x="415" y="182" />
+ <di:waypoint xsi:type="dc:Point" x="415" y="66" />
+ <di:waypoint xsi:type="dc:Point" x="711" y="66" />
+ <di:waypoint xsi:type="dc:Point" x="711" y="182" />
<bpmndi:BPMNLabel>
<dc:Bounds x="430" y="159" width="19" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_0v5ffpe_di" bpmnElement="SequenceFlow_0v5ffpe">
- <di:waypoint x="440" y="207" />
- <di:waypoint x="511" y="207" />
+ <di:waypoint xsi:type="dc:Point" x="440" y="207" />
+ <di:waypoint xsi:type="dc:Point" x="511" y="207" />
<bpmndi:BPMNLabel>
<dc:Bounds x="448" y="210" width="14" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_1qr6cmf_di" bpmnElement="SequenceFlow_1qr6cmf">
- <di:waypoint x="611" y="207" />
- <di:waypoint x="686" y="207" />
+ <di:waypoint xsi:type="dc:Point" x="611" y="207" />
+ <di:waypoint xsi:type="dc:Point" x="686" y="207" />
<bpmndi:BPMNLabel>
<dc:Bounds x="605" y="187" width="90" height="10" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_0j5ksz1_di" bpmnElement="SequenceFlow_0j5ksz1">
- <di:waypoint x="-18" y="207" />
- <di:waypoint x="48" y="207" />
+ <di:waypoint xsi:type="dc:Point" x="-18" y="207" />
+ <di:waypoint xsi:type="dc:Point" x="48" y="207" />
<bpmndi:BPMNLabel>
<dc:Bounds x="-30" y="187" width="90" height="10" />
</bpmndi:BPMNLabel>
@@ -158,22 +162,22 @@
<dc:Bounds x="123" y="523" width="502" height="60" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="MessageFlow_1h3xu88_di" bpmnElement="MessageFlow_1h3xu88">
- <di:waypoint x="561" y="247" />
- <di:waypoint x="561" y="523" />
+ <di:waypoint xsi:type="dc:Point" x="561" y="247" />
+ <di:waypoint xsi:type="dc:Point" x="561" y="523" />
<bpmndi:BPMNLabel>
<dc:Bounds x="531" y="380" width="90" height="10" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="MessageFlow_09ibv5a_di" bpmnElement="MessageFlow_09ibv5a">
- <di:waypoint x="250" y="247" />
- <di:waypoint x="250" y="523" />
+ <di:waypoint xsi:type="dc:Point" x="250" y="247" />
+ <di:waypoint xsi:type="dc:Point" x="250" y="523" />
<bpmndi:BPMNLabel>
<dc:Bounds x="220" y="380" width="90" height="10" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="MessageFlow_0vjul4t_di" bpmnElement="MessageFlow_0vjul4t">
- <di:waypoint x="289" y="523" />
- <di:waypoint x="289" y="247" />
+ <di:waypoint xsi:type="dc:Point" x="289" y="523" />
+ <di:waypoint xsi:type="dc:Point" x="289" y="247" />
<bpmndi:BPMNLabel>
<dc:Bounds x="259" y="380" width="90" height="10" />
</bpmndi:BPMNLabel>
@@ -191,19 +195,19 @@
<dc:Bounds x="-37" y="70" width="243" height="82" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Association_0d7oxnz_di" bpmnElement="Association_0d7oxnz">
- <di:waypoint x="-36" y="189" />
- <di:waypoint x="-36" y="152" />
+ <di:waypoint xsi:type="dc:Point" x="-36" y="189" />
+ <di:waypoint xsi:type="dc:Point" x="-36" y="152" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="MessageFlow_1vrcp2d_di" bpmnElement="MessageFlow_1vrcp2d">
- <di:waypoint x="1060" y="523" />
- <di:waypoint x="1060" y="247" />
+ <di:waypoint xsi:type="dc:Point" x="1060" y="523" />
+ <di:waypoint xsi:type="dc:Point" x="1060" y="247" />
<bpmndi:BPMNLabel>
<dc:Bounds x="996" y="380" width="90" height="10" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_17s9025_di" bpmnElement="SequenceFlow_17s9025">
- <di:waypoint x="736" y="207" />
- <di:waypoint x="803" y="207" />
+ <di:waypoint xsi:type="dc:Point" x="736" y="207" />
+ <di:waypoint xsi:type="dc:Point" x="803" y="207" />
<bpmndi:BPMNLabel>
<dc:Bounds x="719" y="187" width="90" height="10" />
</bpmndi:BPMNLabel>
@@ -215,9 +219,9 @@
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_1kc34bc_di" bpmnElement="SequenceFlow_1kc34bc">
- <di:waypoint x="1092" y="265" />
- <di:waypoint x="1092" y="363" />
- <di:waypoint x="1145" y="363" />
+ <di:waypoint xsi:type="dc:Point" x="1092" y="265" />
+ <di:waypoint xsi:type="dc:Point" x="1092" y="363" />
+ <di:waypoint xsi:type="dc:Point" x="1145" y="363" />
<bpmndi:BPMNLabel>
<dc:Bounds x="1028" y="309" width="90" height="10" />
</bpmndi:BPMNLabel>
@@ -226,22 +230,22 @@
<dc:Bounds x="1008" y="167" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_0p09qgm_di" bpmnElement="SequenceFlow_0p09qgm">
- <di:waypoint x="1108" y="207" />
- <di:waypoint x="1312" y="207" />
+ <di:waypoint xsi:type="dc:Point" x="1108" y="207" />
+ <di:waypoint xsi:type="dc:Point" x="1195" y="207" />
<bpmndi:BPMNLabel>
- <dc:Bounds x="1148" y="187" width="90" height="10" />
+ <dc:Bounds x="1106.5" y="187" width="90" height="10" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_1o8od8e_di" bpmnElement="SequenceFlow_1o8od8e">
- <di:waypoint x="903" y="207" />
- <di:waypoint x="1008" y="207" />
+ <di:waypoint xsi:type="dc:Point" x="903" y="207" />
+ <di:waypoint xsi:type="dc:Point" x="1008" y="207" />
<bpmndi:BPMNLabel>
<dc:Bounds x="893.5" y="187" width="90" height="10" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="MessageFlow_0tg4hw9_di" bpmnElement="MessageFlow_0tg4hw9">
- <di:waypoint x="853" y="247" />
- <di:waypoint x="853" y="523" />
+ <di:waypoint xsi:type="dc:Point" x="853" y="247" />
+ <di:waypoint xsi:type="dc:Point" x="853" y="523" />
<bpmndi:BPMNLabel>
<dc:Bounds x="823" y="380" width="90" height="10" />
</bpmndi:BPMNLabel>
@@ -250,15 +254,15 @@
<dc:Bounds x="803" y="167" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_1miyzfe_di" bpmnElement="SequenceFlow_1miyzfe">
- <di:waypoint x="1245" y="363" />
- <di:waypoint x="1312" y="363" />
+ <di:waypoint xsi:type="dc:Point" x="1245" y="363" />
+ <di:waypoint xsi:type="dc:Point" x="1312" y="363" />
<bpmndi:BPMNLabel>
<dc:Bounds x="1233.5" y="343" width="90" height="10" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="MessageFlow_1py54jr_di" bpmnElement="MessageFlow_1py54jr">
- <di:waypoint x="1195" y="403" />
- <di:waypoint x="1195" y="523" />
+ <di:waypoint xsi:type="dc:Point" x="1195" y="403" />
+ <di:waypoint xsi:type="dc:Point" x="1195" y="523" />
<bpmndi:BPMNLabel>
<dc:Bounds x="1165" y="458" width="90" height="10" />
</bpmndi:BPMNLabel>
@@ -267,8 +271,8 @@
<dc:Bounds x="1145" y="323" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_0967g8p_di" bpmnElement="SequenceFlow_0967g8p">
- <di:waypoint x="148" y="207" />
- <di:waypoint x="219" y="207" />
+ <di:waypoint xsi:type="dc:Point" x="148" y="207" />
+ <di:waypoint xsi:type="dc:Point" x="219" y="207" />
<bpmndi:BPMNLabel>
<dc:Bounds x="183.5" y="187" width="0" height="10" />
</bpmndi:BPMNLabel>
@@ -282,6 +286,16 @@
<dc:Bounds x="672" y="242" width="77" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
+ <bpmndi:BPMNEdge id="SequenceFlow_0o6zhjk_di" bpmnElement="SequenceFlow_0o6zhjk">
+ <di:waypoint xsi:type="dc:Point" x="1295" y="207" />
+ <di:waypoint xsi:type="dc:Point" x="1364" y="207" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="1329.5" y="186" width="0" height="12" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNShape id="ServiceTask_0xn3ug6_di" bpmnElement="CreateRelationId">
+ <dc:Bounds x="1195" y="167" width="100" height="80" />
+ </bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java
index 78a84b1772..f6c9597de8 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java
@@ -41,6 +41,7 @@ import org.onap.so.serviceinstancebeans.ServiceInstancesResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
import com.fasterxml.jackson.core.JsonProcessingException;
@@ -54,6 +55,7 @@ public class WorkflowActionBBTasks {
private static final String G_ALACARTE = "aLaCarte";
private static final String G_ACTION = "requestAction";
private static final String RETRY_COUNT = "retryCount";
+ protected String maxRetries = "mso.rainyDay.maxRetries";
private static final Logger logger = LoggerFactory.getLogger(WorkflowActionBBTasks.class);
@Autowired
@@ -62,6 +64,8 @@ public class WorkflowActionBBTasks {
private WorkflowAction workflowAction;
@Autowired
private WorkflowActionBBFailure workflowActionBBFailure;
+ @Autowired
+ private Environment environment;
public void selectBB(DelegateExecution execution) {
List<ExecuteBuildingBlock> flowsToExecute = (List<ExecuteBuildingBlock>) execution
@@ -215,17 +219,24 @@ public class WorkflowActionBBTasks {
String requestId = (String) execution.getVariable(G_REQUEST_ID);
String retryDuration = (String) execution.getVariable("RetryDuration");
int retryCount = (int) execution.getVariable(RETRY_COUNT);
+ int envMaxRetries;
+ try{
+ envMaxRetries = Integer.parseInt(this.environment.getProperty(maxRetries));
+ } catch (Exception ex) {
+ logger.error("Could not read maxRetries from config file. Setting max to 5 retries");
+ envMaxRetries = 5;
+ }
int nextCount = retryCount +1;
if (handlingCode.equals("Retry")){
workflowActionBBFailure.updateRequestErrorStatusMessage(execution);
try{
InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId);
- request.setRetryStatusMessage("Retry " + nextCount + "/5 will be started in " + retryDuration);
+ request.setRetryStatusMessage("Retry " + nextCount + "/" + envMaxRetries + " will be started in " + retryDuration);
requestDbclient.updateInfraActiveRequests(request);
} catch(Exception ex){
logger.warn("Failed to update Request Db Infra Active Requests with Retry Status",ex);
}
- if(retryCount<5){
+ if(retryCount<envMaxRetries){
int currSequence = (int) execution.getVariable("gCurrentSequence");
execution.setVariable("gCurrentSequence", currSequence-1);
execution.setVariable(RETRY_COUNT, nextCount);
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java
index f3b094f645..2fc62978fb 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java
@@ -31,6 +31,7 @@ import static org.mockito.Mockito.when;
import java.util.ArrayList;
import java.util.List;
+import org.camunda.bpm.engine.delegate.BpmnError;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
import org.junit.Before;
@@ -46,6 +47,7 @@ import org.onap.so.bpmn.core.WorkflowException;
import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock;
import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.springframework.core.env.Environment;
public class WorkflowActionBBTasksTest extends BaseTaskTest {
@@ -64,6 +66,9 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest {
private DelegateExecution execution;
+ @Mock
+ protected Environment environment;
+
@Rule
public ExpectedException thrown = ExpectedException.none();
@@ -287,6 +292,7 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest {
String reqId = "reqId123";
execution.setVariable("mso-request-id", reqId);
doNothing().when(workflowActionBBFailure).updateRequestErrorStatusMessage(isA(DelegateExecution.class));
+ doReturn("6").when(environment).getProperty("mso.rainyDay.maxRetries");
execution.setVariable("handlingCode","Retry");
execution.setVariable("retryCount", 1);
execution.setVariable("gCurrentSequence",1);
@@ -297,6 +303,25 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest {
}
@Test
+ public void checkRetryStatusTestExceededMaxRetries(){
+ String reqId = "reqId123";
+ execution.setVariable("mso-request-id", reqId);
+ doNothing().when(workflowActionBBFailure).updateRequestErrorStatusMessage(isA(DelegateExecution.class));
+ doReturn("6").when(environment).getProperty("mso.rainyDay.maxRetries");
+ execution.setVariable("handlingCode","Retry");
+ execution.setVariable("retryCount", 6);
+ execution.setVariable("gCurrentSequence",1);
+ InfraActiveRequests req = new InfraActiveRequests();
+ doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId(reqId);
+ try{
+ workflowActionBBTasks.checkRetryStatus(execution);
+ } catch (BpmnError e) {
+ WorkflowException exception = (WorkflowException) execution.getVariable("WorkflowException");
+ assertEquals("Exceeded maximum retries. Ending flow with status Abort",exception.getErrorMessage());
+ }
+ }
+
+ @Test
public void checkRetryStatusNoRetryTest(){
String reqId = "reqId123";
execution.setVariable("mso-request-id", reqId);