Search in sources :

Example 1 with Subnet

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);
}
Also used : L3Network(org.onap.aai.domain.yang.L3Network) Subnets(org.onap.aai.domain.yang.Subnets) Subnet(org.onap.aai.domain.yang.Subnet) L3Network(org.onap.aai.domain.yang.L3Network) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 2 with Subnet

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);
    }
}
Also used : L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) Relationships(org.onap.aaiclient.client.aai.entities.Relationships) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) Subnet(org.onap.aai.domain.yang.Subnet) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper)

Aggregations

Subnet (org.onap.aai.domain.yang.Subnet)2 Test (org.junit.Test)1 L3Network (org.onap.aai.domain.yang.L3Network)1 Subnets (org.onap.aai.domain.yang.Subnets)1 AAIResultWrapper (org.onap.aaiclient.client.aai.entities.AAIResultWrapper)1 Relationships (org.onap.aaiclient.client.aai.entities.Relationships)1 AAIResourceUri (org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri)1 BaseTaskTest (org.onap.so.bpmn.BaseTaskTest)1 L3Network (org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network)1