@Test public void shouldHandleMissingFirstSpawn() { // given given(spawnLoader.getFirstSpawn()).willReturn(null); Player player = mock(Player.class); // when command.executeCommand(player, Collections.<String>emptyList()); // then verify(player).sendMessage(argThat(containsString("spawn has failed"))); verify(player, never()).teleport(any(Location.class)); }
@Test public void shouldTeleportToFirstSpawn() { // given Location firstSpawn = mock(Location.class); given(spawnLoader.getFirstSpawn()).willReturn(firstSpawn); Player player = mock(Player.class); // when command.executeCommand(player, Collections.<String>emptyList()); // then verify(player).teleport(firstSpawn); verify(spawnLoader, atLeastOnce()).getFirstSpawn(); }