use of org.onap.aaiclient.client.aai.entities.AAIResultWrapper in project so by onap.
the class BBInputSetupTest method testMapVolumeGroups.
@Test
public void testMapVolumeGroups() throws JsonProcessingException {
org.onap.aai.domain.yang.VolumeGroup expectedAAI = new org.onap.aai.domain.yang.VolumeGroup();
VolumeGroup expected = new VolumeGroup();
AAIResultWrapper vnfWrapper = new AAIResultWrapper(new AAICommonObjectMapperProvider().getMapper().writeValueAsString(expectedAAI));
doReturn(expected).when(bbInputSetupMapperLayer).mapAAIVolumeGroup(isA(org.onap.aai.domain.yang.VolumeGroup.class));
List<VolumeGroup> volumeGroupsList = SPY_bbInputSetup.mapVolumeGroups(Arrays.asList(new AAIResultWrapper[] { vnfWrapper }));
assertEquals(expected, volumeGroupsList.get(0));
}
use of org.onap.aaiclient.client.aai.entities.AAIResultWrapper in project so by onap.
the class BBInputSetupTest method testMapGenericVnfs.
@Test
public void testMapGenericVnfs() throws JsonProcessingException {
org.onap.aai.domain.yang.GenericVnf expectedAAI = new org.onap.aai.domain.yang.GenericVnf();
org.onap.aai.domain.yang.RelationshipList relationshipList = new org.onap.aai.domain.yang.RelationshipList();
org.onap.aai.domain.yang.Relationship relationship = new org.onap.aai.domain.yang.Relationship();
relationshipList.getRelationship().add(relationship);
expectedAAI.setRelationshipList(relationshipList);
GenericVnf expected = new GenericVnf();
AAIResourceUri aaiResourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("vnfId"));
AAIResultWrapper vnfWrapper = new AAIResultWrapper(new AAICommonObjectMapperProvider().getMapper().writeValueAsString(expectedAAI));
doReturn(vnfWrapper).when(SPY_bbInputSetupUtils).getAAIResourceDepthOne(aaiResourceUri);
doReturn(expected).when(bbInputSetupMapperLayer).mapAAIGenericVnfIntoGenericVnf(isA(org.onap.aai.domain.yang.GenericVnf.class));
doNothing().when(SPY_bbInputSetup).mapPlatform(any(), eq(expected));
doNothing().when(SPY_bbInputSetup).mapLineOfBusiness(any(), eq(expected));
doReturn(new ArrayList<>()).when(SPY_bbInputSetup).mapVolumeGroups(any());
List<GenericVnf> genericVnfs = new ArrayList<>();
SPY_bbInputSetup.mapGenericVnfs(Arrays.asList(new AAIResourceUri[] { aaiResourceUri }), genericVnfs);
assertEquals(expected, genericVnfs.get(0));
verify(SPY_bbInputSetup, times(1)).mapPlatform(any(), eq(expected));
verify(SPY_bbInputSetup, times(1)).mapLineOfBusiness(any(), eq(expected));
verify(SPY_bbInputSetup, times(1)).mapVolumeGroups(any());
}
use of org.onap.aaiclient.client.aai.entities.AAIResultWrapper 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.aaiclient.client.aai.entities.AAIResultWrapper in project so by onap.
the class BBInputSetupTest method testMapOwningEntity.
@Test
public void testMapOwningEntity() throws JsonProcessingException {
org.onap.aai.domain.yang.OwningEntity expectedAAI = new org.onap.aai.domain.yang.OwningEntity();
OwningEntity expected = new OwningEntity();
AAIResultWrapper vnfWrapper = new AAIResultWrapper(new AAICommonObjectMapperProvider().getMapper().writeValueAsString(expectedAAI));
doReturn(expected).when(bbInputSetupMapperLayer).mapAAIOwningEntity(isA(org.onap.aai.domain.yang.OwningEntity.class));
ServiceInstance serviceInstance = new ServiceInstance();
SPY_bbInputSetup.mapOwningEntity(Arrays.asList(new AAIResultWrapper[] { vnfWrapper }), serviceInstance);
assertEquals(expected, serviceInstance.getOwningEntity());
}
use of org.onap.aaiclient.client.aai.entities.AAIResultWrapper in project so by onap.
the class BBInputSetupTest method testMapPlatform.
@Test
public void testMapPlatform() throws JsonProcessingException {
org.onap.aai.domain.yang.Platform expectedAAI = new org.onap.aai.domain.yang.Platform();
Platform expected = new Platform();
AAIResultWrapper vnfWrapper = new AAIResultWrapper(new AAICommonObjectMapperProvider().getMapper().writeValueAsString(expectedAAI));
doReturn(expected).when(bbInputSetupMapperLayer).mapAAIPlatform(isA(org.onap.aai.domain.yang.Platform.class));
GenericVnf vnf = new GenericVnf();
SPY_bbInputSetup.mapPlatform(Arrays.asList(new AAIResultWrapper[] { vnfWrapper }), vnf);
assertEquals(expected, vnf.getPlatform());
}
Aggregations