Search in sources :

Example 1 with ModelInfoInstanceGroup

use of org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup in project so by onap.

the class UnassignVnf method deleteInstanceGroups.

/**
 * BPMN access method to deleting instanceGroup in AAI.
 *
 * It will extract the vnf from BBobject ,It will get the instance group from the vnf and add it into a list.
 *
 * Then iterate that list and check the ModelInfoInstanceGroup type.
 *
 * Then it will delete that.
 *
 * @param execution
 */
public void deleteInstanceGroups(BuildingBlockExecution execution) {
    try {
        GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
        List<InstanceGroup> instanceGroups = vnf.getInstanceGroups();
        for (InstanceGroup instanceGroup : instanceGroups) {
            if (ModelInfoInstanceGroup.TYPE_VNFC.equalsIgnoreCase(instanceGroup.getModelInfoInstanceGroup().getType())) {
                aaiInstanceGroupResources.deleteInstanceGroup(instanceGroup);
            }
        }
    } catch (Exception ex) {
        logger.error("Exception occurred in UnassignVnf deleteInstanceGroups", ex);
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
    }
}
Also used : GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) InstanceGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup) ModelInfoInstanceGroup(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup)

Example 2 with ModelInfoInstanceGroup

use of org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup in project so by onap.

the class BBInputSetupTest method testMapVnfcCollectionInstanceGroup.

@Test
public void testMapVnfcCollectionInstanceGroup() {
    VnfResourceCustomization vnfResourceCust = Mockito.mock(VnfResourceCustomization.class);
    GenericVnf genericVnf = new GenericVnf();
    ModelInfo modelInfo = Mockito.mock(ModelInfo.class);
    Service service = Mockito.mock(Service.class);
    org.onap.so.db.catalog.beans.InstanceGroup instanceGroup = new org.onap.so.db.catalog.beans.InstanceGroup();
    instanceGroup.setModelUUID("modelUUID");
    List<VnfcInstanceGroupCustomization> vnfcInstanceGroups = new ArrayList<>();
    VnfcInstanceGroupCustomization vnfcInstanceGroupCust = new VnfcInstanceGroupCustomization();
    vnfcInstanceGroupCust.setInstanceGroup(instanceGroup);
    vnfcInstanceGroupCust.setFunction("function");
    vnfcInstanceGroupCust.setDescription("description");
    vnfcInstanceGroups.add(vnfcInstanceGroupCust);
    ModelInfoInstanceGroup modelInfoInstanceGroup = new ModelInfoInstanceGroup();
    modelInfoInstanceGroup.setModelUUID("modelUUID");
    doReturn(vnfResourceCust).when(SPY_bbInputSetup).getVnfResourceCustomizationFromService(modelInfo, service);
    doReturn(vnfcInstanceGroups).when(vnfResourceCust).getVnfcInstanceGroupCustomizations();
    doReturn(instanceGroup).when(SPY_bbInputSetupUtils).getCatalogInstanceGroup("modelUUID");
    doReturn(modelInfoInstanceGroup).when(bbInputSetupMapperLayer).mapCatalogInstanceGroupToInstanceGroup(null, instanceGroup);
    SPY_bbInputSetup.mapVnfcCollectionInstanceGroup(genericVnf, modelInfo, service);
    assertEquals("Instance Group was created", true, genericVnf.getInstanceGroups().size() == 1);
}
Also used : ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) ModelInfoGenericVnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) ArrayList(java.util.ArrayList) Service(org.onap.so.db.catalog.beans.Service) ModelInfoInstanceGroup(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup) InstanceGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup) VnfcInstanceGroupCustomization(org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization) ModelInfoInstanceGroup(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup) VnfResourceCustomization(org.onap.so.db.catalog.beans.VnfResourceCustomization) Test(org.junit.Test)

Example 3 with ModelInfoInstanceGroup

use of org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup in project so by onap.

the class AssignVnfTest method before.

