Search in sources :

Example 1 with OperationalEnvServiceModelStatus

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

the class ActivateVnfDBHelper method insertRecordToOperationalEnvServiceModelStatus.

/**
 * Insert record to OperationalEnvServiceModelStatus table
 *
 * @param requestId - String
 * @param operationalEnvironmentId - String
 * @param serviceModelVersionId - String
 * @param status - String
 * @param recoveryAction - String
 * @param retryCount - int
 * @param workloadContext - String
 * @return serviceModelStatus - OperationalEnvServiceModelStatus object
 */
public OperationalEnvServiceModelStatus insertRecordToOperationalEnvServiceModelStatus(String requestId, String operationalEnvironmentId, String serviceModelVersionId, String status, String recoveryAction, int retryCount, String workloadContext, String vnfOperationalEnvironmentId) {
    OperationalEnvServiceModelStatus serviceModelStatus = new OperationalEnvServiceModelStatus();
    serviceModelStatus.setRequestId(requestId);
    serviceModelStatus.setOperationalEnvId(operationalEnvironmentId);
    serviceModelStatus.setServiceModelVersionId(serviceModelVersionId);
    serviceModelStatus.setServiceModelVersionDistrStatus(status);
    serviceModelStatus.setRecoveryAction(recoveryAction);
    serviceModelStatus.setRetryCount(new Integer(retryCount));
    serviceModelStatus.setWorkloadContext(workloadContext);
    serviceModelStatus.setVnfOperationalEnvId(vnfOperationalEnvironmentId);
    return serviceModelStatus;
}
Also used : OperationalEnvServiceModelStatus(org.onap.so.db.request.beans.OperationalEnvServiceModelStatus)

Example 2 with OperationalEnvServiceModelStatus

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

the class ActivateVnfStatusOperationalEnvironmentTest method checkOrUpdateOverallStatusTest_Waiting.

@Test
public void checkOrUpdateOverallStatusTest_Waiting() throws Exception {
    OperationalEnvServiceModelStatus serviceModelDb = new OperationalEnvServiceModelStatus();
    serviceModelDb.setRequestId(requestIdOrig);
    serviceModelDb.setServiceModelVersionId(serviceModelVersionId);
    serviceModelDb.setWorkloadContext(workloadContext);
    serviceModelDb.setRecoveryAction(recoveryActionRetry);
    serviceModelDb.setOperationalEnvId(operationalEnvironmentId);
    serviceModelDb.setRetryCount(retryCountTwo);
    serviceModelDb.setServiceModelVersionDistrStatus(statusError);
    serviceModelDb.setVnfOperationalEnvId(vnfOperationalEnvironmentId);
    wireMockServer.stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withBody(mapper.writeValueAsString(serviceModelDb)).withStatus(HttpStatus.SC_OK)));
    activateVnfStatus.checkOrUpdateOverallStatus(operationalEnvironmentId, requestIdOrig);
}
Also used : OperationalEnvServiceModelStatus(org.onap.so.db.request.beans.OperationalEnvServiceModelStatus) BaseTest(org.onap.so.apihandlerinfra.BaseTest) Test(org.junit.Test)

Example 3 with OperationalEnvServiceModelStatus

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

the class ActivateVnfStatusOperationalEnvironmentTest method executionTest_ERROR_Status_And_ABORT.

