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());
}
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));
}
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;
}
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));
}
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));
}
Aggregations