Search in sources :

Example 96 with CommandSender

use of org.bukkit.command.CommandSender in project AuthMeReloaded by AuthMe.

the class PlayerAuthViewerTest method shouldMakeExample.

@Test
public void shouldMakeExample() {
    // given
    CommandSender sender = mock(CommandSender.class);
    // when
    authViewer.execute(sender, Collections.emptyList());
    // then
    verify(sender).sendMessage(argThat(containsString("Example: /authme debug db Bobby")));
}
Also used : CommandSender(org.bukkit.command.CommandSender) Test(org.junit.Test)

Example 97 with CommandSender

use of org.bukkit.command.CommandSender in project AuthMeReloaded by AuthMe.

the class PlayerAuthViewerTest method shouldHandleMissingPlayer.

@Test
public void shouldHandleMissingPlayer() {
    // given
    CommandSender sender = mock(CommandSender.class);
    // when
    authViewer.execute(sender, Collections.singletonList("bogus"));
    // then
    verify(dataSource).getAuth("bogus");
    verify(sender).sendMessage(argThat(containsString("No record exists for 'bogus'")));
}
Also used : CommandSender(org.bukkit.command.CommandSender) Test(org.junit.Test)

Example 98 with CommandSender

use of org.bukkit.command.CommandSender in project AuthMeReloaded by AuthMe.

the class ChangePasswordCommandTest method shouldRejectNonPlayerSender.

@Test
public void shouldRejectNonPlayerSender() {
    // given
    CommandSender sender = mock(BlockCommandSender.class);
    // when
    command.executeCommand(sender, Collections.emptyList());
    // then
    verify(sender).sendMessage(argThat(containsString("use /authme password <playername> <password> instead")));
}
Also used : CommandSender(org.bukkit.command.CommandSender) BlockCommandSender(org.bukkit.command.BlockCommandSender) Test(org.junit.Test)

Example 99 with CommandSender

use of org.bukkit.command.CommandSender in project AuthMeReloaded by AuthMe.

the class PurgeBannedPlayersCommandTest method shouldForwardRequestToService.

@Test
public void shouldForwardRequestToService() {
    // given
    String[] names = { "bannedPlayer", "other_banned", "evilplayer", "Someone" };
    OfflinePlayer[] players = offlinePlayersWithNames(names);
    given(bukkitService.getBannedPlayers()).willReturn(newHashSet(players));
    CommandSender sender = mock(CommandSender.class);
    // when
    command.executeCommand(sender, Collections.emptyList());
    // then
    verify(bukkitService).getBannedPlayers();
    verify(purgeService).purgePlayers(eq(sender), eq(asLowerCaseSet(names)), argThat(arrayContainingInAnyOrder(players)));
}
Also used : OfflinePlayer(org.bukkit.OfflinePlayer) CommandSender(org.bukkit.command.CommandSender) Test(org.junit.Test)

Example 100 with CommandSender

use of org.bukkit.command.CommandSender in project AuthMeReloaded by AuthMe.

the class PlayerCommandTest method shouldRejectNonPlayerAndSendAlternative.

@Test
public void shouldRejectNonPlayerAndSendAlternative() {
    // given
    CommandSender sender = mock(CommandSender.class);
    PlayerCommandWithAlt command = new PlayerCommandWithAlt();
    // when
    command.executeCommand(sender, Collections.emptyList());
    // then
    verify(sender, times(1)).sendMessage(argThat(containsString("use /authme test <command> instead")));
}
Also used : CommandSender(org.bukkit.command.CommandSender) BlockCommandSender(org.bukkit.command.BlockCommandSender) Test(org.junit.Test)

Aggregations

CommandSender (org.bukkit.command.CommandSender)295 Test (org.junit.Test)171 Player (org.bukkit.entity.Player)94 Matchers.containsString (org.hamcrest.Matchers.containsString)68 ConsoleCommandSender (org.bukkit.command.ConsoleCommandSender)50 CoreStateInitException (com.solinia.solinia.Exceptions.CoreStateInitException)43 PlayerAuth (fr.xephi.authme.data.auth.PlayerAuth)30 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)29 PermissionNode (fr.xephi.authme.permission.PermissionNode)17 BlockCommandSender (org.bukkit.command.BlockCommandSender)16 ValidationResult (fr.xephi.authme.service.ValidationService.ValidationResult)12 Location (org.bukkit.Location)10 HashedPassword (fr.xephi.authme.security.crypts.HashedPassword)9 ArrayList (java.util.ArrayList)9 List (java.util.List)9 FoundCommandResult (fr.xephi.authme.command.FoundCommandResult)8 IOException (java.io.IOException)7 Entity (org.bukkit.entity.Entity)7 IEssentialsCommand (com.earth2me.essentials.commands.IEssentialsCommand)6 NoChargeException (com.earth2me.essentials.commands.NoChargeException)6