Search in sources :

Example 71 with InfraActiveRequests

use of org.onap.so.db.request.beans.InfraActiveRequests in project so by onap.

the class MsoHeatUtilsTest method saveStack__Exists_Test.

@Test
public final void saveStack__Exists_Test() throws MsoException, IOException, NovaClientException {
    CreateStackParam createStackParam = new CreateStackParam();
    createStackParam.setStackName("stackName");
    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put("test", "value");
    createStackParam.setParameters(parameters);
    InfraActiveRequests request = new InfraActiveRequests();
    request.setRequestId("requestId");
    CloudApiRequests cloudRequest = new CloudApiRequests();
    cloudRequest.setCloudIdentifier("stackName");
    cloudRequest.setRequestBody("testMe");
    cloudRequest.setRequestId("requestId");
    request.getCloudApiRequests().add(cloudRequest);
    doReturn(request).when(requestDbClient).getInfraActiveRequestbyRequestId("requestId");
    doNothing().when(requestDbClient).updateInfraActiveRequests(request);
    heatUtils.saveStackRequest(createStackParam, "requestId", "stackName");
    Mockito.verify(requestDbClient, times(1)).updateInfraActiveRequests(request);
    assertNotNull(request.getCloudApiRequests().get(0));
    assertEquals("requestId", request.getCloudApiRequests().get(0).getRequestId());
    assertNotEquals("testMe", request.getCloudApiRequests().get(0).getRequestBody());
}
Also used : CloudApiRequests(org.onap.so.db.request.beans.CloudApiRequests) HashMap(java.util.HashMap) CreateStackParam(com.woorea.openstack.heat.model.CreateStackParam) InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) Test(org.junit.Test)

Example 72 with InfraActiveRequests

use of org.onap.so.db.request.beans.InfraActiveRequests in project so by onap.

the class InfraActiveRequestsRepositoryCustomControllerTest method getOrchestrationFiltersFromInfraActiveTest.

@Test
public void getOrchestrationFiltersFromInfraActiveTest() {
    Map<String, List<String>> requestMap = new HashMap<>();
    List<String> values = new ArrayList<>();
    values.add("EQUALS");
    values.add(infraActiveRequests.getServiceInstanceId());
    requestMap.put("serviceInstanceId", values);
    values = new ArrayList<>();
    values.add("EQUALS");
    values.add(infraActiveRequests.getServiceInstanceName());
    requestMap.put("serviceInstanceName", values);
    HttpEntity<Map<String, List<String>>> entityList = new HttpEntity(requestMap, headers);
    UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("/infraActiveRequests") + "/getOrchestrationFiltersFromInfraActive");
    ResponseEntity<List<InfraActiveRequests>> response = restTemplate.exchange(builder.toUriString(), HttpMethod.POST, entityList, new ParameterizedTypeReference<List<InfraActiveRequests>>() {
    });
    List<InfraActiveRequests> iarr = response.getBody();
    assertEquals(200, response.getStatusCodeValue());
    assertTrue(iarr.size() == 1);
    infraActiveRequestsResponse = iarr.get(0);
    verifyInfraActiveRequests();
}
Also used : HttpEntity(org.springframework.http.HttpEntity) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) UriComponentsBuilder(org.springframework.web.util.UriComponentsBuilder) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Example 73 with InfraActiveRequests

use of org.onap.so.db.request.beans.InfraActiveRequests in project so by onap.

the class InfraActiveRequestsRepositoryCustomControllerTest method checkInstanceNameDuplicateTest.

@Test
public void checkInstanceNameDuplicateTest() {
    InstanceNameDuplicateCheckRequest instanceNameDuplicateCheckRequest = new InstanceNameDuplicateCheckRequest((HashMap<String, String>) null, infraActiveRequests.getOperationalEnvName(), infraActiveRequests.getRequestScope());
    HttpEntity<InstanceNameDuplicateCheckRequest> entityList = new HttpEntity(instanceNameDuplicateCheckRequest, headers);
    UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("/infraActiveRequests") + "/checkInstanceNameDuplicate");
    ResponseEntity<InfraActiveRequests> response = restTemplate.exchange(builder.toUriString(), HttpMethod.POST, entityList, new ParameterizedTypeReference<InfraActiveRequests>() {
    });
    infraActiveRequestsResponse = response.getBody();
    assertEquals(200, response.getStatusCodeValue());
    verifyInfraActiveRequests();
}
Also used : InstanceNameDuplicateCheckRequest(org.onap.so.db.request.data.controller.InstanceNameDuplicateCheckRequest) HttpEntity(org.springframework.http.HttpEntity) UriComponentsBuilder(org.springframework.web.util.UriComponentsBuilder) InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) Test(org.junit.Test)

Example 74 with InfraActiveRequests

