@Test public void whenMutedThenNotSent() { PunishmentChecker punishmentChecker = mock(PunishmentChecker.class); FindOnlinePlayer findOnlinePlayer = mock(FindOnlinePlayer.class); PrivateMessage privateMessage = new PrivateMessage(UUID.randomUUID(), "to", "text","fromName"); when(punishmentChecker.checkPunishment(eq(privateMessage.getFrom()), eq(ActivePunishmentType.MUTE))) .thenReturn(Optional.of(mock(ActivePunishmentRecord.class))); SendPrivateMessage sendPrivateMessage = new SendPrivateMessage(punishmentChecker, findOnlinePlayer); MessageSendResponse response = sendPrivateMessage.send(privateMessage); assertEquals(MessageSendResponse.MUTED, response); verifyZeroInteractions(findOnlinePlayer); }
public MessageSendResponse send(PrivateMessage message) { return this.isMuted(message.getFrom()) ? MessageSendResponse.MUTED : findOnlinePlayer.findAndSend(message); }
SendPrivateMessage { public MessageSendResponse send(PrivateMessage message) { return this.isMuted(message.getFrom()) ? MessageSendResponse.MUTED : findOnlinePlayer.findAndSend(message); } }
SendPrivateMessage { public MessageSendResponse send(PrivateMessage message) { return this.isMuted(message.getFrom()) ? MessageSendResponse.MUTED : findOnlinePlayer.findAndSend(message); }  }
SendPrivateMessage { public MessageSendResponse send(PrivateMessage message) { return this.isMuted(message.getFrom()) ? MessageSendResponse.MUTED : findOnlinePlayer.findAndSend(message); }  MessageSendResponse send(PrivateMessage message); }
SendPrivateMessage { public MessageSendResponse send(PrivateMessage message) { return this.isMuted(message.getFrom()) ? MessageSendResponse.MUTED : findOnlinePlayer.findAndSend(message); }  MessageSendResponse send(PrivateMessage message);  }