### Question:
PurgeService { public void runPurge(CommandSender sender, long until) { Set<String> toPurge = dataSource.getRecordsToPurge(until); if (Utils.isCollectionEmpty(toPurge)) { logAndSendMessage(sender, "No players to purge"); return; } purgePlayers(sender, toPurge, bukkitService.getOfflinePlayers()); } PurgeService(); void runAutoPurge(); void runPurge(CommandSender sender, long until); void purgePlayers(CommandSender sender, Set<String> names, OfflinePlayer[] players);  }### Answer:
@Test public void shouldRecognizeNoPlayersToPurge() { final long delay = 123012301L; given(dataSource.getRecordsToPurge(delay)).willReturn(Collections.emptySet()); CommandSender sender = mock(CommandSender.class); purgeService.runPurge(sender, delay); verify(dataSource).getRecordsToPurge(delay); verify(dataSource, never()).purgeRecords(anyCollection()); verify(sender).sendMessage("No players to purge"); verifyZeroInteractions(bukkitService, permissionsManager); }
@Test public void shouldRunPurge() { final long delay = 1809714L; Set<String> playerNames = newHashSet("charlie", "delta", "echo", "foxtrot"); given(dataSource.getRecordsToPurge(delay)).willReturn(playerNames); Player sender = mock(Player.class); UUID uuid = UUID.randomUUID(); given(sender.getUniqueId()).willReturn(uuid); purgeService.runPurge(sender, delay); verify(dataSource).getRecordsToPurge(delay); verifyScheduledPurgeTask(uuid, playerNames); }