Search in sources :

Example 51 with MappingRecordBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder in project lispflowmapping by opendaylight.

the class MapResolverTest method handleMapRequest__withSubscribers.

/**
 * Tests {@link MapResolver#handleMapRequest} method.
 */
@Test
public void handleMapRequest__withSubscribers() {
    // input mapping
    final LocatorRecordBuilder locatorRecordBuilder = getDefaultLocatorBuilder();
    final MappingRecordBuilder mappingRecordBuilder = getDefaultMappingRecordBuilder();
    mappingRecordBuilder.getLocatorRecord().add(locatorRecordBuilder.build());
    final MappingData mappingData = getDefaultMappingData(mappingRecordBuilder.build());
    Mockito.when(mapServiceMock.getMapping(mapRequestBuilder.getSourceEid().getEid(), IPV4_PREFIX_EID_1)).thenReturn(mappingData);
    Mockito.when(mapServiceMock.getData(MappingOrigin.Southbound, IPV4_PREFIX_EID_1, SubKeys.SUBSCRIBERS)).thenReturn(subscriberSetMock);
    Mockito.when(subscriberSetMock.contains(Mockito.any(Subscriber.class))).thenReturn(false);
    // result
    final MapReplyBuilder mapReplyBuilder = getDefaultMapReplyBuilder();
    mapReplyBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(mappingRecordBuilder.build()).build());
    mapResolver.handleMapRequest(mapRequestBuilder.build());
    Mockito.verify(lispMappingServiceMock).handleMapReply(mapReplyBuilder.build());
    Mockito.verify(subscriberSetMock, Mockito.never()).remove(Mockito.any(Subscriber.class));
}
Also used : LocatorRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecordBuilder) MappingRecordItemBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder) Subscriber(org.opendaylight.lispflowmapping.interfaces.dao.Subscriber) MappingRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder) MappingData(org.opendaylight.lispflowmapping.lisp.type.MappingData) MapReplyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapreplymessage.MapReplyBuilder) Test(org.junit.Test)

Example 52 with MappingRecordBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder in project lispflowmapping by opendaylight.

the class MapResolverTest method handleMapRequest_withReplacePolicy.

/**
 * Tests {@link MapResolver#handleMapRequest} method.
 */
@Test
public void handleMapRequest_withReplacePolicy() {
    mapResolver = new MapResolver(mapServiceMock, true, "replace", lispMappingServiceMock);
    final List<IpAddress> ipAddressList = new ArrayList<>();
    // hop 1
    ipAddressList.add(IPV4_ADDRESS_1);
    // hop 2
    ipAddressList.add(IPV4_ADDRESS_2);
    final Rloc rloc = LispAddressUtil.asTeLcafRloc(ipAddressList);
    final LocatorRecordBuilder locatorRecordBuilder_1 = getDefaultLocatorBuilder();
    final LocatorRecordBuilder locatorRecordBuilder_2 = getDefaultLocatorBuilder().setRloc(rloc);
    // input mapping
    final MappingRecordBuilder mappingRecordBuilder = getDefaultMappingRecordBuilder();
    mappingRecordBuilder.getLocatorRecord().add(locatorRecordBuilder_1.build());
    mappingRecordBuilder.getLocatorRecord().add(locatorRecordBuilder_2.build());
    final MappingData mappingData = getDefaultMappingData(mappingRecordBuilder.build());
    final MapRequestBuilder mrb = getDefaultMapRequestBuilder();
    mrb.getItrRloc().add(new ItrRlocBuilder().setRloc(LispAddressUtil.asIpv4Rloc(IPV4_STRING_1)).build());
    mrb.getItrRloc().add(new ItrRlocBuilder().setRloc(LispAddressUtil.asIpv4Rloc(IPV4_STRING_2)).build());
    Mockito.when(mapServiceMock.getMapping(mrb.getSourceEid().getEid(), IPV4_PREFIX_EID_1)).thenReturn(mappingData);
    // result
    final LocatorRecordBuilder locatorRecordBuilder_3 = getDefaultLocatorBuilder().setRloc(LispAddressUtil.asIpv4Rloc(IPV4_STRING_2));
    final MappingRecordBuilder resultMappingRecordBuilder = getDefaultMappingRecordBuilder();
    // as Ipv4
    resultMappingRecordBuilder.getLocatorRecord().add(locatorRecordBuilder_1.build());
    // added to the result
    resultMappingRecordBuilder.getLocatorRecord().add(locatorRecordBuilder_3.build());
    final MapReplyBuilder mapReplyBuilder = getDefaultMapReplyBuilder();
    mapReplyBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(resultMappingRecordBuilder.build()).build());
    // invocation
    mapResolver.handleMapRequest(mrb.build());
    Mockito.verify(lispMappingServiceMock).handleMapReply(mapReplyBuilder.build());
}
Also used : LocatorRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecordBuilder) MappingRecordItemBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder) ItrRlocBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRlocBuilder) MappingRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder) ArrayList(java.util.ArrayList) Rloc(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.Rloc) ItrRloc(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRloc) MappingData(org.opendaylight.lispflowmapping.lisp.type.MappingData) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) MapReplyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapreplymessage.MapReplyBuilder) MapRequestBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestnotification.MapRequestBuilder) Test(org.junit.Test)

Example 53 with MappingRecordBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder in project lispflowmapping by opendaylight.

the class MapResolverTest method handleMapRequest__withSingleLocator.

/**
 * Tests {@link MapResolver#handleMapRequest} method.
 */
