Search in sources :

Example 26 with MockUser

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

the class PersistentUserModelImplTest method testAddAndChangeUser.

public void testAddAndChangeUser() throws Exception {
    myUserModel.addUser(new MockUser("user", "group"));
    checkSaved(true);
    User user = myUserModel.getAllUsers()[0];
    user.setDisplayName("dds dds", myUserModel);
    checkSaved(true);
    user.setGroup("newGroup", myUserModel);
    checkSaved(true);
    user.setCanAccessMyFiles(true, myUserModel);
    checkSaved(true);
    getBroadcaster().fireEvent(new UserEvent.Updated(user, "presence", null, null));
    checkSaved(false);
    PersistentUserModelImpl modelInstance = createModelInstance();
    User[] users = modelInstance.getAllUsers();
    assertEquals(1, users.length);
    assertEquals("dds dds", users[0].getDisplayName());
    assertEquals("newGroup", users[0].getGroup());
}
Also used : User(jetbrains.communicator.core.users.User) MockUser(jetbrains.communicator.mock.MockUser) UserEvent(jetbrains.communicator.core.users.UserEvent) MockUser(jetbrains.communicator.mock.MockUser)

Example 27 with MockUser

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

the class UserModelImplTest method testRemoveUser.

public void testRemoveUser() throws Exception {
    MockUser user = new MockUser("user", null);
    myUserModel.addUser(user);
    myListener.clear();
    myUserModel.removeUser(user);
    myListener.assertLog("Expect messages", "BeforeAfter");
    myUserModel.removeUser(user);
    myListener.assertLog("Expect no messages when not in model", "");
}
Also used : MockUser(jetbrains.communicator.mock.MockUser)

Example 28 with MockUser

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

the class UserModelImplTest method testRemoveGroups.

public void testRemoveGroups() throws Exception {
    assertFalse(myUserModel.removeGroup("group"));
    myUserModel.addGroup("added1");
    myUserModel.addGroup("added2");
    final MockUser addedUser = new MockUser("some addedUser", "added2");
    myUserModel.addUser(addedUser);
    assertTrue("Do not contain users, can be removed", myUserModel.removeGroup("added1"));
    assertTrue("Contains users, removed including users", myUserModel.removeGroup("group1"));
    assertEquals("Wrong groups after deletion", Arrays.asList(new Object[] { "added2", "group2" }), Arrays.asList(myUserModel.getGroups()));
}
Also used : MockUser(jetbrains.communicator.mock.MockUser)

Example 29 with MockUser

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

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

the class SendCodePointerCommandTest method testEnabled.

public void testEnabled() throws Exception {
    assertFalse(myCommand.isEnabled());
    myCommand.setCodePointer(new CodePointer(0, 0));
    assertFalse(myCommand.isEnabled());
    myCommand.setVFile(VFile.create("a path"));
    assertFalse(myCommand.isEnabled());
    myCommand.setUser(new MockUser());
    assertTrue("Now codePointer, file, user are selected - ready to send", myCommand.isEnabled());
}
Also used : CodePointer(jetbrains.communicator.core.vfs.CodePointer) 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