Search in sources :

Example 6 with ModelInfoInstanceGroup

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;
}
Also used : ModelInfoInstanceGroup(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup) CollectionResourceInstanceGroupCustomization(org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization)

Example 7 with 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());
}
Also used : ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) IOException(java.io.IOException) InstanceGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup) ModelInfoInstanceGroup(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup) ModelInfoInstanceGroup(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 8 with ModelInfoInstanceGroup

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());
}
Also used : CloudRegion(org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion) ModelInfoGenericVnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) Customer(org.onap.so.bpmn.servicedecomposition.bbobjects.Customer) HashMap(java.util.HashMap) ModelInfoGenericVnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf) License(org.onap.so.bpmn.servicedecomposition.generalobjects.License) ArrayList(java.util.ArrayList) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) URI(java.net.URI) InstanceGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup) ModelInfoInstanceGroup(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup) GenericResourceApiVnfOperationInformation(org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation) ServiceSubscription(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription) ModelInfoInstanceGroup(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup) RequestContext(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) Test(org.junit.Test)

Example 9 with ModelInfoInstanceGroup

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));
}
Also used : ModelInfoInstanceGroup(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) InstanceGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup) ModelInfoInstanceGroup(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 10 with ModelInfoInstanceGroup

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));
}
Also used : ModelInfoInstanceGroup(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup) CollectionResourceInstanceGroupCustomization(org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization) CollectionResourceCustomization(org.onap.so.db.catalog.beans.CollectionResourceCustomization) File(java.io.File) InstanceGroup(org.onap.so.db.catalog.beans.InstanceGroup) ModelInfoInstanceGroup(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup) Test(org.junit.Test)

Aggregations

ModelInfoInstanceGroup (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup)12 Test (org.junit.Test)8 InstanceGroup (org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup)8 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)6 ArrayList (java.util.ArrayList)4 CollectionResourceInstanceGroupCustomization (org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization)3 BpmnError (org.camunda.bpm.engine.delegate.BpmnError)2 Before (org.junit.Before)2 BaseTaskTest (org.onap.so.bpmn.BaseTaskTest)2 BuildingBlockExecution (org.onap.so.bpmn.common.BuildingBlockExecution)2 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)2 ModelInfoGenericVnf (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf)2 ModelInfoServiceInstance (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)2 BBObjectNotFoundException (org.onap.so.client.exception.BBObjectNotFoundException)2 CollectionResourceCustomization (org.onap.so.db.catalog.beans.CollectionResourceCustomization)2 Service (org.onap.so.db.catalog.beans.Service)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 File (java.io.File)1 IOException (java.io.IOException)1 URI (java.net.URI)1