Search in sources :

Example 11 with OperationalEnvServiceModelStatus

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

the class ActivateVnfStatusOperationalEnvironmentTest method callSDClientForRetryTest_202.

@Test
@Ignore
public void callSDClientForRetryTest_202() throws Exception {
    OperationalEnvServiceModelStatus serviceModelDb = new OperationalEnvServiceModelStatus();
    serviceModelDb.setRequestId(requestIdOrig);
    serviceModelDb.setServiceModelVersionId(serviceModelVersionId);
    serviceModelDb.setWorkloadContext(workloadContext);
    serviceModelDb.setRecoveryAction(recoveryActionRetry);
    serviceModelDb.setOperationalEnvId(operationalEnvironmentId);
    serviceModelDb.setRetryCount(retryCountThree);
    serviceModelDb.setServiceModelVersionDistrStatus(statusSent);
    OperationalEnvDistributionStatus distributionDb = new OperationalEnvDistributionStatus();
    distributionDb.setDistributionId(sdcDistributionId);
    distributionDb.setRequestId(requestIdOrig);
    distributionDb.setOperationalEnvId(operationalEnvironmentId);
    distributionDb.setDistributionIdStatus(statusSent);
    distributionDb.setServiceModelVersionId(serviceModelVersionId);
    distributionDb.setDistributionIdErrorReason(null);
    JSONObject jsonObject = new JSONObject();
    jsonObject.put("statusCode", "202");
    jsonObject.put("message", "Success");
    jsonObject.put("distributionId", sdcDistributionId1);
    // prepare distribution obj
    Distribution distribution = new Distribution();
    distribution.setStatus(Status.DISTRIBUTION_COMPLETE_OK);
    request.setDistribution(distribution);
    request.setDistributionId(sdcDistributionId);
    request.setOperationalEnvironmentId(operationalEnvironmentId);
    wireMockServer.stubFor(post(urlPathMatching("/sdc/v1/catalog/services/TEST_serviceModelVersionId/distr.*")).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(jsonObject.toString()).withStatus(HttpStatus.SC_ACCEPTED)));
    JSONObject jsonResponse = activateVnfStatus.callSDClientForRetry(distributionDb, serviceModelDb, distribution);
    assertEquals("TEST_distributionId1", jsonResponse.get("distributionId"));
    assertEquals("Success", jsonResponse.get("message"));
    assertEquals("202", jsonResponse.get("statusCode"));
}
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) Ignore(org.junit.Ignore) BaseTest(org.onap.so.apihandlerinfra.BaseTest) Test(org.junit.Test)

Example 12 with OperationalEnvServiceModelStatus

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

the class ActivateVnfStatusOperationalEnvironmentTest method checkOrUpdateOverallStatusTest_Error.

@Test
public void checkOrUpdateOverallStatusTest_Error() throws JsonProcessingException {
    OperationalEnvServiceModelStatus serviceModelDb = new OperationalEnvServiceModelStatus();
    serviceModelDb.setRequestId(requestIdOrig);
    serviceModelDb.setServiceModelVersionId(serviceModelVersionId);
    serviceModelDb.setWorkloadContext(workloadContext);
    serviceModelDb.setRecoveryAction(recoveryActionRetry);
    serviceModelDb.setOperationalEnvId(operationalEnvironmentId);
    serviceModelDb.setRetryCount(retryCountZero);
    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)));
    InfraActiveRequests iar = new InfraActiveRequests();
    iar.setRequestId(requestIdOrig);
    iar.setRequestStatus("PENDING");
    wireMockServer.stubFor(get(urlPathEqualTo("/infraActiveRequests/" + requestIdOrig)).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withBody(mapper.writeValueAsString(iar)).withStatus(HttpStatus.SC_OK)));
    try {
        activateVnfStatus.checkOrUpdateOverallStatus(operationalEnvironmentId, requestIdOrig);
    } 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 : 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 13 with OperationalEnvServiceModelStatus

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

the class ActivateVnfStatusOperationalEnvironmentTest method executionTest_Ok.