@Before
public void before() throws BBObjectNotFoundException {
    ModelInfoInstanceGroup modelVnfc = new ModelInfoInstanceGroup();
    modelVnfc.setType("VNFC");
    modelVnfc.setFunction("function");
    ModelInfoInstanceGroup modelNetworkInstanceGroup = new ModelInfoInstanceGroup();
    modelNetworkInstanceGroup.setType("L3-NETWORK");
    modelNetworkInstanceGroup.setFunction("function");
    instanceGroup1 = new InstanceGroup();
    instanceGroup1.setId("test-001");
    instanceGroup1.setModelInfoInstanceGroup(modelVnfc);
    instanceGroup2 = new InstanceGroup();
    instanceGroup2.setId("test-002");
    instanceGroup2.setModelInfoInstanceGroup(modelVnfc);
    instanceGroup3 = new InstanceGroup();
    instanceGroup3.setId("test-003");
    instanceGroup3.setModelInfoInstanceGroup(modelNetworkInstanceGroup);
    instanceGroup4 = new InstanceGroup();
    instanceGroup4.setId("test-004");
    instanceGroup4.setModelInfoInstanceGroup(modelNetworkInstanceGroup);
    genericVnf = setGenericVnf();
    genericVnf.setVnfName("vnfName");
    doNothing().when(aaiInstanceGroupResources).createInstanceGroup(isA(InstanceGroup.class));
    doNothing().when(aaiInstanceGroupResources).connectInstanceGroupToVnf(isA(InstanceGroup.class), isA(GenericVnf.class));
    when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf);
    doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
    doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
}
Also used : ModelInfoInstanceGroup(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) BuildingBlockExecution(org.onap.so.bpmn.common.BuildingBlockExecution) BBObjectNotFoundException(org.onap.so.client.exception.BBObjectNotFoundException) InstanceGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup) ModelInfoInstanceGroup(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup) BpmnError(org.camunda.bpm.engine.delegate.BpmnError) Before(org.junit.Before)

Example 4 with ModelInfoInstanceGroup

use of org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup in project so by onap.

the class CreateNetworkCollectionTest method buildCreateNetworkRequestInstanceGroupModelInfoFunctionNullExceptionTest.

@Test(expected = BpmnError.class)
public void buildCreateNetworkRequestInstanceGroupModelInfoFunctionNullExceptionTest() throws Exception {
    ModelInfoInstanceGroup modelInfoInstanceGroup = new ModelInfoInstanceGroup();
    serviceInstance.getCollection().getInstanceGroup().setModelInfoInstanceGroup(modelInfoInstanceGroup);
    createNetworkCollection.buildNetworkCollectionName(execution);
}
Also used : ModelInfoInstanceGroup(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 5 with ModelInfoInstanceGroup

use of org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup in project so by onap.

the class CreateNetworkCollectionTest method before.

@Before
public void before() throws BBObjectNotFoundException {
    serviceInstance = setServiceInstance();
    network = setL3Network();
    cloudRegion = setCloudRegion();
    List<L3Network> l3NetworkList = new ArrayList<L3Network>();
    l3NetworkList.add(network);
    ModelInfoInstanceGroup modelInfoInstanceGroup = new ModelInfoInstanceGroup();
    modelInfoInstanceGroup.setFunction("function");
    serviceInstance.getCollection().getInstanceGroup().setModelInfoInstanceGroup(modelInfoInstanceGroup);
    orchestrationContext = setOrchestrationContext();
    orchestrationContext.setIsRollbackEnabled(true);
    doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
    when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(network);
    when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID))).thenReturn(serviceInstance);
}
Also used : L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) ModelInfoInstanceGroup(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup) BuildingBlockExecution(org.onap.so.bpmn.common.BuildingBlockExecution) ArrayList(java.util.ArrayList) BBObjectNotFoundException(org.onap.so.client.exception.BBObjectNotFoundException) BpmnError(org.camunda.bpm.engine.delegate.BpmnError) Before(org.junit.Before)

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