use of org.bukkit.command.CommandSender in project AuthMeReloaded by AuthMe.
the class MessagesIntegrationTest method shouldRetrieveMessageWithReplacements.
@Test
public void shouldRetrieveMessageWithReplacements() {
// given
MessageKey key = MessageKey.CAPTCHA_WRONG_ERROR;
CommandSender sender = mock(CommandSender.class);
given(sender.getName()).willReturn("Tester");
// when
String result = messages.retrieveSingle(sender.getName(), key, "24680");
// then
assertThat(result, equalTo("Use /captcha 24680 to solve the captcha"));
}
use of org.bukkit.command.CommandSender in project AuthMeReloaded by AuthMe.
the class MessagesIntegrationTest method shouldFormatColorCodes.
@Test
public void shouldFormatColorCodes() {
// given
MessageKey key = MessageKey.LOGIN_SUCCESS;
CommandSender sender = mock(CommandSender.class);
given(sender.getName()).willReturn("Tester");
// when
String[] message = messages.retrieve(key, sender);
// then
assertThat(message, arrayWithSize(1));
assertThat(message[0], equalTo("§cHere we have§bdefined some colors §dand some other §lthings"));
}
use of org.bukkit.command.CommandSender in project AuthMeReloaded by AuthMe.
the class MessagesIntegrationTest method shouldSendErrorForReplacementsOnKeyWithNoTags.
@Test
public void shouldSendErrorForReplacementsOnKeyWithNoTags() {
// given
Logger logger = mock(Logger.class);
ConsoleLogger.initialize(logger, null);
MessageKey key = MessageKey.UNKNOWN_USER;
CommandSender sender = mock(CommandSender.class);
given(sender.getName()).willReturn("Tester");
// when
messages.send(sender, key, "Replacement");
// then
verify(logger).warning(argThat(containsString("Invalid number of replacements")));
}
use of org.bukkit.command.CommandSender in project AuthMeReloaded by AuthMe.
the class MessagesIntegrationTest method shouldNotSendEmptyMessage.
@Test
public void shouldNotSendEmptyMessage() {
// given
MessageKey key = MessageKey.EMAIL_ALREADY_USED_ERROR;
CommandSender sender = mock(CommandSender.class);
given(sender.getName()).willReturn("Tester");
// when
messages.send(sender, key);
// then
verify(sender, never()).sendMessage(anyString());
}
use of org.bukkit.command.CommandSender in project AuthMeReloaded by AuthMe.
the class MessagesIntegrationTest method shouldNotLogErrorForKeyWithNoTagReplacements.
@Test
public void shouldNotLogErrorForKeyWithNoTagReplacements() {
// given
MessageKey key = MessageKey.CAPTCHA_WRONG_ERROR;
CommandSender sender = mock(CommandSender.class);
given(sender.getName()).willReturn("Tester");
// when
messages.send(sender, key);
// then
verify(sender).sendMessage("Use /captcha %captcha_code to solve the captcha");
}
Aggregations