Search in sources :

Example 1 with EventBroadcaster

use of jetbrains.communicator.core.EventBroadcaster in project intellij-plugins by JetBrains.

the class SendCodePointerCommandTest method testExecute_Cancel.

public void testExecute_Cancel() throws Exception {
    final boolean[] sent = new boolean[1];
    MockUser user = new MockUser() {

        @Override
        public void sendCodeIntervalPointer(VFile file, CodePointer pointer, String comment, EventBroadcaster eventBroadcaster) {
            sent[0] = true;
        }
    };
    myCommand.setCodePointer(new CodePointer(0, 0));
    myCommand.setVFile(VFile.create("a path"));
    myCommand.setUser(user);
    myFacadeMock.expects(once()).method("getMessage").will(returnValue(null));
    myCommand.execute();
    assertFalse("Should call sendCodeIntervalPointer", sent[0]);
}
Also used : EventBroadcaster(jetbrains.communicator.core.EventBroadcaster) CodePointer(jetbrains.communicator.core.vfs.CodePointer) MockUser(jetbrains.communicator.mock.MockUser) VFile(jetbrains.communicator.core.vfs.VFile)

Example 2 with EventBroadcaster

use of jetbrains.communicator.core.EventBroadcaster in project intellij-plugins by JetBrains.

the class SendCodePointerCommandTest method testExecute_WithMessage.

public void testExecute_WithMessage() throws Exception {
    final CodePointer codePointerToSend = new CodePointer(0, 0);
    final VFile fileToSend = VFile.create("a path");
    final boolean[] sent = new boolean[1];
    MockUser user = new MockUser() {

        @Override
        public void sendCodeIntervalPointer(VFile file, CodePointer pointer, String comment, EventBroadcaster eventBroadcaster) {
            sent[0] = true;
            assertSame(fileToSend, file);
            assertSame(codePointerToSend, pointer);
            assertEquals("some message", comment);
        }
    };
    myCommand.setCodePointer(codePointerToSend);
    myCommand.setVFile(fileToSend);
    myCommand.setUser(user);
    myFacadeMock.expects(once()).method("getMessage").will(returnValue("some message"));
    myFacadeMock.expects(once()).method("fillFileContents").with(eq(fileToSend));
    myCommand.execute();
    assertTrue("Should call sendCodeIntervalPointer", sent[0]);
}
Also used : EventBroadcaster(jetbrains.communicator.core.EventBroadcaster) CodePointer(jetbrains.communicator.core.vfs.CodePointer) VFile(jetbrains.communicator.core.vfs.VFile) MockUser(jetbrains.communicator.mock.MockUser)

Aggregations

EventBroadcaster (jetbrains.communicator.core.EventBroadcaster)2 CodePointer (jetbrains.communicator.core.vfs.CodePointer)2 VFile (jetbrains.communicator.core.vfs.VFile)2 MockUser (jetbrains.communicator.mock.MockUser)2