### Question:
FindPlayerProfile { public MessageSendResponse findProfileAndProceed(PrivateMessage message, String targetProxy) { return playerProfileRepository .find(new PlayerNameSpecification(message.getToName()), PlayerAssociation.PREFERENCES) .map(targetProfile -> checkTarget.checkTargetAndSend(targetProfile, message, targetProxy)) .orElseThrow(PlayerNotFoundException::new); }  MessageSendResponse findProfileAndProceed(PrivateMessage message, String targetProxy);  }### Answer:
@Test public void whenProfileFound() { PlayerProfileRepository repository = mock(PlayerProfileRepository.class); CheckTarget checkTarget = mock(CheckTarget.class); FindPlayerProfile findPlayerProfile = new FindPlayerProfile( repository, checkTarget ); PrivateMessage privateMessage= new PrivateMessage(UUID.randomUUID(), "to", "text","fromName"); PlayerProfile playerProfile = mock(PlayerProfile.class); when(repository.find(any(), (PlayerAssociation[]) any())).thenReturn(Optional.of(playerProfile)); when(checkTarget.checkTargetAndSend(eq(playerProfile), eq(privateMessage), eq("proxy"))).thenReturn(MessageSendResponse.OK); findPlayerProfile.findProfileAndProceed(privateMessage, "proxy"); verify(checkTarget).checkTargetAndSend(eq(playerProfile), eq(privateMessage), eq("proxy")); }