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"));
}
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);
}
}
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);
}
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);
}
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;
}
Aggregations