use of org.onap.aai.domain.yang.Subnet in project so by onap.
the class VrfValidationTest method testAaiSubnetValidation.
@Test
public void testAaiSubnetValidation() throws VrfBondingServiceException {
org.onap.aai.domain.yang.L3Network aaiLocalNetwork = new org.onap.aai.domain.yang.L3Network();
aaiLocalNetwork.setNetworkId("myNetworkID");
aaiLocalNetwork.setSubnets(new Subnets());
aaiLocalNetwork.getSubnets().getSubnet().add(new Subnet());
aaiLocalNetwork.getSubnets().getSubnet().get(0).setIpVersion("4");
ExpectedException.none();
vrfValidation.aaiSubnetValidation(aaiLocalNetwork);
aaiLocalNetwork.getSubnets().getSubnet().add(new Subnet());
aaiLocalNetwork.getSubnets().getSubnet().get(1).setIpVersion("6");
ExpectedException.none();
vrfValidation.aaiSubnetValidation(aaiLocalNetwork);
aaiLocalNetwork.setSubnets(null);
exceptionRule.expect(VrfBondingServiceException.class);
exceptionRule.expectMessage("LocalNetwork: myNetworkID has no subnets");
vrfValidation.aaiSubnetValidation(aaiLocalNetwork);
}
use of org.onap.aai.domain.yang.Subnet in project so by onap.
the class AAIQueryTasks method querySubnet.
public void querySubnet(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> subnetsUriList = networkRelationships.get().getRelatedUris(Types.SUBNET);
if (!subnetsUriList.isEmpty()) {
for (AAIResourceUri subnetUri : subnetsUriList) {
Optional<Subnet> oSubnet = aaiNetworkResources.getSubnet(subnetUri);
if (oSubnet.isPresent()) {
l3network.getSubnets().add(modelMapper.map(oSubnet.get(), org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet.class));
}
}
}
} catch (Exception ex) {
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
}
}
Aggregations