Search in sources :

Example 21 with AAICommonObjectMapperProvider

use of org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider in project so by onap.

the class BBInputSetupTest method testGettingVnfcToConfiguration.

@Test
public void testGettingVnfcToConfiguration() throws Exception {
    String vnfcName = "vnfcName";
    org.onap.aai.domain.yang.Configuration expectedAAI = new org.onap.aai.domain.yang.Configuration();
    AAIResourceUri aaiResourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().vnfc(vnfcName));
    AAIResultWrapper configurationWrapper = new AAIResultWrapper(new AAICommonObjectMapperProvider().getMapper().writeValueAsString(expectedAAI));
    doReturn(new AAIResultWrapper(null)).when(SPY_bbInputSetupUtils).getAAIResourceDepthOne(aaiResourceUri);
    Vnfc vnfc = SPY_bbInputSetup.getVnfcToConfiguration(vnfcName);
    Assert.assertNull(vnfc);
    doReturn(configurationWrapper).when(SPY_bbInputSetupUtils).getAAIResourceDepthOne(aaiResourceUri);
    vnfc = SPY_bbInputSetup.getVnfcToConfiguration(vnfcName);
    Assert.assertNotNull(vnfc);
}
Also used : CloudConfiguration(org.onap.so.serviceinstancebeans.CloudConfiguration) Configuration(org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) AAICommonObjectMapperProvider(org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider) Vnfc(org.onap.so.bpmn.servicedecomposition.bbobjects.Vnfc) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) Test(org.junit.Test)

Example 22 with AAICommonObjectMapperProvider

use of org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider in project so by onap.

the class CloudInfoFromAAITest method testGetRelatedCloudRegionAndTenant.

@Test
public void testGetRelatedCloudRegionAndTenant() throws JsonProcessingException {
    String cloudOwner = "cloudOwner";
    String cloudRegionId = "cloudRegionId";
    String cloudRegionVersion = "cloudRegionVersion";
    String cloudRegionComplexName = "cloudRegionComplexName";
    String tenantId = "tenantId";
    CloudRegion expected = new CloudRegion();
    expected.setCloudOwner(cloudOwner);
    expected.setCloudRegionVersion(cloudRegionVersion);
    expected.setComplex(cloudRegionComplexName);
    expected.setLcpCloudRegionId(cloudRegionId);
    expected.setTenantId(tenantId);
    Relationships relationships = Mockito.mock(Relationships.class);
    List<AAIResultWrapper> cloudRegions = new ArrayList<>();
    org.onap.aai.domain.yang.CloudRegion cloudRegion = new org.onap.aai.domain.yang.CloudRegion();
    cloudRegion.setCloudOwner(cloudOwner);
    cloudRegion.setCloudRegionId(cloudRegionId);
    cloudRegion.setCloudRegionVersion(cloudRegionVersion);
    cloudRegion.setComplexName(cloudRegionComplexName);
    AAIResultWrapper cloudRegionWrapper = new AAIResultWrapper(new AAICommonObjectMapperProvider().getMapper().writeValueAsString(cloudRegion));
    cloudRegions.add(cloudRegionWrapper);
    doReturn(cloudRegions).when(relationships).getByType(Types.CLOUD_REGION);
    List<AAIResultWrapper> tenants = new ArrayList<>();
    org.onap.aai.domain.yang.Tenant tenant = new org.onap.aai.domain.yang.Tenant();
    tenant.setTenantId(tenantId);
    AAIResultWrapper tenantWrapper = new AAIResultWrapper(new AAICommonObjectMapperProvider().getMapper().writeValueAsString(tenant));
    tenants.add(tenantWrapper);
    doReturn(tenants).when(relationships).getByType(Types.TENANT);
    Optional<CloudRegion> actual = SPY_CloudInfoFromAAI.getRelatedCloudRegionAndTenant(relationships);
    assertThat(actual.get(), sameBeanAs(expected));
}
Also used : CloudRegion(org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion) ArrayList(java.util.ArrayList) AAICommonObjectMapperProvider(org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider) Relationships(org.onap.aaiclient.client.aai.entities.Relationships) 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