Search in sources :

Example 16 with LocalMessage

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]);
}
Also used : LocalMessage(jetbrains.communicator.core.dispatcher.LocalMessage) MockMessage(jetbrains.communicator.mock.MockMessage)

Example 17 with LocalMessage

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);
}
Also used : LocalMessage(jetbrains.communicator.core.dispatcher.LocalMessage) MockMessage(jetbrains.communicator.mock.MockMessage) File(java.io.File) Date(java.util.Date)

Example 18 with LocalMessage

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];
}
Also used : LocalMessage(jetbrains.communicator.core.dispatcher.LocalMessage) IncomingLocalMessage(jetbrains.communicator.idea.sendMessage.IncomingLocalMessage) EventVisitor(jetbrains.communicator.core.EventVisitor) Nullable(org.jetbrains.annotations.Nullable)

Example 19 with LocalMessage

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];
}
Also used : LocalMessage(jetbrains.communicator.core.dispatcher.LocalMessage) IncomingLocalMessage(jetbrains.communicator.idea.sendMessage.IncomingLocalMessage) IncomingCodePointerMessage(jetbrains.communicator.idea.codePointer.IncomingCodePointerMessage) EventVisitor(jetbrains.communicator.core.EventVisitor) MessageEvent(jetbrains.communicator.core.transport.MessageEvent) StacktraceEvent(jetbrains.communicator.core.transport.StacktraceEvent) CodePointerEvent(jetbrains.communicator.core.transport.CodePointerEvent) IncomingLocalMessage(jetbrains.communicator.idea.sendMessage.IncomingLocalMessage) IncomingStacktraceMessage(jetbrains.communicator.idea.sendMessage.IncomingStacktraceMessage)

Example 20 with LocalMessage

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;
}
Also used : LocalMessage(jetbrains.communicator.core.dispatcher.LocalMessage) User(jetbrains.communicator.core.users.User)

Aggregations

LocalMessage (jetbrains.communicator.core.dispatcher.LocalMessage)20 IncomingLocalMessage (jetbrains.communicator.idea.sendMessage.IncomingLocalMessage)7 MockMessage (jetbrains.communicator.mock.MockMessage)7 Date (java.util.Date)6 TransportEvent (jetbrains.communicator.core.transport.TransportEvent)4 ArrayList (java.util.ArrayList)2 EventVisitor (jetbrains.communicator.core.EventVisitor)2 User (jetbrains.communicator.core.users.User)2 SendMessageEvent (jetbrains.communicator.ide.SendMessageEvent)2 BaseLocalMessage (jetbrains.communicator.idea.BaseLocalMessage)2 IncomingCodePointerMessage (jetbrains.communicator.idea.codePointer.IncomingCodePointerMessage)2 IncomingStacktraceMessage (jetbrains.communicator.idea.sendMessage.IncomingStacktraceMessage)2 MockTransport (jetbrains.communicator.mock.MockTransport)2 File (java.io.File)1 Message (jetbrains.communicator.core.dispatcher.Message)1 CodePointerEvent (jetbrains.communicator.core.transport.CodePointerEvent)1 MessageEvent (jetbrains.communicator.core.transport.MessageEvent)1 StacktraceEvent (jetbrains.communicator.core.transport.StacktraceEvent)1 CodePointer (jetbrains.communicator.core.vfs.CodePointer)1 SendCodePointerEvent (jetbrains.communicator.ide.SendCodePointerEvent)1