@Test public void getChatMessage() { PlayerProfileRepository repository = mock(PlayerProfileRepository.class); UUID uuid = UUID.randomUUID(); PlayerProfile profile = mock(PlayerProfile.class); when(profile.getName()).thenReturn("riguron"); when(profile.getRank()).thenAnswer(invocation -> { Rank rank = mock(Rank.class); when(rank.getPrefix()).thenReturn("admin"); return rank; }); when(repository.get(eq(uuid))).thenReturn(profile); ChatFormatter chatFormatter = new ChatFormatter(repository); String message = chatFormatter.getChatMessage(uuid, "Message"); assertEquals("[admin] riguron: Message", message); }
public String getChatMessage(UUID uuid, String message) { PlayerProfile profile = playerProfileRepository.get(uuid); return String.format("[%s] %s: %s", profile.getRank().getPrefix(), profile.getName(), message); }
ChatFormatter { public String getChatMessage(UUID uuid, String message) { PlayerProfile profile = playerProfileRepository.get(uuid); return String.format("[%s] %s: %s", profile.getRank().getPrefix(), profile.getName(), message); } }
ChatFormatter { public String getChatMessage(UUID uuid, String message) { PlayerProfile profile = playerProfileRepository.get(uuid); return String.format("[%s] %s: %s", profile.getRank().getPrefix(), profile.getName(), message); }  }
ChatFormatter { public String getChatMessage(UUID uuid, String message) { PlayerProfile profile = playerProfileRepository.get(uuid); return String.format("[%s] %s: %s", profile.getRank().getPrefix(), profile.getName(), message); }  String getChatMessage(UUID uuid, String message); }
ChatFormatter { public String getChatMessage(UUID uuid, String message) { PlayerProfile profile = playerProfileRepository.get(uuid); return String.format("[%s] %s: %s", profile.getRank().getPrefix(), profile.getName(), message); }  String getChatMessage(UUID uuid, String message);  }