use of org.onap.so.client.oof.beans.PlacementDemand in project so by onap.
the class OofHomingV2 method buildPlacementDemands.
/**
* Builds the placement demand list for the homing/licensing request
*/
private PlacementInfo buildPlacementDemands(ServiceInstance serviceInstance, PlacementInfo placementInfo) {
logger.trace("Building placement information demands");
List<AllottedResource> allottedResourceList = serviceInstance.getAllottedResources();
if (!allottedResourceList.isEmpty()) {
logger.debug("Adding allotted resources to placement demands list");
for (AllottedResource ar : allottedResourceList) {
if (isBlank(ar.getId())) {
ar.setId(UUID.randomUUID().toString());
}
PlacementDemand demand = buildDemand(ar.getId(), ar.getModelInfoAllottedResource());
// addCandidates(ar, demand);
placementInfo.getPlacementDemands().add(demand);
}
}
List<VpnBondingLink> vpnBondingLinkList = serviceInstance.getVpnBondingLinks();
if (!vpnBondingLinkList.isEmpty()) {
logger.debug("Adding vpn bonding links to placement demands list");
for (VpnBondingLink vbl : vpnBondingLinkList) {
List<ServiceProxy> serviceProxyList = vbl.getServiceProxies();
for (ServiceProxy sp : serviceProxyList) {
if (isBlank(sp.getId())) {
sp.setId(UUID.randomUUID().toString());
}
PlacementDemand demand = buildDemand(sp.getId(), sp.getModelInfoServiceProxy());
// addCandidates(sp, demand);
placementInfo.getPlacementDemands().add(demand);
}
}
}
return placementInfo;
}
use of org.onap.so.client.oof.beans.PlacementDemand in project so by onap.
the class OofHomingV2 method buildDemand.
/**
* Builds a single demand object
*/
private PlacementDemand buildDemand(String id, ModelInfoMetadata metadata) {
logger.debug("Building demand for service or resource: " + id);
PlacementDemand placementDemand = new PlacementDemand();
if (isNotBlank(id) && isNotBlank(metadata.getModelInstanceName())) {
placementDemand.setServiceResourceId(id);
placementDemand.setResourceModuleName(metadata.getModelInstanceName());
placementDemand.setResourceModelInfo(buildModelInfo(metadata));
} else {
throw new BpmnError(UNPROCESSABLE, RESOURCE_MISSING_DATA + "modelInstanceName");
}
return placementDemand;
}
use of org.onap.so.client.oof.beans.PlacementDemand in project so by onap.
the class OofClientTestIT method testPostDemands_success.
@Test
public void testPostDemands_success() throws BadResponseException, JsonProcessingException {
String mockResponse = "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"status\", \"requestStatus\": \"accepted\"}";
ModelInfo modelInfo = new ModelInfo();
modelInfo.setModelCustomizationName("modelCustomizationName-Service");
modelInfo.setModelInvariantId("modelInvariantId-Service");
modelInfo.setModelName("modelName-Service");
modelInfo.setModelType("modelType-Service");
modelInfo.setModelVersion("modelVersion-Service");
modelInfo.setModelVersionId("modelVersionId-Service");
ServiceInfo serviceInfo = new ServiceInfo();
serviceInfo.setModelInfo(modelInfo);
serviceInfo.setServiceInstanceId("serviceInstanceId");
serviceInfo.setServiceName("serviceName");
SubscriberInfo subscriberInfo = new SubscriberInfo();
subscriberInfo.setGlobalSubscriberId("globalSubscriberId");
subscriberInfo.setSubscriberCommonSiteId("subscriberCommonSiteId");
subscriberInfo.setSubscriberName("subscriberName");
ResourceModelInfo resourceModelInfo = new ResourceModelInfo();
resourceModelInfo.setModelType("modelType");
resourceModelInfo.setModelCustomizationName("modelCustomizationName");
resourceModelInfo.setModelInvariantId("invarianteId");
resourceModelInfo.setModelName("modelName");
resourceModelInfo.setModelVersion("version");
resourceModelInfo.setModelVersionId("versionId");
PlacementDemand placementDemand = new PlacementDemand();
placementDemand.setResourceModelInfo(resourceModelInfo);
placementDemand.setResourceModuleName("resourceModuleName");
placementDemand.setServiceResourceId("serviceResourceId");
placementDemand.setTenantId("tenantId");
OofRequestParameters oofRequestParameters = new OofRequestParameters();
oofRequestParameters.setCustomerLatitude("customerLatitude");
oofRequestParameters.setCustomerLongitude("customerLongitude");
oofRequestParameters.setCustomerName("customerName");
ArrayList<PlacementDemand> placementDemands = new ArrayList<>();
placementDemands.add(placementDemand);
PlacementInfo placementInfo = new PlacementInfo();
placementInfo.setPlacementDemands(placementDemands);
placementInfo.setRequestParameters(oofRequestParameters);
placementInfo.setSubscriberInfo(subscriberInfo);
RequestInfo requestInfo = new RequestInfo();
requestInfo.setTransactionId("transactionId");
List<String> optimizer = new ArrayList<>();
optimizer.add("optimizer1");
optimizer.add("optimizer2");
requestInfo.setOptimizers(optimizer);
requestInfo.setCallbackUrl("callBackUrl");
requestInfo.setNumSolutions(1);
requestInfo.setRequestId("requestId");
requestInfo.setSourceId("sourceId");
requestInfo.setTimeout(30L);
requestInfo.setRequestType("requestType");
OofRequest oofRequest = new OofRequest();
oofRequest.setRequestInformation(requestInfo);
oofRequest.setPlacementInformation(placementInfo);
oofRequest.setServiceInformation(serviceInfo);
oofRequest.setLicenseInformation(new LicenseInfo());
wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement")).willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse)));
client.postDemands(oofRequest);
String oofRequestOutput = oofRequest.toJsonString();
JSONAssert.assertEquals("{\n" + " \"requestInfo\" : {\n" + " \"transactionId\" : \"transactionId\",\n" + " \"requestId\" : \"requestId\",\n" + " \"callbackUrl\" : \"callBackUrl\",\n" + " \"sourceId\" : \"sourceId\",\n" + " \"requestType\" : \"requestType\",\n" + " \"numSolutions\" : 1,\n" + " \"optimizers\" : [ \"optimizer1\", \"optimizer2\" ],\n" + " \"timeout\" : 30\n" + " },\n" + " \"serviceInfo\" : {\n" + " \"serviceInstanceId\" : \"serviceInstanceId\",\n" + " \"serviceName\" : \"serviceName\",\n" + " \"modelInfo\" : {\n" + " \"modelType\" : \"modelType-Service\",\n" + " \"modelInvariantId\" : \"modelInvariantId-Service\",\n" + " \"modelVersionId\" : \"modelVersionId-Service\",\n" + " \"modelName\" : \"modelName-Service\",\n" + " \"modelVersion\" : \"modelVersion-Service\",\n" + " \"modelCustomizationName\" : \"modelCustomizationName-Service\"\n" + " }\n" + " },\n" + " \"placementInfo\" : {\n" + " \"requestParameters\" : {\n" + " \"customerLatitude\" : \"customerLatitude\",\n" + " \"customerLongitude\" : \"customerLongitude\",\n" + " \"customerName\" : \"customerName\"\n" + " },\n" + " \"subscriberInfo\" : {\n" + " \"globalSubscriberId\" : \"globalSubscriberId\",\n" + " \"subscriberName\" : \"subscriberName\",\n" + " \"subscriberCommonSiteId\" : \"subscriberCommonSiteId\"\n" + " },\n" + " \"placementDemands\" : [ {\n" + " \"resourceModuleName\" : \"resourceModuleName\",\n" + " \"serviceResourceId\" : \"serviceResourceId\",\n" + " \"tenantId\" : \"tenantId\",\n" + " \"resourceModelInfo\" : {\n" + " \"modelType\" : \"modelType\",\n" + " \"modelInvariantId\" : \"invarianteId\",\n" + " \"modelVersionId\" : \"versionId\",\n" + " \"modelName\" : \"modelName\",\n" + " \"modelVersion\" : \"version\",\n" + " \"modelCustomizationName\" : \"modelCustomizationName\"\n" + " }\n" + " } ]\n" + " },\n" + " \"licenseInfo\" : { \n" + " \"licenseDemands\" : [ ]\n" + "}\n" + "}", oofRequestOutput.replace("\r\n", "\n"), false);
}
Aggregations