Search in sources :

Example 11 with MessageKey

use of fr.xephi.authme.message.MessageKey in project AuthMeReloaded by AuthMe.

the class LimboPlayerTaskManagerTest method shouldRegisterMessageTask.

@Test
public void shouldRegisterMessageTask() {
    // given
    Player player = mock(Player.class);
    LimboPlayer limboPlayer = mock(LimboPlayer.class);
    MessageKey key = MessageKey.REGISTER_MESSAGE;
    given(messages.retrieveSingle(player, key)).willReturn("Please register!");
    int interval = 12;
    given(settings.getProperty(RegistrationSettings.MESSAGE_INTERVAL)).willReturn(interval);
    // when
    limboPlayerTaskManager.registerMessageTask(player, limboPlayer, LimboMessageType.REGISTER);
    // then
    verify(limboPlayer).setMessageTask(any(MessageTask.class));
    verify(messages).retrieveSingle(player, key);
    verify(bukkitService).runTaskTimer(any(MessageTask.class), eq(2L * TICKS_PER_SECOND), eq((long) interval * TICKS_PER_SECOND));
}
Also used : Player(org.bukkit.entity.Player) MessageTask(fr.xephi.authme.task.MessageTask) MessageKey(fr.xephi.authme.message.MessageKey) Test(org.junit.Test)

Example 12 with MessageKey

use of fr.xephi.authme.message.MessageKey in project AuthMeReloaded by AuthMe.

the class CommonServiceTest method shouldRetrieveSingleMessage.

@Test
public void shouldRetrieveSingleMessage() {
    // given
    MessageKey key = MessageKey.ACCOUNT_NOT_ACTIVATED;
    Player player = mock(Player.class);
    String text = "Test text";
    given(messages.retrieveSingle(player, key)).willReturn(text);
    // when
    String result = commonService.retrieveSingleMessage(player, key);
    // then
    assertThat(result, equalTo(text));
    verify(messages).retrieveSingle(player, key);
}
Also used : Player(org.bukkit.entity.Player) MessageKey(fr.xephi.authme.message.MessageKey) Test(org.junit.Test)

Example 13 with MessageKey

use of fr.xephi.authme.message.MessageKey in project AuthMeReloaded by AuthMe.

the class CommonServiceTest method shouldSendMessageToPlayer.

@Test
public void shouldSendMessageToPlayer() {
    // given
    CommandSender sender = mock(CommandSender.class);
    MessageKey key = MessageKey.ACCOUNT_NOT_ACTIVATED;
    // when
    commonService.send(sender, key);
    // then
    verify(messages).send(sender, key);
}
Also used : MessageKey(fr.xephi.authme.message.MessageKey) CommandSender(org.bukkit.command.CommandSender) Test(org.junit.Test)

Example 14 with MessageKey

use of fr.xephi.authme.message.MessageKey in project AuthMeReloaded by AuthMe.

the class CommonServiceTest method shouldSendMessageWithReplacements.

@Test
public void shouldSendMessageWithReplacements() {
    // given
    CommandSender sender = mock(CommandSender.class);
    MessageKey key = MessageKey.ACCOUNT_NOT_ACTIVATED;
    String[] replacements = new String[] { "test", "toast" };
    // when
    commonService.send(sender, key, replacements);
    // then
    verify(messages).send(sender, key, replacements);
}
Also used : MessageKey(fr.xephi.authme.message.MessageKey) CommandSender(org.bukkit.command.CommandSender) Test(org.junit.Test)

Aggregations

MessageKey (fr.xephi.authme.message.MessageKey)14 File (java.io.File)5 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 List (java.util.List)3 PropertyReader (ch.jalu.configme.resource.PropertyReader)2 Lists (com.google.common.collect.Lists)2 MessageTask (fr.xephi.authme.task.MessageTask)2 Arrays.asList (java.util.Arrays.asList)2 Consumer (java.util.function.Consumer)2 Predicate (java.util.function.Predicate)2 Collectors (java.util.stream.Collectors)2 CommandSender (org.bukkit.command.CommandSender)2 Player (org.bukkit.entity.Player)2 FileIoUtils (tools.utils.FileIoUtils)2 ToolsConstants (tools.utils.ToolsConstants)2 ConfigurationData (ch.jalu.configme.configurationdata.ConfigurationData)1 PropertyListBuilder (ch.jalu.configme.configurationdata.PropertyListBuilder)1 Property (ch.jalu.configme.properties.Property)1 StringProperty (ch.jalu.configme.properties.StringProperty)1