aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/ExtractPojosForBBTest.java91
-rw-r--r--bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignPnfBB.bpmn22
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AssignPnfInputsCheckerDelegate.java40
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/tasks/CheckAaiForPnfCorrelationId.java45
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/tasks/CreatePnfEntryInAai.java34
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/tasks/PnfBaseTasks.java29
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AssignPnfInputsCheckerDelegateTest.java52
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfInputCheckersTestUtils.java46
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/tasks/CheckAaiForPnfCorrelationIdTest.java129
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/tasks/CreatePnfEntryInAaiTest.java50
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/tasks/PnfTasksUtils.java17
-rw-r--r--mso-catalog-db/pom.xml12
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java66
-rw-r--r--mso-catalog-db/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java51
-rw-r--r--pom.xml38
15 files changed, 433 insertions, 289 deletions
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/ExtractPojosForBBTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/ExtractPojosForBBTest.java
index 7bd2beeb92..dbd5000387 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/ExtractPojosForBBTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/ExtractPojosForBBTest.java
@@ -115,6 +115,12 @@ public class ExtractPojosForBBTest extends BaseTest {
instanceGroupsPend.add(instanceGroupPend);
lookupKeyMap.put(ResourceKey.INSTANCE_GROUP_ID, instanceGroupPend.getId());
+ List<Pnf> pnfsPend = serviceInstancePend.getPnfs();
+ Pnf pnfPend = new Pnf();
+ pnfPend.setPnfId("abc");
+ pnfsPend.add(pnfPend);
+ lookupKeyMap.put(ResourceKey.PNF, pnfPend.getPnfId());
+
customer.getServiceSubscription().getServiceInstances().add(serviceInstancePend);
gBBInput.setCustomer(customer);
@@ -143,89 +149,49 @@ public class ExtractPojosForBBTest extends BaseTest {
InstanceGroup extractInstanceGroupPend = extractPojos.extractByKey(execution, ResourceKey.INSTANCE_GROUP_ID);
assertEquals(instanceGroupPend.getId(), extractInstanceGroupPend.getId());
+
+ Pnf extractPnfPend = extractPojos.extractByKey(execution, ResourceKey.PNF);
+ assertEquals(extractPnfPend.getPnfId(), pnfPend.getPnfId());
}
@Test
public void siError() throws BBObjectNotFoundException {
- expectedException.expect(BBObjectNotFoundException.class);
-
- Customer customer = new Customer();
- customer.setServiceSubscription(new ServiceSubscription());
- ServiceInstance serviceInstance = new ServiceInstance();
- customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
- gBBInput.setCustomer(customer);
-
- extractPojos.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ assertThrowsBBObjectNotFoundForResource_WhenServiceEmpty(ResourceKey.SERVICE_INSTANCE_ID);
}
@Test
public void vnfError() throws BBObjectNotFoundException {
- expectedException.expect(BBObjectNotFoundException.class);
-
- Customer customer = new Customer();
- customer.setServiceSubscription(new ServiceSubscription());
- ServiceInstance serviceInstance = new ServiceInstance();
- customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
- gBBInput.setCustomer(customer);
- extractPojos.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ assertThrowsBBObjectNotFoundForResource_WhenServiceEmpty(ResourceKey.GENERIC_VNF_ID);
}
@Test
public void vfModuleError() throws BBObjectNotFoundException {
- expectedException.expect(BBObjectNotFoundException.class);
-
- Customer customer = new Customer();
- customer.setServiceSubscription(new ServiceSubscription());
- ServiceInstance serviceInstance = new ServiceInstance();
- customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
- gBBInput.setCustomer(customer);
- extractPojos.extractByKey(execution, ResourceKey.VF_MODULE_ID);
+ assertThrowsBBObjectNotFoundForResource_WhenServiceEmpty(ResourceKey.VF_MODULE_ID);
}
@Test
public void configurationError() throws BBObjectNotFoundException {
- expectedException.expect(BBObjectNotFoundException.class);
-
- Customer customer = new Customer();
- customer.setServiceSubscription(new ServiceSubscription());
- ServiceInstance serviceInstance = new ServiceInstance();
- customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
- gBBInput.setCustomer(customer);
- extractPojos.extractByKey(execution, ResourceKey.CONFIGURATION_ID);
+ assertThrowsBBObjectNotFoundForResource_WhenServiceEmpty(ResourceKey.CONFIGURATION_ID);
}
@Test
public void allotedError() throws BBObjectNotFoundException {
- expectedException.expect(BBObjectNotFoundException.class);
-
- Customer customer = new Customer();
- customer.setServiceSubscription(new ServiceSubscription());
- ServiceInstance serviceInstance = new ServiceInstance();
- customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
- gBBInput.setCustomer(customer);
- extractPojos.extractByKey(execution, ResourceKey.ALLOTTED_RESOURCE_ID);
+ assertThrowsBBObjectNotFoundForResource_WhenServiceEmpty(ResourceKey.ALLOTTED_RESOURCE_ID);
}
@Test
public void vpnBindingError() throws BBObjectNotFoundException {
- expectedException.expect(BBObjectNotFoundException.class);
- Customer customer = new Customer();
- customer.setServiceSubscription(new ServiceSubscription());
- ServiceInstance serviceInstance = new ServiceInstance();
- customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
- gBBInput.setCustomer(customer);
- extractPojos.extractByKey(execution, ResourceKey.VPN_ID);
+ assertThrowsBBObjectNotFoundForResource_WhenServiceEmpty(ResourceKey.VPN_ID);
}
@Test
public void vpnBondingLinkError() throws BBObjectNotFoundException {
- expectedException.expect(BBObjectNotFoundException.class);
- Customer customer = new Customer();
- customer.setServiceSubscription(new ServiceSubscription());
- ServiceInstance serviceInstance = new ServiceInstance();
- customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
- gBBInput.setCustomer(customer);
- extractPojos.extractByKey(execution, ResourceKey.VPN_BONDING_LINK_ID);
+ assertThrowsBBObjectNotFoundForResource_WhenServiceEmpty(ResourceKey.VPN_BONDING_LINK_ID);
+ }
+
+ @Test
+ public void pnfError() throws BBObjectNotFoundException {
+ assertThrowsBBObjectNotFoundForResource_WhenServiceEmpty(ResourceKey.PNF);
}
@Test
@@ -239,4 +205,19 @@ public class ExtractPojosForBBTest extends BaseTest {
ServiceInstance extractServPend = extractPojos.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
assertEquals(extractServPend.getServiceInstanceId(), serviceInstancePend.getServiceInstanceId());
}
+
+ private void assertThrowsBBObjectNotFoundForResource_WhenServiceEmpty(ResourceKey key)
+ throws BBObjectNotFoundException {
+ expectedException.expect(BBObjectNotFoundException.class);
+ setCustomerWithEmptyServiceInstance();
+ extractPojos.extractByKey(execution, key);
+ }
+
+ private void setCustomerWithEmptyServiceInstance() {
+ Customer customer = new Customer();
+ customer.setServiceSubscription(new ServiceSubscription());
+ ServiceInstance serviceInstance = new ServiceInstance();
+ customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
+ gBBInput.setCustomer(customer);
+ }
}
diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignPnfBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignPnfBB.bpmn
index f9c5d0cdb3..930f666bf0 100644
--- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignPnfBB.bpmn
+++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignPnfBB.bpmn
@@ -11,8 +11,8 @@
<bpmn:startEvent id="AssignPnf_StartEvent">
<bpmn:outgoing>SequenceFlow_1fu9o4x</bpmn:outgoing>
</bpmn:startEvent>
- <bpmn:serviceTask id="CheckAaiForPnfCorrelationId" name="Check AAI for pnf_correlation_id" camunda:delegateExpression="${CheckAaiForPnfCorrelationIdDelegate}">
- <bpmn:incoming>SequenceFlow_02j05kk</bpmn:incoming>
+ <bpmn:serviceTask id="CheckAaiForPnfCorrelationId" name="Check AAI for pnf_correlation_id" camunda:expression="${CheckAaiForPnfCorrelationId.execute(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
+ <bpmn:incoming>SequenceFlow_1fu9o4x</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_081rs5d</bpmn:outgoing>
</bpmn:serviceTask>
<bpmn:exclusiveGateway id="DoesAaiContainInfoAboutPnf" name="Does AAI contain info about pnf?">
@@ -20,7 +20,7 @@
<bpmn:outgoing>SequenceFlow_0fn5kgz</bpmn:outgoing>
<bpmn:outgoing>SequenceFlow_1ewfz8r</bpmn:outgoing>
</bpmn:exclusiveGateway>
- <bpmn:serviceTask id="CreatePnfEntryInAai" name="Create Pnf entry in AAI" camunda:delegateExpression="${CreatePnfEntryInAaiDelegate}">
+ <bpmn:serviceTask id="CreatePnfEntryInAai" name="Create Pnf entry in AAI" camunda:expression="${CreatePnfEntryInAai.execute(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
<bpmn:incoming>SequenceFlow_0fn5kgz</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_0l6rtzy</bpmn:outgoing>
</bpmn:serviceTask>
@@ -36,12 +36,7 @@
<bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{aaiContainsInfoAboutPnf}</bpmn:conditionExpression>
</bpmn:sequenceFlow>
<bpmn:sequenceFlow id="SequenceFlow_0l6rtzy" sourceRef="CreatePnfEntryInAai" targetRef="AaiEntryExists" />
- <bpmn:serviceTask id="CheckInputs" name="Check Inputs" camunda:delegateExpression="${AssignPnfInputsCheckerDelegate}">
- <bpmn:incoming>SequenceFlow_1fu9o4x</bpmn:incoming>
- <bpmn:outgoing>SequenceFlow_02j05kk</bpmn:outgoing>
- </bpmn:serviceTask>
- <bpmn:sequenceFlow id="SequenceFlow_02j05kk" sourceRef="CheckInputs" targetRef="CheckAaiForPnfCorrelationId" />
- <bpmn:sequenceFlow id="SequenceFlow_1fu9o4x" sourceRef="AssignPnf_StartEvent" targetRef="CheckInputs" />
+ <bpmn:sequenceFlow id="SequenceFlow_1fu9o4x" sourceRef="AssignPnf_StartEvent" targetRef="CheckAaiForPnfCorrelationId" />
<bpmn:textAnnotation id="TextAnnotation_184cxp4">
<bpmn:text>Inputs:
- pnfCorrelationId - String
@@ -121,16 +116,9 @@
<di:waypoint x="1020" y="287" />
<di:waypoint x="1152" y="287" />
</bpmndi:BPMNEdge>
- <bpmndi:BPMNShape id="ServiceTask_0tv92eb_di" bpmnElement="CheckInputs">
- <dc:Bounds x="400" y="247" width="100" height="80" />
- </bpmndi:BPMNShape>
- <bpmndi:BPMNEdge id="SequenceFlow_02j05kk_di" bpmnElement="SequenceFlow_02j05kk">
- <di:waypoint x="500" y="287" />
- <di:waypoint x="640" y="287" />
- </bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_1fu9o4x_di" bpmnElement="SequenceFlow_1fu9o4x">
<di:waypoint x="255" y="287" />
- <di:waypoint x="400" y="287" />
+ <di:waypoint x="640" y="287" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AssignPnfInputsCheckerDelegate.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AssignPnfInputsCheckerDelegate.java
deleted file mode 100644
index 9176948288..0000000000
--- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AssignPnfInputsCheckerDelegate.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package org.onap.so.bpmn.infrastructure.pnf.delegate;
-
-import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_CORRELATION_ID;
-import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_UUID;
-import com.google.common.base.Strings;
-import org.camunda.bpm.engine.delegate.DelegateExecution;
-import org.camunda.bpm.engine.delegate.JavaDelegate;
-import org.onap.so.bpmn.common.scripts.ExceptionUtil;
-import org.springframework.stereotype.Component;
-
-@Component
-public class AssignPnfInputsCheckerDelegate implements JavaDelegate {
-
- public static final String UUID_REGEX =
- "(?i)^[0-9a-f]{8}-[0-9a-f]{4}-[1-5]{1}[0-9a-f]{3}-[89ab]{1}[0-9a-f]{3}-[0-9a-f]{12}$";
-
- @Override
- public void execute(DelegateExecution execution) {
- validatePnfCorrelationId(execution);
- validatePnfUuid(execution);
- }
-
- private void validatePnfCorrelationId(DelegateExecution execution) {
- String pnfCorrelationId = (String) execution.getVariable(PNF_CORRELATION_ID);
- if (Strings.isNullOrEmpty(pnfCorrelationId)) {
- new ExceptionUtil().buildAndThrowWorkflowException(execution, 9999,
- "pnfCorrelationId variable not defined");
- }
- }
-
- private void validatePnfUuid(DelegateExecution execution) {
- String pnfUuid = (String) execution.getVariable(PNF_UUID);
- if (Strings.isNullOrEmpty(pnfUuid)) {
- new ExceptionUtil().buildAndThrowWorkflowException(execution, 9999, "pnfUuid variable not defined");
- }
- if (!pnfUuid.matches(UUID_REGEX)) {
- new ExceptionUtil().buildAndThrowWorkflowException(execution, 9999, "pnfUuid is not a valid UUID");
- }
- }
-}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/tasks/CheckAaiForPnfCorrelationId.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/tasks/CheckAaiForPnfCorrelationId.java
new file mode 100644
index 0000000000..29914252d8
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/tasks/CheckAaiForPnfCorrelationId.java
@@ -0,0 +1,45 @@
+package org.onap.so.bpmn.infrastructure.pnf.tasks;
+
+import joptsimple.internal.Strings;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.client.exception.BBObjectNotFoundException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+import java.io.IOException;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.AAI_CONTAINS_INFO_ABOUT_PNF;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_CORRELATION_ID;
+
+@Component
+public class CheckAaiForPnfCorrelationId extends PnfBaseTasks {
+ private static final Logger logger = LoggerFactory.getLogger(CheckAaiForPnfCorrelationId.class);
+
+ @Override
+ public void execute(BuildingBlockExecution execution) {
+ try {
+ String pnfCorrelationId = extractPnf(execution).getPnfName();
+ checkIfPnfCorrelationIdPresent(execution, pnfCorrelationId);
+ checkIfPnfExistsInAai(execution, pnfCorrelationId);
+ } catch (BBObjectNotFoundException e) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, e);
+ }
+
+ }
+
+ private void checkIfPnfCorrelationIdPresent(BuildingBlockExecution execution, String pnfCorrelationId) {
+ if (Strings.isNullOrEmpty(pnfCorrelationId)) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, PNF_CORRELATION_ID + " is not set");
+ }
+ }
+
+ private void checkIfPnfExistsInAai(BuildingBlockExecution execution, String pnfCorrelationId) {
+ try {
+ boolean isEntry = pnfManagement.getEntryFor(pnfCorrelationId).isPresent();
+ logger.debug("AAI entry is found for pnf correlation id {}: {}", PNF_CORRELATION_ID, isEntry);
+ execution.setVariable(AAI_CONTAINS_INFO_ABOUT_PNF, isEntry);
+ } catch (IOException e) {
+ logger.error("Exception in check AAI for pnf_correlation_id execution", e);
+ exceptionUtil.buildAndThrowWorkflowException(execution, 9999, e);
+ }
+ }
+}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/tasks/CreatePnfEntryInAai.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/tasks/CreatePnfEntryInAai.java
new file mode 100644
index 0000000000..6e86ad619e
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/tasks/CreatePnfEntryInAai.java
@@ -0,0 +1,34 @@
+package org.onap.so.bpmn.infrastructure.pnf.tasks;
+
+import org.onap.aai.domain.yang.Pnf;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.client.exception.BBObjectNotFoundException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+
+@Component
+public class CreatePnfEntryInAai extends PnfBaseTasks {
+ private static final Logger logger = LoggerFactory.getLogger(CreatePnfEntryInAai.class);
+
+ @Override
+ public void execute(BuildingBlockExecution execution) throws Exception {
+ try {
+ org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf pnf = extractPnf(execution);
+ String pnfCorrelationId = pnf.getPnfName();
+ pnfManagement.createEntry(pnfCorrelationId, preparePnfForAai(pnf));
+ logger.debug("AAI entry is created for pnf correlation id: {}, pnf uuid: {}", pnfCorrelationId,
+ pnf.getPnfId());
+ } catch (BBObjectNotFoundException e) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, e);
+ }
+ }
+
+ private Pnf preparePnfForAai(org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf pnf) {
+ Pnf pnfAai = new Pnf();
+ pnfAai.setPnfId(pnf.getPnfId());
+ pnfAai.setPnfName(pnf.getPnfName());
+ return pnfAai;
+ }
+
+}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/tasks/PnfBaseTasks.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/tasks/PnfBaseTasks.java
new file mode 100644
index 0000000000..d8e3379afb
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/tasks/PnfBaseTasks.java
@@ -0,0 +1,29 @@
+package org.onap.so.bpmn.infrastructure.pnf.tasks;
+
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.infrastructure.pnf.management.PnfManagement;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf;
+import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
+import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
+import org.onap.so.client.exception.BBObjectNotFoundException;
+import org.onap.so.client.exception.ExceptionBuilder;
+import org.springframework.beans.factory.annotation.Autowired;
+
+public abstract class PnfBaseTasks {
+ protected PnfManagement pnfManagement;
+ @Autowired
+ protected ExceptionBuilder exceptionUtil;
+ @Autowired
+ protected ExtractPojosForBB extractPojosForBB;
+
+ @Autowired
+ public void setPnfManagement(PnfManagement pnfManagement) {
+ this.pnfManagement = pnfManagement;
+ }
+
+ public abstract void execute(BuildingBlockExecution execution) throws Exception;
+
+ protected Pnf extractPnf(BuildingBlockExecution execution) throws BBObjectNotFoundException {
+ return extractPojosForBB.extractByKey(execution, ResourceKey.PNF);
+ }
+}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AssignPnfInputsCheckerDelegateTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AssignPnfInputsCheckerDelegateTest.java
deleted file mode 100644
index a562da490b..0000000000
--- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AssignPnfInputsCheckerDelegateTest.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package org.onap.so.bpmn.infrastructure.pnf.delegate;
-
-import org.apache.commons.lang3.StringUtils;
-import org.camunda.bpm.engine.delegate.BpmnError;
-import org.camunda.bpm.engine.delegate.DelegateExecution;
-import org.junit.Before;
-import org.junit.Test;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.onap.so.bpmn.infrastructure.pnf.delegate.PnfInputCheckersTestUtils.DelegateExecutionBuilder;
-import static org.onap.so.bpmn.infrastructure.pnf.delegate.PnfInputCheckersTestUtils.RESERVED_UUID;
-import static org.onap.so.bpmn.infrastructure.pnf.delegate.PnfInputCheckersTestUtils.VALID_UUID;
-
-public class AssignPnfInputsCheckerDelegateTest {
-
- private DelegateExecutionBuilder delegateExecutionBuilder;
- private AssignPnfInputsCheckerDelegate testedObject;
- private DelegateExecution execution;
-
- @Before
- public void setUp() {
- testedObject = new AssignPnfInputsCheckerDelegate();
- delegateExecutionBuilder = new DelegateExecutionBuilder();
- }
-
- @Test
- public void shouldThrowException_whenPnfCorrelationIdNotSet() {
- execution = delegateExecutionBuilder.setPnfCorrelationId(null).setPnfUuid(VALID_UUID).build();
- assertThatSutExecutionThrowsExceptionOfInstance(BpmnError.class);
- }
-
- @Test
- public void shouldThrowException_whenPnfUuidIsNotSet() {
- execution = delegateExecutionBuilder.setPnfUuid(null).build();
- assertThatSutExecutionThrowsExceptionOfInstance(BpmnError.class);
- }
-
- @Test
- public void shouldThrowException_whenPnfUuidIsEmptyString() {
- execution = delegateExecutionBuilder.setPnfUuid(StringUtils.EMPTY).build();
- assertThatSutExecutionThrowsExceptionOfInstance(BpmnError.class);
- }
-
- @Test
- public void shouldThrowException_whenPnfUuidIsReservedUuid() {
- execution = delegateExecutionBuilder.setPnfUuid(RESERVED_UUID).build();
- assertThatSutExecutionThrowsExceptionOfInstance(BpmnError.class);
- }
-
- private void assertThatSutExecutionThrowsExceptionOfInstance(Class<?> type) {
- assertThatThrownBy(() -> testedObject.execute(execution)).isInstanceOf(type);
- }
-}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfInputCheckersTestUtils.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfInputCheckersTestUtils.java
deleted file mode 100644
index c1c7f06d4e..0000000000
--- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfInputCheckersTestUtils.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package org.onap.so.bpmn.infrastructure.pnf.delegate;
-
-import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.*;
-import org.camunda.bpm.engine.delegate.DelegateExecution;
-import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
-import java.util.UUID;
-
-
-public class PnfInputCheckersTestUtils {
-
- static final String PNF_ENTRY_NOTIFICATION_TIMEOUT = "P1D";
- static final String VALID_UUID = UUID.nameUUIDFromBytes("testUuid".getBytes()).toString();
- static final String RESERVED_UUID = new UUID(0, 0).toString();
- private static final String DEFAULT_SERVICE_INSTANCE_ID = "da7d07d9-b71c-4128-809d-2ec01c807169";
- private static final String DEFAULT_PNF_CORRELATION_ID = "testPnfCorrelationId";
-
- static class DelegateExecutionBuilder {
- private String pnfCorrelationId = DEFAULT_PNF_CORRELATION_ID;
- private String pnfUuid = VALID_UUID;
- private String serviceInstanceId = DEFAULT_SERVICE_INSTANCE_ID;
-
- public DelegateExecutionBuilder setPnfCorrelationId(String pnfCorrelationId) {
- this.pnfCorrelationId = pnfCorrelationId;
- return this;
- }
-
- public DelegateExecutionBuilder setPnfUuid(String pnfUuid) {
- this.pnfUuid = pnfUuid;
- return this;
- }
-
- public DelegateExecutionBuilder setServiceInstanceId(String serviceInstanceId) {
- this.serviceInstanceId = serviceInstanceId;
- return this;
- }
-
- public DelegateExecution build() {
- DelegateExecution execution = new DelegateExecutionFake();
- execution.setVariable("testProcessKey", "testProcessKeyValue");
- execution.setVariable(PNF_CORRELATION_ID, this.pnfCorrelationId);
- execution.setVariable(PNF_UUID, this.pnfUuid);
- execution.setVariable(SERVICE_INSTANCE_ID, this.serviceInstanceId);
- return execution;
- }
- }
-}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/tasks/CheckAaiForPnfCorrelationIdTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/tasks/CheckAaiForPnfCorrelationIdTest.java
new file mode 100644
index 0000000000..3fa9fbf3b5
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/tasks/CheckAaiForPnfCorrelationIdTest.java
@@ -0,0 +1,129 @@
+package org.onap.so.bpmn.infrastructure.pnf.tasks;
+
+import org.camunda.bpm.engine.delegate.BpmnError;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.runners.Enclosed;
+import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.infrastructure.pnf.delegate.PnfManagementTestImpl;
+import org.onap.so.bpmn.infrastructure.pnf.delegate.PnfManagementThrowingException;
+import org.onap.so.bpmn.infrastructure.pnf.management.PnfManagement;
+import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
+import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
+import org.onap.so.client.exception.ExceptionBuilder;
+import java.io.IOException;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.anyInt;
+import static org.mockito.Mockito.anyString;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.AAI_CONTAINS_INFO_ABOUT_PNF;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_CORRELATION_ID;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.PnfManagementTestImpl.ID_WITHOUT_ENTRY;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.PnfManagementTestImpl.ID_WITH_ENTRY;
+import static org.onap.so.bpmn.infrastructure.pnf.tasks.PnfTasksUtils.PNF_UUID;
+import static org.onap.so.bpmn.infrastructure.pnf.tasks.PnfTasksUtils.preparePnf;
+
+@RunWith(Enclosed.class)
+public class CheckAaiForPnfCorrelationIdTest {
+
+ @RunWith(MockitoJUnitRunner.class)
+ public static class ConnectionOkTests {
+
+ @Mock
+ private ExtractPojosForBB extractPojosForBB;
+ @Mock
+ private ExceptionBuilder exceptionUtil;
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ @InjectMocks
+ private CheckAaiForPnfCorrelationId task = new CheckAaiForPnfCorrelationId();
+ private PnfManagement pnfManagementTest = new PnfManagementTestImpl();
+
+ @Before
+ public void setUp() {
+ task.setPnfManagement(pnfManagementTest);
+ }
+
+ @Test
+ public void shouldThrowExceptionWhenPnfCorrelationIdIsNotSet() throws Exception {
+ // given
+ when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.PNF))).thenReturn(preparePnf(null, PNF_UUID));
+ BuildingBlockExecution execution = mock(BuildingBlockExecution.class);
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(eq(execution),
+ anyInt(), anyString());
+ // when, then
+ expectedException.expect(BpmnError.class);
+ task.execute(execution);
+ verify(exceptionUtil).buildAndThrowWorkflowException(eq(execution), anyInt(), anyString());
+ }
+
+ @Test
+ public void shouldSetCorrectVariablesWhenAaiDoesNotContainInfoAboutPnf() throws Exception {
+ // given
+ when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.PNF)))
+ .thenReturn(preparePnf(ID_WITHOUT_ENTRY, PNF_UUID));
+ BuildingBlockExecution execution = mock(BuildingBlockExecution.class);
+ // when
+ task.execute(execution);
+ // then
+ verify(execution).setVariable(AAI_CONTAINS_INFO_ABOUT_PNF, false);
+ }
+
+ @Test
+ public void shouldSetCorrectVariablesWhenAaiContainsInfoAboutPnfWithoutIp() throws Exception {
+ // given
+ when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.PNF)))
+ .thenReturn(preparePnf(ID_WITH_ENTRY, PNF_UUID));
+ BuildingBlockExecution execution = mock(BuildingBlockExecution.class);
+ // when
+ task.execute(execution);
+ // then
+ verify(execution).setVariable(AAI_CONTAINS_INFO_ABOUT_PNF, true);
+ }
+ }
+
+ @RunWith(MockitoJUnitRunner.class)
+ public static class NoConnectionTests {
+
+ @Mock
+ private ExtractPojosForBB extractPojosForBB;
+ @Mock
+ private ExceptionBuilder exceptionUtil;
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ @InjectMocks
+ private CheckAaiForPnfCorrelationId task = new CheckAaiForPnfCorrelationId();
+ private PnfManagement pnfManagementTest = new PnfManagementThrowingException();
+
+ @Before
+ public void setUp() throws Exception {
+ task.setPnfManagement(pnfManagementTest);
+ when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.PNF)))
+ .thenReturn(preparePnf(PNF_CORRELATION_ID, PNF_UUID));
+ }
+
+ @Test
+ public void shouldThrowExceptionWhenIoExceptionOnConnectionToAai() {
+ // given
+ BuildingBlockExecution execution = mock(BuildingBlockExecution.class);
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(eq(execution),
+ anyInt(), any(IOException.class));
+ // when, then
+ expectedException.expect(BpmnError.class);
+ task.execute(execution);
+ verify(exceptionUtil).buildAndThrowWorkflowException(eq(execution), anyInt(), any(IOException.class));
+ }
+ }
+}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/tasks/CreatePnfEntryInAaiTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/tasks/CreatePnfEntryInAaiTest.java
new file mode 100644
index 0000000000..ed8dd82efb
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/tasks/CreatePnfEntryInAaiTest.java
@@ -0,0 +1,50 @@
+package org.onap.so.bpmn.infrastructure.pnf.tasks;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.aai.domain.yang.Pnf;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.infrastructure.pnf.delegate.PnfManagementTestImpl;
+import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
+import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.onap.so.bpmn.infrastructure.pnf.tasks.PnfTasksUtils.PNF_CORRELATION_ID;
+import static org.onap.so.bpmn.infrastructure.pnf.tasks.PnfTasksUtils.PNF_UUID;
+import static org.onap.so.bpmn.infrastructure.pnf.tasks.PnfTasksUtils.preparePnf;
+
+@RunWith(MockitoJUnitRunner.class)
+public class CreatePnfEntryInAaiTest {
+
+ @Mock
+ private ExtractPojosForBB extractPojosForBB;
+ @InjectMocks
+ private CreatePnfEntryInAai task = new CreatePnfEntryInAai();
+ private PnfManagementTestImpl pnfManagementTest = new PnfManagementTestImpl();
+
+ @Before
+ public void setUp() throws Exception {
+ task.setPnfManagement(pnfManagementTest);
+ when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.PNF)))
+ .thenReturn(preparePnf(PNF_CORRELATION_ID, PNF_UUID));
+ }
+
+ @Test
+ public void shouldSetPnfIdAndPnfName() throws Exception {
+ // when
+ task.execute(mock(BuildingBlockExecution.class));
+ // then
+ Pnf createdEntry = pnfManagementTest.getCreated().get(PNF_CORRELATION_ID);
+ assertThat(createdEntry.getPnfId()).isEqualTo(PNF_UUID);
+ assertThat(createdEntry.getPnfName()).isEqualTo(PNF_CORRELATION_ID);
+ assertThat(createdEntry.isInMaint()).isNull();
+ }
+
+}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/tasks/PnfTasksUtils.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/tasks/PnfTasksUtils.java
new file mode 100644
index 0000000000..49fe96c3d9
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/tasks/PnfTasksUtils.java
@@ -0,0 +1,17 @@
+package org.onap.so.bpmn.infrastructure.pnf.tasks;
+
+import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf;
+import java.util.UUID;
+
+public class PnfTasksUtils {
+ static final String PNF_UUID = UUID.nameUUIDFromBytes("testUuid".getBytes()).toString();
+ static final String PNF_CORRELATION_ID = "testPnfCorrelationId";
+
+ public static Pnf preparePnf(String pnfName, String pnfUuid) {
+ Pnf pnf = new Pnf();
+ pnf.setPnfName(pnfName);
+ pnf.setPnfId(pnfUuid);
+ return pnf;
+ }
+
+}
diff --git a/mso-catalog-db/pom.xml b/mso-catalog-db/pom.xml
index 610ed25096..6a4a6774e6 100644
--- a/mso-catalog-db/pom.xml
+++ b/mso-catalog-db/pom.xml
@@ -107,17 +107,5 @@
<artifactId>jersey-common</artifactId>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- <version>2.28.2</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-api-mockito2</artifactId>
- <version>2.0.4</version>
- <scope>test</scope>
- </dependency>
</dependencies>
</project>
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java
index 7873d70bd4..7f5907e9bf 100644
--- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java
@@ -124,38 +124,38 @@ public class CatalogDbClient {
private static final String SEARCH = "/search";
private static final String URI_SEPARATOR = "/";
- private static final String SERVICE_MODEL_UUID = "serviceModelUUID";
- private static final String SERVICE_NAME = "serviceName";
- private static final String MODEL_UUID = "modelUUID";
- private static final String MODEL_CUSTOMIZATION_UUID = "modelCustomizationUUID";
- private static final String ACTION = "action";
- private static final String MODEL_NAME = "modelName";
- private static final String MODEL_VERSION = "modelVersion";
- private static final String MODEL_INVARIANT_UUID = "modelInvariantUUID";
- private static final String VNF_RESOURCE_MODEL_UUID = "vnfResourceModelUUID";
- private static final String PNF_RESOURCE_MODEL_UUID = "pnfResourceModelUUID";
- private static final String NF_ROLE = "nfRole";
- private static final String VF_MODULE_MODEL_UUID = "vfModuleModelUUID";
- private static final String VNF_COMPONENT_TYPE = "vnfComponentType";
- private static final String BUILDING_BLOCK_NAME = "buildingBlockName";
- private static final String RESOURCE_TYPE = "resourceType";
- private static final String ORCHESTRATION_STATUS = "orchestrationStatus";
- private static final String TARGET_ACTION = "targetAction";
- private static final String REQUEST_SCOPE = "requestScope";
- private static final String IS_ALACARTE = "isALaCarte";
- private static final String CLOUD_OWNER = "cloudOwner";
- private static final String FLOW_NAME = "flowName";
- private static final String ERROR_MESSAGE = "errorMessage";
- private static final String SERVICE_ROLE = "serviceRole";
- private static final String SERVICE_TYPE = "serviceType";
- private static final String VNF_TYPE = "vnfType";
- private static final String ERROR_CODE = "errorCode";
- private static final String WORK_STEP = "workStep";
- private static final String CLLI = "clli";
- private static final String CLOUD_VERSION = "cloudVersion";
- private static final String HOMING_INSTANCE = "/homingInstance";
- private static final String ARTIFACT_UUID = "artifactUUID";
- private static final String SOURCE = "source";
+ protected static final String SERVICE_MODEL_UUID = "serviceModelUUID";
+ protected static final String SERVICE_NAME = "serviceName";
+ protected static final String MODEL_UUID = "modelUUID";
+ protected static final String MODEL_CUSTOMIZATION_UUID = "modelCustomizationUUID";
+ protected static final String ACTION = "action";
+ protected static final String MODEL_NAME = "modelName";
+ protected static final String MODEL_VERSION = "modelVersion";
+ protected static final String MODEL_INVARIANT_UUID = "modelInvariantUUID";
+ protected static final String VNF_RESOURCE_MODEL_UUID = "vnfResourceModelUUID";
+ protected static final String PNF_RESOURCE_MODEL_UUID = "pnfResourceModelUUID";
+ protected static final String NF_ROLE = "nfRole";
+ protected static final String VF_MODULE_MODEL_UUID = "vfModuleModelUUID";
+ protected static final String VNF_COMPONENT_TYPE = "vnfComponentType";
+ protected static final String BUILDING_BLOCK_NAME = "buildingBlockName";
+ protected static final String RESOURCE_TYPE = "resourceType";
+ protected static final String ORCHESTRATION_STATUS = "orchestrationStatus";
+ protected static final String TARGET_ACTION = "targetAction";
+ protected static final String REQUEST_SCOPE = "requestScope";
+ protected static final String IS_ALACARTE = "isALaCarte";
+ protected static final String CLOUD_OWNER = "cloudOwner";
+ protected static final String FLOW_NAME = "flowName";
+ protected static final String ERROR_MESSAGE = "errorMessage";
+ protected static final String SERVICE_ROLE = "serviceRole";
+ protected static final String SERVICE_TYPE = "serviceType";
+ protected static final String VNF_TYPE = "vnfType";
+ protected static final String ERROR_CODE = "errorCode";
+ protected static final String WORK_STEP = "workStep";
+ protected static final String CLLI = "clli";
+ protected static final String CLOUD_VERSION = "cloudVersion";
+ protected static final String HOMING_INSTANCE = "/homingInstance";
+ protected static final String ARTIFACT_UUID = "artifactUUID";
+ protected static final String SOURCE = "source";
private static final String TARGET_ENTITY = "SO:CatalogDB";
private static final String ASTERISK = "*";
@@ -820,7 +820,7 @@ public class CatalogDbClient {
return client.get(uri);
}
- private <T> List<T> getMultipleResources(Client<T> client, URI uri) {
+ protected <T> List<T> getMultipleResources(Client<T> client, URI uri) {
Iterable<T> iterator = client.getAll(uri);
List<T> list = new ArrayList<>();
Iterator<T> it = iterator.iterator();
diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java
index d87ed517f4..66fc0f5dc5 100644
--- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java
+++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java
@@ -19,42 +19,33 @@
*/
package org.onap.so.db.catalog.client;
+
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.verify;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.EntityNotFoundException;
-import org.junit.Before;
+import javax.ws.rs.core.UriBuilder;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.ArgumentMatchers;
-import org.powermock.api.mockito.PowerMockito;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
+import org.mockito.Spy;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.so.db.catalog.beans.CvnfcCustomization;
import org.onap.so.db.catalog.beans.VfModuleCustomization;
import org.onap.so.db.catalog.beans.VnfResourceCustomization;
-import uk.co.blackpepper.bowman.Client;
import org.onap.so.db.catalog.beans.Workflow;
+import uk.co.blackpepper.bowman.Client;
-@RunWith(PowerMockRunner.class)
-@PrepareForTest(CatalogDbClient.class)
+@RunWith(MockitoJUnitRunner.class)
public class CatalogDbClientTest {
+ @Spy
private CatalogDbClient catalogDbClient;
-
- private CatalogDbClient mockedCatalogDbClient;
-
- @Before
- public void init() {
- catalogDbClient = new CatalogDbClient();
- mockedCatalogDbClient = PowerMockito.spy(catalogDbClient);
- }
-
@Rule
public ExpectedException thrown = ExpectedException.none();
@@ -190,19 +181,13 @@ public class CatalogDbClientTest {
@Test
public final void testFindWorkflowByPnfModelUUID() throws Exception {
String pnfResourceModelUUID = "f2d1f2b2-88bb-49da-b716-36ae420ccbff";
- Workflow wf = new Workflow();
- wf.setArtifactUUID("b2fd5627-55e4-4f4f-8064-9e6f443e9152");
- wf.setArtifactName("DummyPnfWorkflow");
- wf.setVersion(1.0);
- List<Workflow> wfList = new ArrayList<Workflow>();
- wfList.add(wf);
-
- PowerMockito.doReturn(wfList).when(mockedCatalogDbClient, "getMultipleResources",
- ArgumentMatchers.<Client<Workflow>>any(), ArgumentMatchers.anyObject());
- List<Workflow> results = mockedCatalogDbClient.findWorkflowByPnfModelUUID(pnfResourceModelUUID);
- assertEquals(wf.getArtifactUUID(), results.get(0).getArtifactUUID());
- assertEquals(wf.getArtifactName(), results.get(0).getArtifactName());
- assertEquals(wf.getVersion(), results.get(0).getVersion());
+
+ doReturn(new ArrayList()).when(catalogDbClient).getMultipleResources(any(), any());
+ List<Workflow> results = catalogDbClient.findWorkflowByPnfModelUUID(pnfResourceModelUUID);
+ verify(catalogDbClient).getMultipleResources(any(Client.class),
+ eq(UriBuilder.fromUri("/findWorkflowByPnfModelUUID")
+ .queryParam(CatalogDbClient.PNF_RESOURCE_MODEL_UUID, pnfResourceModelUUID).build()));
+
}
}
diff --git a/pom.xml b/pom.xml
index 12d5040aed..9e27d8cf23 100644
--- a/pom.xml
+++ b/pom.xml
@@ -58,7 +58,7 @@
<docker.buildArg.project_version>${project.version}</docker.buildArg.project_version>
<docker.buildArg.artifact_id>${project.artifactId}</docker.buildArg.artifact_id>
<docker.buildArg.docker_repository>${dockerPullRepo}</docker.buildArg.docker_repository>
- <enforcer.skip>true</enforcer.skip>
+ <enforcer.skip>false</enforcer.skip>
<nexusproxy>https://nexus.onap.org</nexusproxy>
<releaseNexusPath>content/repositories/releases/</releaseNexusPath>
<snapshotNexusPath>content/repositories/snapshots/</snapshotNexusPath>
@@ -497,6 +497,42 @@
</dependency>
</dependencies>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-enforcer-plugin</artifactId>
+ <version>3.0.0-M3</version>
+ <executions>
+ <execution>
+ <id>enforce-property</id>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </execution>
+ <execution>
+ <id>enforce-no-snapshots</id>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </execution>
+ <execution>
+ <id>enforce-banned-dependencies</id>
+ <goals>
+ <goal>enforce</goal>
+ </goals>
+ <configuration>
+ <rules>
+ <bannedDependencies>
+ <excludes>
+ <exclude>org.powermock</exclude>
+ </excludes>
+ <searchTransitive>false</searchTransitive>
+ </bannedDependencies>
+ </rules>
+ <fail>true</fail>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
<pluginManagement>
<plugins>