use of jetbrains.communicator.core.dispatcher.LocalMessage 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.core.dispatcher.LocalMessage 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);
}
use of jetbrains.communicator.core.dispatcher.LocalMessage in project intellij-plugins by JetBrains.
the class IDEAFacade method createLocalMessageForOutgoingEvent.
@Override
@Nullable
public LocalMessage createLocalMessageForOutgoingEvent(OwnMessageEvent event) {
final LocalMessage[] result = new LocalMessage[1];
event.accept(new EventVisitor() {
@Override
public void visitSendMessageEvent(SendMessageEvent event) {
result[0] = new OutgoingLocalMessage(event.getMessage());
}
@Override
public void visitSendCodePointerEvent(SendCodePointerEvent event) {
result[0] = new OutgoingCodePointerLocalMessage(event);
}
});
return result[0];
}
use of jetbrains.communicator.core.dispatcher.LocalMessage in project intellij-plugins by JetBrains.
the class IDEAFacade method createLocalMessageForIncomingEvent.
@Override
public LocalMessage createLocalMessageForIncomingEvent(TransportEvent event) {
final LocalMessage[] result = new LocalMessage[1];
event.accept(new EventVisitor() {
@SuppressWarnings({ "RefusedBequest" })
@Override
public void visitStacktraceEvent(StacktraceEvent event) {
result[0] = new IncomingStacktraceMessage(event);
}
@SuppressWarnings({ "RefusedBequest" })
@Override
public void visitCodePointerEvent(CodePointerEvent event) {
result[0] = new IncomingCodePointerMessage(event, IDEAFacade.this);
}
@SuppressWarnings({ "RefusedBequest" })
@Override
public void visitMessageEvent(MessageEvent event) {
result[0] = new IncomingLocalMessage(event);
}
});
return result[0];
}
use of jetbrains.communicator.core.dispatcher.LocalMessage in project intellij-plugins by JetBrains.
the class MessageHistory method getHistory.
private synchronized Map<Date, DayHistory> getHistory() {
Map<Date, DayHistory> result = new HashMap<>();
for (User user : myHistory.keySet()) {
List<LocalMessage> messages = myHistory.get(user);
for (LocalMessage message : messages) {
DayHistory dayHistory = getDayHistoryFor(message, result);
dayHistory.addMessage(user, message);
}
}
return result;
}
Aggregations