@Test public void testSend() throws Exception { WaitForAsyncUtils.async( () -> { handleAllocationRequest(); handleCreatePermissionRequest(); handleChannelBindRequest(); return null; }); instance.connect().get(5, TimeUnit.SECONDS); InetSocketAddress remotePeerAddress = new InetSocketAddress("93.184.216.34", 1234); CreatePermissionMessage createPermissionMessage = new CreatePermissionMessage(); createPermissionMessage.setAddress(remotePeerAddress); verify(lobbyServerAccessor) .addOnMessageListener( eq(CreatePermissionMessage.class), createPermissionListenerCaptor.capture()); createPermissionListenerCaptor.getValue().accept(createPermissionMessage); byte[] bytes = new byte[1024]; DatagramPacket datagramPacket = new DatagramPacket(bytes, bytes.length); datagramPacket.setSocketAddress(remotePeerAddress); instance.send(datagramPacket); }