@Test
public void executionTest_ERROR_Status_And_ABORT() throws JsonProcessingException {
    OperationalEnvServiceModelStatus serviceModelDb = new OperationalEnvServiceModelStatus();
    serviceModelDb.setRequestId(requestIdOrig);
    serviceModelDb.setServiceModelVersionId(serviceModelVersionId);
    serviceModelDb.setWorkloadContext(workloadContext);
    serviceModelDb.setRecoveryAction(recoveryActionAbort);
    serviceModelDb.setOperationalEnvId(operationalEnvironmentId);
    serviceModelDb.setRetryCount(retryCountThree);
    serviceModelDb.setServiceModelVersionDistrStatus(statusError);
    serviceModelDb.setVnfOperationalEnvId(vnfOperationalEnvironmentId);
    OperationalEnvDistributionStatus distributionDb = new OperationalEnvDistributionStatus();
    distributionDb.setDistributionId(sdcDistributionId);
    distributionDb.setRequestId(requestIdOrig);
    distributionDb.setOperationalEnvId(operationalEnvironmentId);
    distributionDb.setDistributionIdStatus(statusError);
    distributionDb.setServiceModelVersionId(serviceModelVersionId);
    distributionDb.setDistributionIdErrorReason(null);
    // prepare distribution obj
    Distribution distribution = new Distribution();
    distribution.setStatus(Status.DISTRIBUTION_COMPLETE_ERROR);
    request.setDistribution(distribution);
    request.setDistributionId(sdcDistributionId);
    request.setOperationalEnvironmentId(operationalEnvironmentId);
    InfraActiveRequests iar = new InfraActiveRequests();
    iar.setRequestId(requestIdOrig);
    iar.setRequestStatus("PENDING");
    wireMockServer.stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withBody(mapper.writeValueAsString(serviceModelDb)).withStatus(HttpStatus.SC_OK)));
    wireMockServer.stubFor(get(urlPathEqualTo("/operationalEnvDistributionStatus/" + sdcDistributionId)).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withBody(mapper.writeValueAsString(distributionDb)).withStatus(HttpStatus.SC_OK)));
    wireMockServer.stubFor(get(urlPathEqualTo("/infraActiveRequests/" + requestIdOrig)).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withBody(mapper.writeValueAsString(iar)).withStatus(HttpStatus.SC_OK)));
    wireMockServer.stubFor(post(urlPathEqualTo("/operationalEnvDistributionStatus/")).withRequestBody(containing("{\"distributionId\":\"TEST_distributionId\",\"operationalEnvId\":\"TEST_operationalEnvironmentId\",\"serviceModelVersionId\":\"TEST_serviceModelVersionId\",\"requestId\":\"TEST_requestIdOrig\",\"distributionIdStatus\":\"DISTRIBUTION_COMPLETE_ERROR\"")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withStatus(HttpStatus.SC_OK)));
    wireMockServer.stubFor(post(urlPathEqualTo("/operationalEnvServiceModelStatus/")).withRequestBody(containing("{\"requestId\":\"TEST_requestIdOrig\",\"operationalEnvId\":\"TEST_operationalEnvironmentId\",\"serviceModelVersionId\":\"TEST_serviceModelVersionId\",\"serviceModelVersionDistrStatus\":\"DISTRIBUTION_COMPLETE_ERROR\"")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withStatus(HttpStatus.SC_OK)));
    wireMockServer.stubFor(get(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*")).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(json).withStatus(HttpStatus.SC_ACCEPTED)));
    wireMockServer.stubFor(put(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*")).willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_ACCEPTED)));
    try {
        activateVnfStatus.execute(requestId, request);
    } catch (ApiException e) {
        assertThat(e.getMessage(), startsWith("Overall Activation process is a Failure. "));
        assertEquals(e.getHttpResponseCode(), HttpStatus.SC_BAD_REQUEST);
        assertEquals(e.getMessageID(), ErrorNumbers.SVC_DETAILED_SERVICE_ERROR);
    }
}
Also used : OperationalEnvDistributionStatus(org.onap.so.db.request.beans.OperationalEnvDistributionStatus) Distribution(org.onap.so.apihandlerinfra.tenantisolationbeans.Distribution) OperationalEnvServiceModelStatus(org.onap.so.db.request.beans.OperationalEnvServiceModelStatus) InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) ApiException(org.onap.so.apihandlerinfra.exceptions.ApiException) BaseTest(org.onap.so.apihandlerinfra.BaseTest) Test(org.junit.Test)

Example 4 with OperationalEnvServiceModelStatus

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

the class ActivateVnfStatusOperationalEnvironmentTest method checkOrUpdateOverallStatusTest_Ok.

@Test
public void checkOrUpdateOverallStatusTest_Ok() throws Exception {
    // two entries, both status Ok & retry 0
    OperationalEnvServiceModelStatus serviceModelDb = new OperationalEnvServiceModelStatus();
    serviceModelDb.setRequestId(requestIdOrig);
    serviceModelDb.setServiceModelVersionId(serviceModelVersionId);
    serviceModelDb.setWorkloadContext(workloadContext);
    serviceModelDb.setRecoveryAction(recoveryActionRetry);
    serviceModelDb.setOperationalEnvId(operationalEnvironmentId);
    serviceModelDb.setRetryCount(retryCountZero);
    serviceModelDb.setServiceModelVersionDistrStatus(statusOk);
    serviceModelDb.setVnfOperationalEnvId(vnfOperationalEnvironmentId);
    serviceModelDb.setRequestId(requestIdOrig);
    serviceModelDb.setServiceModelVersionId(serviceModelVersionId1);
    serviceModelDb.setWorkloadContext(workloadContext);
    serviceModelDb.setRecoveryAction(recoveryActionRetry);
    serviceModelDb.setOperationalEnvId(operationalEnvironmentId);
    serviceModelDb.setRetryCount(retryCountZero);
    serviceModelDb.setServiceModelVersionDistrStatus(statusOk);
    serviceModelDb.setVnfOperationalEnvId(vnfOperationalEnvironmentId);
    InfraActiveRequests iar = new InfraActiveRequests();
    iar.setRequestId(requestIdOrig);
    iar.setRequestStatus("PENDING");
    wireMockServer.stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withBody(mapper.writeValueAsString(serviceModelDb)).withStatus(HttpStatus.SC_OK)));
    wireMockServer.stubFor(get(urlPathEqualTo("/infraActiveRequests/" + requestIdOrig)).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withBody(mapper.writeValueAsString(iar)).withStatus(HttpStatus.SC_OK)));
    activateVnfStatus.checkOrUpdateOverallStatus(operationalEnvironmentId, requestIdOrig);
