Search in sources :

Example 6 with Message

use of at.pcgamingfreaks.Bungee.Message.Message in project Bukkit_Bungee_PluginLib by GeorgH93.

the class LanguageTest method testLanguage.

@Test
public void testLanguage() throws Exception {
    Language language = new Language(TestObjects.getPlugin(), 1);
    assertNotNull("The language object should not be null", language);
    language = spy(language);
    doReturn("TestText").when(language).get("test");
    doReturn(new Message("MessageText")).when(language, at.pcgamingfreaks.Language.class.getDeclaredMethod("getMessage", boolean.class, String.class)).withArguments(true, "test");
    assertEquals("The option string should match", "TestText", language.getString("test"));
    assertEquals("The translated string should match", "TestText", language.getTranslated("test"));
    assertEquals("The base component should be ready to send", 1, language.getReady("test").length);
    assertEquals("The message should be equal", "TestText", language.getMessage("test").getClassicMessage());
}
Also used : Message(at.pcgamingfreaks.Bungee.Message.Message) Test(org.junit.Test)

Example 7 with Message

use of at.pcgamingfreaks.Bungee.Message.Message in project Bukkit_Bungee_PluginLib by GeorgH93.

the class BossBarSenderTest method testBroadcast.

@Test
public void testBroadcast() throws NoSuchFieldException, IllegalAccessException {
    TestObjects.initProxyServer();
    int sendCalls = 0;
    BossBarSender bossBarSender = new BossBarSender();
    bossBarSender.doBroadcast("");
    verify(TestObjects.getPlayer().unsafe(), times(sendCalls)).sendPacket(any(Chat.class));
    bossBarSender.doBroadcast("", 1);
    verify(TestObjects.getPlayer().unsafe(), times(sendCalls)).sendPacket(any(Chat.class));
    BossBarSender.broadcast(new Message(""));
    verify(TestObjects.getPlayer().unsafe(), times(sendCalls)).sendPacket(any(Chat.class));
}
Also used : Message(at.pcgamingfreaks.Bungee.Message.Message) Chat(net.md_5.bungee.protocol.packet.Chat) Test(org.junit.Test)

Example 8 with Message

use of at.pcgamingfreaks.Bungee.Message.Message in project Bukkit_Bungee_PluginLib by GeorgH93.

the class ChatSenderTest method testSend.

@Test
public void testSend() {
    List<ProxiedPlayer> players = new ArrayList<>();
    players.add(TestObjects.getPlayer());
    players.add(TestObjects.getPlayer());
    int sendCalls = 0;
    int playerCount = players.size();
    ChatSender chatSender = new ChatSender();
    chatSender.doSend(TestObjects.getPlayer(), "");
    verify(TestObjects.getPlayer().unsafe(), times(++sendCalls)).sendPacket(any(Chat.class));
    chatSender.doSend(TestObjects.getPlayer(), "", 1);
    verify(TestObjects.getPlayer().unsafe(), times(++sendCalls)).sendPacket(any(Chat.class));
    ChatSender.send(TestObjects.getPlayer(), new Message(""));
    verify(TestObjects.getPlayer().unsafe(), times(++sendCalls)).sendPacket(any(Chat.class));
    chatSender.doSend(players, "");
    sendCalls += playerCount;
    verify(TestObjects.getPlayer().unsafe(), times(sendCalls)).sendPacket(any(Chat.class));
    chatSender.doSend(players, "", 1);
    sendCalls += playerCount;
    verify(TestObjects.getPlayer().unsafe(), times(sendCalls)).sendPacket(any(Chat.class));
    ChatSender.send(players, new Message(""));
    sendCalls += playerCount;
    verify(TestObjects.getPlayer().unsafe(), times(sendCalls)).sendPacket(any(Chat.class));
}
Also used : ProxiedPlayer(net.md_5.bungee.api.connection.ProxiedPlayer) Message(at.pcgamingfreaks.Bungee.Message.Message) ArrayList(java.util.ArrayList) Chat(net.md_5.bungee.protocol.packet.Chat) Test(org.junit.Test)

Example 9 with Message

use of at.pcgamingfreaks.Bungee.Message.Message in project Bukkit_Bungee_PluginLib by GeorgH93.

the class ChatSenderTest method testBroadcast.

@Test
public void testBroadcast() throws NoSuchFieldException, IllegalAccessException {
    TestObjects.initProxyServer();
    int sendCalls = 0;
    int playerCount = TestObjects.getPlayers().size();
    ChatSender chatSender = new ChatSender();
    chatSender.doBroadcast("");
    sendCalls += playerCount;
    verify(TestObjects.getPlayer().unsafe(), times(sendCalls)).sendPacket(any(Chat.class));
    chatSender.doBroadcast("", 1);
    sendCalls += playerCount;
    verify(TestObjects.getPlayer().unsafe(), times(sendCalls)).sendPacket(any(Chat.class));
    ChatSender.broadcast(new Message(""));
    sendCalls += playerCount;
    verify(TestObjects.getPlayer().unsafe(), times(sendCalls)).sendPacket(any(Chat.class));
}
Also used : Message(at.pcgamingfreaks.Bungee.Message.Message) Chat(net.md_5.bungee.protocol.packet.Chat) Test(org.junit.Test)

Aggregations

Message (at.pcgamingfreaks.Bungee.Message.Message)9 Test (org.junit.Test)9 Chat (net.md_5.bungee.protocol.packet.Chat)8 ArrayList (java.util.ArrayList)4 ProxiedPlayer (net.md_5.bungee.api.connection.ProxiedPlayer)4