use of org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule in project so by onap.
the class VfModuleCDSRequestProvider method buildRequestPayload.
@Override
public Optional<String> buildRequestPayload(String action) throws PayloadGenerationException {
JsonObject cdsPropertyObject = new JsonObject();
JsonObject vfModuleObject = new JsonObject();
String vfModuleName;
try {
ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
final String modelCustomizationUuidForVnf = genericVnf.getModelInfoGenericVnf().getModelCustomizationUuid();
blueprintName = genericVnf.getModelInfoGenericVnf().getBlueprintName();
blueprintVersion = genericVnf.getModelInfoGenericVnf().getBlueprintVersion();
VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
vfModuleName = vfModule.getVfModuleName();
final String modelCustomizationUuidForVfModule = vfModule.getModelInfoVfModule().getModelCustomizationUUID();
vfModuleObject.addProperty("service-instance-id", serviceInstance.getServiceInstanceId());
vfModuleObject.addProperty("service-model-uuid", serviceInstance.getModelInfoServiceInstance().getModelUuid());
vfModuleObject.addProperty("vnf-id", genericVnf.getVnfId());
vfModuleObject.addProperty("vnf-name", genericVnf.getVnfName());
vfModuleObject.addProperty("vf-module-id", vfModule.getVfModuleId());
vfModuleObject.addProperty("vf-module-name", vfModule.getVfModuleName());
vfModuleObject.addProperty("vf-module-customization-uuid", vfModule.getModelInfoVfModule().getModelCustomizationUUID());
final GeneralBuildingBlock buildingBlock = execution.getGeneralBuildingBlock();
List<Map<String, Object>> userParamsFromRequest = buildingBlock.getRequestContext().getRequestParameters().getUserParams();
String vfModuleInstanceName = execution.getLookupMap().getOrDefault(ResourceKey.VF_MODULE_INSTANCE_NAME, "");
if (userParamsFromRequest != null && userParamsFromRequest.size() != 0) {
configureInstanceParamsForVfModule.populateInstanceParams(vfModuleObject, userParamsFromRequest, modelCustomizationUuidForVnf, modelCustomizationUuidForVfModule, vfModuleInstanceName);
}
} catch (Exception e) {
throw new PayloadGenerationException("Failed to buildPropertyObject for VF-Module", e);
}
// Not sure for resolutionKey should be same as vfModule name.
cdsPropertyObject.addProperty("resolution-key", vfModuleName);
cdsPropertyObject.addProperty("template-prefix", vfModuleName + action);
cdsPropertyObject.add(action + SEPARATOR + PROPERTIES, vfModuleObject);
return Optional.of(buildRequestJsonObject(cdsPropertyObject, action));
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule in project so by onap.
the class VfModuleTopologyOperationRequestMapperTest method unassignGenericResourceApiVfModuleInformationNullMsoReqIdTest.
@Test
public void unassignGenericResourceApiVfModuleInformationNullMsoReqIdTest() throws Exception {
// prepare and set service instance
ServiceInstance serviceInstance = new ServiceInstance();
serviceInstance.setServiceInstanceId("serviceInstanceId");
// prepare and set vnf instance
GenericVnf vnf = new GenericVnf();
vnf.setVnfId("testVnfId");
vnf.setVnfType("testVnfType");
// prepare and set vf module instance
VfModule vfModule = new VfModule();
vfModule.setVfModuleId("testVfModuleId");
vfModule.setVfModuleName("testVfModuleName");
RequestContext requestContext = new RequestContext();
GenericResourceApiVfModuleOperationInformation vfModuleSDNCrequest = mapper.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN, vfModule, null, vnf, serviceInstance, null, null, requestContext, null, new URI("http://localhost:8080"));
assertNotNull(vfModuleSDNCrequest.getRequestInformation().getRequestId());
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule in project so by onap.
the class VfModuleTopologyOperationRequestMapperTest method reqMapperNoModelInfoTest.
@Test
public void reqMapperNoModelInfoTest() throws Exception {
// 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");
customer.setServiceSubscription(new ServiceSubscription());
// set Customer on service instance
customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
//
RequestContext requestContext = new RequestContext();
Map<String, Object> userParams = new HashMap<String, Object>();
userParams.put("key1", "value1");
requestContext.setUserParams(userParams);
requestContext.setProductFamilyId("productFamilyId");
GenericVnf vnf = new GenericVnf();
vnf.setVnfId("testVnfId");
vnf.setVnfType("testVnfType");
ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
modelInfoGenericVnf.setModelName("vnfModelName");
modelInfoGenericVnf.setModelVersion("vnfModelVersion");
modelInfoGenericVnf.setModelUuid("vnfModelUuid");
modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
VfModule vfModule = new VfModule();
vfModule.setVfModuleId("testVfModuleId");
vfModule.setVfModuleName("testVfModuleName");
vfModule.setModelInfoVfModule(null);
CloudRegion cloudRegion = new CloudRegion();
expectedException.expect(MapperException.class);
expectedException.expectMessage(ERRORMESSAGE);
mapper.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, vfModule, null, vnf, serviceInstance, customer, cloudRegion, requestContext, null, new URI("http://localhost:8080"));
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule in project so by onap.
the class VfModuleTopologyOperationRequestMapperTest method assignGenericResourceApiVfModuleInformationTest.
@Test
public void assignGenericResourceApiVfModuleInformationTest() throws Exception {
// 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);
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");
RequestParameters requestParameters = new RequestParameters();
requestParameters.setUsePreload(true);
requestContext.setRequestParameters(requestParameters);
requestContext.setMsoRequestId("MsoRequestId");
GenericVnf vnf = new GenericVnf();
vnf.setVnfId("testVnfId");
vnf.setVnfType("testVnfType");
vnf.setVnfName("testVnfName");
ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
modelInfoGenericVnf.setModelName("vnfModelName");
modelInfoGenericVnf.setModelVersion("vnfModelVersion");
modelInfoGenericVnf.setModelUuid("vnfModelUuid");
modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
VfModule vfModule = new VfModule();
vfModule.setVfModuleId("testVfModuleId");
vfModule.setVfModuleName("testVfModuleName");
ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
modelInfoVfModule.setModelName("vfModuleModelName");
modelInfoVfModule.setModelVersion("vfModuleModelVersion");
modelInfoVfModule.setModelUUID("vfModuleModelUuid");
modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
vfModule.setModelInfoVfModule(modelInfoVfModule);
HashMap<String, String> cloudParams = new HashMap<String, String>();
cloudParams.put("key2", "value2");
vfModule.setCloudParams(cloudParams);
VolumeGroup volumeGroup = new VolumeGroup();
volumeGroup.setVolumeGroupId("volumeGroupId");
volumeGroup.setVolumeGroupName("volumeGroupName");
CloudRegion cloudRegion = new CloudRegion();
GenericResourceApiVfModuleOperationInformation vfModuleSDNCrequest = mapper.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, vfModule, volumeGroup, vnf, serviceInstance, customer, cloudRegion, requestContext, null, new URI("http://localhost:8080"));
String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleOperationInformationAssign.json")));
ObjectMapper omapper = new ObjectMapper();
GenericResourceApiVfModuleOperationInformation reqMapper1 = omapper.readValue(jsonToCompare, GenericResourceApiVfModuleOperationInformation.class);
assertThat(vfModuleSDNCrequest, sameBeanAs(reqMapper1).ignoring("sdncRequestHeader.svcRequestId").ignoring("requestInformation.requestId"));
assertEquals("MsoRequestId", vfModuleSDNCrequest.getRequestInformation().getRequestId());
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule in project so by onap.
the class VfModuleTopologyOperationRequestMapperTest method reqMapperTest.
@Test
public void reqMapperTest() throws Exception {
// 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");
customer.setServiceSubscription(new ServiceSubscription());
// set Customer on service instance
customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
//
RequestContext requestContext = new RequestContext();
RequestParameters requestParameters = new RequestParameters();
HashMap<String, Object> userParams1 = new HashMap<>();
userParams1.put("key1", "value1");
List<Map<String, Object>> userParams = new ArrayList<>();
userParams.add(userParams1);
requestParameters.setUserParams(userParams);
requestContext.setRequestParameters(requestParameters);
requestContext.setProductFamilyId("productFamilyId");
GenericVnf vnf = new GenericVnf();
vnf.setVnfId("testVnfId");
vnf.setVnfType("testVnfType");
ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
modelInfoGenericVnf.setModelName("vnfModelName");
modelInfoGenericVnf.setModelVersion("vnfModelVersion");
modelInfoGenericVnf.setModelUuid("vnfModelUuid");
modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
VfModule vfModule = new VfModule();
vfModule.setVfModuleId("testVfModuleId");
vfModule.setVfModuleName("testVfModuleName");
ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
modelInfoVfModule.setModelName("vfModuleModelName");
modelInfoVfModule.setModelVersion("vfModuleModelVersion");
modelInfoVfModule.setModelUUID("vfModuleModelUuid");
modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
vfModule.setModelInfoVfModule(modelInfoVfModule);
CloudRegion cloudRegion = new CloudRegion();
GenericResourceApiVfModuleOperationInformation vfModuleSDNCrequest = mapper.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, vfModule, null, vnf, serviceInstance, customer, cloudRegion, requestContext, null, new URI("http://localhost:8080"));
assertNull(vfModuleSDNCrequest.getServiceInformation().getOnapModelInformation().getModelCustomizationUuid());
assertEquals("vnfModelCustomizationUuid", vfModuleSDNCrequest.getVnfInformation().getOnapModelInformation().getModelCustomizationUuid());
assertEquals("vfModuleModelCustomizationUuid", vfModuleSDNCrequest.getVfModuleInformation().getOnapModelInformation().getModelCustomizationUuid());
}
Aggregations