use of org.onap.so.client.oof.beans.OofRequest in project so by onap.
the class OofClientTestIT method testPostDemands_error_failed.
@Test(expected = BadResponseException.class)
public void testPostDemands_error_failed() throws JsonProcessingException, BadResponseException {
String mockResponse = "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"missing data\", \"requestStatus\": \"failed\"}";
wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement")).willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse)));
client.postDemands(new OofRequest());
// TODO assertEquals("missing data", );
}
use of org.onap.so.client.oof.beans.OofRequest in project so by onap.
the class OofClientTestIT method testPostDemands_error_noStatus.
@Test(expected = BadResponseException.class)
public void testPostDemands_error_noStatus() throws JsonProcessingException, BadResponseException {
String mockResponse = "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"missing data\", \"requestStatus\": null}";
wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement")).willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse)));
client.postDemands(new OofRequest());
}
use of org.onap.so.client.oof.beans.OofRequest in project so by onap.
the class OofClientTestIT method testAsyncResponse_success.
@Test
public void testAsyncResponse_success() throws BadResponseException, JsonProcessingException {
String mockResponse = "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"status\", \"requestStatus\": \"accepted\"}";
wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement")).willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse)));
client.postDemands(new OofRequest());
}
use of org.onap.so.client.oof.beans.OofRequest in project so by onap.
the class OofHomingV2 method callOof.
/**
* Generates the request payload then sends to Oof to perform homing and licensing for the provided demands
*
* @param execution
*/
public void callOof(BuildingBlockExecution execution) {
logger.trace("Started Oof Homing Call Oof");
try {
GeneralBuildingBlock bb = execution.getGeneralBuildingBlock();
RequestContext requestContext = bb.getRequestContext();
String requestId = requestContext.getMsoRequestId();
ServiceInstance serviceInstance = bb.getCustomer().getServiceSubscription().getServiceInstances().get(0);
Customer customer = bb.getCustomer();
String timeout = execution.getVariable("timeout");
if (isBlank(timeout)) {
timeout = env.getProperty("oof.timeout", "PT30M");
}
OofRequest oofRequest = new OofRequest();
RequestInfo requestInfo = buildRequestInfo(requestId, timeout);
oofRequest.setRequestInformation(requestInfo);
ServiceInfo serviceInfo = buildServiceInfo(serviceInstance);
oofRequest.setServiceInformation(serviceInfo);
PlacementInfo placementInfo = buildPlacementInfo(customer);
placementInfo = buildPlacementDemands(serviceInstance, placementInfo);
oofRequest.setPlacementInformation(placementInfo);
LicenseInfo licenseInfo = buildLicenseInfo(serviceInstance);
oofRequest.setLicenseInformation(licenseInfo);
if (!placementInfo.getPlacementDemands().isEmpty() || !licenseInfo.getLicenseDemands().isEmpty()) {
oofClient.postDemands(oofRequest);
} else {
logger.debug(SERVICE_MISSING_DATA + " resources eligible for homing or licensing");
throw new BpmnError(UNPROCESSABLE, SERVICE_MISSING_DATA + " resources eligible for homing or licensing");
}
// Variables for ReceiveWorkflowMessage subflow
execution.setVariable("asyncCorrelator", requestId);
execution.setVariable("asyncMessageType", "OofResponse");
execution.setVariable("asyncTimeout", timeout);
logger.trace("Completed Oof Homing Call Oof");
} catch (BpmnError e) {
logger.debug(ERROR_WHILE_PREPARING_OOF_REQUEST + e.getStackTrace());
exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(e.getErrorCode()), e.getMessage());
} catch (BadResponseException e) {
logger.debug(ERROR_WHILE_PREPARING_OOF_REQUEST + e.getStackTrace());
exceptionUtil.buildAndThrowWorkflowException(execution, 400, e.getMessage());
} catch (Exception e) {
logger.debug(ERROR_WHILE_PREPARING_OOF_REQUEST + e.getStackTrace());
exceptionUtil.buildAndThrowWorkflowException(execution, INTERNAL, "Internal Error - occurred while " + "preparing oof request: " + e + " Stack:" + ExceptionUtils.getFullStackTrace(e));
}
}
use of org.onap.so.client.oof.beans.OofRequest in project so by onap.
the class OofClientTestIT method testPostDemands_error_empty.
@Test(expected = BadResponseException.class)
public void testPostDemands_error_empty() throws JsonProcessingException, BadResponseException {
String mockResponse = "{ }";
wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement")).willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse)));
client.postDemands(new OofRequest());
}
Aggregations