use of org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider in project so by onap.
the class BBInputSetupTest method testMapL3Networks.
@Test
public void testMapL3Networks() throws JsonProcessingException {
org.onap.aai.domain.yang.L3Network expectedAAI = new org.onap.aai.domain.yang.L3Network();
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);
L3Network expected = new L3Network();
List<L3Network> l3Networks = new ArrayList<>();
AAIResultWrapper l3NetworksWrapper = new AAIResultWrapper(new AAICommonObjectMapperProvider().getMapper().writeValueAsString(expectedAAI));
AAIResourceUri aaiResourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().l3Network("networkId"));
doReturn(l3NetworksWrapper).when(SPY_bbInputSetupUtils).getAAIResourceDepthTwo(aaiResourceUri);
doReturn(expected).when(bbInputSetupMapperLayer).mapAAIL3Network(isA(org.onap.aai.domain.yang.L3Network.class));
doNothing().when(SPY_bbInputSetup).mapNetworkPolicies(any(), eq(expected.getNetworkPolicies()));
doNothing().when(SPY_bbInputSetup).mapRouteTableReferences(any(), eq(expected.getContrailNetworkRouteTableReferences()));
SPY_bbInputSetup.mapL3Networks(Arrays.asList(new AAIResourceUri[] { aaiResourceUri }), l3Networks);
assertEquals(expected, l3Networks.get(0));
verify(SPY_bbInputSetup, times(1)).mapNetworkPolicies(any(), eq(expected.getNetworkPolicies()));
verify(SPY_bbInputSetup, times(1)).mapRouteTableReferences(any(), eq(expected.getContrailNetworkRouteTableReferences()));
}
use of org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider 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.AAICommonObjectMapperProvider 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.AAICommonObjectMapperProvider 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.AAICommonObjectMapperProvider 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());
}
Aggregations