Search in sources :

Example 1 with MockMessage

use of jetbrains.communicator.mock.MockMessage in project intellij-plugins by JetBrains.

the class UsersTreeModel_OnlyOfflineShownTest method testOfflineUserWithMessage.

public void testOfflineUserWithMessage() throws Exception {
    myTree.expandRow(2);
    myTree.expandRow(1);
    myIDEFacade.setReturnedMessage(new MockMessage());
    getBroadcaster().fireEvent(EventFactory.createMessageEvent(new MockTransport(), myUserModel.getUsers("group1")[0].getName(), "text"));
    TreeUtil.expandAll(myTree);
    assertEquals("Should include user with pending local message", 5, myTree.getRowCount());
}
Also used : MockMessage(jetbrains.communicator.mock.MockMessage) MockTransport(jetbrains.communicator.mock.MockTransport)

Example 2 with MockMessage

use of jetbrains.communicator.mock.MockMessage in project intellij-plugins by JetBrains.

the class AbstractMessageDispatcherTest method testSendMessageToOnlineUser.

public void testSendMessageToOnlineUser() throws Exception {
    MockMessage message = new MockMessage(true);
    myDispatcher.performDispatch(myUser, message);
    assertEquals("should send to online user", "sent to " + myUser + ":success", message.getLog());
}
Also used : MockMessage(jetbrains.communicator.mock.MockMessage)

Example 3 with MockMessage

use of jetbrains.communicator.mock.MockMessage in project intellij-plugins by JetBrains.

the class AsyncMessageDispatcherTest method testAddMessagesWhileDispatching.

public void testAddMessagesWhileDispatching() throws Exception {
    NotifyableMessage mockMessage = new NotifyableMessage(true, myLog);
    MockUser user1 = new MockUser("user1", null);
    MockUser user2 = new MockUser("user2", null);
    user1.setOnline(true);
    user2.setOnline(true);
    myDispatcher.sendLater(user1, mockMessage);
    mockMessage.waitUntilDispatchingStarted();
    myDispatcher.sendLater(user2, new MockMessage(true));
    assertEquals("Messages not delivered yet", 2, myDispatcher.getUsersWithMessages().length);
    triggerMessageProcessing(mockMessage);
    new WaitFor(200) {

        @Override
        protected boolean condition() {
            return myDispatcher.getUsersWithMessages().length == 0;
        }
    };
    assertEquals("All messages should be delivered", 0, myDispatcher.getUsersWithMessages().length);
}
Also used : WaitFor(jetbrains.communicator.util.WaitFor) MockMessage(jetbrains.communicator.mock.MockMessage) MockUser(jetbrains.communicator.mock.MockUser)

Example 4 with MockMessage

use of jetbrains.communicator.mock.MockMessage in project intellij-plugins by JetBrains.

the class LocalMessageDispatcherTest method testSendMessageEvent.

public void testSendMessageEvent() throws Exception {
    MockTransport mockTransport = new MockTransport();
    MockMessage localMessage = new MockMessage();
    MockMessage localMessage1 = new MockMessage();
    myIdeFacade.setReturnedMessage(localMessage);
    getBroadcaster().fireEvent(new SendMessageEvent("text", myUser));
    myIdeFacade.setReturnedMessage(localMessage1);
    getBroadcaster().fireEvent(new SendMessageEvent("text", myUser));
    LocalMessage[] history = myDispatcher.getHistory(myUser, null);
    assertEquals("Expect localMessages as a result to OwnMessageEvent", 2, history.length);
    assertSame(localMessage, history[0]);
    assertSame(localMessage1, history[1]);
}
Also used : LocalMessage(jetbrains.communicator.core.dispatcher.LocalMessage) MockTransport(jetbrains.communicator.mock.MockTransport) MockMessage(jetbrains.communicator.mock.MockMessage) SendMessageEvent(jetbrains.communicator.ide.SendMessageEvent)

Example 5 with MockMessage

use of jetbrains.communicator.mock.MockMessage in project intellij-plugins by JetBrains.

the class LocalMessageDispatcherTest method testIconBlinkingStatus.

public void testIconBlinkingStatus() throws Exception {
    assertFalse(hasMessagesWhichRequireIconBlinking());
    MockMessage message = new MockMessage();
    myDispatcher.addPendingMessage(myUser, message);
    assertEquals(1, myDispatcher.getPendingMessages(myUser).length);
    assertTrue("Should blink to inform user about urgent event", hasMessagesWhichRequireIconBlinking());
    myDispatcher.sendNow(myUser, message);
    assertFalse("No more blinking expected - message was dispatched", hasMessagesWhichRequireIconBlinking());
}
Also used : MockMessage(jetbrains.communicator.mock.MockMessage)

Aggregations

MockMessage (jetbrains.communicator.mock.MockMessage)22 LocalMessage (jetbrains.communicator.core.dispatcher.LocalMessage)7 Date (java.util.Date)6 MockTransport (jetbrains.communicator.mock.MockTransport)3 File (java.io.File)2 ArrayList (java.util.ArrayList)1 Message (jetbrains.communicator.core.dispatcher.Message)1 TransportEvent (jetbrains.communicator.core.transport.TransportEvent)1 UserEvent (jetbrains.communicator.core.users.UserEvent)1 SendMessageEvent (jetbrains.communicator.ide.SendMessageEvent)1 MockUser (jetbrains.communicator.mock.MockUser)1 WaitFor (jetbrains.communicator.util.WaitFor)1 WatchDog (jetbrains.communicator.util.WatchDog)1 Level (org.apache.log4j.Level)1 Logger (org.apache.log4j.Logger)1