use of org.onap.aaiclient.client.aai.entities.AAIResultWrapper in project so by onap.
the class AAIQueryTasks method queryNetworkTableRef.
/**
* BPMN access method to query data for network table ref from the AAI result wrapper The resulting route table
* reference is mapped to the corresponding bbobject and added to the network bbobject contrail network route table
* references list
*
* @param execution
*/
public void queryNetworkTableRef(BuildingBlockExecution execution) {
try {
L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
AAIResultWrapper aaiResultWrapper = aaiNetworkResources.queryNetworkWrapperById(l3network);
Optional<Relationships> networkRelationships = aaiResultWrapper.getRelationships();
if (!networkRelationships.isPresent()) {
throw (new Exception(ERROR_MSG));
}
List<AAIResourceUri> routeTableUriList = networkRelationships.get().getRelatedUris(Types.ROUTE_TABLE_REFERENCE);
if (!routeTableUriList.isEmpty()) {
for (AAIResourceUri routeTableUri : routeTableUriList) {
Optional<RouteTableReference> oRouteTableReference = aaiNetworkResources.getRouteTable(routeTableUri);
if (oRouteTableReference.isPresent()) {
org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTableReference mappedRouteTableReference = modelMapper.map(oRouteTableReference.get(), org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTableReference.class);
l3network.getContrailNetworkRouteTableReferences().add(mappedRouteTableReference);
}
}
}
} catch (Exception ex) {
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
}
}
use of org.onap.aaiclient.client.aai.entities.AAIResultWrapper in project so by onap.
the class VrfValidationTest method testAaiRouteTargetValidation.
@Test
public void testAaiRouteTargetValidation() throws VrfBondingServiceException, JsonParseException, JsonMappingException, IOException {
L3Network l3Network = mapper.readValue(new File("src/test/resources/__files/BuildingBlocks/aaiNetworkWrapper.json"), L3Network.class);
AAIResultWrapper networkWrapper = new AAIResultWrapper(l3Network);
if (networkWrapper.getRelationships().isPresent()) {
List<AAIResourceUri> vpnBindingUris = networkWrapper.getRelationships().get().getRelatedUris(Types.VPN_BINDING);
VpnBinding vpnBinding = new VpnBinding();
vpnBinding.setRouteTargets(new RouteTargets());
vpnBinding.getRouteTargets().getRouteTarget().add(new RouteTarget());
AAIResultWrapper wrapper = Mockito.mock(AAIResultWrapper.class);
doReturn(wrapper).when(bbSetupUtils).getAAIResourceDepthOne(vpnBindingUris.get(0));
doReturn(Optional.of(vpnBinding)).when(wrapper).asBean(VpnBinding.class);
ExpectedException.none();
vrfValidation.aaiRouteTargetValidation(l3Network);
}
}
use of org.onap.aaiclient.client.aai.entities.AAIResultWrapper in project so by onap.
the class AAIVnfResourcesTest method queryVnfWrapperByIdTest.
@Test
public void queryVnfWrapperByIdTest() throws Exception {
AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("vnfId")).depth(Depth.ALL);
final String aaiResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiGenericVnf.json")));
GenericVnf genericVnf = new GenericVnf();
genericVnf.setVnfId("vnfId");
AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(aaiResponse);
doReturn(aaiResultWrapper).when(MOCK_aaiResourcesClient).get(eq(uri));
AAIResultWrapper actualResult = aaiVnfResources.queryVnfWrapperById(genericVnf);
assertEquals(actualResult, aaiResultWrapper);
}
use of org.onap.aaiclient.client.aai.entities.AAIResultWrapper in project so by onap.
the class AAINetworkResourcesTest method queryNetworkWrapperByIdTest.
@Test
public void queryNetworkWrapperByIdTest() throws Exception {
final String content = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiQueryAAIResponse-Wrapper.json")));
AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(content);
L3Network network = new L3Network();
network.setNetworkId("0384d743-f69b-4cc8-9aa8-c3ae66662c44");
network.setNetworkName("Dev_Bindings_1802_020118");
network.setOrchestrationStatus(OrchestrationStatus.CREATED);
doReturn(aaiResultWrapper).when(MOCK_aaiResourcesClient).get(isA(AAIResourceUri.class));
AAIResultWrapper result = aaiNetworkResources.queryNetworkWrapperById(network);
verify(MOCK_aaiResourcesClient, times(1)).get(isA(AAIResourceUri.class));
assertEquals(aaiResultWrapper.getJson(), result.getJson());
assertNotNull(result);
Optional<Relationships> resultNetworkRelationships = result.getRelationships();
assertTrue(resultNetworkRelationships.isPresent());
Optional<org.onap.aai.domain.yang.L3Network> aaiL3Network = result.asBean(org.onap.aai.domain.yang.L3Network.class);
assertEquals(network.getNetworkId(), aaiL3Network.get().getNetworkId());
assertEquals(network.getNetworkName(), aaiL3Network.get().getNetworkName());
}
use of org.onap.aaiclient.client.aai.entities.AAIResultWrapper in project so by onap.
the class AAINetworkResourcesTest method getNetworkPolicyTest.
@Test
public void getNetworkPolicyTest() throws Exception {
final String content = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "queryAaiNetworkPolicy.json")));
AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(content);
Optional<org.onap.aai.domain.yang.NetworkPolicy> oNetPolicy = Optional.empty();
AAIResourceUri netPolicyUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().networkPolicy("ModelInvariantUUID"));
doReturn(aaiResultWrapper).when(MOCK_aaiResourcesClient).get(isA(AAIResourceUri.class));
oNetPolicy = aaiNetworkResources.getNetworkPolicy(netPolicyUri);
verify(MOCK_aaiResourcesClient, times(1)).get(any(AAIResourceUri.class));
if (oNetPolicy.isPresent()) {
org.onap.aai.domain.yang.NetworkPolicy networkPolicy = oNetPolicy.get();
assertThat(aaiResultWrapper.asBean(org.onap.aai.domain.yang.NetworkPolicy.class).get(), sameBeanAs(networkPolicy));
}
}
Aggregations