use of fr.xephi.authme.command.FoundCommandResult in project AuthMeReloaded by AuthMe.
the class SwitchAntiBotCommandTest method shouldShowHelpForUnknownState.
@Test
public void shouldShowHelpForUnknownState() {
// given
CommandSender sender = mock(CommandSender.class);
FoundCommandResult foundCommandResult = mock(FoundCommandResult.class);
given(commandMapper.mapPartsToCommand(sender, asList("authme", "antibot"))).willReturn(foundCommandResult);
// when
command.executeCommand(sender, Collections.singletonList("wrong"));
// then
verify(antiBot, never()).overrideAntiBotStatus(anyBoolean());
verify(sender).sendMessage(argThat(containsString("Invalid")));
verify(helpProvider).outputHelp(sender, foundCommandResult, HelpProvider.SHOW_ARGUMENTS);
}
use of fr.xephi.authme.command.FoundCommandResult 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));
}
use of fr.xephi.authme.command.FoundCommandResult 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"));
}
use of fr.xephi.authme.command.FoundCommandResult 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());
}
use of fr.xephi.authme.command.FoundCommandResult 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"));
}
Aggregations