Search in sources :

Example 31 with MockUser

use of jetbrains.communicator.mock.MockUser 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)

Example 32 with MockUser

use of jetbrains.communicator.mock.MockUser in project intellij-plugins by JetBrains.

the class SendMessageCommandTest method testInvokeDialogWithExplicitUser.

public void testInvokeDialogWithExplicitUser() throws Exception {
    MockUser user1 = new MockUser();
    myUserModel.addUser(user1);
    myCommand.setUser(user1);
    myFacadeMock.expects(once()).method("invokeSendMessage").with(eq(myUserModel.getAllUsers()), eq(new User[] { user1 }), eq(""), ANYTHING);
    myCommand.execute();
}
Also used : User(jetbrains.communicator.core.users.User) MockUser(jetbrains.communicator.mock.MockUser) MockUser(jetbrains.communicator.mock.MockUser)

Example 33 with MockUser

use of jetbrains.communicator.mock.MockUser in project intellij-plugins by JetBrains.

the class SendMessageCommandTest method testInvokeDialog.

public void testInvokeDialog() throws Exception {
    MockUser user1 = new MockUser("user1", null);
    MockUser user2 = new MockUser("user2", null);
    MockUser user3 = new MockUser("user3", null);
    myUserModel.addUser(user1);
    myUserModel.addUser(user2);
    myUserModel.addUser(user3);
    myMockUserListComponent.setSelectedNodes(new Object[] { "a group", user2, "grp2", user1 });
    myCommand.setMessage("a text");
    myFacadeMock.expects(once()).method("invokeSendMessage").with(eq(myUserModel.getAllUsers()), eq(new User[] { user2, user1 }), eq("a text"), ANYTHING);
    myCommand.execute();
}
Also used : User(jetbrains.communicator.core.users.User) MockUser(jetbrains.communicator.mock.MockUser) MockUser(jetbrains.communicator.mock.MockUser)

Example 34 with MockUser

use of jetbrains.communicator.mock.MockUser in project intellij-plugins by JetBrains.

the class ShowDiffCommandTest method testExecute_NoContent.

public void testExecute_NoContent() throws Exception {
    final VFile vFile = VFile.create("a file");
    MockUser user = new MockUser() {

        @Override
        public String getVFile(VFile file, IDEFacade ideFacade) {
            assertSame(vFile, file);
            return null;
        }
    };
    myCommand.setUser(user);
    myCommand.setVFile(vFile);
    myCommand.execute();
}
Also used : IDEFacade(jetbrains.communicator.ide.IDEFacade) VFile(jetbrains.communicator.core.vfs.VFile) MockUser(jetbrains.communicator.mock.MockUser)

Example 35 with MockUser

use of jetbrains.communicator.mock.MockUser in project intellij-plugins by JetBrains.

the class DeleteCommandTest method testDeleteGroup_WithUsers_DeleteAll.

public void testDeleteGroup_WithUsers_DeleteAll() throws Exception {
    myUserModel.addGroup(GROUP_NAME);
    MockUser user = new MockUser("user", GROUP_NAME);
    myUserModel.addUser(user);
    myUserListComponentMock.stubs().method("getSelectedNodes").will(returnValue(new Object[] { GROUP_NAME, user }));
    assertTrue("Want to delete group with users in it", myCommand.isEnabled());
    myIDEFacade.expects(once()).method("askQuestion").will(returnValue(true));
    myCommand.execute();
    assertEquals(0, myUserModel.getAllUsers().length);
    assertEquals(0, myUserModel.getGroups().length);
}
Also used : MockUser(jetbrains.communicator.mock.MockUser)

Aggregations

MockUser (jetbrains.communicator.mock.MockUser)55 User (jetbrains.communicator.core.users.User)13 VFile (jetbrains.communicator.core.vfs.VFile)5 IDEFacade (jetbrains.communicator.ide.IDEFacade)5 MockIDEFacade (jetbrains.communicator.mock.MockIDEFacade)4 AddOnlineUserP2PCommand (jetbrains.communicator.p2p.commands.AddOnlineUserP2PCommand)4 TreeNode (javax.swing.tree.TreeNode)3 CodePointer (jetbrains.communicator.core.vfs.CodePointer)3 ProjectsData (jetbrains.communicator.core.vfs.ProjectsData)3 EventBroadcaster (jetbrains.communicator.core.EventBroadcaster)2 BaseUserImpl (jetbrains.communicator.core.impl.users.BaseUserImpl)2 UserModelImpl (jetbrains.communicator.core.impl.users.UserModelImpl)2 UserEvent (jetbrains.communicator.core.users.UserEvent)2 WaitFor (jetbrains.communicator.util.WaitFor)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Vector (java.util.Vector)1 TreePath (javax.swing.tree.TreePath)1 LocalMessageDispatcherImpl (jetbrains.communicator.core.impl.dispatcher.LocalMessageDispatcherImpl)1 MockMessage (jetbrains.communicator.mock.MockMessage)1