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