Search in sources :

Example 1 with ModelInfoCollection

use of org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoCollection 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 2 with ModelInfoCollection

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

the class BBInputSetupMapperLayerTest method testMapCatalogCollectionToCollection.

@Test
public void testMapCatalogCollectionToCollection() throws IOException {
    ModelInfoCollection expected = mapper.readValue(new File(RESOURCE_PATH + "ModelInfoCollection.json"), ModelInfoCollection.class);
    CollectionResourceCustomization collectionCust = mapper.readValue(new File(RESOURCE_PATH + "CollectionResourceCustomization.json"), CollectionResourceCustomization.class);
    CollectionResource collectionResource = mapper.readValue(new File(RESOURCE_PATH + "CollectionResource.json"), CollectionResource.class);
    ModelInfoCollection actual = bbInputSetupMapperLayer.mapCatalogCollectionToCollection(collectionCust, collectionResource);
    assertThat(actual, sameBeanAs(expected));
}
Also used : CollectionResource(org.onap.so.db.catalog.beans.CollectionResource) ModelInfoCollection(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoCollection) CollectionResourceCustomization(org.onap.so.db.catalog.beans.CollectionResourceCustomization) File(java.io.File) Test(org.junit.Test)

Example 3 with ModelInfoCollection

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

the class BBInputSetupMapperLayer method mapCatalogCollectionToCollection.

protected ModelInfoCollection mapCatalogCollectionToCollection(CollectionResourceCustomization collectionCust, CollectionResource collectionResource) {
    ModelInfoCollection modelInfoCollection = new ModelInfoCollection();
    modelInfoCollection.setCollectionFunction(collectionCust.getFunction());
    modelInfoCollection.setCollectionRole(collectionCust.getRole());
    modelInfoCollection.setCollectionType(collectionCust.getType());
    modelInfoCollection.setDescription(collectionResource.getDescription());
    modelInfoCollection.setModelInvariantUUID(collectionResource.getModelInvariantUUID());
    modelInfoCollection.setModelVersionId(collectionResource.getModelUUID());
    modelInfoCollection.setModelCustomizationUUID(collectionCust.getModelCustomizationUUID());
    return modelInfoCollection;
}
Also used : ModelInfoCollection(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoCollection)

Example 4 with ModelInfoCollection

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

the class AAIObjectMapperTest method mapCollectionTest.

@Test
public void mapCollectionTest() {
    Collection networkCollection = new Collection();
    networkCollection.setId("networkCollectionId");
    ModelInfoCollection modelInfoCollection = new ModelInfoCollection();
    modelInfoCollection.setCollectionFunction("networkCollectionFunction");
    modelInfoCollection.setCollectionRole("networkCollectionRole");
    modelInfoCollection.setCollectionType("networkCollectionType");
    modelInfoCollection.setModelCustomizationUUID("modelCustomizationUUID");
    modelInfoCollection.setModelVersionId("modelVersionId");
    modelInfoCollection.setModelInvariantUUID("modelInvariantUUID");
    networkCollection.setModelInfoCollection(modelInfoCollection);
    networkCollection.setName("networkCollectionName");
    org.onap.aai.domain.yang.Collection expectedCollection = new org.onap.aai.domain.yang.Collection();
    expectedCollection.setCollectionId("networkCollectionId");
    expectedCollection.setCollectionType("networkCollectionType");
    expectedCollection.setCollectionCustomizationId("modelCustomizationUUID");
    expectedCollection.setModelVersionId("modelVersionId");
    expectedCollection.setModelInvariantId("modelInvariantUUID");
    expectedCollection.setCollectionFunction("networkCollectionFunction");
    expectedCollection.setCollectionRole("networkCollectionRole");
    expectedCollection.setCollectionName("networkCollectionName");
    org.onap.aai.domain.yang.Collection actualCollection = aaiObjectMapper.mapCollection(networkCollection);
    assertThat(actualCollection, sameBeanAs(expectedCollection));
}
Also used : Collection(org.onap.so.bpmn.servicedecomposition.bbobjects.Collection) ModelInfoCollection(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoCollection) ModelInfoCollection(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoCollection) Test(org.junit.Test)

Example 5 with ModelInfoCollection

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

the class BBInputSetupTest method testMapCatalogCollectionAndInstanceGroup.

