Search in sources :

Example 1 with AAICommonObjectMapperProvider

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()));
}
Also used : L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) ArrayList(java.util.ArrayList) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) AAICommonObjectMapperProvider(org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) Test(org.junit.Test)

Example 2 with AAICommonObjectMapperProvider

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));
}
Also used : VolumeGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup) AAICommonObjectMapperProvider(org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) Test(org.junit.Test)

Example 3 with AAICommonObjectMapperProvider

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());
}
Also used : ModelInfoGenericVnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) ArrayList(java.util.ArrayList) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) AAICommonObjectMapperProvider(org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) Test(org.junit.Test)

Example 4 with AAICommonObjectMapperProvider

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());
}
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 5 with AAICommonObjectMapperProvider

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());
}
Also used : OwningEntity(org.onap.so.bpmn.servicedecomposition.bbobjects.OwningEntity) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) AAICommonObjectMapperProvider(org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) Test(org.junit.Test)

Aggregations

AAICommonObjectMapperProvider (org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider)22 AAIResultWrapper (org.onap.aaiclient.client.aai.entities.AAIResultWrapper)20 Test (org.junit.Test)17 AAIResourceUri (org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri)8 ArrayList (java.util.ArrayList)7 Relationships (org.onap.aaiclient.client.aai.entities.Relationships)5 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)4 Relationship (org.onap.aai.domain.yang.Relationship)3 RelationshipList (org.onap.aai.domain.yang.RelationshipList)3 VfModule (org.onap.aai.domain.yang.VfModule)3 Configuration (org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration)3 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)3 ModelInfoGenericVnf (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf)3 ModelInfoServiceInstance (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)3 AaiHelper (org.onap.so.heatbridge.helpers.AaiHelper)3 Server (org.openstack4j.model.compute.Server)3 Ignore (org.junit.Ignore)2 L3Network (org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network)2 CloudConfiguration (org.onap.so.serviceinstancebeans.CloudConfiguration)2 Flavor (org.openstack4j.model.compute.Flavor)2