Search in sources :

Example 6 with VpnBinding

use of org.onap.aai.domain.yang.VpnBinding in project so by onap.

the class WorkflowActionExtractResourcesAAITest method extractRelationshipsVpnBinding_notFound_listEmpty.

@Test
public void extractRelationshipsVpnBinding_notFound_listEmpty() {
    // given
    Relationships relationships = mock(Relationships.class);
    when(relationships.getRelatedUris(Types.VPN_BINDING)).thenReturn(Collections.emptyList());
    // when
    Optional<VpnBinding> resultOpt = testedObject.extractRelationshipsVpnBinding(relationships);
    // then
    assertThat(resultOpt).isEmpty();
}
Also used : Relationships(org.onap.aaiclient.client.aai.entities.Relationships) VpnBinding(org.onap.aai.domain.yang.VpnBinding) Test(org.junit.Test)

Example 7 with VpnBinding

use of org.onap.aai.domain.yang.VpnBinding in project so by onap.

the class WorkflowActionExtractResourcesAAITest method extractRelationshipsVpnBinding_noVpnBindingFoundInList.

@Test
public void extractRelationshipsVpnBinding_noVpnBindingFoundInList() {
    // given
    Relationships relationships = mock(Relationships.class);
    AAIResourceUri aaiResourceUri = mock(AAISimpleUri.class);
    List<AAIResourceUri> aaiResourceUriList = new ArrayList<>();
    aaiResourceUriList.add(aaiResourceUri);
    when(relationships.getRelatedUris(Types.VPN_BINDING)).thenReturn(aaiResourceUriList);
    AAIResultWrapper aaiResultWrapper = new AAIResultWrapper("noJson");
    when(bbInputSetupUtils.getAAIResourceDepthOne(aaiResourceUri)).thenReturn(aaiResultWrapper);
    // when
    Optional<VpnBinding> resultOpt = testedObject.extractRelationshipsVpnBinding(relationships);
    // then
    assertThat(resultOpt).isEmpty();
}
Also used : Relationships(org.onap.aaiclient.client.aai.entities.Relationships) VpnBinding(org.onap.aai.domain.yang.VpnBinding) ArrayList(java.util.ArrayList) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) Test(org.junit.Test)

Example 8 with VpnBinding

use of org.onap.aai.domain.yang.VpnBinding 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 9 with VpnBinding

use of org.onap.aai.domain.yang.VpnBinding in project so by onap.

the class WorkflowActionExtractResourcesAAITest method extractRelationshipsVpnBindingSuccess.

@Test
public void extractRelationshipsVpnBindingSuccess() {
    // given
    Relationships relationships = mock(Relationships.class);
    AAIResourceUri aaiResourceUri = mock(AAISimpleUri.class);
    List<AAIResourceUri> aaiResourceUriList = new ArrayList<>();
    aaiResourceUriList.add(aaiResourceUri);
    when(relationships.getRelatedUris(Types.VPN_BINDING)).thenReturn(aaiResourceUriList);
    AAIResultWrapper aaiResultWrapper = new AAIResultWrapper("{\"vpn-id\" : \"" + VPN_ID + "\"}");
    when(bbInputSetupUtils.getAAIResourceDepthOne(aaiResourceUri)).thenReturn(aaiResultWrapper);
    // when
    Optional<VpnBinding> resultOpt = testedObject.extractRelationshipsVpnBinding(relationships);
    // then
    assertThat(resultOpt).isNotEmpty();
    assertThat(resultOpt.get().getVpnId()).isEqualTo(VPN_ID);
}
Also used : Relationships(org.onap.aaiclient.client.aai.entities.Relationships) VpnBinding(org.onap.aai.domain.yang.VpnBinding) ArrayList(java.util.ArrayList) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) Test(org.junit.Test)

Aggregations

VpnBinding (org.onap.aai.domain.yang.VpnBinding)9 AAIResultWrapper (org.onap.aaiclient.client.aai.entities.AAIResultWrapper)7 AAIResourceUri (org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri)7 Test (org.junit.Test)6 Relationships (org.onap.aaiclient.client.aai.entities.Relationships)5 ArrayList (java.util.ArrayList)4 File (java.io.File)2 L3Network (org.onap.aai.domain.yang.L3Network)2 RouteTargets (org.onap.aai.domain.yang.RouteTargets)2 L3Network (org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network)2 PropertyMap (org.modelmapper.PropertyMap)1 RouteTarget (org.onap.aai.domain.yang.RouteTarget)1 CreateNetworkRequest (org.onap.so.adapters.nwrest.CreateNetworkRequest)1 BaseTaskTest (org.onap.so.bpmn.BaseTaskTest)1