aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks/src/test
diff options
context:
space:
mode:
authorJoanna Jeremicz <joanna.jeremicz@nokia.com>2020-01-21 13:30:45 +0100
committerJoanna Jeremicz <joanna.jeremicz@nokia.com>2020-01-29 07:57:39 +0100
commit76a37d03413fd1798e50274c57566c0ed3d752e4 (patch)
tree73aa936f3c01f9e890d9460749e7c8faa5b85f3b /bpmn/so-bpmn-tasks/src/test
parent48cb43adc20ac10fa6f22c0e03fe2b6775d45b87 (diff)
AssignPnfBB connects PNF and service instance in AAI
Change-Id: I92ab4b45acb120d647ea3de7a455e2e873c12a72 Issue-ID: SO-2605 Signed-off-by: Joanna Jeremicz <joanna.jeremicz@nokia.com>
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/test')
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/BaseTaskTest.java6
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java18
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIPnfResourcesTest.java86
3 files changed, 110 insertions, 0 deletions
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/BaseTaskTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/BaseTaskTest.java
index 39efa6dc76..73896d7d6d 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/BaseTaskTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/BaseTaskTest.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2020 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
@@ -40,6 +42,7 @@ import org.onap.so.client.orchestration.AAICollectionResources;
import org.onap.so.client.orchestration.AAIConfigurationResources;
import org.onap.so.client.orchestration.AAIInstanceGroupResources;
import org.onap.so.client.orchestration.AAINetworkResources;
+import org.onap.so.client.orchestration.AAIPnfResources;
import org.onap.so.client.orchestration.AAIServiceInstanceResources;
import org.onap.so.client.orchestration.AAIVfModuleResources;
import org.onap.so.client.orchestration.AAIVnfResources;
@@ -69,6 +72,9 @@ public abstract class BaseTaskTest extends TestDataSetup {
protected AAIVnfResources aaiVnfResources;
@Mock
+ protected AAIPnfResources aaiPnfResources;
+
+ @Mock
protected AAIVfModuleResources aaiVfModuleResources;
@Mock
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java
index a8550d8df9..a8f47fc763 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2020 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
@@ -55,6 +57,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
import org.onap.so.bpmn.servicedecomposition.bbobjects.LineOfBusiness;
import org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Platform;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf;
import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup;
@@ -74,6 +77,7 @@ public class AAICreateTasksTest extends BaseTaskTest {
private ServiceInstance serviceInstance;
private L3Network network;
private GenericVnf genericVnf;
+ private Pnf pnf;
private VolumeGroup volumeGroup;
private CloudRegion cloudRegion;
private VfModule vfModule;
@@ -93,6 +97,7 @@ public class AAICreateTasksTest extends BaseTaskTest {
serviceInstance = setServiceInstance();
network = setL3Network();
genericVnf = setGenericVnf();
+ pnf = buildPnf();
volumeGroup = setVolumeGroup();
cloudRegion = setCloudRegion();
vfModule = setVfModule();
@@ -324,6 +329,19 @@ public class AAICreateTasksTest extends BaseTaskTest {
verify(aaiVnfResources, times(1)).createVnfandConnectServiceInstance(genericVnf, serviceInstance);
}
+ @Test
+ public void createPnfShouldCallCreatePnfAndConnectServiceInstance() throws BBObjectNotFoundException {
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.PNF))).thenReturn(pnf);
+ aaiCreateTasks.createPnf(execution);
+ verify(aaiPnfResources, times(1)).createPnfAndConnectServiceInstance(pnf, serviceInstance);
+ }
+
+ @Test
+ public void createPnfShouldThrowBpmnErrorWhenPnfIsNotFound() throws BBObjectNotFoundException {
+ expectedException.expect(BpmnError.class);
+ doThrow(BBObjectNotFoundException.class).when(extractPojosForBB).extractByKey(execution, ResourceKey.PNF);
+ aaiCreateTasks.createPnf(execution);
+ }
@Test
public void createVfModuleTest() throws Exception {
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIPnfResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIPnfResourcesTest.java
new file mode 100644
index 0000000000..a929f256ac
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIPnfResourcesTest.java
@@ -0,0 +1,86 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Nokia Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.client.orchestration;
+
+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.times;
+import static org.mockito.Mockito.verify;
+import java.util.Optional;
+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.so.bpmn.common.InjectionHelper;
+import org.onap.so.bpmn.common.data.TestDataSetup;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
+import org.onap.so.client.aai.AAIResourcesClient;
+import org.onap.so.client.aai.entities.uri.AAIResourceUri;
+import org.onap.so.client.aai.mapper.AAIObjectMapper;
+import org.onap.so.db.catalog.beans.OrchestrationStatus;
+
+@RunWith(MockitoJUnitRunner.Silent.class)
+public class AAIPnfResourcesTest extends TestDataSetup {
+
+ private Pnf pnf;
+ private ServiceInstance serviceInstance;
+
+ @Mock
+ protected AAIObjectMapper aaiObjectMapperMock;
+
+ @Mock
+ protected InjectionHelper injectionHelperMock;
+
+ @Mock
+ protected AAIResourcesClient aaiResourcesClientMock;
+
+ @InjectMocks
+ AAIPnfResources aaiPnfResources = new AAIPnfResources();
+
+ @Before
+ public void setUp() {
+ pnf = buildPnf();
+ pnf.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
+ serviceInstance = buildServiceInstance();
+
+ doReturn(aaiResourcesClientMock).when(injectionHelperMock).getAaiClient();
+ }
+
+ @Test
+ public void createPnfAndConnectServiceInstanceShouldSetInventoriedStatusAndCallConnectMethod() {
+ org.onap.aai.domain.yang.Pnf pnfYang = new org.onap.aai.domain.yang.Pnf();
+
+ doReturn(pnfYang).when(aaiObjectMapperMock).mapPnf(pnf);
+ doReturn(aaiResourcesClientMock).when(aaiResourcesClientMock).createIfNotExists(any(AAIResourceUri.class),
+ eq(Optional.of(pnfYang)));
+
+ aaiPnfResources.createPnfAndConnectServiceInstance(pnf, serviceInstance);
+
+ assertEquals(OrchestrationStatus.INVENTORIED, pnf.getOrchestrationStatus());
+ verify(aaiResourcesClientMock, times(1)).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
+ }
+
+}