Search in sources :

Example 1 with Collection

use of org.onap.so.bpmn.servicedecomposition.bbobjects.Collection in project so by onap.

the class CreateNetworkCollection method connectCollectionToServiceInstance.

/**
 * BPMN access method to connect Network Collection
 *
 * @param execution
 * @throws Exception
 */
public void connectCollectionToServiceInstance(BuildingBlockExecution execution) throws Exception {
    execution.setVariable("connectCollectionToServiceInstanceRollback", false);
    try {
        ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
        Collection networkCollection = serviceInstance.getCollection();
        aaiNetworkResources.connectNetworkCollectionToServiceInstance(networkCollection, serviceInstance);
        execution.setVariable("connectCollectionToServiceInstanceRollback", true);
    } catch (Exception ex) {
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
    }
}
Also used : ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) Collection(org.onap.so.bpmn.servicedecomposition.bbobjects.Collection)

Example 2 with Collection

use of org.onap.so.bpmn.servicedecomposition.bbobjects.Collection in project so by onap.

the class BuildingBlockTestDataSetup method buildCollection.

public Collection buildCollection() {
    collectionCounter++;
    Collection collection = new Collection();
    collection.setId("testId" + collectionCounter);
    collection.setInstanceGroup(buildInstanceGroup());
    return collection;
}
Also used : Collection(org.onap.so.bpmn.servicedecomposition.bbobjects.Collection)

Example 3 with Collection

use of org.onap.so.bpmn.servicedecomposition.bbobjects.Collection in project so by onap.

the class BBInputSetupTest method testMapCollection.

@Test
public void testMapCollection() throws JsonProcessingException {
    List<AAIResultWrapper> collections = new ArrayList<>();
    ServiceInstance serviceInstance = new ServiceInstance();
    org.onap.aai.domain.yang.Collection aaiCollection = new org.onap.aai.domain.yang.Collection();
    org.onap.aai.domain.yang.RelationshipList collectionRelationshipList = new org.onap.aai.domain.yang.RelationshipList();
    org.onap.aai.domain.yang.Relationship collectionInstanceGroupRelationship = new org.onap.aai.domain.yang.Relationship();
    collectionRelationshipList.getRelationship().add(collectionInstanceGroupRelationship);
    aaiCollection.setRelationshipList(collectionRelationshipList);
    collections.add(new AAIResultWrapper(new AAICommonObjectMapperProvider().getMapper().writeValueAsString(aaiCollection)));
    Collection collection = new Collection();
    ModelInfoCollection modelInfoCollection = new ModelInfoCollection();
    List<InstanceGroup> instanceGroupsList = new ArrayList<>();
    InstanceGroup instanceGroup = new InstanceGroup();
    instanceGroupsList.add(instanceGroup);
    NetworkCollectionResourceCustomization networkCollectionCust = Mockito.mock(NetworkCollectionResourceCustomization.class);
    CollectionResource collectionResource = new CollectionResource();
    doReturn(collection).when(bbInputSetupMapperLayer).mapAAICollectionIntoCollection(isA(org.onap.aai.domain.yang.Collection.class));
    doReturn(instanceGroupsList).when(SPY_bbInputSetup).mapInstanceGroups(any());
    doReturn(networkCollectionCust).when(SPY_bbInputSetupUtils).getCatalogNetworkCollectionResourceCustByID(aaiCollection.getCollectionCustomizationId());
    doReturn(collectionResource).when(networkCollectionCust).getCollectionResource();
    doReturn(modelInfoCollection).when(bbInputSetupMapperLayer).mapCatalogCollectionToCollection(networkCollectionCust, collectionResource);
    SPY_bbInputSetup.mapCollection(collections, serviceInstance);
    assertEquals(collection, serviceInstance.getCollection());
    assertEquals(instanceGroup, collection.getInstanceGroup());
    instanceGroupsList.clear();
    collection = new Collection();
    SPY_bbInputSetup.mapCollection(collections, serviceInstance);
    assertEquals(collection, serviceInstance.getCollection());
    assertNull(collection.getInstanceGroup());
}
Also used : CollectionResource(org.onap.so.db.catalog.beans.CollectionResource) ArrayList(java.util.ArrayList) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) ModelInfoCollection(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoCollection) AAICommonObjectMapperProvider(org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider) ModelInfoInstanceGroup(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup) InstanceGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup) NetworkCollectionResourceCustomization(org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization) Collection(org.onap.so.bpmn.servicedecomposition.bbobjects.Collection) ModelInfoCollection(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoCollection) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) Test(org.junit.Test)

Example 4 with Collection

use of org.onap.so.bpmn.servicedecomposition.bbobjects.Collection in project so by onap.

the class TestDataSetup method buildCollection.

public Collection buildCollection() {
    collectionCounter++;
    Collection collection = new Collection();
    collection.setId("testId" + collectionCounter);
    collection.setInstanceGroup(buildInstanceGroup());
    return collection;
}
Also used : Collection(org.onap.so.bpmn.servicedecomposition.bbobjects.Collection)

Example 5 with Collection

use of org.onap.so.bpmn.servicedecomposition.bbobjects.Collection in project so by onap.

the class BBInputSetup method populateNetworkCollectionAndInstanceGroupAssign.

protected void populateNetworkCollectionAndInstanceGroupAssign(BBInputSetupParameter parameter) throws Exception {
    if (parameter.getServiceInstance().getCollection() == null && parameter.getBbName().equalsIgnoreCase(AssignFlows.NETWORK_COLLECTION.toString())) {
        Collection collection = this.createCollection(parameter.getResourceId());
        parameter.getServiceInstance().setCollection(collection);
        this.mapCatalogCollection(parameter.getService(), parameter.getServiceInstance().getCollection(), parameter.getKey());
        if (isVlanTagging(parameter.getService(), parameter.getKey())) {
            InstanceGroup instanceGroup = this.createInstanceGroup();
            parameter.getServiceInstance().getCollection().setInstanceGroup(instanceGroup);
            this.mapCatalogNetworkCollectionInstanceGroup(parameter.getService(), parameter.getServiceInstance().getCollection().getInstanceGroup(), parameter.getKey());
        }
    }
}
Also used : Collection(org.onap.so.bpmn.servicedecomposition.bbobjects.Collection) InstanceGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup)

Aggregations

Collection (org.onap.so.bpmn.servicedecomposition.bbobjects.Collection)24 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)13 InstanceGroup (org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup)8 ModelInfoServiceInstance (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)8 Test (org.junit.Test)6 ModelInfoCollection (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoCollection)6 BBObjectNotFoundException (org.onap.so.client.exception.BBObjectNotFoundException)5 ArrayList (java.util.ArrayList)4 NetworkCollectionResourceCustomization (org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization)4 ModelInfoInstanceGroup (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup)3 CollectionResource (org.onap.so.db.catalog.beans.CollectionResource)3 File (java.io.File)2 AAIResultWrapper (org.onap.aaiclient.client.aai.entities.AAIResultWrapper)2 L3Network (org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network)2 CollectionResourceCustomization (org.onap.so.db.catalog.beans.CollectionResourceCustomization)2 Service (org.onap.so.db.catalog.beans.Service)2 HashMap (java.util.HashMap)1 List (java.util.List)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 Before (org.junit.Before)1