@Test public void whenNotMutedThenSent() { PunishmentChecker punishmentChecker = mock(PunishmentChecker.class); FindOnlinePlayer findOnlinePlayer = mock(FindOnlinePlayer.class); PrivateMessage privateMessage = new PrivateMessage(UUID.randomUUID(), "to", "text","fromName"); when(punishmentChecker.checkPunishment(any(), any())).thenReturn(Optional.empty()); SendPrivateMessage sendPrivateMessage = new SendPrivateMessage(punishmentChecker, findOnlinePlayer); when(findOnlinePlayer.findAndSend(eq(privateMessage))).thenReturn(MessageSendResponse.OK); MessageSendResponse response = sendPrivateMessage.send(privateMessage); assertEquals(MessageSendResponse.OK, response); verify(findOnlinePlayer).findAndSend(eq(privateMessage)); }
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);  }