Search in sources :

Example 86 with AAIResultWrapper

use of org.onap.aaiclient.client.aai.entities.AAIResultWrapper 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 87 with AAIResultWrapper

use of org.onap.aaiclient.client.aai.entities.AAIResultWrapper 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)

Example 88 with AAIResultWrapper

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

the class AppcRunTasks method getVserversForAppc.

protected void getVserversForAppc(BuildingBlockExecution execution, GenericVnf vnf) throws RuntimeException {
    AAIResultWrapper aaiRW = aaiVnfResources.queryVnfWrapperById(vnf);
    if (aaiRW == null || aaiRW.getRelationships() == null || !aaiRW.getRelationships().isPresent()) {
        return;
    }
    Relationships relationships = aaiRW.getRelationships().get();
    List<AAIResourceUri> vserverUris = relationships.getRelatedUris(Types.VSERVER);
    JSONArray vserverIds = new JSONArray();
    JSONArray vserverSelfLinks = new JSONArray();
    if (vserverUris != null) {
        for (AAIResourceUri j : vserverUris) {
            if (j != null) {
                if (j.getURIKeys() != null) {
                    String vserverId = j.getURIKeys().get(AAIFluentTypeBuilder.Types.VSERVER.getUriParams().vserverId);
                    vserverIds.put(vserverId);
                }
                aaiVnfResources.getVserver(j).ifPresent((vserver) -> {
                    String vserverSelfLink = vserver.getVserverSelflink();
                    vserverSelfLinks.put(vserverSelfLink);
                });
            }
        }
    }
    JSONObject vmidsArray = new JSONObject();
    JSONObject vserveridsArray = new JSONObject();
    vmidsArray.put("vmIds", vserverSelfLinks.toString());
    vserveridsArray.put("vserverIds", vserverIds.toString());
    logger.debug("vmidsArray is: {}", vmidsArray.toString());
    logger.debug("vserveridsArray is: {}", vserveridsArray.toString());
    execution.setVariable("vmIdList", vmidsArray.toString());
    execution.setVariable("vserverIdList", vserveridsArray.toString());
}
Also used : Relationships(org.onap.aaiclient.client.aai.entities.Relationships) JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper)

Aggregations

AAIResultWrapper (org.onap.aaiclient.client.aai.entities.AAIResultWrapper)88 AAIResourceUri (org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri)47 Test (org.junit.Test)46 Relationships (org.onap.aaiclient.client.aai.entities.Relationships)27 ArrayList (java.util.ArrayList)22 AAICommonObjectMapperProvider (org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider)22 L3Network (org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network)14 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)11 VpnBinding (org.onap.aai.domain.yang.VpnBinding)7 CloudConfiguration (org.onap.so.serviceinstancebeans.CloudConfiguration)7 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)6 HashMap (java.util.HashMap)6 OperationalEnvironment (org.onap.aai.domain.yang.OperationalEnvironment)6 RelationshipList (org.onap.aai.domain.yang.RelationshipList)6 AAIResourcesClient (org.onap.aaiclient.client.aai.AAIResourcesClient)6 List (java.util.List)5 Optional (java.util.Optional)5 AAIFluentTypeBuilder (org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder)5 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)5 Map (java.util.Map)4