use of org.onap.so.bpmn.servicedecomposition.bbobjects.Customer in project so by onap.
the class GeneralTopologyObjectMapperTest method testBuildServiceInformation.
@Test
public void testBuildServiceInformation() {
// prepare and set service instance
ServiceInstance serviceInstance = new ServiceInstance();
serviceInstance.setServiceInstanceId("serviceInstanceId");
ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
modelInfoServiceInstance.setModelName("serviceModelName");
modelInfoServiceInstance.setModelUuid("serviceModelUuid");
modelInfoServiceInstance.setModelVersion("serviceModelVersion");
serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
// prepare Customer object
Customer customer = new Customer();
customer.setGlobalCustomerId("globalCustomerId");
ServiceSubscription serviceSubscription = new ServiceSubscription();
serviceSubscription.setServiceType("productFamilyId");
customer.setServiceSubscription(serviceSubscription);
// set Customer on service instance
customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
//
RequestContext requestContext = new RequestContext();
Map<String, Object> userParams = new HashMap<>();
userParams.put("key1", "value1");
requestContext.setUserParams(userParams);
requestContext.setProductFamilyId("productFamilyId");
GenericResourceApiServiceinformationServiceInformation serviceInfo = genObjMapper.buildServiceInformation(serviceInstance, requestContext, customer, true);
assertEquals("serviceModelInvariantUuid", serviceInfo.getOnapModelInformation().getModelInvariantUuid());
assertEquals("serviceModelName", serviceInfo.getOnapModelInformation().getModelName());
assertEquals("serviceModelUuid", serviceInfo.getOnapModelInformation().getModelUuid());
assertEquals("serviceModelVersion", serviceInfo.getOnapModelInformation().getModelVersion());
assertNull(serviceInfo.getOnapModelInformation().getModelCustomizationUuid());
assertEquals("serviceInstanceId", serviceInfo.getServiceInstanceId());
assertEquals("serviceInstanceId", serviceInfo.getServiceId());
assertEquals("globalCustomerId", serviceInfo.getGlobalCustomerId());
assertEquals("productFamilyId", serviceInfo.getSubscriptionServiceType());
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.Customer 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.bpmn.servicedecomposition.bbobjects.Customer in project so by onap.
the class AAIObjectMapperTest method mapCustomerTest.
@Test
public void mapCustomerTest() {
Customer customer = new Customer();
customer.setGlobalCustomerId("globalCustomerId");
customer.setSubscriberName("subscriberName");
customer.setSubscriberType("subscriberType");
org.onap.aai.domain.yang.Customer expectedCustomer = new org.onap.aai.domain.yang.Customer();
expectedCustomer.setGlobalCustomerId("globalCustomerId");
expectedCustomer.setSubscriberName("subscriberName");
expectedCustomer.setSubscriberType("subscriberType");
org.onap.aai.domain.yang.Customer actualCustomer = aaiObjectMapper.mapCustomer(customer);
assertThat(actualCustomer, sameBeanAs(expectedCustomer));
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.Customer in project so by onap.
the class BBInputSetup method getGBBALaCarteService.
protected GeneralBuildingBlock getGBBALaCarteService(ExecuteBuildingBlock executeBB, RequestDetails requestDetails, Map<ResourceKey, String> lookupKeyMap, String requestAction, String resourceId) throws Exception {
Customer customer = getCustomerAndServiceSubscription(requestDetails, resourceId);
if (customer != null) {
Project project = null;
OwningEntity owningEntity = null;
if (requestDetails.getProject() != null)
project = mapperLayer.mapRequestProject(requestDetails.getProject());
if (requestDetails.getOwningEntity() != null)
owningEntity = mapperLayer.mapRequestOwningEntity(requestDetails.getOwningEntity());
String modelVersionId = requestDetails.getModelInfo().getModelVersionId();
if (ModelType.vnf == requestDetails.getModelInfo().getModelType()) {
for (RelatedInstanceList relatedInstanceList : requestDetails.getRelatedInstanceList()) {
if (ModelType.service == relatedInstanceList.getRelatedInstance().getModelInfo().getModelType()) {
modelVersionId = relatedInstanceList.getRelatedInstance().getModelInfo().getModelVersionId();
break;
}
}
}
Service service = bbInputSetupUtils.getCatalogServiceByModelUUID(modelVersionId);
if (service == null) {
service = bbInputSetupUtils.getCatalogServiceByModelVersionAndModelInvariantUUID(requestDetails.getModelInfo().getModelVersion(), requestDetails.getModelInfo().getModelInvariantId());
if (service == null) {
throw new Exception("Could not find service for model version Id: " + requestDetails.getModelInfo().getModelVersionId() + " and for model invariant Id: " + requestDetails.getModelInfo().getModelInvariantId());
}
}
ServiceInstance serviceInstance = this.getALaCarteServiceInstance(service, requestDetails, customer, project, owningEntity, lookupKeyMap, resourceId, Boolean.TRUE.equals(executeBB.isaLaCarte()), executeBB.getBuildingBlock().getBpmnFlowName());
BBInputSetupParameter parameter = new BBInputSetupParameter.Builder().setRequestDetails(requestDetails).setServiceInstance(serviceInstance).setExecuteBB(executeBB).setRequestAction(requestAction).setCustomer(customer).build();
return this.populateGBBWithSIAndAdditionalInfo(parameter);
} else {
throw new Exception("Could not find customer");
}
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.Customer in project so by onap.
the class BBInputSetup method getCustomerAndServiceSubscription.
protected Customer getCustomerAndServiceSubscription(RequestDetails requestDetails, String resourceId) {
Customer customer;
if (requestDetails.getSubscriberInfo() != null) {
customer = this.getCustomerFromRequest(requestDetails);
} else {
customer = this.getCustomerFromURI(resourceId);
}
if (customer != null) {
ServiceSubscription serviceSubscription = null;
serviceSubscription = getServiceSubscription(requestDetails, customer);
if (serviceSubscription == null) {
serviceSubscription = getServiceSubscriptionFromURI(resourceId, customer);
}
customer.setServiceSubscription(serviceSubscription);
return customer;
} else {
return null;
}
}
Aggregations