Search in sources :

Example 11 with Relationships

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

the class HeatBridgeImpl method getPserverToPciIdMap.

private Map<String, List<String>> getPserverToPciIdMap(List<AAIResourceUri> vserverUris) {
    Map<String, List<String>> pserverToPciIdMap = new HashMap<>();
    for (AAIResourceUri vserverUri : vserverUris) {
        AAIResultWrapper vserverWrapper = resourcesClient.get(vserverUri.depth(Depth.TWO));
        Optional<Relationships> vserverRelationships = vserverWrapper.getRelationships();
        if (vserverRelationships.isPresent() && CollectionUtils.isNotEmpty(vserverRelationships.get().getRelatedLinks(Types.PSERVER))) {
            Vserver vserver = vserverWrapper.asBean(Vserver.class).get();
            List<String> pciIds = HeatBridgeUtils.extractPciIdsFromVServer(vserver);
            if (CollectionUtils.isNotEmpty(pciIds)) {
                List<AAIResourceUri> matchingPservers = vserverRelationships.get().getRelatedUris(Types.PSERVER);
                if (matchingPservers != null && matchingPservers.size() == 1) {
                    pserverToPciIdMap.put(matchingPservers.get(0).getURIKeys().get("hostname"), pciIds);
                }
            }
        }
    }
    return pserverToPciIdMap;
}
Also used : Relationships(org.onap.aaiclient.client.aai.entities.Relationships) Vserver(org.onap.aai.domain.yang.Vserver) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) L3InterfaceIpv4AddressList(org.onap.aai.domain.yang.L3InterfaceIpv4AddressList) List(java.util.List) L3InterfaceIpv6AddressList(org.onap.aai.domain.yang.L3InterfaceIpv6AddressList) ArrayList(java.util.ArrayList) RelationshipList(org.onap.aai.domain.yang.RelationshipList) IPAddressString(inet.ipaddr.IPAddressString) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper)

Example 12 with Relationships

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

the class BBInputSetup method serviceInstanceSetCollection.

private void serviceInstanceSetCollection(ServiceInstance serviceInstance, AAIResultWrapper collectionWrapper, org.onap.aai.domain.yang.Collection aaiCollection) {
    Collection collection = getCollection(aaiCollection);
    Optional<Relationships> relationshipsOp = collectionWrapper.getRelationships();
    relationshipsOp.ifPresent(relationships -> setInstanceGroupForCollection(collection, relationships));
    serviceInstance.setCollection(collection);
}
Also used : Relationships(org.onap.aaiclient.client.aai.entities.Relationships) Collection(org.onap.so.bpmn.servicedecomposition.bbobjects.Collection)

Example 13 with Relationships

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

the class WorkflowActionExtractResourcesAAITest method extractRelationshipsConfiguration_notFound_listEmpty.

@Test
public void extractRelationshipsConfiguration_notFound_listEmpty() {
    // given
    Relationships relationships = mock(Relationships.class);
    when(relationships.getByType(Types.CONFIGURATION)).thenReturn(Collections.emptyList());
    // when
    Optional<Configuration> resultOpt = testedObject.extractRelationshipsConfiguration(relationships);
    // then
    assertThat(resultOpt).isEmpty();
}
Also used : Relationships(org.onap.aaiclient.client.aai.entities.Relationships) Configuration(org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration) Test(org.junit.Test)

Example 14 with Relationships

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

the class WorkflowActionExtractResourcesAAITest method extractRelationshipsVpnBinding_noVpnBindingFoundInList.

@Test
public void extractRelationshipsVpnBinding_noVpnBindingFoundInList() {
    // given
    Relationships relationships = mock(Relationships.class);
    AAIResourceUri aaiResourceUri = mock(AAISimpleUri.class);
    List<AAIResourceUri> aaiResourceUriList = new ArrayList<>();
    aaiResourceUriList.add(aaiResourceUri);
    when(relationships.getRelatedUris(Types.VPN_BINDING)).thenReturn(aaiResourceUriList);
    AAIResultWrapper aaiResultWrapper = new AAIResultWrapper("noJson");
    when(bbInputSetupUtils.getAAIResourceDepthOne(aaiResourceUri)).thenReturn(aaiResultWrapper);
    // when
    Optional<VpnBinding> resultOpt = testedObject.extractRelationshipsVpnBinding(relationships);
    // then
    assertThat(resultOpt).isEmpty();
}
Also used : Relationships(org.onap.aaiclient.client.aai.entities.Relationships) VpnBinding(org.onap.aai.domain.yang.VpnBinding) ArrayList(java.util.ArrayList) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) Test(org.junit.Test)

Example 15 with Relationships

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

the class WorkflowActionExtractResourcesAAITest method extractRelationshipsVpnBinding_notFound_listEmpty.

@Test
public void extractRelationshipsVpnBinding_notFound_listEmpty() {
    // given
    Relationships relationships = mock(Relationships.class);
    when(relationships.getRelatedUris(Types.VPN_BINDING)).thenReturn(Collections.emptyList());
    // when
    Optional<VpnBinding> resultOpt = testedObject.extractRelationshipsVpnBinding(relationships);
    // then
    assertThat(resultOpt).isEmpty();
}
Also used : Relationships(org.onap.aaiclient.client.aai.entities.Relationships) VpnBinding(org.onap.aai.domain.yang.VpnBinding) Test(org.junit.Test)

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