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"));
}
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));
}
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"));
}
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));
}
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"));
}
Aggregations