From d230e3bf3495156651b39f03a2bc7e17324ce269 Mon Sep 17 00:00:00 2001 From: mharazin Date: Wed, 20 May 2020 12:55:36 +0200 Subject: Check if existing Pnf is related to service instance Issue-ID: SO-2937 Signed-off-by: Mateusz Harazin Change-Id: I3e1e8b7534c1ffa36b0383b52ca9ea547f5bac7e --- .../client/orchestration/AAIPnfResourcesTest.java | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'bpmn/so-bpmn-tasks/src/test/java/org/onap') 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 index 15c4b48d66..5e9b4c7592 100644 --- 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 @@ -29,7 +29,10 @@ import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import java.io.File; +import java.io.IOException; import java.util.Optional; +import com.fasterxml.jackson.databind.ObjectMapper; import joptsimple.internal.Strings; import org.junit.Before; import org.junit.Test; @@ -151,6 +154,27 @@ public class AAIPnfResourcesTest extends TestDataSetup { } } + @Test + public void existingPnfInAaiIsRelatedToService() throws IOException { + // given + final String relatedTo = "service-instance"; + final String serviceInstanceId = "service-instance-id"; + final String path = "src/test/resources/__files/BuildingBlocks/aaiPnf.json"; + org.onap.aai.domain.yang.Pnf pnfFromAai = + new ObjectMapper().readValue(new File(path), org.onap.aai.domain.yang.Pnf.class); + when(injectionHelperMock.getAaiClient().get(org.onap.aai.domain.yang.Pnf.class, + AAIUriFactory.createResourceUri(AAIObjectType.PNF, PNF_NAME))).thenReturn(Optional.of(pnfFromAai)); + // when + try { + testedObject.checkIfPnfExistsInAaiAndCanBeUsed(PNF_NAME); + } catch (Exception e) { + // then + assertThat(e.getMessage()).isEqualTo(String.format( + "Pnf with name %s exist with orchestration status %s and is related to %s service with certain service-instance-id: %s", + PNF_NAME, OrchestrationStatus.ACTIVE, relatedTo, serviceInstanceId)); + } + } + private org.onap.aai.domain.yang.Pnf createPnf(String orchestrationStatus) { org.onap.aai.domain.yang.Pnf pnfFromAai = new org.onap.aai.domain.yang.Pnf(); pnfFromAai.setPnfName(PNF_NAME); -- cgit 1.2.3-korg