Search in sources :

Example 26 with CommandDescription

use of fr.xephi.authme.command.CommandDescription in project AuthMeReloaded by AuthMe.

the class HelpMessagesServiceTest method shouldReturnLocalizedCommandWithDefaults.

@Test
public void shouldReturnLocalizedCommandWithDefaults() {
    // given
    CommandDescription command = getCommandWithLabel(COMMANDS, "authme", "login");
    // when
    CommandDescription localCommand = helpMessagesService.buildLocalizedDescription(command);
    // then
    assertThat(localCommand.getDescription(), equalTo("Logging in"));
    assertThat(localCommand.getDetailedDescription(), equalTo("'login' test command"));
    assertThat(localCommand.getArguments(), hasSize(1));
    assertThat(localCommand.getArguments().get(0).getName(), equalTo("user password"));
    assertThat(localCommand.getArguments().get(0).getDescription(), equalTo("'password' argument description"));
}
Also used : CommandDescription(fr.xephi.authme.command.CommandDescription) Test(org.junit.Test)

Example 27 with CommandDescription

use of fr.xephi.authme.command.CommandDescription in project AuthMeReloaded by AuthMe.

the class HelpMessagesServiceTest method shouldReturnSameCommandForNoLocalization.

@Test
public void shouldReturnSameCommandForNoLocalization() {
    // given
    CommandDescription command = getCommandWithLabel(COMMANDS, "email");
    // when
    CommandDescription localCommand = helpMessagesService.buildLocalizedDescription(command);
    // then
    assertThat(localCommand, sameInstance(command));
}
Also used : CommandDescription(fr.xephi.authme.command.CommandDescription) Test(org.junit.Test)

Example 28 with CommandDescription

use of fr.xephi.authme.command.CommandDescription in project AuthMeReloaded by AuthMe.

the class HelpMessagesServiceTest method shouldKeepChildrenInLocalCommand.

@Test
public void shouldKeepChildrenInLocalCommand() {
    // given
    CommandDescription command = getCommandWithLabel(COMMANDS, "authme");
    // when
    CommandDescription localCommand = helpMessagesService.buildLocalizedDescription(command);
    // then
    assertThat(localCommand.getChildren(), equalTo(command.getChildren()));
    assertThat(localCommand.getDescription(), equalTo("authme cmd"));
    assertThat(localCommand.getDetailedDescription(), equalTo("Main command"));
}
Also used : CommandDescription(fr.xephi.authme.command.CommandDescription) Test(org.junit.Test)

Example 29 with CommandDescription

use of fr.xephi.authme.command.CommandDescription in project AuthMeReloaded by AuthMe.

the class HelpProviderTest method shouldNotShowAnythingIfHasNoAlternatives.

@Test
public void shouldNotShowAnythingIfHasNoAlternatives() {
    // given
    CommandDescription command = getCommandWithLabel(commands, "authme", "login");
    FoundCommandResult result = newFoundResult(command, Arrays.asList("authme", "login"));
    // when
    helpProvider.outputHelp(sender, result, SHOW_ALTERNATIVES);
    // then
    List<String> lines = getLines(sender);
    assertThat(lines, hasSize(1));
}
Also used : FoundCommandResult(fr.xephi.authme.command.FoundCommandResult) CommandDescription(fr.xephi.authme.command.CommandDescription) Matchers.containsString(org.hamcrest.Matchers.containsString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 30 with CommandDescription

use of fr.xephi.authme.command.CommandDescription in project AuthMeReloaded by AuthMe.

the class HelpProviderTest method shouldShowAndEvaluatePermissions.

@Test
public void shouldShowAndEvaluatePermissions() {
    // given
    CommandDescription command = getCommandWithLabel(commands, "unregister");
    FoundCommandResult result = newFoundResult(command, Collections.singletonList("unreg"));
    given(sender.isOp()).willReturn(true);
    given(permissionsManager.hasPermission(sender, AdminPermission.UNREGISTER)).willReturn(true);
    given(permissionsManager.hasPermission(sender, command.getPermission())).willReturn(true);
    // when
    helpProvider.outputHelp(sender, result, SHOW_PERMISSIONS);
    // then
    List<String> lines = getLines(sender);
    assertThat(lines, hasSize(5));
    assertThat(lines.get(1), containsString("Permissions:"));
    assertThat(lines.get(2), containsString(AdminPermission.UNREGISTER.getNode() + " (Has permission)"));
    assertThat(lines.get(3), containsString("Default: Op only (Has permission)"));
    assertThat(lines.get(4), containsString("Result: Has permission"));
}
Also used : FoundCommandResult(fr.xephi.authme.command.FoundCommandResult) CommandDescription(fr.xephi.authme.command.CommandDescription) Matchers.containsString(org.hamcrest.Matchers.containsString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Aggregations

CommandDescription (fr.xephi.authme.command.CommandDescription)38 Test (org.junit.Test)30 Matchers.containsString (org.hamcrest.Matchers.containsString)22 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)22 FoundCommandResult (fr.xephi.authme.command.FoundCommandResult)20 CommandInitializer (fr.xephi.authme.command.CommandInitializer)4 CommandSender (org.bukkit.command.CommandSender)3 FileConfiguration (org.bukkit.configuration.file.FileConfiguration)2 TestHelper (fr.xephi.authme.TestHelper)1 CommandArgumentDescription (fr.xephi.authme.command.CommandArgumentDescription)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 LinkedHashMap (java.util.LinkedHashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 List (java.util.List)1 MemorySection (org.bukkit.configuration.MemorySection)1 YamlConfiguration (org.bukkit.configuration.file.YamlConfiguration)1 Matchers.contains (org.hamcrest.Matchers.contains)1 Matchers.equalTo (org.hamcrest.Matchers.equalTo)1