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