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());
}
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());
}
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));
}
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());
}
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());
}
Aggregations