Search in sources :

Example 81 with CommandSender

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"));
}
Also used : CommandSender(org.bukkit.command.CommandSender) Matchers.containsString(org.hamcrest.Matchers.containsString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 82 with CommandSender

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"));
}
Also used : CommandSender(org.bukkit.command.CommandSender) Matchers.containsString(org.hamcrest.Matchers.containsString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 83 with CommandSender

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")));
}
Also used : CommandSender(org.bukkit.command.CommandSender) ConsoleLogger(fr.xephi.authme.ConsoleLogger) Logger(java.util.logging.Logger) Test(org.junit.Test)

Example 84 with CommandSender

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());
}
Also used : CommandSender(org.bukkit.command.CommandSender) Test(org.junit.Test)

Example 85 with CommandSender

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");
}
Also used : CommandSender(org.bukkit.command.CommandSender) Test(org.junit.Test)

Aggregations

CommandSender (org.bukkit.command.CommandSender)295 Test (org.junit.Test)171 Player (org.bukkit.entity.Player)94 Matchers.containsString (org.hamcrest.Matchers.containsString)68 ConsoleCommandSender (org.bukkit.command.ConsoleCommandSender)50 CoreStateInitException (com.solinia.solinia.Exceptions.CoreStateInitException)43 PlayerAuth (fr.xephi.authme.data.auth.PlayerAuth)30 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)29 PermissionNode (fr.xephi.authme.permission.PermissionNode)17 BlockCommandSender (org.bukkit.command.BlockCommandSender)16 ValidationResult (fr.xephi.authme.service.ValidationService.ValidationResult)12 Location (org.bukkit.Location)10 HashedPassword (fr.xephi.authme.security.crypts.HashedPassword)9 ArrayList (java.util.ArrayList)9 List (java.util.List)9 FoundCommandResult (fr.xephi.authme.command.FoundCommandResult)8 IOException (java.io.IOException)7 Entity (org.bukkit.entity.Entity)7 IEssentialsCommand (com.earth2me.essentials.commands.IEssentialsCommand)6 NoChargeException (com.earth2me.essentials.commands.NoChargeException)6