Search in sources :

Example 91 with ServiceInstancesRequest

use of org.onap.so.serviceinstancebeans.ServiceInstancesRequest in project so by onap.

the class BpmnRequestBuilderTest method test_mapCloudConfigurationVnf.

@Test
public void test_mapCloudConfigurationVnf() throws Exception {
    String vnfId = "6fb01019-c3c4-41fe-b307-d1c56850b687";
    Map<String, String[]> filters = new HashMap<>();
    filters.put("vnfId", new String[] { "EQ", vnfId });
    filters.put("requestStatus", new String[] { "EQ", Status.COMPLETE.toString() });
    filters.put("action", new String[] { "EQ", "createInstance" });
    ServiceInstancesRequest serviceRequest = new ServiceInstancesRequest();
    CloudConfiguration cloudConfiguration = new CloudConfiguration();
    RequestDetails requestDetails = new RequestDetails();
    cloudConfiguration.setCloudOwner("cloudOwner");
    cloudConfiguration.setTenantId("tenantId");
    cloudConfiguration.setLcpCloudRegionId("lcpCloudRegionId");
    requestDetails.setCloudConfiguration(cloudConfiguration);
    serviceRequest.setRequestDetails(requestDetails);
    doReturn(filters).when(reqBuilder).createQueryRequest("vnfId", vnfId);
    doReturn(Optional.of(serviceRequest)).when(reqBuilder).findServiceInstanceRequest(filters);
    CloudConfiguration result = reqBuilder.mapCloudConfigurationVnf(vnfId);
    assertEquals("tenantId", result.getTenantId());
    assertEquals("cloudOwner", result.getCloudOwner());
    assertEquals("lcpCloudRegionId", result.getLcpCloudRegionId());
}
Also used : HashMap(java.util.HashMap) CloudConfiguration(org.onap.so.serviceinstancebeans.CloudConfiguration) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) Test(org.junit.Test)

Example 92 with ServiceInstancesRequest

use of org.onap.so.serviceinstancebeans.ServiceInstancesRequest in project so by onap.

the class BpmnRequestBuilderTest method test_buildVnfDeleteRequest.

@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(AAIFluentTypeBuilder.network().genericVnf("vnfId")));
    ServiceInstancesRequest expectedRequest = mapper.readValue(new File(RESOURCE_PATH + "ExpectedVnfRequest.json"), ServiceInstancesRequest.class);
    ServiceInstancesRequest actualRequest = reqBuilder.buildVnfDeleteRequest("vnfId");
    assertThat(actualRequest, sameBeanAs(expectedRequest));
}
Also used : GenericVnf(org.onap.aai.domain.yang.GenericVnf) File(java.io.File) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest) Test(org.junit.Test)

Example 93 with ServiceInstancesRequest

use of org.onap.so.serviceinstancebeans.ServiceInstancesRequest in project so by onap.

the class BpmnRequestBuilderTest method test_buildServiceInstanceDeleteRequest.

@Test
public void test_buildServiceInstanceDeleteRequest() throws Exception {
    ServiceInstance service = provider.getMapper().readValue(new File(RESOURCE_PATH + "ServiceInstance.json"), ServiceInstance.class);
    doReturn(service).when(aaiData).getServiceInstance("serviceId");
    ServiceInstancesRequest expectedRequest = mapper.readValue(new File(RESOURCE_PATH + "ExpectedServiceRequest.json"), ServiceInstancesRequest.class);
    // bad getter/setter setting multiple
    expectedRequest.getRequestDetails().getModelInfo().setModelId(null);
    // fields
    ServiceInstancesRequest actualRequest = reqBuilder.buildServiceDeleteRequest("serviceId");
    assertThat(actualRequest, sameBeanAs(expectedRequest));
}
Also used : ServiceInstance(org.onap.aai.domain.yang.ServiceInstance) File(java.io.File) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest) Test(org.junit.Test)

Example 94 with ServiceInstancesRequest

use of org.onap.so.serviceinstancebeans.ServiceInstancesRequest in project so by onap.

the class VfModuleRestHandlerTest method test_saveInstanceName.

@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());
}
Also used : InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest) Test(org.junit.Test)

Example 95 with ServiceInstancesRequest

use of org.onap.so.serviceinstancebeans.ServiceInstancesRequest in project so by onap.

the class ServiceInstanceRestHandlerTest method test_saveInstanceName.

@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());
}
Also used : InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest) Test(org.junit.Test)

Aggregations

ServiceInstancesRequest (org.onap.so.serviceinstancebeans.ServiceInstancesRequest)100 Test (org.junit.Test)58 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)36 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)33 InfraActiveRequests (org.onap.so.db.request.beans.InfraActiveRequests)17 ModelInfo (org.onap.so.serviceinstancebeans.ModelInfo)15 RequestInfo (org.onap.so.serviceinstancebeans.RequestInfo)15 IOException (java.io.IOException)11 BaseTest (org.onap.so.apihandlerinfra.BaseTest)11 CloudConfiguration (org.onap.so.serviceinstancebeans.CloudConfiguration)11 ValidationException (org.onap.so.exceptions.ValidationException)10 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)8 ValidateException (org.onap.so.apihandlerinfra.exceptions.ValidateException)8 CloudConfigurationNotFoundException (org.onap.so.apihandlerinfra.infra.rest.exception.CloudConfigurationNotFoundException)8 Service (org.onap.so.db.catalog.beans.Service)8 ArrayList (java.util.ArrayList)7 RequestClientParameter (org.onap.so.apihandler.common.RequestClientParameter)7 ApiException (org.onap.so.apihandlerinfra.exceptions.ApiException)7 ServiceInstancesResponse (org.onap.so.serviceinstancebeans.ServiceInstancesResponse)7 GenericVnf (org.onap.aai.domain.yang.GenericVnf)6