Search in sources :

Example 21 with FoundCommandResult

use of fr.xephi.authme.command.FoundCommandResult 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 22 with FoundCommandResult

use of fr.xephi.authme.command.FoundCommandResult 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 23 with FoundCommandResult

use of fr.xephi.authme.command.FoundCommandResult 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)

Example 24 with FoundCommandResult

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

the class HelpProviderTest method shouldNotShowAnythingForNullPermissionsOnCommand.

@Test
public void shouldNotShowAnythingForNullPermissionsOnCommand() {
    // given
    CommandDescription command = mock(CommandDescription.class);
    given(command.getPermission()).willReturn(null);
    given(command.getLabels()).willReturn(Collections.singletonList("test"));
    FoundCommandResult result = newFoundResult(command, Collections.singletonList("test"));
    // when
    helpProvider.outputHelp(sender, result, SHOW_PERMISSIONS);
    // 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 25 with FoundCommandResult

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

the class HelpProviderTest method shouldShowAlternatives.

@Test
public void shouldShowAlternatives() {
    // given
    CommandDescription command = getCommandWithLabel(commands, "authme", "register");
    FoundCommandResult result = newFoundResult(command, Arrays.asList("authme", "reg"));
    // when
    helpProvider.outputHelp(sender, result, SHOW_ALTERNATIVES);
    // then
    List<String> lines = getLines(sender);
    assertThat(lines, hasSize(4));
    assertThat(lines.get(1), containsString("Alternatives:"));
    assertThat(lines.get(2), containsString("/authme register <password> <confirmation>"));
    assertThat(lines.get(3), containsString("/authme r <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)

Aggregations

FoundCommandResult (fr.xephi.authme.command.FoundCommandResult)26 Test (org.junit.Test)24 Matchers.containsString (org.hamcrest.Matchers.containsString)22 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)22 CommandDescription (fr.xephi.authme.command.CommandDescription)20 CommandSender (org.bukkit.command.CommandSender)6 FoundResultStatus (fr.xephi.authme.command.FoundResultStatus)1