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);
}
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());
}
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());
}
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();
}
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);
}
Aggregations