@Test
public void handleMapRequest__withSingleLocator() {
    // input mapping
    final LocatorRecordBuilder locatorRecordBuilder = getDefaultLocatorBuilder();
    final MappingRecordBuilder mappingRecordBuilder = getDefaultMappingRecordBuilder();
    mappingRecordBuilder.getLocatorRecord().add(locatorRecordBuilder.build());
    final MappingData mappingData = getDefaultMappingData(mappingRecordBuilder.build());
    Mockito.when(mapServiceMock.getMapping(mapRequestBuilder.getSourceEid().getEid(), IPV4_PREFIX_EID_1)).thenReturn(mappingData);
    // result
    final MapReplyBuilder mapReplyBuilder = getDefaultMapReplyBuilder();
    mapReplyBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(mappingRecordBuilder.build()).build());
    mapResolver.handleMapRequest(mapRequestBuilder.build());
    Mockito.verify(lispMappingServiceMock).handleMapReply(mapReplyBuilder.build());
}
Also used : LocatorRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecordBuilder) MappingRecordItemBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder) MappingRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder) MappingData(org.opendaylight.lispflowmapping.lisp.type.MappingData) MapReplyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapreplymessage.MapReplyBuilder) Test(org.junit.Test)

Example 54 with MappingRecordBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder in project lispflowmapping by opendaylight.

the class MapServerTest method handleMapRegisterTest_findNegativeSubscribers.

@Test
@Ignore
public void handleMapRegisterTest_findNegativeSubscribers() throws NoSuchFieldException, IllegalAccessException {
    setConfigIniMappingMergeField(true);
    mapRegister.getMappingRecordItem().clear();
    mapRegister.getMappingRecordItem().add(getDefaultMappingRecordItemBuilder(IPV4_PREFIX_EID_1).build());
    final MappingRecordBuilder mappingRecordBuilder_1 = getDefaultMappingRecordBuilder().setEid(IPV4_PREFIX_EID_2);
    final MappingRecordBuilder mappingRecordBuilder_2 = getDefaultMappingRecordBuilder();
    final Eid maskedEid1 = LispAddressUtil.asIpv4Eid("1.2.0.0");
    final Subscriber subscriber1 = Mockito.mock(Subscriber.class);
    Mockito.when(subscriber1.timedOut()).thenReturn(true);
    Mockito.when(subscriber1.toString()).thenReturn("sub1");
    final Set<Subscriber> set1 = Sets.newHashSet(subscriber1);
    Mockito.when(mapService.getAuthenticationKey(IPV4_PREFIX_EID_1)).thenReturn(MAPPING_AUTHKEY);
    Mockito.when(mapService.getData(MappingOrigin.Southbound, IPV4_PREFIX_EID_1, SubKeys.SRC_RLOCS)).thenReturn(DEFAULT_IP_ADDRESS_SET);
    Mockito.when(mapService.getParentPrefix(IPV4_PREFIX_EID_1)).thenReturn(maskedEid1);
    Mockito.when(mapService.getData(MappingOrigin.Southbound, IPV4_PREFIX_EID_1, SubKeys.SUBSCRIBERS)).thenReturn(null);
    Mockito.when(mapService.getData(MappingOrigin.Southbound, maskedEid1, SubKeys.SUBSCRIBERS)).thenReturn(set1);
    Mockito.when(mapService.getMapping(MappingOrigin.Southbound, IPV4_PREFIX_EID_1)).thenReturn(getDefaultMappingData(mappingRecordBuilder_1.build())).thenReturn(getDefaultMappingData(mappingRecordBuilder_2.build())).thenReturn(null);
    mapServer.handleMapRegister(mapRegister);
    Mockito.verify(subscriber1).timedOut();
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) Subscriber(org.opendaylight.lispflowmapping.interfaces.dao.Subscriber) MappingRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 55 with MappingRecordBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder in project lispflowmapping by opendaylight.

the class MappingServiceTest method addMappingTest.

/**
 * Tests {@link MappingService#addMapping} method.
 */
@Test
public void addMappingTest() throws ExecutionException, InterruptedException {
    final MappingRecordBuilder mappingRecordBuilder = getDefaultMappingRecordBuilder();
    final AddMappingInput addMappingInput = new AddMappingInputBuilder().setMappingRecord(mappingRecordBuilder.build()).build();
    final Future<RpcResult<Void>> result = mappingService.addMapping(addMappingInput);
    Mockito.verify(dsbe).addMapping(RPCInputConvertorUtil.toMapping(addMappingInput));
    assertEquals(RPC_RESULT_SUCCESS.getErrors(), result.get().getErrors());
    assertEquals(RPC_RESULT_SUCCESS.getResult(), result.get().getResult());
    assertEquals(RPC_RESULT_SUCCESS.isSuccessful(), result.get().isSuccessful());
}
Also used : MappingRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) AddMappingInput(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.AddMappingInput) AddMappingInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.AddMappingInputBuilder) Test(org.junit.Test)

Aggregations

MappingRecordBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder)57 Test (org.junit.Test)30 MappingRecordItemBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder)27 MappingRecordItem (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem)20 LocatorRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord)16 ByteBuffer (java.nio.ByteBuffer)14 MappingData (org.opendaylight.lispflowmapping.lisp.type.MappingData)14 MapReplyBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapreplymessage.MapReplyBuilder)14 LocatorRecordBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecordBuilder)13 ArrayList (java.util.ArrayList)8 SiteId (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.SiteId)8 MapRegisterBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapregisternotification.MapRegisterBuilder)8 MapNotifyBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapnotifymessage.MapNotifyBuilder)7 ItrRloc (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRloc)7 Rloc (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.Rloc)6 MappingBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.MappingBuilder)6 Subscriber (org.opendaylight.lispflowmapping.interfaces.dao.Subscriber)5 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)5 EidItemBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.list.EidItemBuilder)5 MappingRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord)5