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;
}
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);
}
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();
}
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();
}
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();
}
Aggregations