diff options
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra/src/test')
18 files changed, 1390 insertions, 22 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/MsoRequestTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/MsoRequestTest.java index bc10aa744e..86bf8060a7 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/MsoRequestTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/MsoRequestTest.java @@ -24,13 +24,11 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import java.io.IOException; import java.io.StringReader; -import java.net.URL; import java.nio.file.Files; import java.nio.file.Paths; import java.util.Arrays; import java.util.Collection; import java.util.HashMap; -import java.util.Optional; import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.Response; import javax.xml.parsers.DocumentBuilder; @@ -46,13 +44,13 @@ import org.onap.so.exceptions.ValidationException; import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; import org.springframework.test.context.junit4.rules.SpringClassRule; import org.springframework.test.context.junit4.rules.SpringMethodRule; +import org.w3c.dom.Document; +import org.xml.sax.InputSource; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import junitparams.JUnitParamsRunner; import junitparams.Parameters; -import org.w3c.dom.Document; -import org.xml.sax.InputSource; @RunWith(JUnitParamsRunner.class) public class MsoRequestTest extends BaseTest { @@ -1062,20 +1060,5 @@ public class MsoRequestTest extends BaseTest { assertNotNull(result); } - @Test - public void buildSelfLinkUrlTest() throws Exception { - // v - version - String incomingUrl = "http://localhost:8080/onap/infra/so/serviceInstantiation/v7/serviceInstances"; - String expectedSelfLink = "http://localhost:8080/orchestrationRequests/v7/efce3167-5e45-4666-9d4d-22e23648e5d1"; - String requestId = "efce3167-5e45-4666-9d4d-22e23648e5d1"; - this.msoRequest = new MsoRequest(); - Optional<URL> actualSelfLinkUrl = msoRequest.buildSelfLinkUrl(incomingUrl, requestId); - assertEquals(expectedSelfLink, actualSelfLinkUrl.get().toString()); - // V - Version - String incomingUrlV = "http://localhost:8080/onap/infra/so/serviceInstantiation/V7/serviceInstances"; - String expectedSelfLinkV = - "http://localhost:8080/orchestrationRequests/V7/efce3167-5e45-4666-9d4d-22e23648e5d1"; - Optional<URL> actualSelfLinkUrlV = msoRequest.buildSelfLinkUrl(incomingUrlV, requestId); - assertEquals(expectedSelfLinkV, actualSelfLinkUrlV.get().toString()); - } + } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsTest.java index dc0cd473c2..62a6f44a63 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsTest.java @@ -38,7 +38,6 @@ import java.net.URL; import java.nio.file.Files; import java.nio.file.Paths; import java.util.List; -import javax.ws.rs.container.ContainerRequestContext; import javax.ws.rs.core.MediaType; import org.apache.http.HttpStatus; import org.junit.Before; @@ -50,6 +49,7 @@ import org.onap.so.db.catalog.beans.Service; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.logger.HttpHeadersConstants; import org.onap.so.serviceinstancebeans.ModelInfo; +import org.onap.so.serviceinstancebeans.ModelType; import org.onap.so.serviceinstancebeans.RequestDetails; import org.onap.so.serviceinstancebeans.RequestInfo; import org.onap.so.serviceinstancebeans.RequestParameters; diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java index ea43a54e69..b72e5124d1 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java @@ -67,6 +67,7 @@ import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.logger.HttpHeadersConstants; import org.onap.so.serviceinstancebeans.CloudConfiguration; import org.onap.so.serviceinstancebeans.ModelInfo; +import org.onap.so.serviceinstancebeans.ModelType; import org.onap.so.serviceinstancebeans.RequestDetails; import org.onap.so.serviceinstancebeans.RequestError; import org.onap.so.serviceinstancebeans.RequestInfo; @@ -90,7 +91,6 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.github.tomakehurst.wiremock.http.Fault; import ch.qos.logback.classic.spi.ILoggingEvent; - public class ServiceInstancesTest extends BaseTest { private final ObjectMapper mapper = new ObjectMapper(); @@ -2947,4 +2947,15 @@ public class ServiceInstancesTest extends BaseTest { Actions action = servInstances.handleReplaceInstance(Action.replaceInstance, sir); assertEquals(Action.replaceInstanceRetainAssignments, action); } + /* + * @Test public void buildSelfLinkUrlTest() throws Exception { // v - version String incomingUrl = + * "http://localhost:8080/onap/infra/so/serviceInstantiation/v7/serviceInstances"; String expectedSelfLink = + * "http://localhost:8080/orchestrationRequests/v7/efce3167-5e45-4666-9d4d-22e23648e5d1"; String requestId = + * "efce3167-5e45-4666-9d4d-22e23648e5d1"; Optional<URL> actualSelfLinkUrl = buildSelfLinkUrl(incomingUrl, + * requestId); assertEquals(expectedSelfLink, actualSelfLinkUrl.get().toString()); // V - Version String + * incomingUrlV = "http://localhost:8080/onap/infra/so/serviceInstantiation/V7/serviceInstances"; String + * expectedSelfLinkV = "http://localhost:8080/orchestrationRequests/V7/efce3167-5e45-4666-9d4d-22e23648e5d1"; + * Optional<URL> actualSelfLinkUrlV = buildSelfLinkUrl(incomingUrlV, requestId); assertEquals(expectedSelfLinkV, + * actualSelfLinkUrlV.get().toString()); } + */ } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/BpmnRequestBuilderTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/BpmnRequestBuilderTest.java new file mode 100644 index 0000000000..3644dd8e7f --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/BpmnRequestBuilderTest.java @@ -0,0 +1,140 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T 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.apihandlerinfra.infra.rest; + +import static com.shazam.shazamcrest.MatcherAssert.assertThat; +import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; +import static org.mockito.Mockito.doReturn; +import java.io.File; +import java.util.Optional; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Spy; +import org.mockito.junit.MockitoJUnitRunner; +import org.onap.aai.domain.yang.GenericVnf; +import org.onap.aai.domain.yang.ServiceInstance; +import org.onap.aai.domain.yang.VfModule; +import org.onap.aai.domain.yang.VolumeGroup; +import org.onap.so.client.aai.AAIObjectType; +import org.onap.so.client.aai.AAIResourcesClient; +import org.onap.so.client.aai.entities.uri.AAIUriFactory; +import org.onap.so.client.graphinventory.GraphInventoryCommonObjectMapperProvider; +import org.onap.so.db.request.client.RequestsDbClient; +import org.onap.so.serviceinstancebeans.ModelType; +import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; +import com.fasterxml.jackson.databind.ObjectMapper; + +@RunWith(MockitoJUnitRunner.class) +public class BpmnRequestBuilderTest { + + private static final String RESOURCE_PATH = "src/test/resources/__files/infra/"; + + @Rule + public ExpectedException exceptionRule = ExpectedException.none(); + + @InjectMocks + @Spy + BpmnRequestBuilder reqBuilder; + + @Mock + private RequestsDbClient requestDBClient; + + @Mock + private AAIResourcesClient aaiResourcesClient; + + private ObjectMapper mapper = new ObjectMapper(); + + private GraphInventoryCommonObjectMapperProvider provider = new GraphInventoryCommonObjectMapperProvider(); + + @Before + public void setup() { + reqBuilder.setAaiResourcesClient(aaiResourcesClient); + + } + + @Test + public void test_buildServiceInstanceDeleteRequest() throws Exception { + ServiceInstance service = + provider.getMapper().readValue(new File(RESOURCE_PATH + "ServiceInstance.json"), ServiceInstance.class); + + doReturn(service).when(reqBuilder).getServiceInstance("serviceId"); + ServiceInstancesRequest expectedRequest = mapper + .readValue(new File(RESOURCE_PATH + "ExpectedServiceRequest.json"), ServiceInstancesRequest.class); + expectedRequest.getRequestDetails().getModelInfo().setModelId(null); + // bad getter/setter setting multiple fields + ServiceInstancesRequest actualRequest = reqBuilder.buildServiceDeleteRequest("serviceId"); + assertThat(actualRequest, sameBeanAs(expectedRequest)); + } + + @Test + public void test_buildVnfDeleteRequest() throws Exception { + GenericVnf vnf = provider.getMapper().readValue(new File(RESOURCE_PATH + "Vnf.json"), GenericVnf.class); + + doReturn(Optional.of(vnf)).when(aaiResourcesClient).get(GenericVnf.class, + AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "vnfId")); + + ServiceInstancesRequest expectedRequest = + mapper.readValue(new File(RESOURCE_PATH + "ExpectedVnfRequest.json"), ServiceInstancesRequest.class); + ServiceInstancesRequest actualRequest = reqBuilder.buildVnfDeleteRequest("vnfId"); + assertThat(actualRequest, sameBeanAs(expectedRequest)); + } + + @Test + public void test_buildVFModuleDeleteRequest() throws Exception { + GenericVnf vnf = provider.getMapper().readValue(new File(RESOURCE_PATH + "Vnf.json"), GenericVnf.class); + + doReturn(Optional.of(vnf)).when(aaiResourcesClient).get(GenericVnf.class, + AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "vnfId")); + VfModule vfModule = provider.getMapper().readValue(new File(RESOURCE_PATH + "VfModule.json"), VfModule.class); + + doReturn(Optional.of(vfModule)).when(aaiResourcesClient).get(VfModule.class, + AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, "vnfId", "vfModuleId")); + + ServiceInstancesRequest expectedRequest = mapper + .readValue(new File(RESOURCE_PATH + "ExpectedVfModuleRequest.json"), ServiceInstancesRequest.class); + ServiceInstancesRequest actualRequest = + reqBuilder.buildVFModuleDeleteRequest("vnfId", "vfModuleId", ModelType.vfModule); + assertThat(actualRequest, sameBeanAs(expectedRequest)); + } + + @Test + public void test_buildVolumeGroupDeleteRequest() throws Exception { + GenericVnf vnf = provider.getMapper().readValue(new File(RESOURCE_PATH + "Vnf.json"), GenericVnf.class); + + doReturn(Optional.of(vnf)).when(aaiResourcesClient).get(GenericVnf.class, + AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "vnfId")); + VolumeGroup volumeGroup = + provider.getMapper().readValue(new File(RESOURCE_PATH + "VolumeGroup.json"), VolumeGroup.class); + + doReturn(Optional.of(volumeGroup)).when(aaiResourcesClient).get(VolumeGroup.class, AAIUriFactory + .createResourceUri(AAIObjectType.VOLUME_GROUP, "cloudOwner", "regionOne", "volumeGroupId")); + + ServiceInstancesRequest expectedRequest = mapper + .readValue(new File(RESOURCE_PATH + "ExpectedVolumeGroupRequest.json"), ServiceInstancesRequest.class); + ServiceInstancesRequest actualRequest = reqBuilder.buildVolumeGroupDeleteRequest("vnfId", "volumeGroupId"); + assertThat(actualRequest, sameBeanAs(expectedRequest)); + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/AbstractRestHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/AbstractRestHandlerTest.java new file mode 100644 index 0000000000..d39192cdf0 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/AbstractRestHandlerTest.java @@ -0,0 +1,64 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T 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.apihandlerinfra.infra.rest.handler; + +import static com.shazam.shazamcrest.MatcherAssert.assertThat; +import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; +import static org.mockito.Mockito.doReturn; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Optional; +import javax.ws.rs.container.ContainerRequestContext; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.Spy; +import org.mockito.junit.MockitoJUnitRunner; +import org.onap.so.apihandlerinfra.infra.rest.handler.AbstractRestHandler; +import org.onap.so.serviceinstancebeans.RequestReferences; +import org.onap.so.serviceinstancebeans.ServiceInstancesResponse; + +@RunWith(MockitoJUnitRunner.class) +public class AbstractRestHandlerTest { + + @Spy + AbstractRestHandler restHandler; + + @Mock + ContainerRequestContext mockRequestContext; + + @Test + public void test_createResponse() throws MalformedURLException { + ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); + RequestReferences requestReferences = new RequestReferences(); + URL selfLinkURL = new URL("http://localhost:8080/v1"); + requestReferences.setInstanceId("instanceId"); + requestReferences.setRequestId("requestId"); + requestReferences.setRequestSelfLink(selfLinkURL); + expectedResponse.setRequestReferences(requestReferences); + + doReturn("http://localhost:8080/v1").when(restHandler).getRequestUri(mockRequestContext); + doReturn(Optional.of(selfLinkURL)).when(restHandler).buildSelfLinkUrl("http://localhost:8080/v1", "requestId"); + ServiceInstancesResponse actualResponse = + restHandler.createResponse("instanceId", "requestId", mockRequestContext); + assertThat(actualResponse, sameBeanAs(expectedResponse)); + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/NetworkRestHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/NetworkRestHandlerTest.java new file mode 100644 index 0000000000..8ff7517da8 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/NetworkRestHandlerTest.java @@ -0,0 +1,143 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T 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.apihandlerinfra.infra.rest.handler; + +import static com.shazam.shazamcrest.MatcherAssert.assertThat; +import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; +import static org.junit.Assert.assertEquals; +import static org.mockito.ArgumentMatchers.eq; +import java.net.MalformedURLException; +import java.util.HashMap; +import java.util.Map; +import javax.ws.rs.container.ContainerRequestContext; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.junit.runner.RunWith; +import org.mockito.ArgumentCaptor; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.junit.MockitoJUnitRunner; +import org.onap.so.apihandler.common.RequestClientParameter; +import org.onap.so.apihandlerinfra.Action; +import org.onap.so.apihandlerinfra.Constants; +import org.onap.so.apihandlerinfra.Status; +import org.onap.so.apihandlerinfra.infra.rest.exception.NoRecipeException; +import org.onap.so.apihandlerinfra.infra.rest.handler.NetworkRestHandler; +import org.onap.so.db.catalog.client.CatalogDbClient; +import org.onap.so.db.request.beans.InfraActiveRequests; +import org.onap.so.db.request.client.RequestsDbClient; +import org.onap.so.serviceinstancebeans.ModelType; +import org.onap.so.serviceinstancebeans.RequestDetails; +import org.onap.so.serviceinstancebeans.RequestInfo; +import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; +import com.fasterxml.jackson.databind.ObjectMapper; + +@RunWith(MockitoJUnitRunner.class) +public class NetworkRestHandlerTest { + + @Rule + public ExpectedException exceptionRule = ExpectedException.none(); + + @InjectMocks + NetworkRestHandler restHandler; + + @Mock + ContainerRequestContext mockRequestContext; + + @Mock + private CatalogDbClient catalogDbClient; + + @Mock + private RequestsDbClient infraActiveRequestsClient; + + private ObjectMapper mapper = new ObjectMapper(); + + @Test + public void test_checkDuplicateRequest() throws MalformedURLException, NoRecipeException { + ArgumentCaptor<HashMap> instanceIdCaptor = ArgumentCaptor.forClass(HashMap.class); + restHandler.checkDuplicateRequest("serviceInstanceId", "networkId", "instanceName", "requestId"); + Mockito.verify(infraActiveRequestsClient, Mockito.times(1)).checkInstanceNameDuplicate( + instanceIdCaptor.capture(), eq("instanceName"), eq(ModelType.network.toString())); + Map actualMap = instanceIdCaptor.getValue(); + assertEquals("ServiceInstanceID should exist in map", "serviceInstanceId", actualMap.get("serviceInstanceId")); + assertEquals("NetworkId should exit in map", "networkId", actualMap.get("networkInstanceId")); + } + + @Test + public void test_saveInstanceName() throws MalformedURLException, NoRecipeException { + ServiceInstancesRequest request = createTestRequest(); + InfraActiveRequests dbRequest = createDatabaseRecord(); + restHandler.saveInstanceName(request, dbRequest); + Mockito.verify(infraActiveRequestsClient, Mockito.times(1)).updateInfraActiveRequests(dbRequest); + assertEquals("InstanceName Should Be Equal", "instanceName", dbRequest.getNetworkName()); + } + + @Test + public void test_buildRequestParams() throws Exception { + RequestClientParameter expected = new RequestClientParameter.Builder().setRequestId("requestId") + .setServiceInstanceId("serviceInstanceId").setNetworkId("networkId").setALaCarte(true) + .setRequestDetails(mapper.writeValueAsString(createTestRequest())) + .setRequestAction(Action.deleteInstance.toString()) + .setRequestUri("http://localhost:8080/serviceInstances").setApiVersion("v8").build(); + RequestClientParameter actual = restHandler.buildRequestParams(createTestRequest(), + "http://localhost:8080/serviceInstances", "requestId", "serviceInstanceId", "networkId"); + assertThat(actual, sameBeanAs(expected)); + } + + @Test + public void test_createInfraActiveRequestForDelete() throws Exception { + InfraActiveRequests expected = new InfraActiveRequests(); + expected.setRequestAction(Action.deleteInstance.toString()); + expected.setAction(Action.deleteInstance.toString()); + expected.setServiceInstanceId("serviceInstanceId"); + expected.setNetworkId("networkId"); + expected.setRequestId("requestId"); + expected.setRequestorId("userId"); + expected.setSource("VID"); + expected.setRequestStatus(Status.IN_PROGRESS.toString()); + expected.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER); + expected.setRequestScope(ModelType.network.toString()); + expected.setRequestUrl("http://localhost:9090"); + InfraActiveRequests actual = restHandler.createInfraActiveRequestForDelete("requestId", "serviceInstanceId", + "networkId", "userId", "VID", "http://localhost:9090"); + assertThat(actual, sameBeanAs(expected).ignoring("startTime")); + Mockito.verify(infraActiveRequestsClient, Mockito.times(1)).save(actual); + } + + private ServiceInstancesRequest createTestRequest() { + ServiceInstancesRequest request = new ServiceInstancesRequest(); + RequestDetails requestDetails = new RequestDetails(); + RequestInfo requestInfo = new RequestInfo(); + requestInfo.setInstanceName("instanceName"); + requestDetails.setRequestInfo(requestInfo); + request.setRequestDetails(requestDetails); + return request; + } + + private InfraActiveRequests createDatabaseRecord() { + InfraActiveRequests request = new InfraActiveRequests(); + request.setRequestId("requestId"); + return request; + } + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/ServiceInstanceRestHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/ServiceInstanceRestHandlerTest.java new file mode 100644 index 0000000000..56d57aa2d5 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/ServiceInstanceRestHandlerTest.java @@ -0,0 +1,189 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T 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.apihandlerinfra.infra.rest.handler; + +import static com.shazam.shazamcrest.MatcherAssert.assertThat; +import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; +import static org.junit.Assert.assertEquals; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doReturn; +import java.net.MalformedURLException; +import java.util.HashMap; +import java.util.Map; +import javax.ws.rs.container.ContainerRequestContext; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.junit.runner.RunWith; +import org.mockito.ArgumentCaptor; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.junit.MockitoJUnitRunner; +import org.onap.so.apihandler.common.RequestClientParameter; +import org.onap.so.apihandlerinfra.Action; +import org.onap.so.apihandlerinfra.Constants; +import org.onap.so.apihandlerinfra.Status; +import org.onap.so.apihandlerinfra.infra.rest.exception.NoRecipeException; +import org.onap.so.apihandlerinfra.infra.rest.exception.RequestConflictedException; +import org.onap.so.apihandlerinfra.infra.rest.handler.ServiceInstanceRestHandler; +import org.onap.so.db.catalog.beans.Recipe; +import org.onap.so.db.catalog.beans.ServiceRecipe; +import org.onap.so.db.catalog.client.CatalogDbClient; +import org.onap.so.db.request.beans.InfraActiveRequests; +import org.onap.so.db.request.client.RequestsDbClient; +import org.onap.so.serviceinstancebeans.ModelType; +import org.onap.so.serviceinstancebeans.RequestDetails; +import org.onap.so.serviceinstancebeans.RequestInfo; +import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; +import com.fasterxml.jackson.databind.ObjectMapper; + +@RunWith(MockitoJUnitRunner.class) +public class ServiceInstanceRestHandlerTest { + + @Rule + public ExpectedException exceptionRule = ExpectedException.none(); + + @InjectMocks + ServiceInstanceRestHandler restHandler; + + @Mock + ContainerRequestContext mockRequestContext; + + @Mock + private CatalogDbClient catalogDbClient; + + @Mock + private RequestsDbClient infraActiveRequestsClient; + + private ObjectMapper mapper = new ObjectMapper(); + + @Test + public void test_find_service_recipe() throws MalformedURLException, NoRecipeException { + ServiceRecipe expected = new ServiceRecipe(); + expected.setAction("createInstance"); + doReturn(expected).when(catalogDbClient) + .findServiceRecipeByActionAndServiceModelUUID(Action.createInstance.toString(), "testModelId"); + Recipe actual = restHandler.findServiceRecipe("testModelId", Action.createInstance.toString()); + assertThat(actual, sameBeanAs(expected)); + Mockito.verify(catalogDbClient, Mockito.times(1)) + .findServiceRecipeByActionAndServiceModelUUID(Action.createInstance.toString(), "testModelId"); + } + + @Test + public void test_find_service_recipe_default_recipe() throws MalformedURLException, NoRecipeException { + ServiceRecipe expected = new ServiceRecipe(); + expected.setAction("createInstance"); + doReturn(null).when(catalogDbClient) + .findServiceRecipeByActionAndServiceModelUUID(Action.createInstance.toString(), "testModelId"); + doReturn(expected).when(catalogDbClient).findServiceRecipeByActionAndServiceModelUUID( + Action.createInstance.toString(), "d88da85c-d9e8-4f73-b837-3a72a431622b"); + Recipe actual = restHandler.findServiceRecipe("testModelId", Action.createInstance.toString()); + assertThat(actual, sameBeanAs(expected)); + Mockito.verify(catalogDbClient, Mockito.times(1)) + .findServiceRecipeByActionAndServiceModelUUID(Action.createInstance.toString(), "testModelId"); + Mockito.verify(catalogDbClient, Mockito.times(1)).findServiceRecipeByActionAndServiceModelUUID( + Action.createInstance.toString(), "d88da85c-d9e8-4f73-b837-3a72a431622b"); + } + + @Test + public void test_find_service_recipe_not_found() throws MalformedURLException, NoRecipeException { + ServiceRecipe expected = new ServiceRecipe(); + expected.setAction("createInstance"); + doReturn(null).when(catalogDbClient) + .findServiceRecipeByActionAndServiceModelUUID(Action.createInstance.toString(), "testModelId"); + doReturn(null).when(catalogDbClient).findServiceRecipeByActionAndServiceModelUUID( + Action.createInstance.toString(), "d88da85c-d9e8-4f73-b837-3a72a431622b"); + exceptionRule.expect(NoRecipeException.class); + exceptionRule.expectMessage( + "Unable to locate custom or default recipe for, Action: createInstance, Model UUID: testModelId"); + restHandler.findServiceRecipe("testModelId", Action.createInstance.toString()); + } + + @Test + public void test_checkDuplicateRequest() + throws MalformedURLException, NoRecipeException, RequestConflictedException { + ArgumentCaptor<HashMap> instanceIdCaptor = ArgumentCaptor.forClass(HashMap.class); + restHandler.checkDuplicateRequest("serviceInstanceId", "instanceName", "requestId"); + Mockito.verify(infraActiveRequestsClient, Mockito.times(1)).checkInstanceNameDuplicate( + instanceIdCaptor.capture(), eq("instanceName"), eq(ModelType.service.toString())); + Map actualMap = instanceIdCaptor.getValue(); + assertEquals("serviceInstanceId", actualMap.get("serviceInstanceId")); + } + + @Test + public void test_saveInstanceName() throws MalformedURLException, NoRecipeException { + ServiceInstancesRequest request = createTestRequest(); + InfraActiveRequests dbRequest = createDatabaseRecord(); + restHandler.saveInstanceName(request, dbRequest); + Mockito.verify(infraActiveRequestsClient, Mockito.times(1)).updateInfraActiveRequests(dbRequest); + assertEquals("InstanceName Should Be Equal", "instanceName", dbRequest.getServiceInstanceName()); + } + + @Test + public void test_buildRequestParams() throws Exception { + RequestClientParameter expected = + new RequestClientParameter.Builder().setRequestId("requestId").setServiceInstanceId("serviceInstanceId") + .setALaCarte(true).setRequestDetails(mapper.writeValueAsString(createTestRequest())) + .setRequestAction(Action.deleteInstance.toString()) + .setRequestUri("http://localhost:8080/serviceInstances").setApiVersion("v8").build(); + RequestClientParameter actual = restHandler.buildRequestParams(createTestRequest(), + "http://localhost:8080/serviceInstances", "requestId", "serviceInstanceId"); + assertThat(actual, sameBeanAs(expected)); + } + + @Test + public void test_createInfraActiveRequestForDelete() throws Exception { + InfraActiveRequests expected = new InfraActiveRequests(); + expected.setRequestAction(Action.deleteInstance.toString()); + expected.setAction(Action.deleteInstance.toString()); + expected.setServiceInstanceId("serviceInstanceId"); + expected.setRequestId("requestId"); + expected.setRequestorId("userId"); + expected.setSource("VID"); + expected.setRequestStatus(Status.IN_PROGRESS.toString()); + expected.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER); + expected.setRequestUrl("http://localhost:9090"); + expected.setRequestScope(ModelType.service.toString()); + InfraActiveRequests actual = restHandler.createInfraActiveRequestForDelete("requestId", "serviceInstanceId", + "userId", "VID", "http://localhost:9090"); + assertThat(actual, sameBeanAs(expected).ignoring("startTime")); + Mockito.verify(infraActiveRequestsClient, Mockito.times(1)).save(actual); + } + + private ServiceInstancesRequest createTestRequest() { + + ServiceInstancesRequest request = new ServiceInstancesRequest(); + RequestDetails requestDetails = new RequestDetails(); + RequestInfo requestInfo = new RequestInfo(); + requestInfo.setInstanceName("instanceName"); + requestDetails.setRequestInfo(requestInfo); + request.setRequestDetails(requestDetails); + return request; + } + + private InfraActiveRequests createDatabaseRecord() { + InfraActiveRequests request = new InfraActiveRequests(); + request.setRequestId("requestId"); + return request; + } + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/VfModuleRestHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/VfModuleRestHandlerTest.java new file mode 100644 index 0000000000..280ae9c071 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/VfModuleRestHandlerTest.java @@ -0,0 +1,190 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T 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.apihandlerinfra.infra.rest.handler; + +import static com.shazam.shazamcrest.MatcherAssert.assertThat; +import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; +import static org.junit.Assert.assertEquals; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doReturn; +import java.net.MalformedURLException; +import java.util.HashMap; +import java.util.Map; +import javax.ws.rs.container.ContainerRequestContext; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.junit.runner.RunWith; +import org.mockito.ArgumentCaptor; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.junit.MockitoJUnitRunner; +import org.onap.so.apihandler.common.RequestClientParameter; +import org.onap.so.apihandlerinfra.Action; +import org.onap.so.apihandlerinfra.Constants; +import org.onap.so.apihandlerinfra.Status; +import org.onap.so.apihandlerinfra.infra.rest.exception.NoRecipeException; +import org.onap.so.apihandlerinfra.infra.rest.handler.VFModuleRestHandler; +import org.onap.so.db.catalog.beans.Recipe; +import org.onap.so.db.catalog.beans.VnfComponentsRecipe; +import org.onap.so.db.catalog.client.CatalogDbClient; +import org.onap.so.db.request.beans.InfraActiveRequests; +import org.onap.so.db.request.client.RequestsDbClient; +import org.onap.so.serviceinstancebeans.ModelType; +import org.onap.so.serviceinstancebeans.RequestDetails; +import org.onap.so.serviceinstancebeans.RequestInfo; +import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; +import com.fasterxml.jackson.databind.ObjectMapper; + +@RunWith(MockitoJUnitRunner.class) +public class VfModuleRestHandlerTest { + + @Rule + public ExpectedException exceptionRule = ExpectedException.none(); + + @InjectMocks + VFModuleRestHandler restHandler; + + @Mock + ContainerRequestContext mockRequestContext; + + @Mock + private CatalogDbClient catalogDbClient; + + @Mock + private RequestsDbClient infraActiveRequestsClient; + + private ObjectMapper mapper = new ObjectMapper(); + + @Test + public void test_find_vf_module_recipe() throws MalformedURLException, NoRecipeException { + VnfComponentsRecipe expected = new VnfComponentsRecipe(); + expected.setAction("createInstance"); + doReturn(expected).when(catalogDbClient) + .getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction("testModelId", + ModelType.vfModule.toString(), Action.createInstance.toString()); + Recipe actual = restHandler.findVfModuleRecipe("testModelId", ModelType.vfModule.toString(), + Action.createInstance.toString()); + assertThat(actual, sameBeanAs(expected)); + Mockito.verify(catalogDbClient, Mockito.times(1)) + .getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction("testModelId", + ModelType.vfModule.toString(), Action.createInstance.toString()); + } + + @Test + public void test_find_vf_module_recipe_default_recipe() throws MalformedURLException, NoRecipeException { + VnfComponentsRecipe expected = new VnfComponentsRecipe(); + expected.setAction("createInstance"); + doReturn(null).when(catalogDbClient).getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction( + "testModelId", ModelType.vfModule.toString(), Action.createInstance.toString()); + doReturn(expected).when(catalogDbClient) + .getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction("GR-API-DEFAULT", + ModelType.vfModule.toString(), Action.createInstance.toString()); + Recipe actual = restHandler.findVfModuleRecipe("testModelId", ModelType.vfModule.toString(), + Action.createInstance.toString()); + assertThat(actual, sameBeanAs(expected)); + Mockito.verify(catalogDbClient, Mockito.times(1)) + .getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction("testModelId", + ModelType.vfModule.toString(), Action.createInstance.toString()); + } + + @Test + public void test_find_vf_module_recipe_not_found() throws MalformedURLException, NoRecipeException { + VnfComponentsRecipe expected = new VnfComponentsRecipe(); + expected.setAction("createInstance"); + exceptionRule.expect(NoRecipeException.class); + exceptionRule.expectMessage( + "Unable to locate custom or default recipe for ModelType: vfModule , Action: createInstance, CustomizationId: testModelId"); + restHandler.findVfModuleRecipe("testModelId", ModelType.vfModule.toString(), Action.createInstance.toString()); + } + + @Test + public void test_checkDuplicateRequest() throws MalformedURLException, NoRecipeException { + ArgumentCaptor<HashMap> instanceIdCaptor = ArgumentCaptor.forClass(HashMap.class); + restHandler.checkDuplicateRequest("serviceInstanceId", "vnfId", "vfModuleId", "instanceName", "requestId"); + Mockito.verify(infraActiveRequestsClient, Mockito.times(1)).checkInstanceNameDuplicate( + instanceIdCaptor.capture(), eq("instanceName"), eq(ModelType.vfModule.toString())); + Map actualMap = instanceIdCaptor.getValue(); + assertEquals("ServiceInstanceID should exist in map", "serviceInstanceId", actualMap.get("serviceInstanceId")); + assertEquals("VnfId should exit in map", "vnfId", actualMap.get("vnfInstanceId")); + assertEquals("VFModuleId should exit in map", "vfModuleId", actualMap.get("vfModuleInstanceId")); + } + + @Test + public void test_saveInstanceName() throws MalformedURLException, NoRecipeException { + ServiceInstancesRequest request = createTestRequest(); + InfraActiveRequests dbRequest = createDatabaseRecord(); + restHandler.saveInstanceName(request, dbRequest); + Mockito.verify(infraActiveRequestsClient, Mockito.times(1)).updateInfraActiveRequests(dbRequest); + assertEquals("InstanceName Should Be Equal", "instanceName", dbRequest.getVfModuleName()); + } + + @Test + public void test_buildRequestParams() throws Exception { + RequestClientParameter expected = new RequestClientParameter.Builder().setRequestId("requestId") + .setServiceInstanceId("serviceInstanceId").setVnfId("vnfId").setVfModuleId("vfModuleId") + .setALaCarte(true).setRequestDetails(mapper.writeValueAsString(createTestRequest())) + .setRequestAction(Action.deleteInstance.toString()) + .setRequestUri("http://localhost:8080/serviceInstances").setApiVersion("v8").build(); + RequestClientParameter actual = restHandler.buildRequestParams(createTestRequest(), + "http://localhost:8080/serviceInstances", "requestId", "serviceInstanceId", "vnfId", "vfModuleId"); + assertThat(actual, sameBeanAs(expected)); + } + + @Test + public void test_createInfraActiveRequestForDelete() throws Exception { + InfraActiveRequests expected = new InfraActiveRequests(); + expected.setRequestAction(Action.deleteInstance.toString()); + expected.setAction(Action.deleteInstance.toString()); + expected.setServiceInstanceId("serviceInstanceId"); + expected.setVnfId("vnfId"); + expected.setVfModuleId("vfModuleId"); + expected.setRequestId("requestId"); + expected.setRequestorId("userId"); + expected.setSource("VID"); + expected.setRequestStatus(Status.IN_PROGRESS.toString()); + expected.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER); + expected.setRequestUrl("http://localhost:9090"); + expected.setRequestScope(ModelType.vfModule.toString()); + InfraActiveRequests actual = restHandler.createInfraActiveRequestForDelete("requestId", "vfModuleId", + "serviceInstanceId", "vnfId", "userId", "VID", "http://localhost:9090"); + assertThat(actual, sameBeanAs(expected).ignoring("startTime")); + Mockito.verify(infraActiveRequestsClient, Mockito.times(1)).save(actual); + } + + private ServiceInstancesRequest createTestRequest() { + ServiceInstancesRequest request = new ServiceInstancesRequest(); + RequestDetails requestDetails = new RequestDetails(); + RequestInfo requestInfo = new RequestInfo(); + requestInfo.setInstanceName("instanceName"); + requestDetails.setRequestInfo(requestInfo); + request.setRequestDetails(requestDetails); + return request; + } + + private InfraActiveRequests createDatabaseRecord() { + InfraActiveRequests request = new InfraActiveRequests(); + request.setRequestId("requestId"); + return request; + } + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/VnfRestHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/VnfRestHandlerTest.java new file mode 100644 index 0000000000..2ea537b6ad --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/VnfRestHandlerTest.java @@ -0,0 +1,154 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T 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.apihandlerinfra.infra.rest.handler; + +import static com.shazam.shazamcrest.MatcherAssert.assertThat; +import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; +import static org.junit.Assert.assertEquals; +import static org.mockito.ArgumentMatchers.eq; +import java.net.MalformedURLException; +import java.util.HashMap; +import java.util.Map; +import javax.ws.rs.container.ContainerRequestContext; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.junit.runner.RunWith; +import org.mockito.ArgumentCaptor; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.junit.MockitoJUnitRunner; +import org.onap.so.apihandler.common.RequestClientParameter; +import org.onap.so.apihandlerinfra.Action; +import org.onap.so.apihandlerinfra.Constants; +import org.onap.so.apihandlerinfra.Status; +import org.onap.so.apihandlerinfra.infra.rest.exception.NoRecipeException; +import org.onap.so.apihandlerinfra.infra.rest.handler.VnfRestHandler; +import org.onap.so.db.catalog.beans.Recipe; +import org.onap.so.db.catalog.beans.ServiceRecipe; +import org.onap.so.db.catalog.client.CatalogDbClient; +import org.onap.so.db.request.beans.InfraActiveRequests; +import org.onap.so.db.request.client.RequestsDbClient; +import org.onap.so.serviceinstancebeans.ModelType; +import org.onap.so.serviceinstancebeans.RequestDetails; +import org.onap.so.serviceinstancebeans.RequestInfo; +import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; +import com.fasterxml.jackson.databind.ObjectMapper; + +@RunWith(MockitoJUnitRunner.class) +public class VnfRestHandlerTest { + + @Rule + public ExpectedException exceptionRule = ExpectedException.none(); + + @InjectMocks + VnfRestHandler restHandler; + + @Mock + ContainerRequestContext mockRequestContext; + + @Mock + private CatalogDbClient catalogDbClient; + + @Mock + private RequestsDbClient infraActiveRequestsClient; + + private ObjectMapper mapper = new ObjectMapper(); + + @Test + public void test_find_vnf_recipe() throws MalformedURLException, NoRecipeException { + ServiceRecipe expected = new ServiceRecipe(); + expected.setOrchestrationUri("/mso/async/services/WorkflowActionBB"); + Recipe actual = restHandler.findVnfModuleRecipe("testModelId", ModelType.vnf.toString(), + Action.createInstance.toString()); + assertThat(actual, sameBeanAs(expected)); + } + + @Test + public void test_checkDuplicateRequest() throws MalformedURLException, NoRecipeException { + ArgumentCaptor<HashMap> instanceIdCaptor = ArgumentCaptor.forClass(HashMap.class); + restHandler.checkDuplicateRequest("serviceInstanceId", "vnfId", "instanceName", "requestId"); + Mockito.verify(infraActiveRequestsClient, Mockito.times(1)).checkInstanceNameDuplicate( + instanceIdCaptor.capture(), eq("instanceName"), eq(ModelType.vnf.toString())); + Map actualMap = instanceIdCaptor.getValue(); + assertEquals("ServiceInstanceID should exist in map", "serviceInstanceId", actualMap.get("serviceInstanceId")); + assertEquals("VnfId should exit in map", "vnfId", actualMap.get("vnfInstanceId")); + } + + @Test + public void test_saveInstanceName() throws MalformedURLException, NoRecipeException { + ServiceInstancesRequest request = createTestRequest(); + InfraActiveRequests dbRequest = createDatabaseRecord(); + restHandler.saveInstanceName(request, dbRequest); + Mockito.verify(infraActiveRequestsClient, Mockito.times(1)).updateInfraActiveRequests(dbRequest); + assertEquals("InstanceName Should Be Equal", "instanceName", dbRequest.getVnfName()); + } + + @Test + public void test_buildRequestParams() throws Exception { + RequestClientParameter expected = new RequestClientParameter.Builder().setRequestId("requestId") + .setServiceInstanceId("serviceInstanceId").setVnfId("vnfId").setALaCarte(true) + .setRequestDetails(mapper.writeValueAsString(createTestRequest())) + .setRequestAction(Action.deleteInstance.toString()) + .setRequestUri("http://localhost:8080/serviceInstances").setApiVersion("v8").build(); + RequestClientParameter actual = restHandler.buildRequestParams(createTestRequest(), + "http://localhost:8080/serviceInstances", "requestId", "serviceInstanceId", "vnfId"); + assertThat(actual, sameBeanAs(expected)); + } + + @Test + public void test_createInfraActiveRequestForDelete() throws Exception { + InfraActiveRequests expected = new InfraActiveRequests(); + expected.setRequestAction(Action.deleteInstance.toString()); + expected.setAction(Action.deleteInstance.toString()); + expected.setServiceInstanceId("serviceInstanceId"); + expected.setVnfId("vnfId"); + expected.setRequestId("requestId"); + expected.setRequestorId("userId"); + expected.setSource("VID"); + expected.setRequestStatus(Status.IN_PROGRESS.toString()); + expected.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER); + expected.setRequestUrl("http://localhost:9090"); + expected.setRequestScope(ModelType.vnf.toString()); + InfraActiveRequests actual = restHandler.createInfraActiveRequestForDelete("requestId", "serviceInstanceId", + "vnfId", "userId", "VID", "http://localhost:9090"); + assertThat(actual, sameBeanAs(expected).ignoring("startTime")); + Mockito.verify(infraActiveRequestsClient, Mockito.times(1)).save(actual); + } + + private ServiceInstancesRequest createTestRequest() { + ServiceInstancesRequest request = new ServiceInstancesRequest(); + RequestDetails requestDetails = new RequestDetails(); + RequestInfo requestInfo = new RequestInfo(); + requestInfo.setInstanceName("instanceName"); + requestDetails.setRequestInfo(requestInfo); + request.setRequestDetails(requestDetails); + return request; + } + + private InfraActiveRequests createDatabaseRecord() { + InfraActiveRequests request = new InfraActiveRequests(); + request.setRequestId("requestId"); + return request; + } + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/VolumeRestHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/VolumeRestHandlerTest.java new file mode 100644 index 0000000000..2721f8a14a --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/VolumeRestHandlerTest.java @@ -0,0 +1,145 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T 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.apihandlerinfra.infra.rest.handler; + +import static com.shazam.shazamcrest.MatcherAssert.assertThat; +import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; +import static org.junit.Assert.assertEquals; +import static org.mockito.ArgumentMatchers.eq; +import java.net.MalformedURLException; +import java.util.HashMap; +import java.util.Map; +import javax.ws.rs.container.ContainerRequestContext; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.junit.runner.RunWith; +import org.mockito.ArgumentCaptor; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.junit.MockitoJUnitRunner; +import org.onap.so.apihandler.common.RequestClientParameter; +import org.onap.so.apihandlerinfra.Action; +import org.onap.so.apihandlerinfra.Constants; +import org.onap.so.apihandlerinfra.Status; +import org.onap.so.apihandlerinfra.infra.rest.exception.NoRecipeException; +import org.onap.so.apihandlerinfra.infra.rest.handler.VolumeRestHandler; +import org.onap.so.db.catalog.client.CatalogDbClient; +import org.onap.so.db.request.beans.InfraActiveRequests; +import org.onap.so.db.request.client.RequestsDbClient; +import org.onap.so.serviceinstancebeans.ModelType; +import org.onap.so.serviceinstancebeans.RequestDetails; +import org.onap.so.serviceinstancebeans.RequestInfo; +import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; +import com.fasterxml.jackson.databind.ObjectMapper; + +@RunWith(MockitoJUnitRunner.class) +public class VolumeRestHandlerTest { + + @Rule + public ExpectedException exceptionRule = ExpectedException.none(); + + @InjectMocks + VolumeRestHandler restHandler; + + @Mock + ContainerRequestContext mockRequestContext; + + @Mock + private CatalogDbClient catalogDbClient; + + @Mock + private RequestsDbClient infraActiveRequestsClient; + + private ObjectMapper mapper = new ObjectMapper(); + + @Test + public void test_checkDuplicateRequest() throws MalformedURLException, NoRecipeException { + ArgumentCaptor<HashMap> instanceIdCaptor = ArgumentCaptor.forClass(HashMap.class); + restHandler.checkDuplicateRequest("serviceInstanceId", "vnfId", "volumeGroupId", "instanceName", "requestId"); + Mockito.verify(infraActiveRequestsClient, Mockito.times(1)).checkInstanceNameDuplicate( + instanceIdCaptor.capture(), eq("instanceName"), eq(ModelType.volumeGroup.toString())); + Map actualMap = instanceIdCaptor.getValue(); + assertEquals("ServiceInstanceID should exist in map", "serviceInstanceId", actualMap.get("serviceInstanceId")); + assertEquals("VnfId should exit in map", "vnfId", actualMap.get("vnfInstanceId")); + assertEquals("VolumeGroupId should exit in map", "volumeGroupId", actualMap.get("volumeGroupInstanceId")); + } + + @Test + public void test_saveInstanceName() throws MalformedURLException, NoRecipeException { + ServiceInstancesRequest request = createTestRequest(); + InfraActiveRequests dbRequest = createDatabaseRecord(); + restHandler.saveInstanceName(request, dbRequest); + Mockito.verify(infraActiveRequestsClient, Mockito.times(1)).updateInfraActiveRequests(dbRequest); + assertEquals("InstanceName Should Be Equal", "instanceName", dbRequest.getVolumeGroupName()); + } + + @Test + public void test_buildRequestParams() throws Exception { + RequestClientParameter expected = new RequestClientParameter.Builder().setRequestId("requestId") + .setServiceInstanceId("serviceInstanceId").setVnfId("vnfId").setVolumeGroupId("volumeGroupId") + .setALaCarte(true).setRequestDetails(mapper.writeValueAsString(createTestRequest())) + .setRequestAction(Action.deleteInstance.toString()) + .setRequestUri("http://localhost:8080/serviceInstances").setApiVersion("v8").build(); + RequestClientParameter actual = restHandler.buildRequestParams(createTestRequest(), + "http://localhost:8080/serviceInstances", "requestId", "serviceInstanceId", "vnfId", "volumeGroupId"); + assertThat(actual, sameBeanAs(expected)); + } + + @Test + public void test_createInfraActiveRequestForDelete() throws Exception { + InfraActiveRequests expected = new InfraActiveRequests(); + expected.setRequestAction(Action.deleteInstance.toString()); + expected.setAction(Action.deleteInstance.toString()); + expected.setServiceInstanceId("serviceInstanceId"); + expected.setVnfId("vnfId"); + expected.setVolumeGroupId("volumeGroupId"); + expected.setRequestId("requestId"); + expected.setRequestorId("userId"); + expected.setSource("VID"); + expected.setRequestStatus(Status.IN_PROGRESS.toString()); + expected.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER); + expected.setRequestScope(ModelType.volumeGroup.toString()); + expected.setRequestUrl("http://localhost:9090"); + InfraActiveRequests actual = restHandler.createInfraActiveRequestForDelete("requestId", "volumeGroupId", + "serviceInstanceId", "vnfId", "userId", "VID", "http://localhost:9090"); + assertThat(actual, sameBeanAs(expected).ignoring("startTime")); + Mockito.verify(infraActiveRequestsClient, Mockito.times(1)).save(actual); + } + + private ServiceInstancesRequest createTestRequest() { + ServiceInstancesRequest request = new ServiceInstancesRequest(); + RequestDetails requestDetails = new RequestDetails(); + RequestInfo requestInfo = new RequestInfo(); + requestInfo.setInstanceName("instanceName"); + requestDetails.setRequestInfo(requestInfo); + request.setRequestDetails(requestDetails); + return request; + } + + private InfraActiveRequests createDatabaseRecord() { + InfraActiveRequests request = new InfraActiveRequests(); + request.setRequestId("requestId"); + return request; + } + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/ExpectedServiceRequest.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/ExpectedServiceRequest.json new file mode 100644 index 0000000000..3ad3d1efec --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/ExpectedServiceRequest.json @@ -0,0 +1,20 @@ +{ + "requestDetails": { + "modelInfo": { + "modelType": "service", + "modelVersionId": "bad955c3-29b2-4a27-932e-28e942cc6480", + "modelUuid": "bad955c3-29b2-4a27-932e-28e942cc6480" + }, + "requestInfo": { + "instanceName": "Robot_SI_For_VolumeGroup", + "suppressRollback": false + }, + "requestParameters": { + "userParams": [], + "aLaCarte": true, + "testApi": "GR_API" + }, + "instanceName": [], + "configurationParameters": [] + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/ExpectedVfModuleRequest.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/ExpectedVfModuleRequest.json new file mode 100644 index 0000000000..9670c3b645 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/ExpectedVfModuleRequest.json @@ -0,0 +1,25 @@ +{ + "requestDetails": { + "modelInfo": { + "modelType": "vfModule", + "modelCustomizationUuid": "074c64d0-7e13-4bcc-8bdb-ea922331102d", + "modelCustomizationId": "074c64d0-7e13-4bcc-8bdb-ea922331102d" + }, + "requestInfo": { + "instanceName": "dummy_id", + "suppressRollback": false + }, + "cloudConfiguration": { + "tenantId": "0422ffb57ba042c0800a29dc85ca70f8", + "cloudOwner": "cloudOwner", + "lcpCloudRegionId": "regionOne" + }, + "requestParameters": { + "userParams": [], + "aLaCarte": true, + "testApi": "GR_API" + }, + "instanceName": [], + "configurationParameters": [] + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/ExpectedVnfRequest.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/ExpectedVnfRequest.json new file mode 100644 index 0000000000..59602f7ac2 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/ExpectedVnfRequest.json @@ -0,0 +1,20 @@ +{ + "requestDetails": { + "modelInfo": { + "modelType": "vnf", + "modelCustomizationUuid": "96c23a4a-6887-4b2c-9cce-1e4ea35eaade", + "modelCustomizationId": "96c23a4a-6887-4b2c-9cce-1e4ea35eaade" + }, + "requestInfo": { + "instanceName": "Robot_VNF_For_Volume_Group", + "suppressRollback": false + }, + "requestParameters": { + "userParams": [], + "aLaCarte": true, + "testApi": "GR_API" + }, + "instanceName": [], + "configurationParameters": [] + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/ExpectedVolumeGroupRequest.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/ExpectedVolumeGroupRequest.json new file mode 100644 index 0000000000..ec7acf1e41 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/ExpectedVolumeGroupRequest.json @@ -0,0 +1,25 @@ +{ + "requestDetails": { + "modelInfo": { + "modelType": "volumeGroup", + "modelCustomizationUuid": "e38906fa-717c-49b0-b391-e6ec12b50c4a", + "modelCustomizationId": "e38906fa-717c-49b0-b391-e6ec12b50c4a" + }, + "requestInfo": { + "instanceName": "VolumeGroup", + "suppressRollback": false + }, + "cloudConfiguration": { + "tenantId": "0422ffb57ba042c0800a29dc85ca70f8", + "cloudOwner": "cloudOwner", + "lcpCloudRegionId": "regionOne" + }, + "requestParameters": { + "userParams": [], + "aLaCarte": true, + "testApi": "GR_API" + }, + "instanceName": [], + "configurationParameters": [] + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/ServiceInstance.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/ServiceInstance.json new file mode 100644 index 0000000000..7d7a103123 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/ServiceInstance.json @@ -0,0 +1,35 @@ +{ + "service-instance-id": "e9fbfab4-d91c-4508-a429-2046c8751371", + "service-instance-name": "Robot_SI_For_VolumeGroup", + "environment-context": "General_Revenue-Bearing", + "model-invariant-id": "b16a9398-ffa3-4041-b78c-2956b8ad9c7b", + "model-version-id": "bad955c3-29b2-4a27-932e-28e942cc6480", + "resource-version": "1560538276937", + "orchestration-status": "Active", + "relationship-list": { + "relationship": [ + { + "related-to": "project", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v15/business/projects/project/GR_API_OE_MSO_Test200", + "relationship-data": [ + { + "relationship-key": "project.project-name", + "relationship-value": "GR_API_OE_MSO_Test200" + } + ] + }, + { + "related-to": "owning-entity", + "relationship-label": "org.onap.relationships.inventory.BelongsTo", + "related-link": "/aai/v15/business/owning-entities/owning-entity/c3f57fa8-ac7d-11e8-98d0-529269fb1459", + "relationship-data": [ + { + "relationship-key": "owning-entity.owning-entity-id", + "relationship-value": "c3f57fa8-ac7d-11e8-98d0-529269fb1459" + } + ] + } + ] + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/VfModule.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/VfModule.json new file mode 100644 index 0000000000..cfd9eb3e3c --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/VfModule.json @@ -0,0 +1,37 @@ +{ + "vf-module-id": "b70060b7-0031-4065-9462-3cd5b753d2db", + "vf-module-name": "dummy_id", + "heat-stack-id": "dummy_id/stackId", + "orchestration-status": "Active", + "is-base-vf-module": true, + "automated-assignment": false, + "resource-version": "1560538368229", + "model-invariant-id": "f7a867f2-596b-4f4a-a128-421e825a6190", + "model-version-id": "eb5de6fb-9ecf-4009-b922-fae3a9ae7d46", + "model-customization-id": "074c64d0-7e13-4bcc-8bdb-ea922331102d", + "module-index": 0, + "selflink": "/sim/restconf/config/GENERIC-RESOURCE-API:services/service/e9fbfab4-d91c-4508-a429-2046c8751371/service-data/vnfs/vnf/829924cc-8932-4875-b0af-d7a02799da9a/vnf-data//vf-modules/vf-module/dummy_id/vf-module-data/vf-module-topology/", + "relationship-list": { + "relationship": [ + { + "related-to": "volume-group", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v15/cloud-infrastructure/cloud-regions/cloud-region/cloudOwner/regionOne/volume-groups/volume-group/18b220c8-af84-4b82-a8c0-41bbea6328a6", + "relationship-data": [ + { + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "cloudOwner" + }, + { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "regionOne" + }, + { + "relationship-key": "volume-group.volume-group-id", + "relationship-value": "18b220c8-af84-4b82-a8c0-41bbea6328a6" + } + ] + } + ] + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/Vnf.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/Vnf.json new file mode 100644 index 0000000000..09f6d81da3 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/Vnf.json @@ -0,0 +1,131 @@ +{ + "vnf-id": "829924cc-8932-4875-b0af-d7a02799da9a", + "vnf-name": "Robot_VNF_For_Volume_Group", + "vnf-type": "Vf zrdm5bpxmc02092017-Service/Vf zrdm5bpxmc02092017-VF 0", + "service-id": "06f76284-8710-11e6-ae22-56b6b6499611", + "prov-status": "PREPROV", + "orchestration-status": "Active", + "in-maint": false, + "is-closed-loop-disabled": false, + "resource-version": "1560538316260", + "model-invariant-id": "23122c9b-dd7f-483f-bf0a-e069303db2f7", + "model-version-id": "d326f424-2312-4dd6-b7fe-364fadbd1ef5", + "model-customization-id": "96c23a4a-6887-4b2c-9cce-1e4ea35eaade", + "selflink": "/sim/restconf/config/GENERIC-RESOURCE-API:services/service/e9fbfab4-d91c-4508-a429-2046c8751371/service-data/vnfs/vnf/829924cc-8932-4875-b0af-d7a02799da9a/vnf-data/vnf-topology/", + "relationship-list": { + "relationship": [ + { + "related-to": "service-instance", + "relationship-label": "org.onap.relationships.inventory.ComposedOf", + "related-link": "/aai/v15/business/customers/customer/Robot_Test_Subscriber_ID/service-subscriptions/service-subscription/Robot_Test_Service_Type/service-instances/service-instance/e9fbfab4-d91c-4508-a429-2046c8751371", + "relationship-data": [ + { + "relationship-key": "customer.global-customer-id", + "relationship-value": "Robot_Test_Subscriber_ID" + }, + { + "relationship-key": "service-subscription.service-type", + "relationship-value": "Robot_Test_Service_Type" + }, + { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "e9fbfab4-d91c-4508-a429-2046c8751371" + } + ], + "related-to-property": [ + { + "property-key": "service-instance.service-instance-name", + "property-value": "Robot_SI_For_VolumeGroup" + } + ] + }, + { + "related-to": "platform", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v15/business/platforms/platform/vSAMP12_14-2XXX-Aug18-9001%20-%20Platform", + "relationship-data": [ + { + "relationship-key": "platform.platform-name", + "relationship-value": "vSAMP12_14-2XXX-Aug18-9001 - Platform" + } + ] + }, + { + "related-to": "line-of-business", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v15/business/lines-of-business/line-of-business/vSAMP12_14-2XXX-Aug18-9001%20-%20LOB", + "relationship-data": [ + { + "relationship-key": "line-of-business.line-of-business-name", + "relationship-value": "vSAMP12_14-2XXX-Aug18-9001 - LOB" + } + ] + }, + { + "related-to": "tenant", + "relationship-label": "org.onap.relationships.inventory.BelongsTo", + "related-link": "/aai/v15/cloud-infrastructure/cloud-regions/cloud-region/cloudOwner/regionOne/tenants/tenant/0422ffb57ba042c0800a29dc85ca70f8", + "relationship-data": [ + { + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "cloudOwner" + }, + { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "regionOne" + }, + { + "relationship-key": "tenant.tenant-id", + "relationship-value": "0422ffb57ba042c0800a29dc85ca70f8" + } + ], + "related-to-property": [ + { + "property-key": "tenant.tenant-name", + "property-value": "tenantName" + } + ] + }, + { + "related-to": "volume-group", + "relationship-label": "org.onap.relationships.inventory.DependsOn", + "related-link": "/aai/v15/cloud-infrastructure/cloud-regions/cloud-region/cloudOwner/regionOne/volume-groups/volume-group/volumeGroupId", + "relationship-data": [ + { + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "cloudOwner" + }, + { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "regionOne" + }, + { + "relationship-key": "volume-group.volume-group-id", + "relationship-value": "18b220c8-af84-4b82-a8c0-41bbea6328a6" + } + ] + }, + { + "related-to": "cloud-region", + "relationship-label": "org.onap.relationships.inventory.LocatedIn", + "related-link": "/aai/v15/cloud-infrastructure/cloud-regions/cloud-region/cloudOwner/regionOne", + "relationship-data": [ + { + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "cloudOwner" + }, + { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "regionOne" + } + ], + "related-to-property": [ + { + "property-key": "cloud-region.owner-defined-type", + "property-value": "LCP" + } + ] + } + ] + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/VolumeGroup.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/VolumeGroup.json new file mode 100644 index 0000000000..328b82ed55 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/VolumeGroup.json @@ -0,0 +1,56 @@ +{ + "volume-group-id": "5e6bca5b-8e14-4bdd-a419-820f68019b19", + "volume-group-name": "VolumeGroup", + "heat-stack-id": "VolumeGroup/stackId", + "vnf-type": "Vf zrdm5bpxmc02092017-Service/Vf zrdm5bpxmc02092017-VF 0", + "orchestration-status": "Active", + "model-customization-id": "e38906fa-717c-49b0-b391-e6ec12b50c4a", + "vf-module-model-customization-id": "e38906fa-717c-49b0-b391-e6ec12b50c4a", + "resource-version": "1560526466219", + "relationship-list": { + "relationship": [ + { + "related-to": "tenant", + "relationship-label": "org.onap.relationships.inventory.DependsOn", + "related-link": "/aai/v15/cloud-infrastructure/cloud-regions/cloud-region/cloudOwner/regionOne/tenants/tenant/0422ffb57ba042c0800a29dc85ca70f8", + "relationship-data": [ + { + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "cloudOwner" + }, + { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "regionOne" + }, + { + "relationship-key": "tenant.tenant-id", + "relationship-value": "0422ffb57ba042c0800a29dc85ca70f8" + } + ], + "related-to-property": [ + { + "property-key": "tenant.tenant-name", + "property-value": "tenantName" + } + ] + }, + { + "related-to": "generic-vnf", + "relationship-label": "org.onap.relationships.inventory.DependsOn", + "related-link": "/aai/v15/network/generic-vnfs/generic-vnf/82035634-1878-4fd9-ab14-04b819bea24b", + "relationship-data": [ + { + "relationship-key": "generic-vnf.vnf-id", + "relationship-value": "82035634-1878-4fd9-ab14-04b819bea24b" + } + ], + "related-to-property": [ + { + "property-key": "generic-vnf.vnf-name", + "property-value": "Robot_VNF_For_Volume_Group" + } + ] + } + ] + } +} |