### Question:
CheckTarget { public MessageSendResponse checkTargetAndSend(PlayerProfile targetProfile, PrivateMessage privateMessage, String targetProxy) { if (ignoreRepository.isIgnoring(targetProfile.getUuid(), privateMessage.getFromName())) { return MessageSendResponse.IGNORING; } else if (!targetProfile.getPlayerPreferences().isPrivateMessages()) { return MessageSendResponse.DISABLED; } else { return finalStage.sendFinalStage(targetProfile, privateMessage, targetProxy); } }  MessageSendResponse checkTargetAndSend(PlayerProfile targetProfile, PrivateMessage privateMessage, String targetProxy);  }### Answer:
@Test public void whenTargetIsIgnoring() { IgnoreRepository ignoreRepository = mock(IgnoreRepository.class); CheckTarget checkTarget = new CheckTarget(ignoreRepository, mock(FinalStage.class)); PlayerProfile targetProfile = mock(PlayerProfile.class); UUID targetProfileUUID = UUID.randomUUID(); when(targetProfile.getUuid()).thenReturn(targetProfileUUID); PrivateMessage privateMessage = new PrivateMessage(UUID.randomUUID(), "to", "text", "fromName"); when(ignoreRepository.isIgnoring(eq(targetProfileUUID), eq(privateMessage.getFromName()))).thenReturn(true); Assert.assertEquals(MessageSendResponse.IGNORING, checkTarget.checkTargetAndSend(targetProfile, privateMessage, "proxy")); }
@Test public void whenTargetHasDisabled() { IgnoreRepository ignoreRepository = mock(IgnoreRepository.class); CheckTarget checkTarget = new CheckTarget(ignoreRepository, mock(FinalStage.class)); PlayerProfile targetProfile = mock(PlayerProfile.class); UUID targetProfileUUID = UUID.randomUUID(); when(targetProfile.getUuid()).thenReturn(targetProfileUUID); PrivateMessage privateMessage = new PrivateMessage(UUID.randomUUID(), "to", "text", "fromName"); when(ignoreRepository.isIgnoring(any(), any())).thenReturn(false); when(targetProfile.getPlayerPreferences()).thenAnswer((Answer<PlayerPreferences>) invocation -> { PlayerPreferences playerPreferences = mock(PlayerPreferences.class); when(playerPreferences.isPrivateMessages()).thenReturn(false); return playerPreferences; }); Assert.assertEquals(MessageSendResponse.DISABLED ,checkTarget.checkTargetAndSend( targetProfile, privateMessage, "proxy" )); }