@Test public void whenPlayerNotOnlineThenNotSent() { PlayerRepository playerRepository = mock(PlayerRepository.class); FindPlayerProfile findPlayerProfile = mock(FindPlayerProfile.class); when(playerRepository.getPlayerProxy(any())).thenReturn(Optional.empty()); FindOnlinePlayer findOnlinePlayer = new FindOnlinePlayer(playerRepository, findPlayerProfile); PrivateMessage privateMessage = new PrivateMessage( UUID.randomUUID(), "player", "text","fromName" ); Assert.assertEquals(MessageSendResponse.OFFLINE, findOnlinePlayer.findAndSend(privateMessage)); verifyZeroInteractions(findPlayerProfile); }
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);  }