diff options
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra/src/test/java')
16 files changed, 283 insertions, 32 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/AAIDeserializeTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/AAIDeserializeTest.java index e6409fab87..a279144eba 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/AAIDeserializeTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/AAIDeserializeTest.java @@ -31,7 +31,7 @@ import javax.ws.rs.core.MediaType; import org.junit.Before; import org.junit.Test; import org.onap.aai.domain.yang.Tenant; -import org.onap.so.client.aai.AAIVersion; +import org.onap.aaiclient.client.aai.AAIVersion; import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/E2EServiceInstancesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/E2EServiceInstancesTest.java index 979aa8fbb1..86e847234b 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/E2EServiceInstancesTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/E2EServiceInstancesTest.java @@ -103,7 +103,7 @@ public class E2EServiceInstancesTest extends BaseTest { String uri = e2eServInstancesUri + "v3"; ResponseEntity<String> response = sendRequest(inputStream("/Request.json"), uri, HttpMethod.POST); - assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value()); + assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value()); } @Test @@ -143,7 +143,7 @@ public class E2EServiceInstancesTest extends BaseTest { String uri = e2eServInstancesUri + "v5/9b9f02c0-298b-458a-bc9c-be3692e4f35e"; ResponseEntity<String> response = sendRequest(inputStream("/DeleteRequest.json"), uri, HttpMethod.DELETE); - assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value()); + assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value()); } @Test @@ -183,14 +183,14 @@ public class E2EServiceInstancesTest extends BaseTest { String uri = e2eServInstancesUri + "v5/9b9f02c0-298b-458a-bc9c-be3692e4f35e/scale"; ResponseEntity<String> response = sendRequest(inputStream("/ScaleRequest.json"), uri, HttpMethod.POST); - assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value()); + assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value()); } @Test public void updateE2EServiceInstance() throws IOException { String uri = e2eServInstancesUri + "v3/9b9f02c0-298b-458a-bc9c-be3692e4f35e"; ResponseEntity<String> response = sendRequest(inputStream("/Request.json"), uri, HttpMethod.PUT); - assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value()); + assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value()); } @Test @@ -240,8 +240,8 @@ public class E2EServiceInstancesTest extends BaseTest { RequestError expectedResponse = new RequestError(); ServiceException exception = new ServiceException(); exception.setMessageId("SVC1000"); - exception.setText( - "Failed calling bpmn localhost:" + env.getProperty("wiremock.server.port") + " failed to respond"); + exception.setText("Failed calling bpmn Client from http://localhost:" + env.getProperty("wiremock.server.port") + + "/mso/async/services/CompareModelofE2EServiceInstance failed to connect or respond"); expectedResponse.setServiceException(exception); String uri = e2eServInstancesUri + "v5/9b9f02c0-298b-458a-bc9c-be3692e4f35e/modeldifferences"; diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/InstanceManagementTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/InstanceManagementTest.java index ba7fe2b9cb..081f235db1 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/InstanceManagementTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/InstanceManagementTest.java @@ -45,9 +45,11 @@ import org.apache.http.HttpStatus; import org.junit.Before; import org.junit.Test; import org.onap.logging.ref.slf4j.ONAPLogConstants; +import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.logger.HttpHeadersConstants; import org.onap.so.serviceinstancebeans.RequestReferences; import org.onap.so.serviceinstancebeans.ServiceInstancesResponse; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; @@ -63,6 +65,9 @@ public class InstanceManagementTest extends BaseTest { private final ObjectMapper mapper = new ObjectMapper(); private ObjectMapper errorMapper = new ObjectMapper(); + @Autowired + InstanceManagement instanceManagement; + @Value("${wiremock.server.port}") private String wiremockPort; @@ -201,4 +206,18 @@ public class InstanceManagementTest extends BaseTest { ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); } + + @Test + public void workflowAndOperationNameTest() { + wireMockServer.stubFor(get(urlMatching( + ".*/workflow/search/findByArtifactUUID[?]artifactUUID=71526781-e55c-4cb7-adb3-97e09d9c76be")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("workflow_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + InfraActiveRequests activeReq = new InfraActiveRequests(); + activeReq = + instanceManagement.setWorkflowNameAndOperationName(activeReq, "71526781-e55c-4cb7-adb3-97e09d9c76be"); + assertEquals(activeReq.getWorkflowName(), "testingWorkflow"); + assertEquals(activeReq.getOperationName(), "testOperation"); + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ManualTasksTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ManualTasksTest.java index fcf25b23e9..f4ff19f53d 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ManualTasksTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ManualTasksTest.java @@ -182,7 +182,8 @@ public class ManualTasksTest extends BaseTest { RequestError expectedResponse = new RequestError(); ServiceException se = new ServiceException(); se.setMessageId("SVC1000"); - se.setText("Request Failed due to BPEL error with HTTP Status = 502"); + se.setText("Client from http://localhost:" + env.getProperty("wiremock.server.port") + + "/sobpmnengine/task/55/complete failed to connect or respond"); expectedResponse.setServiceException(se); HttpHeaders headers = new HttpHeaders(); headers.set("Accept", MediaType.APPLICATION_JSON); diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsUnitTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsUnitTest.java index 3db2b2d96d..fdaca3566f 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsUnitTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsUnitTest.java @@ -85,6 +85,9 @@ public class OrchestrationRequestsUnitTest { private static final String RETRY_STATUS_MESSAGE = "RetryStatusMessage"; private static final String ROLLBACK_STATUS_MESSAGE = "RollbackStatusMessage"; private static final String TASK_INFORMATION = " TASK INFORMATION: Last task executed: Call SDNC"; + private static final String WORKFLOW_NAME = "testWorkflowName"; + private static final String OPERATION_NAME = "testOperationName"; + private static final String REQUEST_ACTION = "createInstance"; private InfraActiveRequests iar; boolean includeCloudRequest = false; private static final String ROLLBACK_EXT_SYSTEM_ERROR_SOURCE = "SDNC"; @@ -152,12 +155,80 @@ public class OrchestrationRequestsUnitTest { expected.setRequestScope(SERVICE); expected.setStartTime(new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(startTime) + " GMT"); + iar.setWorkflowName(WORKFLOW_NAME); + iar.setOperationName(OPERATION_NAME); + Request result = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest, OrchestrationRequestFormat.DETAIL.toString(), "v7"); assertThat(result, sameBeanAs(expected)); } @Test + public void mapInfraActiveRequestToRequestWithWorkflowNameAndOperationNameTest() throws ApiException { + doReturn("Last task executed: Call SDNC").when(camundaRequestHandler).getTaskName(REQUEST_ID); + InstanceReferences instanceReferences = new InstanceReferences(); + instanceReferences.setServiceInstanceId(SERVICE_INSTANCE_ID); + RequestStatus requestStatus = new RequestStatus(); + requestStatus.setRequestState(iar.getRequestStatus()); + requestStatus.setStatusMessage( + String.format("FLOW STATUS: %s RETRY STATUS: %s ROLLBACK STATUS: %s RESOURCE STATUS: %s", + FLOW_STATUS + TASK_INFORMATION, RETRY_STATUS_MESSAGE, ROLLBACK_STATUS_MESSAGE, + "The vf module already exist")); + + Request expected = new Request(); + expected.setRequestId(REQUEST_ID); + expected.setOriginalRequestId(ORIGINAL_REQUEST_ID); + expected.setInstanceReferences(instanceReferences); + expected.setRequestStatus(requestStatus); + expected.setRequestScope(SERVICE); + expected.setStartTime(new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(startTime) + " GMT"); + expected.setWorkflowName(WORKFLOW_NAME); + expected.setOperationName(OPERATION_NAME); + + iar.setOriginalRequestId(ORIGINAL_REQUEST_ID); + iar.setWorkflowName(WORKFLOW_NAME); + iar.setOperationName(OPERATION_NAME); + + Request result = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest, + OrchestrationRequestFormat.DETAIL.toString(), "v8"); + assertThat(result, sameBeanAs(expected)); + } + + @Test + public void mapInfraActiveRequestToRequestWithNoWorkflowNameAndNoOperationNameTest() throws ApiException { + doReturn("Last task executed: Call SDNC").when(camundaRequestHandler).getTaskName(REQUEST_ID); + InstanceReferences instanceReferences = new InstanceReferences(); + instanceReferences.setServiceInstanceId(SERVICE_INSTANCE_ID); + RequestStatus requestStatus = new RequestStatus(); + requestStatus.setRequestState(iar.getRequestStatus()); + requestStatus.setStatusMessage( + String.format("FLOW STATUS: %s RETRY STATUS: %s ROLLBACK STATUS: %s RESOURCE STATUS: %s", + FLOW_STATUS + TASK_INFORMATION, RETRY_STATUS_MESSAGE, ROLLBACK_STATUS_MESSAGE, + "The vf module already exist")); + + Request expected = new Request(); + expected.setRequestId(REQUEST_ID); + expected.setOriginalRequestId(ORIGINAL_REQUEST_ID); + expected.setInstanceReferences(instanceReferences); + expected.setRequestStatus(requestStatus); + expected.setRequestScope(SERVICE); + expected.setStartTime(new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(startTime) + " GMT"); + + + expected.setWorkflowName(REQUEST_ACTION); + expected.setRequestType(REQUEST_ACTION); + + iar.setOriginalRequestId(ORIGINAL_REQUEST_ID); + iar.setRequestAction(REQUEST_ACTION); + iar.setWorkflowName(null); + iar.setOperationName(null); + + Request result = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest, + OrchestrationRequestFormat.DETAIL.toString(), "v8"); + assertThat(result, sameBeanAs(expected)); + } + + @Test public void mapRequestStatusAndExtSysErrSrcToRequestFalseTest() throws ApiException { doReturn("Last task executed: Call SDNC").when(camundaRequestHandler).getTaskName(REQUEST_ID); InstanceReferences instanceReferences = new InstanceReferences(); 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 1332ffd913..ef90b22b01 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 @@ -26,6 +26,7 @@ import static com.github.tomakehurst.wiremock.client.WireMock.get; import static com.github.tomakehurst.wiremock.client.WireMock.post; import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching; import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; +import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching; import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -1389,7 +1390,7 @@ public class ServiceInstancesTest extends BaseTest { @Test public void replaceVfModuleInstanceNoCloudConfigurationTest() throws IOException { wireMockServer.stubFor( - get(urlPathEqualTo("/aai/v19/network/generic-vnfs/generic-vnf/ff305d54-75b4-431b-adb2-eb6b9e5ff000")) + get(urlPathMatching("/aai/v\\d+/network/generic-vnfs/generic-vnf/ff305d54-75b4-431b-adb2-eb6b9e5ff000")) .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBodyFile("infra/Vnf.json").withStatus(org.apache.http.HttpStatus.SC_OK))); wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) @@ -2214,7 +2215,6 @@ public class ServiceInstancesTest extends BaseTest { wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) - .withBodyFile("Camunda/UnauthorizedResponse.json") .withStatus(org.apache.http.HttpStatus.SC_UNAUTHORIZED))); wireMockServer.stubFor(get(urlMatching(".*/service/.*")) @@ -2231,7 +2231,7 @@ public class ServiceInstancesTest extends BaseTest { assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value()); RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class); - assertEquals("Exception caught mapping Camunda JSON response to object", + assertEquals("Request Failed due to BPEL error with HTTP Status = 401 UNAUTHORIZED", realResponse.getServiceException().getText()); } @@ -2430,7 +2430,7 @@ public class ServiceInstancesTest extends BaseTest { ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers); - assertEquals(Response.Status.NOT_ACCEPTABLE.getStatusCode(), response.getStatusCode().value()); + assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value()); RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class); assertEquals("Exception caught mapping Camunda JSON response to object", realResponse.getServiceException().getText()); diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/AAIDataRetrievalTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/AAIDataRetrievalTest.java new file mode 100644 index 0000000000..9d5d80592d --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/AAIDataRetrievalTest.java @@ -0,0 +1,122 @@ +/*- + * ============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 org.junit.Assert.assertEquals; +import static org.mockito.Mockito.doReturn; +import java.util.List; +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.aai.domain.yang.GenericVnf; +import org.onap.aai.domain.yang.VfModule; +import org.onap.aai.domain.yang.VfModules; +import org.onap.aai.domain.yang.VolumeGroup; +import org.onap.aai.domain.yang.VolumeGroups; +import org.onap.aaiclient.client.aai.AAIObjectPlurals; +import org.onap.aaiclient.client.aai.AAIObjectType; +import org.onap.aaiclient.client.aai.AAIResourcesClient; +import org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri; +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; + +@RunWith(MockitoJUnitRunner.class) +public class AAIDataRetrievalTest { + @Mock + private AAIResourcesClient aaiResourcesClient; + + @InjectMocks + private AAIDataRetrieval aaiDataRetrieval = new AAIDataRetrieval(); + + @Test + public void getVfModulesOfVnfTest() { + VfModules vfModules = getVfModules(); + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VF_MODULE, "vnfId"); + doReturn(Optional.of(vfModules)).when(aaiResourcesClient).get(VfModules.class, uri); + List<VfModule> vfModulesList = aaiDataRetrieval.getVfModulesOfVnf("vnfId"); + assertEquals("vfm1", vfModulesList.get(0).getVfModuleId()); + + Optional<String> vfModuleIds = aaiDataRetrieval.getVfModuleIdsByVnfId("vnfId"); + assertEquals(Optional.of("vfm1,vfm2"), vfModuleIds); + } + + @Test + public void getVfModulesOfVnfWhenNoneTest() { + VfModules vfModules = new VfModules(); + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VF_MODULE, "vnfId"); + doReturn(Optional.of(vfModules)).when(aaiResourcesClient).get(VfModules.class, uri); + List<VfModule> vfModulesList = aaiDataRetrieval.getVfModulesOfVnf("vnfId"); + assertEquals(true, vfModulesList.isEmpty()); + + Optional<String> vfModuleIds = aaiDataRetrieval.getVfModuleIdsByVnfId("vnfId"); + assertEquals(false, vfModuleIds.isPresent()); + } + + @Test + public void getVolumeGroupsOfVnfTest() throws Exception { + VolumeGroups volumeGroups = getVolumeGroups(); + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "vnfId") + .relatedTo(AAIObjectPlurals.VOLUME_GROUP); + doReturn(Optional.of(volumeGroups)).when(aaiResourcesClient).get(VolumeGroups.class, uri); + List<VolumeGroup> volumeGroupList = aaiDataRetrieval.getVolumeGroupsOfVnf("vnfId"); + assertEquals("vg1", volumeGroupList.get(0).getVolumeGroupId()); + Optional<String> volumeGroupIds = aaiDataRetrieval.getVolumeGroupIdsByVnfId("vnfId"); + assertEquals(Optional.of("vg1,vg2"), volumeGroupIds); + } + + @Test + public void getVolumeGroupsOfVnfWhenNoneTest() throws Exception { + VolumeGroups volumeGroups = new VolumeGroups(); + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "vnfId") + .relatedTo(AAIObjectPlurals.VOLUME_GROUP); + doReturn(Optional.of(volumeGroups)).when(aaiResourcesClient).get(VolumeGroups.class, uri); + List<VolumeGroup> volumeGroupList = aaiDataRetrieval.getVolumeGroupsOfVnf("vnfId"); + assertEquals(true, volumeGroupList.isEmpty()); + Optional<String> volumeGroupIds = aaiDataRetrieval.getVolumeGroupIdsByVnfId("vnfId"); + assertEquals(false, volumeGroupIds.isPresent()); + } + + + private VfModules getVfModules() { + VfModule vfModule1 = new VfModule(); + VfModule vfModule2 = new VfModule(); + vfModule1.setVfModuleId("vfm1"); + vfModule2.setVfModuleId("vfm2"); + VfModules vfModules = new VfModules(); + vfModules.getVfModule().add(vfModule1); + vfModules.getVfModule().add(vfModule2); + return vfModules; + } + + private VolumeGroups getVolumeGroups() { + VolumeGroup volumeGroup1 = new VolumeGroup(); + volumeGroup1.setVolumeGroupId("vg1"); + VolumeGroup volumeGroup2 = new VolumeGroup(); + volumeGroup2.setVolumeGroupId("vg2"); + VolumeGroups volumeGroups = new VolumeGroups(); + volumeGroups.getVolumeGroup().add(volumeGroup1); + volumeGroups.getVolumeGroup().add(volumeGroup2); + return volumeGroups; + } +} 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 index faac11715a..389ff28dbd 100644 --- 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 @@ -41,11 +41,11 @@ 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.AAIResultWrapper; -import org.onap.so.client.aai.entities.uri.AAIUriFactory; -import org.onap.so.client.graphinventory.GraphInventoryCommonObjectMapperProvider; +import org.onap.aaiclient.client.aai.AAIObjectType; +import org.onap.aaiclient.client.aai.AAIResourcesClient; +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper; +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; +import org.onap.aaiclient.client.graphinventory.GraphInventoryCommonObjectMapperProvider; import org.onap.so.constants.Status; import org.onap.so.db.request.client.RequestsDbClient; import org.onap.so.serviceinstancebeans.CloudConfiguration; diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/validator/ServiceInstanceDeleteValidatorTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/validator/ServiceInstanceDeleteValidatorTest.java index c334d522b6..f461df3720 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/validator/ServiceInstanceDeleteValidatorTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/validator/ServiceInstanceDeleteValidatorTest.java @@ -5,6 +5,7 @@ import static org.mockito.Mockito.when; import java.util.HashMap; import java.util.Map; import java.util.Optional; +import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; @@ -14,6 +15,8 @@ import org.mockito.junit.MockitoJUnitRunner; import org.onap.so.apihandlerinfra.Action; import org.onap.so.apihandlerinfra.infra.rest.AAIDataRetrieval; import org.onap.so.apihandlerinfra.infra.rest.validators.ServiceInstanceDeleteValidator; +import org.onap.so.serviceinstancebeans.RequestDetails; +import org.onap.so.serviceinstancebeans.RequestParameters; import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; @@ -30,22 +33,41 @@ public class ServiceInstanceDeleteValidatorTest { private Map<String, String> instanceIdMap = new HashMap<>(); + private ServiceInstancesRequest serviceInstancesRequest; + + @Before + public void before() { + serviceInstancesRequest = new ServiceInstancesRequest(); + RequestDetails requestDetails = new RequestDetails(); + RequestParameters requestParameters = new RequestParameters(); + requestParameters.setaLaCarte(true); + requestDetails.setRequestParameters(requestParameters); + serviceInstancesRequest.setRequestDetails(requestDetails); + } + @Test public void validateURIMatchTest() { - assertEquals(true, serviceValidator.shouldRunFor("v8/serviceInstances/uasdfasdf", new ServiceInstancesRequest(), + assertEquals(true, serviceValidator.shouldRunFor("v8/serviceInstances/uasdfasdf", serviceInstancesRequest, Action.deleteInstance)); } @Test public void validateURINotMatchTest() { assertEquals(false, serviceValidator.shouldRunFor("v8/serviceInstances/uasdfasdf/vnfs/asdfasdf", - new ServiceInstancesRequest(), Action.deleteInstance)); + serviceInstancesRequest, Action.deleteInstance)); } @Test public void validateURINotMatch2Test() { assertEquals(false, serviceValidator.shouldRunFor("v8/serviceInstances/uasdfasdf/update", - new ServiceInstancesRequest(), Action.deleteInstance)); + serviceInstancesRequest, Action.deleteInstance)); + } + + @Test + public void validateNotALaCarteTest() { + serviceInstancesRequest.getRequestDetails().getRequestParameters().setaLaCarte(false); + assertEquals(false, serviceValidator.shouldRunFor("v8/serviceInstances/uasdfasdf", serviceInstancesRequest, + Action.deleteInstance)); } @Test diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/validator/VnfDeleteValidatorTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/validator/VnfDeleteValidatorTest.java index d4f57d3146..65ce355ad1 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/validator/VnfDeleteValidatorTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/validator/VnfDeleteValidatorTest.java @@ -2,6 +2,7 @@ package org.onap.so.apihandlerinfra.infra.rest.validator; import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.when; +import static org.mockito.Mockito.doReturn; import java.util.HashMap; import java.util.Map; import java.util.Optional; @@ -49,19 +50,34 @@ public class VnfDeleteValidatorTest { } @Test - public void validateSuccessTest() { + public void validateFailureVfModuleVnfTest() { instanceIdMap.put("vnfInstanceId", "1"); - when(aaiDataRetrieval.isVnfRelatedToVolumes("1")).thenReturn(false); + doReturn(Optional.of("test")).when(aaiDataRetrieval).getVfModuleIdsByVnfId("1"); + Optional<String> result = vnfValidator.validate(instanceIdMap, null, null); + assertEquals(true, result.isPresent()); + } + + @Test + public void validateSuccessVfModuleVnfTest() { + instanceIdMap.put("vnfInstanceId", "1"); + doReturn(Optional.empty()).when(aaiDataRetrieval).getVfModuleIdsByVnfId("1"); Optional<String> result = vnfValidator.validate(instanceIdMap, null, null); assertEquals(false, result.isPresent()); } @Test - public void validateFailureVnfTest() { + public void validateFailureVolumeGroupVnfTest() { instanceIdMap.put("vnfInstanceId", "1"); - when(aaiDataRetrieval.isVnfRelatedToVolumes("1")).thenReturn(true); + doReturn(Optional.of("test")).when(aaiDataRetrieval).getVolumeGroupIdsByVnfId("1"); Optional<String> result = vnfValidator.validate(instanceIdMap, null, null); assertEquals(true, result.isPresent()); } + @Test + public void validateSuccessVolumeGroupVnfTest() { + instanceIdMap.put("vnfInstanceId", "1"); + doReturn(Optional.empty()).when(aaiDataRetrieval).getVolumeGroupIdsByVnfId("1"); + Optional<String> result = vnfValidator.validate(instanceIdMap, null, null); + assertEquals(false, result.isPresent()); + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelperTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelperTest.java index 3a389ce227..75d98180ac 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelperTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelperTest.java @@ -40,8 +40,8 @@ import org.apache.http.HttpStatus; import org.junit.Test; import org.onap.aai.domain.yang.OperationalEnvironment; import org.onap.so.apihandlerinfra.BaseTest; -import org.onap.so.client.aai.AAIVersion; -import org.onap.so.client.aai.entities.AAIResultWrapper; +import org.onap.aaiclient.client.aai.AAIVersion; +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper; import org.springframework.beans.factory.annotation.Autowired; diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironmentTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironmentTest.java index feebbd49d1..2cf9662b82 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironmentTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironmentTest.java @@ -50,8 +50,8 @@ import org.onap.so.apihandlerinfra.tenantisolationbeans.RecoveryAction; import org.onap.so.apihandlerinfra.tenantisolationbeans.RequestDetails; import org.onap.so.apihandlerinfra.tenantisolationbeans.RequestParameters; import org.onap.so.apihandlerinfra.tenantisolationbeans.ServiceModelList; -import org.onap.so.client.aai.AAIVersion; -import org.onap.so.client.aai.entities.AAIResultWrapper; +import org.onap.aaiclient.client.aai.AAIVersion; +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper; import org.onap.so.db.request.beans.InfraActiveRequests; import org.springframework.beans.factory.annotation.Autowired; import com.fasterxml.jackson.core.JsonProcessingException; diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironmentTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironmentTest.java index 9100e82beb..b21b468ce3 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironmentTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironmentTest.java @@ -46,7 +46,7 @@ import org.onap.so.apihandlerinfra.tenantisolation.CloudOrchestrationRequest; import org.onap.so.apihandlerinfra.tenantisolationbeans.Distribution; import org.onap.so.apihandlerinfra.tenantisolationbeans.DistributionStatus; import org.onap.so.apihandlerinfra.tenantisolationbeans.Status; -import org.onap.so.client.aai.AAIVersion; +import org.onap.aaiclient.client.aai.AAIVersion; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.beans.OperationalEnvDistributionStatus; import org.onap.so.db.request.beans.OperationalEnvServiceModelStatus; diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironmentTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironmentTest.java index 0f096ee374..865bfd12a2 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironmentTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironmentTest.java @@ -44,7 +44,7 @@ import org.onap.so.apihandlerinfra.tenantisolationbeans.OperationalEnvironment; import org.onap.so.apihandlerinfra.tenantisolationbeans.RequestDetails; import org.onap.so.apihandlerinfra.tenantisolationbeans.RequestInfo; import org.onap.so.apihandlerinfra.tenantisolationbeans.RequestParameters; -import org.onap.so.client.aai.AAIVersion; +import org.onap.aaiclient.client.aai.AAIVersion; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironmentTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironmentTest.java index 6c00f8db27..59fc5075d5 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironmentTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironmentTest.java @@ -41,7 +41,7 @@ import org.onap.aai.domain.yang.OperationalEnvironment; import org.onap.so.apihandlerinfra.BaseTest; import org.onap.so.apihandlerinfra.exceptions.ApiException; import org.onap.so.apihandlerinfra.tenantisolation.CloudOrchestrationRequest; -import org.onap.so.client.aai.AAIVersion; +import org.onap.aaiclient.client.aai.AAIVersion; import org.onap.so.client.grm.beans.Property; import org.onap.so.client.grm.beans.ServiceEndPointList; import org.onap.so.db.request.beans.InfraActiveRequests; diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironmentTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironmentTest.java index 9911bb8cb8..e49d8f7fe6 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironmentTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironmentTest.java @@ -41,7 +41,7 @@ import org.onap.so.apihandler.common.ErrorNumbers; import org.onap.so.apihandlerinfra.BaseTest; import org.onap.so.apihandlerinfra.exceptions.ValidateException; import org.onap.so.apihandlerinfra.tenantisolation.CloudOrchestrationRequest; -import org.onap.so.client.aai.AAIVersion; +import org.onap.aaiclient.client.aai.AAIVersion; import org.onap.so.db.request.beans.InfraActiveRequests; import org.springframework.beans.factory.annotation.Autowired; import com.fasterxml.jackson.databind.ObjectMapper; |