Search in sources :

Example 16 with Relationships

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

the class WorkflowActionExtractResourcesAAITest method extractRelationshipsConfigurationSuccess.

@Test
public void extractRelationshipsConfigurationSuccess() {
    // given
    Relationships relationships = mock(Relationships.class);
    when(relationships.getByType(Types.CONFIGURATION)).thenReturn(getConfigurationList("{\"configuration-id\" : \"" + CONFIGURATION_ID + "\"}"));
    // when
    Optional<Configuration> resultOpt = testedObject.extractRelationshipsConfiguration(relationships);
    // then
    assertThat(resultOpt).isNotEmpty();
    assertThat(resultOpt.get().getConfigurationId()).isEqualTo(CONFIGURATION_ID);
}
Also used : Relationships(org.onap.aaiclient.client.aai.entities.Relationships) Configuration(org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration) Test(org.junit.Test)

Example 17 with Relationships

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

the class WorkflowActionExtractResourcesAAITest method extractRelationshipsVnfcSuccess.

@Test
public void extractRelationshipsVnfcSuccess() {
    // given
    Relationships relationships = mock(Relationships.class);
    when(relationships.getByType(Types.VNFC)).thenReturn(getConfigurationList("{\"relationship-list\": {\"relationship\": [{\"related-to\": \"tenant\"}]}}"));
    // when
    Optional<Relationships> resultOpt = testedObject.extractRelationshipsVnfc(relationships);
    // then
    assertThat(resultOpt).isNotEmpty();
    assertThat(resultOpt.get().getJson()).isEqualTo("{\"relationship\":[{\"related-to\":\"tenant\"}]}");
}
Also used : Relationships(org.onap.aaiclient.client.aai.entities.Relationships) Test(org.junit.Test)

Example 18 with Relationships

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

the class BBInputSetup method addRelationshipsToSI.

protected void addRelationshipsToSI(org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI, ServiceInstance serviceInstance) throws Exception {
    AAIResultWrapper serviceInstanceWrapper = new AAIResultWrapper(new AAICommonObjectMapperProvider().getMapper().writeValueAsString(serviceInstanceAAI));
    Optional<Relationships> relationshipsOp = serviceInstanceWrapper.getRelationships();
    if (relationshipsOp.isPresent()) {
        mapRelationship(serviceInstance, relationshipsOp.get());
    }
}
Also used : Relationships(org.onap.aaiclient.client.aai.entities.Relationships) AAICommonObjectMapperProvider(org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper)

Example 19 with Relationships

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

the class BBInputSetup method mapL3Network.

protected L3Network mapL3Network(AAIResourceUri aaiResourceUri) {
    AAIResultWrapper aaiNetworkWrapper = this.bbInputSetupUtils.getAAIResourceDepthTwo(aaiResourceUri);
    Optional<org.onap.aai.domain.yang.L3Network> aaiL3NetworkOp = aaiNetworkWrapper.asBean(org.onap.aai.domain.yang.L3Network.class);
    org.onap.aai.domain.yang.L3Network aaiL3Network = null;
    if (!aaiL3NetworkOp.isPresent()) {
        return null;
    }
    aaiL3Network = aaiL3NetworkOp.get();
    L3Network network = this.mapperLayer.mapAAIL3Network(aaiL3Network);
    Optional<Relationships> relationshipsOp = aaiNetworkWrapper.getRelationships();
    if (relationshipsOp.isPresent()) {
        Relationships relationships = relationshipsOp.get();
        this.mapNetworkPolicies(relationships.getByType(Types.NETWORK_POLICY), network.getNetworkPolicies());
        mapRouteTableReferences(relationships.getByType(Types.ROUTE_TABLE_REFERENCE), network.getContrailNetworkRouteTableReferences());
    }
    return network;
}
Also used : L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) Relationships(org.onap.aaiclient.client.aai.entities.Relationships) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper)

Example 20 with Relationships

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

the class CloudInfoFromAAI method getCloudInfoFromAAI.

protected Optional<CloudRegion> getCloudInfoFromAAI(ServiceInstance serviceInstance) throws JsonProcessingException {
    Optional<Relationships> relationshipsOp = Optional.empty();
    if (!serviceInstance.getVnfs().isEmpty()) {
        GenericVnf vnf = serviceInstance.getVnfs().get(0);
        org.onap.aai.domain.yang.GenericVnf aaiVnf = bbInputSetupUtils.getAAIGenericVnf(vnf.getVnfId());
        AAIResultWrapper vnfWrapper = new AAIResultWrapper(new AAICommonObjectMapperProvider().getMapper().writeValueAsString(aaiVnf));
        relationshipsOp = getRelationshipsFromWrapper(vnfWrapper);
    } else if (!serviceInstance.getNetworks().isEmpty()) {
        L3Network network = serviceInstance.getNetworks().get(0);
        org.onap.aai.domain.yang.L3Network aaiL3Network = bbInputSetupUtils.getAAIL3Network(network.getNetworkId());
        AAIResultWrapper networkWrapper = new AAIResultWrapper(new AAICommonObjectMapperProvider().getMapper().writeValueAsString(aaiL3Network));
        relationshipsOp = getRelationshipsFromWrapper(networkWrapper);
    } else {
        logger.debug("BBInputSetup could not find a cloud region or tenant, since there are no resources under the SI.");
        return Optional.empty();
    }
    if (relationshipsOp.isPresent()) {
        return getRelatedCloudRegionAndTenant(relationshipsOp.get());
    } else {
        logger.debug("BBInputSetup could not find a cloud region or tenant");
        return Optional.empty();
    }
}
Also used : L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) Relationships(org.onap.aaiclient.client.aai.entities.Relationships) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) AAICommonObjectMapperProvider(org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper)

Aggregations

Relationships (org.onap.aaiclient.client.aai.entities.Relationships)36 AAIResultWrapper (org.onap.aaiclient.client.aai.entities.AAIResultWrapper)27 AAIResourceUri (org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri)20 Test (org.junit.Test)13 ArrayList (java.util.ArrayList)12 L3Network (org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network)10 AAICommonObjectMapperProvider (org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider)6 Configuration (org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration)6 HashMap (java.util.HashMap)4 List (java.util.List)4 VpnBinding (org.onap.aai.domain.yang.VpnBinding)4 IPAddressString (inet.ipaddr.IPAddressString)3 RelationshipList (org.onap.aai.domain.yang.RelationshipList)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 IOException (java.io.IOException)2 Map (java.util.Map)2 Objects (java.util.Objects)2 Optional (java.util.Optional)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 NotFoundException (javax.ws.rs.NotFoundException)2