use of org.onap.so.db.request.beans.InfraActiveRequests in project so by onap.

the class InfraActiveRequestsRepositoryCustomControllerTest method getCloudOrchestrationFiltersFromInfraActiveTest.

@Test
public void getCloudOrchestrationFiltersFromInfraActiveTest() {
    Map<String, String> requestMap = new HashMap<>();
    requestMap.put("operationalEnvironmentId", infraActiveRequests.getOperationalEnvId());
    requestMap.put("operationalEnvironmentName", infraActiveRequests.getOperationalEnvName());
    requestMap.put("resourceType", "operationalEnvironment");
    HttpEntity<Map<String, String>> entity = new HttpEntity<>(requestMap, headers);
    UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("/infraActiveRequests") + "/getCloudOrchestrationFiltersFromInfraActive");
    ResponseEntity<List<InfraActiveRequests>> response = restTemplate.exchange(builder.toUriString(), HttpMethod.POST, entity, new ParameterizedTypeReference<List<InfraActiveRequests>>() {
    });
    List<InfraActiveRequests> iarr = response.getBody();
    assertEquals(200, response.getStatusCodeValue());
    assertTrue(iarr.size() == 1);
    infraActiveRequestsResponse = iarr.get(0);
    verifyInfraActiveRequests();
}
Also used : HttpEntity(org.springframework.http.HttpEntity) HashMap(java.util.HashMap) UriComponentsBuilder(org.springframework.web.util.UriComponentsBuilder) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) Test(org.junit.Test)

Example 75 with InfraActiveRequests

use of org.onap.so.db.request.beans.InfraActiveRequests in project so by onap.

the class InfraActiveRequestsRepositoryCustomControllerTest method setup.

@Before
public void setup() {
    infraActiveRequests = new InfraActiveRequests();
    infraActiveRequests.setRequestId(UUID.randomUUID().toString());
    infraActiveRequests.setOperationalEnvId(UUID.randomUUID().toString());
    infraActiveRequests.setServiceInstanceId(UUID.randomUUID().toString());
    infraActiveRequests.setServiceInstanceName("serviceInstanceNameTest");
    infraActiveRequests.setVnfId(UUID.randomUUID().toString());
    infraActiveRequests.setVnfName("vnfInstanceNameTest");
    infraActiveRequests.setVfModuleId(UUID.randomUUID().toString());
    infraActiveRequests.setVfModuleName("vfModuleInstanceNameTest");
    infraActiveRequests.setVolumeGroupId(UUID.randomUUID().toString());
    infraActiveRequests.setVolumeGroupName("volumeGroupInstanceNameTest");
    infraActiveRequests.setNetworkId(UUID.randomUUID().toString());
    infraActiveRequests.setNetworkName("networkInstanceNameTest");
    infraActiveRequests.setConfigurationId(UUID.randomUUID().toString());
    infraActiveRequests.setConfigurationName("configurationInstanceNameTest");
    infraActiveRequests.setCloudRegion("1");
    infraActiveRequests.setTenantId(UUID.randomUUID().toString());
    infraActiveRequests.setRequestScope("operationalEnvironment");
    infraActiveRequests.setRequestorId(UUID.randomUUID().toString());
    infraActiveRequests.setSource("sourceTest");
    infraActiveRequests.setOperationalEnvName(UUID.randomUUID().toString());
    infraActiveRequests.setRequestStatus("IN_PROGRESS");
    infraActiveRequests.setRequestUrl("http://localhost:8080/onap/so/infra/serviceInstantiation/v7/serviceInstances");
    saveInfraActiveRequest(infraActiveRequests);
}
Also used : InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) Before(org.junit.Before)

Aggregations

InfraActiveRequests (org.onap.so.db.request.beans.InfraActiveRequests)214 Test (org.junit.Test)119 BaseTaskTest (org.onap.so.bpmn.BaseTaskTest)29 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)26 Timestamp (java.sql.Timestamp)23 HttpEntity (org.springframework.http.HttpEntity)21 IOException (java.io.IOException)20 HashMap (java.util.HashMap)20 ApiException (org.onap.so.apihandlerinfra.exceptions.ApiException)20 ValidateException (org.onap.so.apihandlerinfra.exceptions.ValidateException)19 ServiceInstancesRequest (org.onap.so.serviceinstancebeans.ServiceInstancesRequest)19 BaseTest (org.onap.so.apihandlerinfra.BaseTest)18 ErrorLoggerInfo (org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo)18 ArrayList (java.util.ArrayList)16 ValidationException (org.onap.so.exceptions.ValidationException)15 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)13 Transactional (javax.transaction.Transactional)13 UriComponentsBuilder (org.springframework.web.util.UriComponentsBuilder)12 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)11 ResponseBuilder (org.onap.so.apihandler.common.ResponseBuilder)11