Search in sources :

Example 1 with MockTransport

use of jetbrains.communicator.mock.MockTransport 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 MockTransport

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

the class UserListComponentTest method testExpandGroupMessageReceived.

public void testExpandGroupMessageReceived() throws Exception {
    MockTransport transport = new MockTransport();
    User user = UserImpl.create("nick", transport.getName());
    user.setGroup("some non-default group", myUserModel);
    myUserModel.addUser(user);
    TreeUtils.collapseAll(getTree());
    assertEquals("Sanity check", 1, getTree().getRowCount());
    myBroadcaster.fireEvent(new TransportEvent(transport, "nick") {
    });
    assertEquals("User group should be expanded to show incoming message icon", 2, getTree().getRowCount());
}
Also used : TransportEvent(jetbrains.communicator.core.transport.TransportEvent) User(jetbrains.communicator.core.users.User) MockUser(jetbrains.communicator.mock.MockUser) MockTransport(jetbrains.communicator.mock.MockTransport)

Example 3 with MockTransport

use of jetbrains.communicator.mock.MockTransport 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 4 with MockTransport

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

the class LocalMessageDispatcherTest method testTransportEvent.

public void testTransportEvent() throws Exception {
    MockTransport mockTransport = new MockTransport();
    MockMessage localMessage = new MockMessage();
    MockMessage localMessage1 = new MockMessage();
    myIdeFacade.setReturnedMessage(localMessage);
    getBroadcaster().fireEvent(new TransportEvent(mockTransport, "user") {
    });
    myIdeFacade.setReturnedMessage(localMessage1);
    getBroadcaster().fireEvent(new TransportEvent(mockTransport, "user") {
    });
    Message[] pendingMessages = myDispatcher.getPendingMessages(myUser);
    assertEquals("Expect a local localMessages as a result to TransportEvent", 2, pendingMessages.length);
    assertSame(localMessage, pendingMessages[0]);
    assertSame(localMessage1, pendingMessages[1]);
    assertEquals("", localMessage.getLog());
}
Also used : TransportEvent(jetbrains.communicator.core.transport.TransportEvent) MockMessage(jetbrains.communicator.mock.MockMessage) Message(jetbrains.communicator.core.dispatcher.Message) LocalMessage(jetbrains.communicator.core.dispatcher.LocalMessage) MockTransport(jetbrains.communicator.mock.MockTransport) MockMessage(jetbrains.communicator.mock.MockMessage)

Example 5 with MockTransport

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

the class UserModelImplTest method testStacktrace.

public void testStacktrace() throws Exception {
    int hadUsers = myUserModel.getAllUsers().length;
    getBroadcaster().fireEvent(EventFactory.createStacktraceEvent(new MockTransport(), "aaaaaa", "statcktrace", "comment"));
    assertEquals("Another user should be added", hadUsers + 1, myUserModel.getAllUsers().length);
    User addedUser = myUserModel.getAllUsers()[0];
    assertEquals("aaaaaa", addedUser.getName());
}
Also used : MockUser(jetbrains.communicator.mock.MockUser) User(jetbrains.communicator.core.users.User) MockTransport(jetbrains.communicator.mock.MockTransport)

Aggregations

MockTransport (jetbrains.communicator.mock.MockTransport)13 User (jetbrains.communicator.core.users.User)4 MockMessage (jetbrains.communicator.mock.MockMessage)3 MockUser (jetbrains.communicator.mock.MockUser)3 LocalMessage (jetbrains.communicator.core.dispatcher.LocalMessage)2 MessageEvent (jetbrains.communicator.core.transport.MessageEvent)2 TransportEvent (jetbrains.communicator.core.transport.TransportEvent)2 UserPresence (jetbrains.communicator.core.users.UserPresence)2 Message (jetbrains.communicator.core.dispatcher.Message)1 CodePointerEvent (jetbrains.communicator.core.transport.CodePointerEvent)1 Transport (jetbrains.communicator.core.transport.Transport)1 SendMessageEvent (jetbrains.communicator.ide.SendMessageEvent)1 Element (org.jdom.Element)1