@Test
public void executionTest_Ok() throws Exception {
    OperationalEnvServiceModelStatus serviceModelDb = new OperationalEnvServiceModelStatus();
    serviceModelDb.setRequestId(requestIdOrig);
    serviceModelDb.setServiceModelVersionId(serviceModelVersionId);
    serviceModelDb.setWorkloadContext(workloadContext);
    serviceModelDb.setRecoveryAction(recoveryActionRetry);
    serviceModelDb.setOperationalEnvId(operationalEnvironmentId);
    serviceModelDb.setRetryCount(retryCountThree);
    serviceModelDb.setServiceModelVersionDistrStatus(statusSent);
    serviceModelDb.setOperationalEnvId(operationalEnvironmentId);
    serviceModelDb.setVnfOperationalEnvId(vnfOperationalEnvironmentId);
    OperationalEnvDistributionStatus distributionDb = new OperationalEnvDistributionStatus();
    distributionDb.setDistributionId(sdcDistributionId);
    distributionDb.setRequestId(requestIdOrig);
    distributionDb.setOperationalEnvId(operationalEnvironmentId);
    distributionDb.setDistributionIdStatus(statusSent);
    distributionDb.setServiceModelVersionId(serviceModelVersionId);
    distributionDb.setDistributionIdErrorReason(null);
    // prepare distribution obj
    Distribution distribution = new Distribution();
    distribution.setStatus(Status.DISTRIBUTION_COMPLETE_OK);
    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("/operationalEnvServiceModelStatus/")).withRequestBody(equalTo("{\"requestId\":\"TEST_requestIdOrig\",\"operationalEnvId\":\"TEST_operationalEnvironmentId\",\"serviceModelVersionId\":\"TEST_serviceModelVersionId\",\"serviceModelVersionDistrStatus\":\"DISTRIBUTION_COMPLETE_OK\",\"recoveryAction\":\"RETRY\",\"retryCount\":0,\"workloadContext\":\"TEST_workloadContext\",\"createTime\":null,\"modifyTime\":null,\"vnfOperationalEnvId\":\"VNF_operationalEnvironmentId\"}")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withStatus(HttpStatus.SC_OK)));
    wireMockServer.stubFor(post(urlPathEqualTo("/operationalEnvDistributionStatus/")).withRequestBody(equalTo("{\"distributionId\":\"TEST_distributionId\",\"operationalEnvId\":\"TEST_operationalEnvironmentId\",\"serviceModelVersionId\":\"TEST_serviceModelVersionId\",\"requestId\":\"TEST_requestIdOrig\",\"distributionIdStatus\":\"DISTRIBUTION_COMPLETE_OK\",\"distributionIdErrorReason\":\"\",\"createTime\":null,\"modifyTime\":null}")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withStatus(HttpStatus.SC_OK)));
    wireMockServer.stubFor(get(urlPathEqualTo("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/operational-environment/VNF_operationalEnvironmentId")).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(json).withStatus(HttpStatus.SC_ACCEPTED)));
    wireMockServer.stubFor(put(urlPathEqualTo("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/operational-environment/VNF_operationalEnvironmentId")).willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_ACCEPTED)));
    activateVnfStatus.execute(requestId, request);
}
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) BaseTest(org.onap.so.apihandlerinfra.BaseTest) Test(org.junit.Test)

Example 14 with OperationalEnvServiceModelStatus

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

the class ActivateVnfDBHelperTest method testSetUp.

@Before
public void testSetUp() {
    // prepare expected OperationalEnvDistributionStatus object
    expectedDistStatus = new OperationalEnvDistributionStatus();
    expectedDistStatus.setDistributionId(distributionId1);
    expectedDistStatus.setOperationalEnvId(operationalEnvironmentId);
    expectedDistStatus.setServiceModelVersionId(serviceModelVersionId1);
    expectedDistStatus.setDistributionIdStatus(statusOk);
    expectedDistStatus.setRequestId(requestId);
    expectedDistStatus.setDistributionIdErrorReason("");
    // prepare expected OperationalEnvServiceModelStatus object
    expectedServiceModelStatus = new OperationalEnvServiceModelStatus();
    expectedServiceModelStatus.setRequestId(requestId);
    expectedServiceModelStatus.setOperationalEnvId(operationalEnvironmentId);
    expectedServiceModelStatus.setServiceModelVersionId(serviceModelVersionId1);
    expectedServiceModelStatus.setServiceModelVersionDistrStatus(statusOk);
    expectedServiceModelStatus.setRecoveryAction(recoveryActionRetry);
    expectedServiceModelStatus.setRetryCount(new Integer(retryCountThree));
    expectedServiceModelStatus.setWorkloadContext(workloadContext1);
    expectedServiceModelStatus.setVnfOperationalEnvId(vnfOperationalEnvironmentId);
}
Also used : OperationalEnvDistributionStatus(org.onap.so.db.request.beans.OperationalEnvDistributionStatus) OperationalEnvServiceModelStatus(org.onap.so.db.request.beans.OperationalEnvServiceModelStatus) Before(org.junit.Before)

Example 15 with OperationalEnvServiceModelStatus

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

the class RequestsDbClient method findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId.

public OperationalEnvServiceModelStatus findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId(String operationalEnvironmentId, String serviceModelVersionId, String requestId) {
    OperationalEnvServiceModelStatus modelStatus = getSingleResponse(getUri(UriBuilder.fromUri(findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestIdURI).queryParam(OPERATIONAL_ENVIRONMENT_ID, operationalEnvironmentId).queryParam(SERVICE_MODEL_VERSION_ID, serviceModelVersionId).queryParam(REQUEST_ID, requestId).build().toString()), OperationalEnvServiceModelStatus.class);
    if (null != modelStatus) {
        modelStatus.setOperationalEnvId(operationalEnvironmentId);
        modelStatus.setServiceModelVersionId(serviceModelVersionId);
        modelStatus.setRequestId(requestId);
    }
    return modelStatus;
}
Also used : OperationalEnvServiceModelStatus(org.onap.so.db.request.beans.OperationalEnvServiceModelStatus)

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