Search in sources :

Example 76 with InfraActiveRequests

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

the class InfraActiveRequestsRepositoryCustomControllerTest method checkInstanceNameDuplicateViaTestNotFound.

@Test
public void checkInstanceNameDuplicateViaTestNotFound() {
    Map<String, String> requestMap = new HashMap<>();
    requestMap.put("operationalEnvironmentId", "NotFoundOperationalEnvId");
    InstanceNameDuplicateCheckRequest instanceNameDuplicateCheckRequest = new InstanceNameDuplicateCheckRequest((HashMap<String, String>) requestMap, null, 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());
    assertEquals(null, response.getBody());
}
Also used : InstanceNameDuplicateCheckRequest(org.onap.so.db.request.data.controller.InstanceNameDuplicateCheckRequest) HttpEntity(org.springframework.http.HttpEntity) HashMap(java.util.HashMap) UriComponentsBuilder(org.springframework.web.util.UriComponentsBuilder) InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) Test(org.junit.Test)

Example 77 with InfraActiveRequests

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

the class InfraActiveRequestsRepositoryCustomControllerTest method checkInstanceNameDuplicateTestNotFound.

@Test
public void checkInstanceNameDuplicateTestNotFound() {
    String instanceNameDuplicateCheckRequest = "{\r\n\t \"instanceName\":\"TestNotFoundInstanceName\",\r\n\t \"requestScope\":\"testasdfasdfasdf\"\r\n}";
    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>() {
    });
    assertEquals(200, response.getStatusCodeValue());
    assertEquals(null, response.getBody());
}
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 78 with InfraActiveRequests

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

the class MsoRequestsDbAdapterImpl method updateInfraRequest.

@Transactional
@Override
public void updateInfraRequest(String requestId, String lastModifiedBy, String statusMessage, String responseBody, RequestStatusType requestStatus, String progress, String vnfOutputs, String serviceInstanceId, String networkId, String vnfId, String vfModuleId, String volumeGroupId, String serviceInstanceName, String configurationId, String configurationName, String vfModuleName) throws MsoRequestsDbException {
    try {
        InfraActiveRequests request = infraActive.findOneByRequestId(requestId);
        if (request == null) {
            String error = "Entity not found. Unable to retrieve MSO Infra Requests DB for Request ID " + requestId;
            throw new MsoRequestsDbException(error);
        }
        if (statusMessage != null) {
            request.setStatusMessage(statusMessage);
        }
        if (responseBody != null) {
            request.setResponseBody(responseBody);
        }
        if (requestStatus != null) {
            request.setRequestStatus(requestStatus.toString());
        }
        if (progress != null) {
            setProgress(progress, request);
        }
        if (vnfOutputs != null) {
            request.setVnfOutputs(vnfOutputs);
        }
        if (serviceInstanceId != null) {
            request.setServiceInstanceId(serviceInstanceId);
        }
        if (networkId != null) {
            request.setNetworkId(networkId);
        }
        if (vnfId != null) {
            request.setVnfId(vnfId);
        }
        if (vfModuleId != null) {
            request.setVfModuleId(vfModuleId);
        }
        if (volumeGroupId != null) {
            request.setVolumeGroupId(volumeGroupId);
        }
        if (serviceInstanceName != null) {
            request.setServiceInstanceName(serviceInstanceName);
        }
        if (vfModuleName != null) {
            request.setVfModuleName(vfModuleName);
        }
        if (configurationId != null) {
            request.setConfigurationId(configurationId);
        }
        if (configurationName != null) {
            request.setConfigurationName(configurationName);
        }
        if (requestStatus == RequestStatusType.COMPLETE || requestStatus == RequestStatusType.FAILED) {
            Timestamp nowTimeStamp = new Timestamp(System.currentTimeMillis());
            request.setEndTime(nowTimeStamp);
        }
        request.setLastModifiedBy(lastModifiedBy);
        infraActive.save(request);
    } catch (Exception e) {
        String error = "Error retrieving MSO Infra Requests DB for Request ID " + requestId;
        logger.error(error, e);
        throw new MsoRequestsDbException(error, ErrorCode.BusinessProcessError, e);
    }
}
Also used : MsoRequestsDbException(org.onap.so.adapters.requestsdb.exceptions.MsoRequestsDbException) InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) Timestamp(java.sql.Timestamp) MsoRequestsDbException(org.onap.so.adapters.requestsdb.exceptions.MsoRequestsDbException) Transactional(javax.transaction.Transactional)

Example 79 with InfraActiveRequests

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

the class MSORequestDBImplTest method getByRequestId.

@Test
public void getByRequestId() throws MsoRequestsDbException {
    InfraActiveRequests testRequest = setupTestEntities();
    // Given
    String requestId = "00032ab7-3fb3-42e5-965d-8ea592502017";
    // When
    InfraActiveRequests infraRequest = dbAdapter.getInfraRequest(requestId);
    if (infraRequest == null)
        fail("Null infraRequest");
    // Then
    assertThat(infraRequest, sameBeanAs(testRequest).ignoring("requestBody").ignoring("endTime").ignoring("startTime").ignoring("modifyTime"));
}
Also used : InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) Test(org.junit.Test)

Example 80 with InfraActiveRequests

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

the class MSORequestDBImplTest method updateInfraRequestNulls.

@Test
public void updateInfraRequestNulls() throws MsoRequestsDbException {
    InfraActiveRequests testRequest = setupTestEntities();
    // Given
    String requestId = "00032ab7-3fb3-42e5-965d-8ea592502017";
    // When
    dbAdapter.updateInfraRequest(testRequest.getRequestId(), testRequest.getLastModifiedBy(), null, null, null, null, null, null, null, null, null, null, null, null, null, null);
    InfraActiveRequests infraRequest = dbAdapter.getInfraRequest(requestId);
    // Then
    assertThat(infraRequest, sameBeanAs(testRequest).ignoring("requestBody").ignoring("endTime").ignoring("startTime").ignoring("modifyTime"));
}
Also used : InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) Test(org.junit.Test)

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