@Test
public void testMapCatalogCollectionAndInstanceGroup() {
    ModelInfoCollection modelInfoCollection = new ModelInfoCollection();
    modelInfoCollection.setCollectionFunction("collectionFunction");
    modelInfoCollection.setCollectionRole("collectionRole");
    modelInfoCollection.setCollectionType("collectionType");
    modelInfoCollection.setDescription("description");
    modelInfoCollection.setModelInvariantUUID("modelInvariantUUID");
    modelInfoCollection.setQuantity(0);
    ModelInfoInstanceGroup modelInfoInstanceGroup = new ModelInfoInstanceGroup();
    modelInfoInstanceGroup.setFunction("function");
    modelInfoInstanceGroup.setInstanceGroupRole("instanceGroupRole");
    modelInfoInstanceGroup.setModelInvariantUUID("modelInvariantUUID");
    modelInfoInstanceGroup.setModelUUID("modelUUID");
    modelInfoInstanceGroup.setType("VNFC");
    modelInfoInstanceGroup.setDescription("description");
    InstanceGroup instanceGroup = new InstanceGroup();
    Collection collection = new Collection();
    collection.setInstanceGroup(instanceGroup);
    CollectionResource collectionResource = new CollectionResource();
    org.onap.so.db.catalog.beans.InstanceGroup catalogInstanceGroup = new org.onap.so.db.catalog.beans.InstanceGroup();
    collectionResource.setToscaNodeType("NetworkCollection");
    collectionResource.setInstanceGroup(catalogInstanceGroup);
    CollectionResourceCustomization collectionCust = new NetworkCollectionResourceCustomization();
    collectionCust.setModelCustomizationUUID("modelCustomizationUUID");
    collectionCust.setCollectionResource(collectionResource);
    Service service = new Service();
    service.getCollectionResourceCustomizations().add(collectionCust);
    ServiceInstance serviceInstance = new ServiceInstance();
    serviceInstance.setCollection(collection);
    List<CollectionResourceInstanceGroupCustomization> instanceGroupCustList = new ArrayList<>();
    CollectionResourceInstanceGroupCustomization instanceGroupCust = new CollectionResourceInstanceGroupCustomization();
    instanceGroupCust.setFunction("function");
    instanceGroupCust.setDescription("description");
    doReturn(modelInfoCollection).when(bbInputSetupMapperLayer).mapCatalogCollectionToCollection(collectionCust, collectionResource);
    doReturn(modelInfoInstanceGroup).when(bbInputSetupMapperLayer).mapCatalogInstanceGroupToInstanceGroup(collectionCust, catalogInstanceGroup);
    SPY_bbInputSetup.mapCatalogCollection(service, serviceInstance.getCollection(), "modelCustomizationUUID");
    SPY_bbInputSetup.mapCatalogNetworkCollectionInstanceGroup(service, serviceInstance.getCollection().getInstanceGroup(), collectionCust.getModelCustomizationUUID());
    assertThat(collection.getModelInfoCollection(), sameBeanAs(modelInfoCollection));
    assertThat(instanceGroup.getModelInfoInstanceGroup(), sameBeanAs(modelInfoInstanceGroup));
}
Also used : CollectionResource(org.onap.so.db.catalog.beans.CollectionResource) CollectionResourceInstanceGroupCustomization(org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization) ArrayList(java.util.ArrayList) ModelInfoCollection(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoCollection) Service(org.onap.so.db.catalog.beans.Service) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) ModelInfoInstanceGroup(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup) InstanceGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup) NetworkCollectionResourceCustomization(org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization) ModelInfoInstanceGroup(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup) Collection(org.onap.so.bpmn.servicedecomposition.bbobjects.Collection) ModelInfoCollection(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoCollection) CollectionResourceCustomization(org.onap.so.db.catalog.beans.CollectionResourceCustomization) NetworkCollectionResourceCustomization(org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization) Test(org.junit.Test)

Aggregations

ModelInfoCollection (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoCollection)5 Test (org.junit.Test)4 Collection (org.onap.so.bpmn.servicedecomposition.bbobjects.Collection)3 CollectionResource (org.onap.so.db.catalog.beans.CollectionResource)3 ArrayList (java.util.ArrayList)2 InstanceGroup (org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup)2 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)2 ModelInfoInstanceGroup (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup)2 ModelInfoServiceInstance (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)2 CollectionResourceCustomization (org.onap.so.db.catalog.beans.CollectionResourceCustomization)2 NetworkCollectionResourceCustomization (org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization)2 File (java.io.File)1 AAICommonObjectMapperProvider (org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider)1 AAIResultWrapper (org.onap.aaiclient.client.aai.entities.AAIResultWrapper)1 CollectionResourceInstanceGroupCustomization (org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization)1 Service (org.onap.so.db.catalog.beans.Service)1