Search in sources :

Example 61 with AAIResultWrapper

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

Example 62 with AAIResultWrapper

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);
    }
}
Also used : L3Network(org.onap.aai.domain.yang.L3Network) VpnBinding(org.onap.aai.domain.yang.VpnBinding) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) RouteTargets(org.onap.aai.domain.yang.RouteTargets) RouteTarget(org.onap.aai.domain.yang.RouteTarget) File(java.io.File) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 63 with AAIResultWrapper

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);
}
Also used : GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) Test(org.junit.Test)

Example 64 with 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());
}
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) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) Test(org.junit.Test)

Example 65 with AAIResultWrapper

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));
    }
}
Also used : NetworkPolicy(org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) Test(org.junit.Test)

Aggregations

AAIResultWrapper (org.onap.aaiclient.client.aai.entities.AAIResultWrapper)88 AAIResourceUri (org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri)47 Test (org.junit.Test)46 Relationships (org.onap.aaiclient.client.aai.entities.Relationships)27 ArrayList (java.util.ArrayList)22 AAICommonObjectMapperProvider (org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider)22 L3Network (org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network)14 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)11 VpnBinding (org.onap.aai.domain.yang.VpnBinding)7 CloudConfiguration (org.onap.so.serviceinstancebeans.CloudConfiguration)7 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)6 HashMap (java.util.HashMap)6 OperationalEnvironment (org.onap.aai.domain.yang.OperationalEnvironment)6 RelationshipList (org.onap.aai.domain.yang.RelationshipList)6 AAIResourcesClient (org.onap.aaiclient.client.aai.AAIResourcesClient)6 List (java.util.List)5 Optional (java.util.Optional)5 AAIFluentTypeBuilder (org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder)5 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)5 Map (java.util.Map)4