Search in sources :

Example 31 with CommandDescription

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

the class HelpProviderTest method shouldNotReturnAnythingForAllDisabledSections.

@Test
public void shouldNotReturnAnythingForAllDisabledSections() {
    // given
    given(helpMessagesService.getMessage(HelpSection.COMMAND)).willReturn("");
    given(helpMessagesService.getMessage(HelpSection.ALTERNATIVES)).willReturn("");
    given(helpMessagesService.getMessage(HelpSection.PERMISSIONS)).willReturn("");
    CommandDescription command = getCommandWithLabel(commands, "authme", "register");
    FoundCommandResult result = newFoundResult(command, Collections.singletonList("authme"));
    // when
    helpProvider.outputHelp(sender, result, SHOW_COMMAND | SHOW_ALTERNATIVES | SHOW_PERMISSIONS);
    // then
    verify(sender, never()).sendMessage(anyString());
}
Also used : FoundCommandResult(fr.xephi.authme.command.FoundCommandResult) CommandDescription(fr.xephi.authme.command.CommandDescription) Test(org.junit.Test)

Example 32 with CommandDescription

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

the class HelpProviderTest method shouldShowLongDescription.

@Test
public void shouldShowLongDescription() {
    // given
    CommandDescription command = getCommandWithLabel(commands, "authme", "login");
    FoundCommandResult result = newFoundResult(command, Arrays.asList("authme", "login"));
    // when
    helpProvider.outputHelp(sender, result, SHOW_COMMAND | SHOW_LONG_DESCRIPTION | SHOW_DESCRIPTION);
    // then
    List<String> lines = getLines(sender);
    assertThat(lines, hasSize(5));
    assertThat(lines.get(0), containsString("Header"));
    assertThat(lines.get(1), containsString("Command: /authme login <password>"));
    assertThat(lines.get(2), containsString("Short description: login cmd"));
    assertThat(lines.get(3), equalTo("Detailed description:"));
    assertThat(lines.get(4), containsString("'login' test command"));
}
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 33 with CommandDescription

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

the class HelpProviderTest method shouldShowChildren.

@Test
public void shouldShowChildren() {
    // given
    CommandDescription command = getCommandWithLabel(commands, "authme");
    FoundCommandResult result = newFoundResult(command, Collections.singletonList("authme"));
    given(helpMessagesService.getDescription(getCommandWithLabel(commands, "authme", "login"))).willReturn("Command for login [localized]");
    given(helpMessagesService.getDescription(getCommandWithLabel(commands, "authme", "register"))).willReturn("Registration command [localized]");
    // when
    helpProvider.outputHelp(sender, result, SHOW_CHILDREN);
    // then
    List<String> lines = getLines(sender);
    assertThat(lines, hasSize(4));
    assertThat(lines.get(1), equalTo("Children:"));
    assertThat(lines.get(2), equalTo(" /authme login: Command for login [localized]"));
    assertThat(lines.get(3), equalTo(" /authme register: Registration command [localized]"));
}
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 34 with CommandDescription

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

the class HelpProviderTest method shouldSkipEmptyHeader.

@Test
public void shouldSkipEmptyHeader() {
    // given
    given(helpMessagesService.getMessage(HelpMessage.HEADER)).willReturn("");
    CommandDescription command = getCommandWithLabel(commands, "authme", "register");
    FoundCommandResult result = newFoundResult(command, Collections.singletonList("authme"));
    // when
    helpProvider.outputHelp(sender, result, SHOW_COMMAND);
    // then
    List<String> lines = getLines(sender);
    assertThat(lines, hasSize(1));
    assertThat(lines.get(0), equalTo("Command: /authme register <password> <confirmation>"));
}
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 35 with CommandDescription

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

the class HelpProviderTest method shouldShowArguments.

@Test
public void shouldShowArguments() {
    // given
    CommandDescription command = getCommandWithLabel(commands, "authme", "register");
    FoundCommandResult result = newFoundResult(command, Arrays.asList("authme", "reg"));
    // when
    helpProvider.outputHelp(sender, result, SHOW_ARGUMENTS);
    // then
    List<String> lines = getLines(sender);
    assertThat(lines, hasSize(4));
    assertThat(lines.get(0), containsString("Header"));
    assertThat(lines.get(1), equalTo("Arguments:"));
    assertThat(lines.get(2), containsString("password: 'password' argument description"));
    assertThat(lines.get(3), containsString("confirmation: 'confirmation' argument description"));
}
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