use of org.bukkit.command.CommandSender in project AuthMeReloaded by AuthMe.
the class TotpDisableAdminCommandTest method shouldHandleErrorWhileRemovingTotp.
@Test
public void shouldHandleErrorWhileRemovingTotp() {
// given
CommandSender sender = mock(CommandSender.class);
PlayerAuth auth = PlayerAuth.builder().name("Bobby").totpKey("321654").build();
given(dataSource.getAuth("Bobby")).willReturn(auth);
given(dataSource.removeTotpKey("Bobby")).willReturn(false);
// when
command.executeCommand(sender, Collections.singletonList("Bobby"));
// then
verify(messages).send(sender, MessageKey.ERROR);
}
use of org.bukkit.command.CommandSender in project AuthMeReloaded by AuthMe.
the class UnregisterAdminCommandTest method shouldInvokeUnregisterProcessWithNullPlayer.
@Test
public void shouldInvokeUnregisterProcessWithNullPlayer() {
// given
String user = "personaNonGrata";
given(dataSource.isAuthAvailable(user)).willReturn(true);
given(bukkitService.getPlayerExact(user)).willReturn(null);
CommandSender sender = mock(CommandSender.class);
// when
command.executeCommand(sender, Collections.singletonList(user));
// then
verify(dataSource, only()).isAuthAvailable(user);
verify(bukkitService).getPlayerExact(user);
verify(management).performUnregisterByAdmin(sender, user, null);
}
use of org.bukkit.command.CommandSender in project AuthMeReloaded by AuthMe.
the class UnregisterCommandTest method shouldStopIfSenderIsNotPlayer.
@Test
public void shouldStopIfSenderIsNotPlayer() {
// given
CommandSender sender = mock(CommandSender.class);
// when
command.executeCommand(sender, Collections.singletonList("password"));
// then
verifyNoInteractions(playerCache, management);
verify(sender).sendMessage(argThat(containsString("/authme unregister <player>")));
}
use of org.bukkit.command.CommandSender in project AuthMeReloaded by AuthMe.
the class MessagesIntegrationTest method shouldNotUseMessageFromDefaultFile.
@Test
public void shouldNotUseMessageFromDefaultFile() {
// given
// Key is present in both files
MessageKey key = MessageKey.WRONG_PASSWORD;
CommandSender sender = mock(CommandSender.class);
given(sender.getName()).willReturn("Tester");
// when
String message = messages.retrieveSingle(sender, key);
// then
assertThat(message, equalTo("§cWrong password!"));
}
use of org.bukkit.command.CommandSender in project AuthMeReloaded by AuthMe.
the class MessagesIntegrationTest method shouldLogErrorForInvalidReplacementCount.
@Test
public void shouldLogErrorForInvalidReplacementCount() {
// given
Logger logger = mock(Logger.class);
ConsoleLogger.initialize(logger, null);
MessageKey key = MessageKey.CAPTCHA_WRONG_ERROR;
CommandSender sender = mock(CommandSender.class);
given(sender.getName()).willReturn("Tester");
// when
messages.send(sender, key, "rep", "rep2");
// then
verify(logger).warning(argThat(containsString("Invalid number of replacements")));
}
Aggregations