use of jetbrains.communicator.mock.MockMessage in project intellij-plugins by JetBrains.
the class LocalMessageDispatcherTest method testHistory.
public void testHistory() throws Exception {
assertEquals(0, myDispatcher.getHistory(myUser, null).length);
MockMessage message = new MockMessage();
myDispatcher.addPendingMessage(myUser, message);
assertEquals(1, myDispatcher.getPendingMessages(myUser).length);
assertEquals(0, myDispatcher.getHistory(myUser, null).length);
myDispatcher.sendNow(myUser, message);
assertEquals(0, myDispatcher.getPendingMessages(myUser).length);
assertEquals(1, myDispatcher.getHistory(myUser, null).length);
MockMessage message2 = new MockMessage();
myDispatcher.sendNow(myUser, message2);
LocalMessage[] history = myDispatcher.getHistory(myUser, null);
assertEquals(2, history.length);
assertSame(message, history[0]);
assertSame(message2, history[1]);
}
use of jetbrains.communicator.mock.MockMessage in project intellij-plugins by JetBrains.
the class LocalMessageDispatcherTest method testHistoryInSeveralFiles.
public void testHistoryInSeveralFiles() throws Exception {
myDispatcher.sendNow(myUser, new MockMessage(new Date()));
myDispatcher.sendNow(myUser, new MockMessage(yesterday()));
Thread.sleep(SAVE_WAIT_TIMEOUT);
assertEquals(2, new File(myIdeFacade.getCacheDir(), "history").listFiles().length);
LocalMessageDispatcherImpl localMessageDispatcher = createLocalMessageDispatcher();
LocalMessage[] messages = localMessageDispatcher.getHistory(myUser, a_moment_ago());
assertEquals(1, messages.length);
messages = localMessageDispatcher.getHistory(myUser, new Date(System.currentTimeMillis() - 1000 * 3601 * 24));
assertEquals(2, messages.length);
}
Aggregations