Search in sources :

Example 66 with CommandSender

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

the class HasPermissionCheckerTest method shouldShowUsageInfo.

@Test
public void shouldShowUsageInfo() {
    // given
    CommandSender sender = mock(CommandSender.class);
    // when
    hasPermissionChecker.execute(sender, emptyList());
    // then
    ArgumentCaptor<String> msgCaptor = ArgumentCaptor.forClass(String.class);
    verify(sender, atLeast(2)).sendMessage(msgCaptor.capture());
    assertThat(msgCaptor.getAllValues().stream().anyMatch(msg -> msg.contains("/authme debug perm bobby my.perm.node")), equalTo(true));
}
Also used : PermissionNode(fr.xephi.authme.permission.PermissionNode) ClassCollector(fr.xephi.authme.ClassCollector) Mock(org.mockito.Mock) RunWith(org.junit.runner.RunWith) AdminPermission(fr.xephi.authme.permission.AdminPermission) Player(org.bukkit.entity.Player) Assert.assertThat(org.junit.Assert.assertThat) PermissionsManager(fr.xephi.authme.permission.PermissionsManager) ArgumentCaptor(org.mockito.ArgumentCaptor) BDDMockito.given(org.mockito.BDDMockito.given) Arrays.asList(java.util.Arrays.asList) MockitoHamcrest.argThat(org.mockito.hamcrest.MockitoHamcrest.argThat) Mockito.atLeast(org.mockito.Mockito.atLeast) TestHelper(fr.xephi.authme.TestHelper) InjectMocks(org.mockito.InjectMocks) CommandSender(org.bukkit.command.CommandSender) Collections.emptyList(java.util.Collections.emptyList) BukkitService(fr.xephi.authme.service.BukkitService) Test(org.junit.Test) Collectors(java.util.stream.Collectors) Mockito.verify(org.mockito.Mockito.verify) List(java.util.List) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) Matchers.equalTo(org.hamcrest.Matchers.equalTo) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) Matchers.containsString(org.hamcrest.Matchers.containsString) Mockito.mock(org.mockito.Mockito.mock) CommandSender(org.bukkit.command.CommandSender) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 67 with CommandSender

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

the class ChangeEmailCommandTest method shouldRejectNonPlayerSender.

@Test
public void shouldRejectNonPlayerSender() {
    // given
    CommandSender sender = mock(BlockCommandSender.class);
    // when
    command.executeCommand(sender, Collections.emptyList());
    // then
    verifyNoInteractions(management);
}
Also used : CommandSender(org.bukkit.command.CommandSender) BlockCommandSender(org.bukkit.command.BlockCommandSender) Test(org.junit.Test)

Example 68 with CommandSender

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

the class AddEmailCommandTest method shouldRejectNonPlayerSender.

@Test
public void shouldRejectNonPlayerSender() {
    // given
    CommandSender sender = mock(BlockCommandSender.class);
    // when
    command.executeCommand(sender, Collections.emptyList());
    // then
    verifyNoInteractions(management);
}
Also used : CommandSender(org.bukkit.command.CommandSender) BlockCommandSender(org.bukkit.command.BlockCommandSender) Test(org.junit.Test)

Example 69 with CommandSender

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

the class EmailBaseCommandTest method shouldDisplayHelp.

@Test
public void shouldDisplayHelp() {
    // given
    CommandSender sender = mock(CommandSender.class);
    FoundCommandResult result = mock(FoundCommandResult.class);
    given(commandMapper.mapPartsToCommand(eq(sender), anyList())).willReturn(result);
    // when
    command.executeCommand(sender, Collections.emptyList());
    // then
    verify(commandMapper).mapPartsToCommand(sender, Collections.singletonList("email"));
    verify(helpProvider).outputHelp(sender, result, HelpProvider.SHOW_CHILDREN);
}
Also used : FoundCommandResult(fr.xephi.authme.command.FoundCommandResult) CommandSender(org.bukkit.command.CommandSender) Test(org.junit.Test)

Example 70 with CommandSender

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

the class TotpBaseCommandTest method shouldOutputHelp.

@Test
public void shouldOutputHelp() {
    // given
    CommandSender sender = mock(CommandSender.class);
    FoundCommandResult mappingResult = mock(FoundCommandResult.class);
    given(mapper.mapPartsToCommand(sender, Collections.singletonList("totp"))).willReturn(mappingResult);
    // when
    command.executeCommand(sender, Collections.emptyList());
    // then
    verify(mapper).mapPartsToCommand(sender, Collections.singletonList("totp"));
    verify(helpProvider).outputHelp(sender, mappingResult, HelpProvider.SHOW_CHILDREN);
}
Also used : FoundCommandResult(fr.xephi.authme.command.FoundCommandResult) CommandSender(org.bukkit.command.CommandSender) 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