summaryrefslogtreecommitdiffstats
path: root/bpmn
diff options
context:
space:
mode:
authorwaqas.ikram <waqas.ikram@est.tech>2019-06-02 15:24:20 +0000
committerwaqas.ikram <waqas.ikram@est.tech>2019-06-02 15:24:20 +0000
commitf5034c75fb4178791a51fd16e1322e80c05b44a8 (patch)
tree40e60e0899b8d7b136f5788483e930df67fc7506 /bpmn
parentf8aefb2f8773bf2a4b56b6d4e9657df6eff2170e (diff)
Fixing EtSI BB ClassCastException
Change-Id: Ia5a37f80392693f603d6597760ca9725882de169 Issue-ID: SO-1971 Signed-off-by: waqas.ikram <waqas.ikram@est.tech>
Diffstat (limited to 'bpmn')
-rw-r--r--bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/MonitorVnfmCreateNodeStatus.bpmn2
-rw-r--r--bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/MonitorVnfmDeleteNodeStatus.bpmn4
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorInstantiateVnfmNodeTask.java53
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorTerminateVnfmNodeTask.java53
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmNodeTask.java53
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/exception/GenericVnfNotFoundException.java33
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorInstantiateVnfmNodeTaskTest.java129
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorTerminateVnfmNodeTaskTest.java (renamed from bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmNodeJobTest.java)62
8 files changed, 343 insertions, 46 deletions
diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/MonitorVnfmCreateNodeStatus.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/MonitorVnfmCreateNodeStatus.bpmn
index e7d40e84b5..9712ca8ab7 100644
--- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/MonitorVnfmCreateNodeStatus.bpmn
+++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/MonitorVnfmCreateNodeStatus.bpmn
@@ -24,7 +24,7 @@
<bpmn:endEvent id="EndEvent_0tei3i9">
<bpmn:incoming>SequenceFlow_1rxbeqi</bpmn:incoming>
</bpmn:endEvent>
- <bpmn:serviceTask id="ServiceTask_0y71su8" name="&#10;Get node status &#10;" camunda:asyncAfter="true" camunda:expression="${MonitorVnfmNodeTask.getNodeStatus(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
+ <bpmn:serviceTask id="ServiceTask_0y71su8" name="&#10;Get node status &#10;" camunda:asyncAfter="true" camunda:expression="${MonitorInstantiateVnfmNodeTask.getNodeStatus(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
<bpmn:incoming>SequenceFlow_1moaz0q</bpmn:incoming>
<bpmn:incoming>SequenceFlow_09t51ao</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_0qvy3sn</bpmn:outgoing>
diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/MonitorVnfmDeleteNodeStatus.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/MonitorVnfmDeleteNodeStatus.bpmn
index 8fababaffe..668cfaa44a 100644
--- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/MonitorVnfmDeleteNodeStatus.bpmn
+++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/MonitorVnfmDeleteNodeStatus.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_15jp7td" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="2.2.4">
+<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_15jp7td" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="2.0.3">
<bpmn:process id="MonitorVnfmDeleteNodeStatus" name="MonitorVnfmDeleteNodeStatus" isExecutable="true">
<bpmn:startEvent id="StartEvent_0f7nbs2">
<bpmn:outgoing>SequenceFlow_0spr34x</bpmn:outgoing>
@@ -28,7 +28,7 @@
<bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${execution.getVariable("deleteVnfNodeStatus")}</bpmn:conditionExpression>
</bpmn:sequenceFlow>
<bpmn:sequenceFlow id="SequenceFlow_0zlblru" sourceRef="ExclusiveGateway_1j9jbtk" targetRef="IntermediateCatchEvent_15yl23y" />
- <bpmn:serviceTask id="ServiceTask_1ksqjjf" name="&#10;Get node status &#10;" camunda:asyncAfter="true" camunda:expression="${MonitorVnfmNodeTask.getNodeStatus(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
+ <bpmn:serviceTask id="ServiceTask_1ksqjjf" name="&#10;Get node status &#10;" camunda:asyncAfter="true" camunda:expression="${MonitorTerminateVnfmNodeTask.getNodeStatus(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
<bpmn:incoming>SequenceFlow_17vvpzi</bpmn:incoming>
<bpmn:incoming>SequenceFlow_11rfobu</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_1unicf9</bpmn:outgoing>
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorInstantiateVnfmNodeTask.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorInstantiateVnfmNodeTask.java
new file mode 100644
index 0000000000..b885cc2ee5
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorInstantiateVnfmNodeTask.java
@@ -0,0 +1,53 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Ericsson. All rights reserved.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks;
+
+import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.CREATE_VNF_NODE_STATUS;
+import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.VNF_CREATED;
+import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
+import org.onap.so.client.exception.ExceptionBuilder;
+import org.onap.so.client.orchestration.AAIVnfResources;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * @author waqas.ikram@est.tech
+ *
+ */
+@Component
+public class MonitorInstantiateVnfmNodeTask extends MonitorVnfmNodeTask {
+
+ @Autowired
+ public MonitorInstantiateVnfmNodeTask(final ExtractPojosForBB extractPojosForBB,
+ final ExceptionBuilder exceptionUtil, final AAIVnfResources aaiVnfResources) {
+ super(extractPojosForBB, exceptionUtil, aaiVnfResources);
+ }
+
+ @Override
+ public String getNodeStatusVariableName() {
+ return CREATE_VNF_NODE_STATUS;
+ }
+
+ @Override
+ public boolean isOrchestrationStatusValid(final String orchestrationStatus) {
+ return VNF_CREATED.equalsIgnoreCase(orchestrationStatus);
+ }
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorTerminateVnfmNodeTask.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorTerminateVnfmNodeTask.java
new file mode 100644
index 0000000000..34296c20d6
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorTerminateVnfmNodeTask.java
@@ -0,0 +1,53 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Ericsson. All rights reserved.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks;
+
+import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.DELETE_VNF_NODE_STATUS;
+import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.VNF_ASSIGNED;
+import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
+import org.onap.so.client.exception.ExceptionBuilder;
+import org.onap.so.client.orchestration.AAIVnfResources;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * @author waqas.ikram@est.tech
+ *
+ */
+@Component
+public class MonitorTerminateVnfmNodeTask extends MonitorVnfmNodeTask {
+
+ @Autowired
+ public MonitorTerminateVnfmNodeTask(final ExtractPojosForBB extractPojosForBB, final ExceptionBuilder exceptionUtil,
+ final AAIVnfResources aaiVnfResources) {
+ super(extractPojosForBB, exceptionUtil, aaiVnfResources);
+ }
+
+ @Override
+ public String getNodeStatusVariableName() {
+ return DELETE_VNF_NODE_STATUS;
+ }
+
+ @Override
+ public boolean isOrchestrationStatusValid(final String orchestrationStatus) {
+ return VNF_ASSIGNED.equalsIgnoreCase(orchestrationStatus);
+ }
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmNodeTask.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmNodeTask.java
index 65b05e21f5..a7a4eadb33 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmNodeTask.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmNodeTask.java
@@ -19,38 +19,39 @@
*/
package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks;
-import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.CREATE_VNF_NODE_STATUS;
-import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.DELETE_VNF_NODE_STATUS;
-import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.VNF_ASSIGNED;
-import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.VNF_CREATED;
import static org.onap.so.bpmn.servicedecomposition.entities.ResourceKey.GENERIC_VNF_ID;
+import java.util.Optional;
import org.onap.aai.domain.yang.GenericVnf;
import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.exception.GenericVnfNotFoundException;
import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
import org.onap.so.client.exception.ExceptionBuilder;
+import org.onap.so.client.orchestration.AAIVnfResources;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
/**
*
* @author Lathishbabu Ganesan (lathishbabu.ganesan@est.tech)
+ * @author Waqas Ikram (waqas.ikram@est.tech)
*
*/
-@Component
-public class MonitorVnfmNodeTask {
+public abstract class MonitorVnfmNodeTask {
private static final Logger LOGGER = LoggerFactory.getLogger(MonitorVnfmNodeTask.class);
private final ExtractPojosForBB extractPojosForBB;
private final ExceptionBuilder exceptionUtil;
+ private final AAIVnfResources aaiVnfResources;
@Autowired
- public MonitorVnfmNodeTask(final ExtractPojosForBB extractPojosForBB, final ExceptionBuilder exceptionUtil) {
+ public MonitorVnfmNodeTask(final ExtractPojosForBB extractPojosForBB, final ExceptionBuilder exceptionUtil,
+ final AAIVnfResources aaiVnfResources) {
this.exceptionUtil = exceptionUtil;
this.extractPojosForBB = extractPojosForBB;
+ this.aaiVnfResources = aaiVnfResources;
}
/**
@@ -61,11 +62,23 @@ public class MonitorVnfmNodeTask {
public void getNodeStatus(final BuildingBlockExecution execution) {
try {
LOGGER.debug("Executing getNodeStatus ...");
- final GenericVnf vnf = extractPojosForBB.extractByKey(execution, GENERIC_VNF_ID);
- String orchestrationStatus = vnf.getOrchestrationStatus();
- LOGGER.debug("Orchestration Status in AAI {}", orchestrationStatus);
- execution.setVariable(CREATE_VNF_NODE_STATUS, VNF_CREATED.equalsIgnoreCase(orchestrationStatus));
- execution.setVariable(DELETE_VNF_NODE_STATUS, VNF_ASSIGNED.equalsIgnoreCase(orchestrationStatus));
+
+ final org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf =
+ extractPojosForBB.extractByKey(execution, GENERIC_VNF_ID);
+
+ final String vnfId = vnf.getVnfId();
+ LOGGER.debug("Query A&AI for generic VNF using vnfID: {}", vnfId);
+ final Optional<GenericVnf> aaiGenericVnfOptional = aaiVnfResources.getGenericVnf(vnfId);
+
+ if (!aaiGenericVnfOptional.isPresent()) {
+ throw new GenericVnfNotFoundException("Unable to find generic vnf in A&AI using vnfID: " + vnfId);
+ }
+ final GenericVnf genericVnf = aaiGenericVnfOptional.get();
+ final String orchestrationStatus = genericVnf.getOrchestrationStatus();
+ LOGGER.debug("Found generic vnf with orchestration status : {}", orchestrationStatus);
+
+ execution.setVariable(getNodeStatusVariableName(), isOrchestrationStatusValid(orchestrationStatus));
+
} catch (final Exception exception) {
LOGGER.error("Unable to get vnf from AAI", exception);
exceptionUtil.buildAndThrowWorkflowException(execution, 1220, exception);
@@ -73,6 +86,20 @@ public class MonitorVnfmNodeTask {
}
/**
+ * Get variable to store in execution context
+ *
+ * @return the variable name
+ */
+ public abstract String getNodeStatusVariableName();
+
+ /**
+ * @param orchestrationStatus the orchestration status from A&AI
+ * @return true if valid
+ */
+ public abstract boolean isOrchestrationStatusValid(final String orchestrationStatus);
+
+
+ /**
* Log and throw exception on timeout for job status
*
* @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/exception/GenericVnfNotFoundException.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/exception/GenericVnfNotFoundException.java
new file mode 100644
index 0000000000..d33d0bc895
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/exception/GenericVnfNotFoundException.java
@@ -0,0 +1,33 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Ericsson. All rights reserved.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.exception;
+
+/**
+ * @author waqas.ikram@est.tech
+ *
+ */
+public class GenericVnfNotFoundException extends Exception {
+ private static final long serialVersionUID = -2049370314818025597L;
+
+ public GenericVnfNotFoundException(final String message) {
+ super(message);
+ }
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorInstantiateVnfmNodeTaskTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorInstantiateVnfmNodeTaskTest.java
new file mode 100644
index 0000000000..effcf24a8d
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorInstantiateVnfmNodeTaskTest.java
@@ -0,0 +1,129 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks;
+
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.CREATE_VNF_NODE_STATUS;
+import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.VNF_CREATED;
+import java.util.Optional;
+import java.util.UUID;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.onap.aai.domain.yang.GenericVnf;
+import org.onap.so.bpmn.BaseTaskTest;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
+import org.onap.so.client.orchestration.AAIVnfResources;
+
+/**
+ *
+ * @author Lathishbabu Ganesan (lathishbabu.ganesan@est.tech)
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+public class MonitorInstantiateVnfmNodeTaskTest extends BaseTaskTest {
+
+ private static final String VNF_ID = UUID.randomUUID().toString();
+
+ private static final String VNF_NAME = "VNF_NAME";
+
+ private MonitorVnfmNodeTask objUnderTest;
+
+ @Mock
+ private VnfmAdapterServiceProvider mockedVnfmAdapterServiceProvider;
+
+ @Mock
+ private AAIVnfResources mockedAaiVnfResources;
+
+ private final BuildingBlockExecution stubbedxecution = new StubbedBuildingBlockExecution();
+
+ @Before
+ public void setUp() {
+ objUnderTest = getEtsiVnfMonitorNodeJobTask();
+ }
+
+ @Test
+ public void testGetNodeStatus_genericVnfWithOrchStatusCreated_executionVariableSetToCreate() throws Exception {
+ final org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf = getGenericVnf();
+ final GenericVnf aaiGenericVnf = getAAIGenericVnf();
+ aaiGenericVnf.setOrchestrationStatus(VNF_CREATED);
+
+ when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(vnf);
+ when(mockedAaiVnfResources.getGenericVnf(eq(VNF_ID))).thenReturn(Optional.of(aaiGenericVnf));
+ objUnderTest.getNodeStatus(stubbedxecution);
+ assertTrue(stubbedxecution.getVariable(CREATE_VNF_NODE_STATUS));
+ }
+
+ @Test
+ public void testGetNodeStatus_noGenericVnfFoundInAAI_throwException() throws Exception {
+ final org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf = getGenericVnf();
+
+ when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(vnf);
+ when(mockedAaiVnfResources.getGenericVnf(eq(VNF_ID))).thenReturn(Optional.empty());
+ objUnderTest.getNodeStatus(stubbedxecution);
+ verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1220),
+ any(Exception.class));
+ assertNull(stubbedxecution.getVariable(CREATE_VNF_NODE_STATUS));
+
+ }
+
+ @Test
+ public void testGetNodeStatusException() throws Exception {
+ when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenThrow(RuntimeException.class);
+ objUnderTest.getNodeStatus(stubbedxecution);
+ assertNull(stubbedxecution.getVariable(CREATE_VNF_NODE_STATUS));
+ verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1220),
+ any(Exception.class));
+ }
+
+ @Test
+ public void testTimeOutLogFailue() throws Exception {
+ objUnderTest.timeOutLogFailue(stubbedxecution);
+ verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1221),
+ eq("Node operation time out"));
+ }
+
+ private GenericVnf getAAIGenericVnf() {
+ final GenericVnf genericVnf = new GenericVnf();
+ genericVnf.setVnfId(VNF_ID);
+ genericVnf.setVnfName(VNF_NAME);
+ return genericVnf;
+ }
+
+ private org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf getGenericVnf() {
+ final org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf genericVnf =
+ new org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf();
+ genericVnf.setVnfId(VNF_ID);
+ return genericVnf;
+
+ }
+
+ private MonitorInstantiateVnfmNodeTask getEtsiVnfMonitorNodeJobTask() {
+ return new MonitorInstantiateVnfmNodeTask(extractPojosForBB, exceptionUtil, mockedAaiVnfResources);
+ }
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmNodeJobTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorTerminateVnfmNodeTaskTest.java
index 6b84f6a918..04831733e1 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmNodeJobTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorTerminateVnfmNodeTaskTest.java
@@ -20,16 +20,15 @@
package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks;
-import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.CREATE_VNF_NODE_STATUS;
-import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.DELETE_VNF_NODE_STATUS;
-import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.VNF_CREATED;
-import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.VNF_ASSIGNED;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.DELETE_VNF_NODE_STATUS;
+import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.VNF_ASSIGNED;
+import java.util.Optional;
import java.util.UUID;
import org.junit.Before;
import org.junit.Test;
@@ -38,13 +37,14 @@ import org.onap.aai.domain.yang.GenericVnf;
import org.onap.so.bpmn.BaseTaskTest;
import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
+import org.onap.so.client.orchestration.AAIVnfResources;
/**
*
- * @author Lathishbabu Ganesan (lathishbabu.ganesan@est.tech)
+ * @author Waqas Ikram (waqas.ikram@est.tech)
*
*/
-public class MonitorVnfmNodeJobTest extends BaseTaskTest {
+public class MonitorTerminateVnfmNodeTaskTest extends BaseTaskTest {
private static final String VNF_ID = UUID.randomUUID().toString();
@@ -55,6 +55,9 @@ public class MonitorVnfmNodeJobTest extends BaseTaskTest {
@Mock
private VnfmAdapterServiceProvider mockedVnfmAdapterServiceProvider;
+ @Mock
+ private AAIVnfResources mockedAaiVnfResources;
+
private final BuildingBlockExecution stubbedxecution = new StubbedBuildingBlockExecution();
@Before
@@ -63,49 +66,48 @@ public class MonitorVnfmNodeJobTest extends BaseTaskTest {
}
@Test
- public void testGetNodeStatusCreate() throws Exception {
- GenericVnf vnf = getGenericVnf();
- vnf.setOrchestrationStatus(VNF_CREATED);
- when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(vnf);
- objUnderTest.getNodeStatus(stubbedxecution);
- assertTrue(stubbedxecution.getVariable(CREATE_VNF_NODE_STATUS));
- }
-
- @Test
public void testGetNodeStatusDelete() throws Exception {
- GenericVnf vnf = getGenericVnf();
- vnf.setOrchestrationStatus(VNF_ASSIGNED);
+ final org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf = getGenericVnf();
+ final GenericVnf aaiGenericVnf = getAAIGenericVnf();
+ aaiGenericVnf.setOrchestrationStatus(VNF_ASSIGNED);
+
when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(vnf);
+ when(mockedAaiVnfResources.getGenericVnf(eq(VNF_ID))).thenReturn(Optional.of(aaiGenericVnf));
+
objUnderTest.getNodeStatus(stubbedxecution);
assertTrue(stubbedxecution.getVariable(DELETE_VNF_NODE_STATUS));
}
@Test
- public void testGetNodeStatusException() throws Exception {
- when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenThrow(RuntimeException.class);
+ public void testGetNodeStatus_noGenericVnfFoundInAAI_throwException() throws Exception {
+ final org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf = getGenericVnf();
+
+ when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(vnf);
+ when(mockedAaiVnfResources.getGenericVnf(eq(VNF_ID))).thenReturn(Optional.empty());
objUnderTest.getNodeStatus(stubbedxecution);
- assertNull(stubbedxecution.getVariable(CREATE_VNF_NODE_STATUS));
- assertNull(stubbedxecution.getVariable(DELETE_VNF_NODE_STATUS));
verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1220),
any(Exception.class));
- }
+ assertNull(stubbedxecution.getVariable(DELETE_VNF_NODE_STATUS));
- @Test
- public void testTimeOutLogFailue() throws Exception {
- objUnderTest.timeOutLogFailue(stubbedxecution);
- verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1221),
- eq("Node operation time out"));
}
- private GenericVnf getGenericVnf() {
+ private GenericVnf getAAIGenericVnf() {
final GenericVnf genericVnf = new GenericVnf();
genericVnf.setVnfId(VNF_ID);
genericVnf.setVnfName(VNF_NAME);
return genericVnf;
}
- private MonitorVnfmNodeTask getEtsiVnfMonitorNodeJobTask() {
- return new MonitorVnfmNodeTask(extractPojosForBB, exceptionUtil);
+ private org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf getGenericVnf() {
+ final org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf genericVnf =
+ new org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf();
+ genericVnf.setVnfId(VNF_ID);
+ return genericVnf;
+
+ }
+
+ private MonitorTerminateVnfmNodeTask getEtsiVnfMonitorNodeJobTask() {
+ return new MonitorTerminateVnfmNodeTask(extractPojosForBB, exceptionUtil, mockedAaiVnfResources);
}
}