use of org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup in project so by onap.
the class BBInputSetupMapperLayer method mapCatalogInstanceGroupToInstanceGroup.
protected ModelInfoInstanceGroup mapCatalogInstanceGroupToInstanceGroup(CollectionResourceCustomization collectionCust, InstanceGroup instanceGroup) {
ModelInfoInstanceGroup modelInfoInstanceGroup = modelMapper.map(instanceGroup, ModelInfoInstanceGroup.class);
if (instanceGroup.getType() != null && instanceGroup.getType().equals(InstanceGroupType.L3_NETWORK))
modelInfoInstanceGroup.setType(ModelInfoInstanceGroup.TYPE_L3_NETWORK);
else
modelInfoInstanceGroup.setType(ModelInfoInstanceGroup.TYPE_VNFC);
if (collectionCust != null) {
List<CollectionResourceInstanceGroupCustomization> instanceGroupCustList = instanceGroup.getCollectionInstanceGroupCustomizations();
for (CollectionResourceInstanceGroupCustomization collectionInsatnceGroupCust : instanceGroupCustList) {
if (collectionInsatnceGroupCust.getModelCustomizationUUID().equalsIgnoreCase(collectionCust.getModelCustomizationUUID())) {
modelInfoInstanceGroup.setFunction(collectionInsatnceGroupCust.getFunction());
modelInfoInstanceGroup.setDescription(collectionInsatnceGroupCust.getDescription());
break;
}
}
}
return modelInfoInstanceGroup;
}
use of org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup in project so by onap.
the class AAIObjectMapperTest method testMapInstanceGroup.
@Test
public void testMapInstanceGroup() {
InstanceGroup instanceGroup = new InstanceGroup();
instanceGroup.setId("test-id");
instanceGroup.setDescription("test-description");
instanceGroup.setInstanceGroupName("test-instanceGroupName");
instanceGroup.setResourceVersion("test-resourceVersion");
ModelInfoInstanceGroup model = new ModelInfoInstanceGroup();
model.setFunction("test-function");
model.setInstanceGroupRole("SUB-INTERFACE");
model.setType("VNFC");
model.setModelInvariantUUID("modelInvariantUUID-000");
model.setModelUUID("modelUUID-000");
model.setDescription("test-description");
model.setInstanceGroupRole("SUB-INTERFACE");
instanceGroup.setModelInfoInstanceGroup(model);
org.onap.aai.domain.yang.InstanceGroup aaiInstanceGroup = aaiObjectMapper.mapInstanceGroup(instanceGroup);
try {
com.fasterxml.jackson.databind.ObjectMapper mapper = new com.fasterxml.jackson.databind.ObjectMapper();
String json = mapper.writeValueAsString(aaiInstanceGroup);
System.out.println("GGG - json:\n" + json);
} catch (Exception e) {
e.printStackTrace();
}
assertEquals(aaiInstanceGroup.getId(), instanceGroup.getId());
assertEquals(aaiInstanceGroup.getDescription(), instanceGroup.getDescription());
assertEquals(aaiInstanceGroup.getInstanceGroupRole(), instanceGroup.getModelInfoInstanceGroup().getInstanceGroupRole());
assertEquals(aaiInstanceGroup.getModelInvariantId(), instanceGroup.getModelInfoInstanceGroup().getModelInvariantUUID());
assertEquals(aaiInstanceGroup.getModelVersionId(), instanceGroup.getModelInfoInstanceGroup().getModelUUID());
assertEquals(aaiInstanceGroup.getResourceVersion(), instanceGroup.getResourceVersion());
assertEquals(aaiInstanceGroup.getInstanceGroupType(), instanceGroup.getModelInfoInstanceGroup().getType());
assertEquals(aaiInstanceGroup.getInstanceGroupRole(), instanceGroup.getModelInfoInstanceGroup().getInstanceGroupRole());
}
use of org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup in project so by onap.
the class VnfTopologyOperationRequestMapperTest method reqMapperTest.
@Test
public void reqMapperTest() throws Exception {
// prepare and set service instance
ServiceInstance serviceInstance = new ServiceInstance();
ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
modelInfoServiceInstance.setModelInvariantUuid("modelInvariantUuid");
modelInfoServiceInstance.setModelName("modelName");
modelInfoServiceInstance.setModelUuid("modelUuid");
modelInfoServiceInstance.setModelVersion("modelVersion");
serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
// prepare VNF
ModelInfoGenericVnf genericVnf = new ModelInfoGenericVnf();
genericVnf.setModelInvariantUuid("vnfModelInvariantUUID");
genericVnf.setModelVersion("vnfModelVersion");
genericVnf.setModelName("vnfModelName");
genericVnf.setModelUuid("vnfModelUUID");
genericVnf.setModelCustomizationUuid("vnfModelCustomizationUUID");
ModelInfoInstanceGroup modelL3Network = new ModelInfoInstanceGroup();
modelL3Network.setType("L3-NETWORK");
InstanceGroup instanceGroup1 = new InstanceGroup();
instanceGroup1.setId("l3-network-ig-111");
instanceGroup1.setModelInfoInstanceGroup(modelL3Network);
InstanceGroup instanceGroup2 = new InstanceGroup();
instanceGroup2.setId("l3-network-ig-222");
instanceGroup2.setModelInfoInstanceGroup(modelL3Network);
GenericVnf vnf = new GenericVnf();
vnf.setModelInfoGenericVnf(genericVnf);
vnf.setVnfId("vnfId");
vnf.setVnfType("vnfType");
vnf.getInstanceGroups().add(instanceGroup1);
vnf.getInstanceGroups().add(instanceGroup2);
License license = new License();
List<String> entitlementPoolUuids = new ArrayList<>();
entitlementPoolUuids.add("entitlementPoolUuid");
List<String> licenseKeyGroupUuids = new ArrayList<>();
licenseKeyGroupUuids.add("licenseKeyGroupUuid");
license.setEntitlementPoolUuids(entitlementPoolUuids);
license.setLicenseKeyGroupUuids(licenseKeyGroupUuids);
vnf.setLicense(license);
// 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);
// prepare RequestContext
RequestContext requestContext = new RequestContext();
Map<String, Object> userParams = new HashMap<>();
userParams.put("key1", "value1");
requestContext.setUserParams(userParams);
requestContext.setProductFamilyId("productFamilyId");
requestContext.setMsoRequestId("MsoRequestId");
CloudRegion cloudRegion = new CloudRegion();
GenericResourceApiVnfOperationInformation vnfOpInformation = mapper.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, GenericResourceApiRequestActionEnumeration.CREATEVNFINSTANCE, vnf, serviceInstance, customer, cloudRegion, requestContext, true, new URI("http://localhost:8080"));
GenericResourceApiVnfOperationInformation vnfOpInformationNullReqContext = mapper.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, GenericResourceApiRequestActionEnumeration.CREATEVNFINSTANCE, vnf, serviceInstance, customer, cloudRegion, null, true, new URI("http://localhost:8080"));
assertNull(vnfOpInformation.getServiceInformation().getOnapModelInformation().getModelCustomizationUuid());
assertEquals("vnfModelCustomizationUUID", vnfOpInformation.getVnfInformation().getOnapModelInformation().getModelCustomizationUuid());
assertEquals(2, vnfOpInformation.getVnfRequestInput().getVnfNetworkInstanceGroupIds().size());
assertEquals("l3-network-ig-111", vnfOpInformation.getVnfRequestInput().getVnfNetworkInstanceGroupIds().get(0).getVnfNetworkInstanceGroupId());
assertEquals("l3-network-ig-222", vnfOpInformation.getVnfRequestInput().getVnfNetworkInstanceGroupIds().get(1).getVnfNetworkInstanceGroupId());
assertEquals("entitlementPoolUuid", vnfOpInformation.getVnfRequestInput().getVnfInputParameters().getParam().get(1).getValue());
assertEquals("licenseKeyGroupUuid", vnfOpInformation.getVnfRequestInput().getVnfInputParameters().getParam().get(2).getValue());
assertEquals("MsoRequestId", vnfOpInformation.getRequestInformation().getRequestId());
assertNotNull(vnfOpInformationNullReqContext.getRequestInformation().getRequestId());
}
use of org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup in project so by onap.
the class UnassignVnfTest method deleteInstanceGroupsSunnyDayTest.
@Test
public void deleteInstanceGroupsSunnyDayTest() throws Exception {
GenericVnf genericVnf = setGenericVnf();
ModelInfoInstanceGroup modelVnfc = new ModelInfoInstanceGroup();
modelVnfc.setType("VNFC");
InstanceGroup instanceGroup1 = new InstanceGroup();
instanceGroup1.setId("test-001");
instanceGroup1.setModelInfoInstanceGroup(modelVnfc);
genericVnf.getInstanceGroups().add(instanceGroup1);
InstanceGroup instanceGroup2 = new InstanceGroup();
instanceGroup2.setId("test-002");
instanceGroup2.setModelInfoInstanceGroup(modelVnfc);
genericVnf.getInstanceGroups().add(instanceGroup2);
when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf);
unassignVnf.deleteInstanceGroups(execution);
verify(aaiInstanceGroupResources, times(1)).deleteInstanceGroup(eq(instanceGroup1));
verify(aaiInstanceGroupResources, times(1)).deleteInstanceGroup(eq(instanceGroup2));
}
use of org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup in project so by onap.
the class BBInputSetupMapperLayerTest method testMapCatalogInstanceGroupToInstanceGroup.
@Test
public void testMapCatalogInstanceGroupToInstanceGroup() throws IOException {
ModelInfoInstanceGroup expected = mapper.readValue(new File(RESOURCE_PATH + "ModelInfoInstanceGroup.json"), ModelInfoInstanceGroup.class);
InstanceGroup instanceGroup = mapper.readValue(new File(RESOURCE_PATH + "InstanceGroup.json"), InstanceGroup.class);
instanceGroup.setCollectionInstanceGroupCustomizations(new ArrayList<>());
CollectionResourceInstanceGroupCustomization collectionInstanceGroupCust = new CollectionResourceInstanceGroupCustomization();
collectionInstanceGroupCust.setModelCustomizationUUID("modelCustomizationUUID");
collectionInstanceGroupCust.setFunction("function");
collectionInstanceGroupCust.setDescription("description");
instanceGroup.getCollectionInstanceGroupCustomizations().add(collectionInstanceGroupCust);
CollectionResourceCustomization collectionResourceCust = new CollectionResourceCustomization();
collectionResourceCust.setModelCustomizationUUID("modelCustomizationUUID");
ModelInfoInstanceGroup actual = bbInputSetupMapperLayer.mapCatalogInstanceGroupToInstanceGroup(collectionResourceCust, instanceGroup);
assertThat(actual, sameBeanAs(expected));
}
Aggregations