Search in sources :

Example 11 with MockMessage

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

the class LocalMessageDispatcherTest method testHistoryWithDate.

public void testHistoryWithDate() throws Exception {
    MockMessage message = new MockMessage();
    myDispatcher.sendNow(myUser, message);
    Thread.sleep(10);
    assertEquals(1, myDispatcher.getHistory(myUser, a_moment_ago()).length);
    assertEquals("Do not expect old history", 0, myDispatcher.getHistory(myUser, new Date()).length);
}
Also used : MockMessage(jetbrains.communicator.mock.MockMessage) Date(java.util.Date)

Example 12 with MockMessage

use of jetbrains.communicator.mock.MockMessage 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 13 with MockMessage

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

the class LocalMessageDispatcherTest method testHistoryPersistence.

public void testHistoryPersistence() throws Exception {
    // Test Saving history message:
    MockMessage message = new MockMessage(new Date(), "some text РП ТХУУЛЙ");
    myDispatcher.sendNow(myUser, message);
    Thread.sleep(SAVE_WAIT_TIMEOUT);
    LocalMessageDispatcherImpl localMessageDispatcher = createLocalMessageDispatcher();
    assertEquals(1, localMessageDispatcher.getHistory(myUser, null).length);
    assertEquals("some text РП ТХУУЛЙ", ((MockMessage) localMessageDispatcher.getHistory(myUser, null)[0]).getMessage());
}
Also used : MockMessage(jetbrains.communicator.mock.MockMessage) Date(java.util.Date)

Example 14 with MockMessage

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

the class SearchHistoryCommandTest method testSearchHistory_WithResult.

public void testSearchHistory_WithResult() throws Exception {
    MockMessage m1 = new MockMessage(new Date(), "some text1");
    MockMessage m2 = new MockMessage(new Date(), "some text2");
    MockMessage m3 = new MockMessage(new Date(), "some text2 ataing");
    query("text2");
    myDispatcherMock.expects(once()).method("getHistory").with(eq(myUser), eq(null)).will(returnValue(new LocalMessage[] { m1, m2, m3 }));
    myIdeMock.expects(once()).method("showSearchHistoryResults").with(eq(new ArrayList<LocalMessage>(Arrays.asList(m2, m3))), eq(myUser));
    myCommand.execute();
}
Also used : LocalMessage(jetbrains.communicator.core.dispatcher.LocalMessage) MockMessage(jetbrains.communicator.mock.MockMessage) ArrayList(java.util.ArrayList) Date(java.util.Date)

Example 15 with MockMessage

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

the class AbstractMessageDispatcherTest method testRemoveMessageFromQueue.

public void testRemoveMessageFromQueue() throws Exception {
    MockMessage message1 = new MockMessage();
    MockMessage message2 = new MockMessage();
    MockMessage message3 = new MockMessage();
    myDispatcher.addPendingMessage(myUser, message1);
    myDispatcher.addPendingMessage(myUser, message2);
    myDispatcher.addPendingMessage(myUser, message3);
    myDispatcher.removePendingMessage(myUser, 0);
    assertSame(message2, myDispatcher.getPendingMessages(myUser)[0]);
    myDispatcher.removePendingMessage(myUser, 1);
    assertSame(message2, myDispatcher.getPendingMessages(myUser)[0]);
    assertEquals(1, myDispatcher.getPendingMessages(myUser).length);
}
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