@Test public void whenPlayerOnlineThenSent() { PlayerRepository playerRepository = mock(PlayerRepository.class); FindPlayerProfile findPlayerProfile = mock(FindPlayerProfile.class); when(playerRepository.getPlayerProxy(eq("player"))).thenReturn( Optional.of("proxy-1") ); FindOnlinePlayer findOnlinePlayer = new FindOnlinePlayer(playerRepository, findPlayerProfile); PrivateMessage privateMessage = new PrivateMessage( UUID.randomUUID(), "player", "text","fromName" ); when(findPlayerProfile.findProfileAndProceed(eq(privateMessage), eq("proxy-1"))).thenReturn( MessageSendResponse.OK ); Assert.assertEquals(MessageSendResponse.OK, findOnlinePlayer.findAndSend(privateMessage)); }
public MessageSendResponse findAndSend(PrivateMessage message) { return playerRepository .getPlayerProxy(message.getToName()) .map(x -> findPlayerProfile.findProfileAndProceed(message, x)) .orElse(MessageSendResponse.OFFLINE); }
FindOnlinePlayer { public MessageSendResponse findAndSend(PrivateMessage message) { return playerRepository .getPlayerProxy(message.getToName()) .map(x -> findPlayerProfile.findProfileAndProceed(message, x)) .orElse(MessageSendResponse.OFFLINE); } }
FindOnlinePlayer { public MessageSendResponse findAndSend(PrivateMessage message) { return playerRepository .getPlayerProxy(message.getToName()) .map(x -> findPlayerProfile.findProfileAndProceed(message, x)) .orElse(MessageSendResponse.OFFLINE); }  }
FindOnlinePlayer { public MessageSendResponse findAndSend(PrivateMessage message) { return playerRepository .getPlayerProxy(message.getToName()) .map(x -> findPlayerProfile.findProfileAndProceed(message, x)) .orElse(MessageSendResponse.OFFLINE); }  MessageSendResponse findAndSend(PrivateMessage message); }
FindOnlinePlayer { public MessageSendResponse findAndSend(PrivateMessage message) { return playerRepository .getPlayerProxy(message.getToName()) .map(x -> findPlayerProfile.findProfileAndProceed(message, x)) .orElse(MessageSendResponse.OFFLINE); }  MessageSendResponse findAndSend(PrivateMessage message);  }