use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply in project lispflowmapping by opendaylight.
the class LispMappingServiceTest method onRequestMappingTest.
/**
* Tests {@link LispMappingService#onRequestMapping} method.
*/
@Test
public void onRequestMappingTest() {
final RequestMapping requestMapping = Mockito.mock(RequestMapping.class);
final org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestnotification.MapRequest mapRequest = Mockito.mock(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestnotification.MapRequest.class);
final MapReply mapReply = new MapReplyBuilder().build();
Mockito.when(requestMapping.getMapRequest()).thenReturn(mapRequest);
Mockito.when(requestMapping.getTransportAddress()).thenReturn(TRANSPORT_ADDRESS_1);
Mockito.when(mapRequest.getEidItem()).thenReturn(Lists.newArrayList(EID_ITEM_BUILDER.build()));
Mockito.when(tlsMapReplyMock.get()).thenReturn(mapReply);
// result
final SendMapReplyInputBuilder smrib = new SendMapReplyInputBuilder().setMapReply(new MapReplyBuilder(mapReply).build()).setTransportAddress(TRANSPORT_ADDRESS_1);
lispMappingService.onRequestMapping(requestMapping);
Mockito.verify(odlLispSbService).sendMapReply(smrib.build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply in project lispflowmapping by opendaylight.
the class LispMappingServiceTest method onRequestMappingTest_withNullMapReply.
/**
* Tests {@link LispMappingService#onRequestMapping} method with mapReply == null.
*/
@Test
public void onRequestMappingTest_withNullMapReply() {
final RequestMapping requestMapping = Mockito.mock(RequestMapping.class);
final org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestnotification.MapRequest mapRequest = Mockito.mock(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestnotification.MapRequest.class);
Mockito.when(requestMapping.getMapRequest()).thenReturn(mapRequest);
Mockito.when(mapRequest.getEidItem()).thenReturn(Lists.newArrayList(EID_ITEM_BUILDER.build()));
Mockito.when(tlsMapReplyMock.get()).thenReturn(null);
lispMappingService.onRequestMapping(requestMapping);
Mockito.verifyZeroInteractions(odlLispSbService);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply in project lispflowmapping by opendaylight.
the class LispMappingServiceTest method handleMapRequestTest.
/**
* Tests {@link LispMappingService#handleMapRequest} method.
*/
@Test
public void handleMapRequestTest() {
final MapRequest mapRequest = Mockito.mock(MapRequest.class);
final MapReply mapReply = new MapReplyBuilder().build();
Mockito.when(mapRequest.getEidItem()).thenReturn(Lists.newArrayList(EID_ITEM_BUILDER.build()));
Mockito.when(tlsMapRequestMock.get()).thenReturn(null);
Mockito.when(tlsMapReplyMock.get()).thenReturn(mapReply);
final MapReply result = lispMappingService.handleMapRequest(mapRequest);
Mockito.verify(tlsMapRequestMock).set(null);
Mockito.verify(tlsMapRequestMock).get();
Mockito.verifyNoMoreInteractions(tlsMapRequestMock);
Mockito.verify(mapResolverMock).handleMapRequest(mapRequest);
Mockito.verify(tlsMapReplyMock).set(Mockito.any(MapReply.class));
Mockito.verify(tlsMapReplyMock).get();
assertEquals(result, mapReply);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply in project lispflowmapping by opendaylight.
the class LispMappingService method onRequestMapping.
@Override
public void onRequestMapping(RequestMapping mapRequestNotification) {
MapReply mapReply = handleMapRequest(mapRequestNotification.getMapRequest());
if (mapReply != null) {
SendMapReplyInputBuilder smrib = new SendMapReplyInputBuilder();
smrib.setMapReply((new MapReplyBuilder(mapReply).build()));
smrib.setTransportAddress(mapRequestNotification.getTransportAddress());
getLispSB().sendMapReply(smrib.build());
} else {
LOG.debug("handleMapRequest: Got null MapReply");
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply in project lispflowmapping by opendaylight.
the class LispSouthboundHandler method handleMapReply.
@SuppressWarnings("checkstyle:IllegalCatch")
private void handleMapReply(ByteBuffer inBuffer, InetAddress sourceAddress, int port) {
try {
MapReply mapReply = MapReplySerializer.getInstance().deserialize(inBuffer);
GotMapReplyBuilder gotMapReplyBuilder = new GotMapReplyBuilder();
gotMapReplyBuilder.setMapReply(LispNotificationHelper.convertMapReply(mapReply));
TransportAddressBuilder transportAddressBuilder = new TransportAddressBuilder();
transportAddressBuilder.setIpAddress(LispNotificationHelper.getIpAddressBinaryFromInetAddress(sourceAddress));
transportAddressBuilder.setPort(new PortNumber(port));
gotMapReplyBuilder.setTransportAddress(transportAddressBuilder.build());
lispSbPlugin.sendNotificationIfPossible(gotMapReplyBuilder.build());
} catch (RuntimeException re) {
throw new LispMalformedPacketException("Couldn't deserialize Map-Reply (len=" + inBuffer.capacity() + ")", re);
} catch (InterruptedException e) {
LOG.warn("Notification publication interrupted!");
}
}
Aggregations