Search in sources :

Example 26 with MappingRecordItemBuilder

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

the class MapResolverTest method handleMapRequest__withNoMapping.

/**
 * Tests {@link MapResolver#handleMapRequest} method.
 */
@Test
public void handleMapRequest__withNoMapping() {
    final MappingRecordBuilder mappingRecordBuilder = new MappingRecordBuilder().setAuthoritative(false).setMapVersion((short) 0).setEid(IPV4_PREFIX_EID_1).setAction(LispMessage.NEGATIVE_MAPPING_ACTION).setRecordTtl(TTL_RLOC_TIMED_OUT);
    Mockito.when(mapServiceMock.getMapping(mapRequestBuilder.getSourceEid().getEid(), IPV4_PREFIX_EID_1)).thenReturn(null);
    Mockito.when(mapServiceMock.addNegativeMapping(IPV4_PREFIX_EID_1)).thenReturn(getDefaultMappingData(mappingRecordBuilder.build()));
    // 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 : 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) MapReplyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapreplymessage.MapReplyBuilder) Test(org.junit.Test)

Example 27 with MappingRecordItemBuilder

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

the class MapResolverTest method handleMapRequest_withBothPolicy.

/**
 * Tests {@link MapResolver#handleMapRequest} method.
 */
@Test
public void handleMapRequest_withBothPolicy() {
    mapResolver = new MapResolver(mapServiceMock, true, "both", 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)).setPriority((short) 1);
    final MappingRecordBuilder resultMappingRecordBuilder = getDefaultMappingRecordBuilder();
    // as Ipv4
    resultMappingRecordBuilder.getLocatorRecord().add(locatorRecordBuilder_1.build());
    // as ELP
    resultMappingRecordBuilder.getLocatorRecord().add(locatorRecordBuilder_2.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 28 with MappingRecordItemBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder 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 29 with MappingRecordItemBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder 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 30 with MappingRecordItemBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder 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)

Aggregations

MappingRecordItemBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder)34 MappingRecordBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder)27 Test (org.junit.Test)25 MappingRecordItem (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem)23 MapReplyBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapreplymessage.MapReplyBuilder)15 ByteBuffer (java.nio.ByteBuffer)14 MappingData (org.opendaylight.lispflowmapping.lisp.type.MappingData)9 MapNotifyBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapnotifymessage.MapNotifyBuilder)9 LocatorRecordBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecordBuilder)8 MapRegisterBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapregisternotification.MapRegisterBuilder)8 ArrayList (java.util.ArrayList)5 LocatorRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord)5 SiteId (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.SiteId)4 ItrRloc (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRloc)4 LispSerializationException (org.opendaylight.lispflowmapping.lisp.serializer.exception.LispSerializationException)3 MapNotify (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapNotify)3 XtrId (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.XtrId)3 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)3 EidItemBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.list.EidItemBuilder)3 ItrRlocBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRlocBuilder)3