// overall is success
}
Also used : OperationalEnvServiceModelStatus(org.onap.so.db.request.beans.OperationalEnvServiceModelStatus) InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) BaseTest(org.onap.so.apihandlerinfra.BaseTest) Test(org.junit.Test)

Example 5 with OperationalEnvServiceModelStatus

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

the class ActivateVnfStatusOperationalEnvironmentTest method executionTest_ERROR_Status_And_RETRY_And_ErrorSdc.

@Test
public void executionTest_ERROR_Status_And_RETRY_And_ErrorSdc() throws JsonProcessingException {
    OperationalEnvServiceModelStatus serviceModelDb = new OperationalEnvServiceModelStatus();
    serviceModelDb.setRequestId(requestIdOrig);
    serviceModelDb.setServiceModelVersionId(serviceModelVersionId);
    serviceModelDb.setWorkloadContext(workloadContext);
    serviceModelDb.setRecoveryAction(recoveryActionRetry);
    serviceModelDb.setOperationalEnvId(operationalEnvironmentId);
    serviceModelDb.setRetryCount(retryCountThree);
    serviceModelDb.setServiceModelVersionDistrStatus(statusError);
    serviceModelDb.setVnfOperationalEnvId(vnfOperationalEnvironmentId);
    OperationalEnvDistributionStatus distributionDb = new OperationalEnvDistributionStatus();
    distributionDb.setDistributionId(sdcDistributionId);
    distributionDb.setRequestId(requestIdOrig);
    distributionDb.setOperationalEnvId(operationalEnvironmentId);
    distributionDb.setDistributionIdStatus(statusError);
    distributionDb.setServiceModelVersionId(serviceModelVersionId);
    distributionDb.setDistributionIdErrorReason(null);
    // prepare distribution obj
    Distribution distribution = new Distribution();
    distribution.setStatus(Status.DISTRIBUTION_COMPLETE_ERROR);
    distribution.setErrorReason("Unable to process.");
    request.setDistribution(distribution);
    request.setDistributionId(sdcDistributionId);
    request.setOperationalEnvironmentId(operationalEnvironmentId);
    // ERROR in sdc
    JSONObject jsonMessages = new JSONObject();
    jsonMessages.put("statusCode", "409");
    jsonMessages.put("message", "Undefined Error Message!");
    jsonMessages.put("messageId", "SVC4675");
    jsonMessages.put("text", "Error: Service state is invalid for this action.");
    JSONObject jsonServException = new JSONObject();
    jsonServException.put("serviceException", jsonMessages);
    JSONObject jsonErrorRequest = new JSONObject();
    jsonErrorRequest.put("requestError", jsonServException);
    InfraActiveRequests iar = new InfraActiveRequests();
    iar.setRequestId(requestIdOrig);
    iar.setRequestStatus("PENDING");
    wireMockServer.stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withBody(mapper.writeValueAsString(serviceModelDb)).withStatus(HttpStatus.SC_OK)));
    wireMockServer.stubFor(get(urlPathEqualTo("/operationalEnvDistributionStatus/" + sdcDistributionId)).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withBody(mapper.writeValueAsString(distributionDb)).withStatus(HttpStatus.SC_OK)));
    wireMockServer.stubFor(get(urlPathEqualTo("/infraActiveRequests/" + requestIdOrig)).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withBody(mapper.writeValueAsString(iar)).withStatus(HttpStatus.SC_OK)));
    wireMockServer.stubFor(post(urlPathEqualTo("/infraActiveRequests/")).withRequestBody(containing("operationalEnvId\":\"VNF_operationalEnvironmentId\"")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withStatus(HttpStatus.SC_OK)));
    wireMockServer.stubFor(post(urlPathMatching("/sdc/v1/catalog/services/.*")).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(jsonMessages.toString()).withStatus(HttpStatus.SC_CONFLICT)));
    wireMockServer.stubFor(get(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*")).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(json).withStatus(HttpStatus.SC_ACCEPTED)));
    wireMockServer.stubFor(put(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*")).willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_ACCEPTED)));
    try {
        activateVnfStatus.execute(requestId, request);
    } catch (ApiException e) {
        assertThat(e.getMessage(), startsWith("Failure calling SDC: statusCode: "));
        assertEquals(e.getHttpResponseCode(), HttpStatus.SC_BAD_REQUEST);
        assertEquals(e.getMessageID(), ErrorNumbers.SVC_DETAILED_SERVICE_ERROR);
    }
}
Also used : JSONObject(org.json.JSONObject) OperationalEnvDistributionStatus(org.onap.so.db.request.beans.OperationalEnvDistributionStatus) Distribution(org.onap.so.apihandlerinfra.tenantisolationbeans.Distribution) OperationalEnvServiceModelStatus(org.onap.so.db.request.beans.OperationalEnvServiceModelStatus) InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) ApiException(org.onap.so.apihandlerinfra.exceptions.ApiException) BaseTest(org.onap.so.apihandlerinfra.BaseTest) Test(org.junit.Test)

Aggregations

OperationalEnvServiceModelStatus (org.onap.so.db.request.beans.OperationalEnvServiceModelStatus)20 Test (org.junit.Test)13 BaseTest (org.onap.so.apihandlerinfra.BaseTest)11 OperationalEnvDistributionStatus (org.onap.so.db.request.beans.OperationalEnvDistributionStatus)11 JSONObject (org.json.JSONObject)7 Distribution (org.onap.so.apihandlerinfra.tenantisolationbeans.Distribution)7 InfraActiveRequests (org.onap.so.db.request.beans.InfraActiveRequests)7 ApiException (org.onap.so.apihandlerinfra.exceptions.ApiException)4 ErrorLoggerInfo (org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo)3 ValidateException (org.onap.so.apihandlerinfra.exceptions.ValidateException)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 Before (org.junit.Before)1 Ignore (org.junit.Ignore)1 AAIFluentTypeBuilder (org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder)1 ServiceModelList (org.onap.so.apihandlerinfra.tenantisolationbeans.ServiceModelList)1 NoEntityFoundException (org.onap.so.db.request.exceptions.NoEntityFoundException)1 ExampleMatcher (org.springframework.data.domain.ExampleMatcher)1