Search in sources :

Example 41 with MockUser

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

the class ViewFilesCommandTest method testExecute_WithInformation.

public void testExecute_WithInformation() throws Exception {
    final ProjectsData projectsData = new ProjectsData();
    projectsData.addNonProjectFile(VFile.create("a path"));
    MockUser mockUser = new MockUser("user", null) {

        @Override
        public ProjectsData getProjectsData(IDEFacade ideFacade) {
            return projectsData;
        }
    };
    mockUser.setOnline(true);
    myMockUserListComponent.setSelectedNodes(new User[] { mockUser });
    myFacadeMock.expects(once()).method("showUserFiles").with(eq(mockUser), eq(projectsData));
    myCommand.execute();
}
Also used : ProjectsData(jetbrains.communicator.core.vfs.ProjectsData) IDEFacade(jetbrains.communicator.ide.IDEFacade) MockUser(jetbrains.communicator.mock.MockUser)

Example 42 with MockUser

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

the class ViewFilesCommandTest method testIsEnabled.

public void testIsEnabled() throws Exception {
    assertFalse(myCommand.isEnabled());
    myMockUserListComponent.setSelectedNodes(new Object[] { "group" });
    assertFalse(myCommand.isEnabled());
    MockUser mockUser = new MockUser("user", null);
    myMockUserListComponent.setSelectedNodes(new User[] { mockUser });
    assertFalse("User is offline", myCommand.isEnabled());
    mockUser.setOnline(true);
    mockUser.setIDEtalkUser(false);
    assertFalse("Single user selected and online but not IDEtalk user- command should be disabled", myCommand.isEnabled());
    mockUser.setIDEtalkUser(true);
    assertTrue("Single user selected and online and IDEtalk user- command should be disabled", myCommand.isEnabled());
    myMockUserListComponent.setSelectedNodes(new User[] { mockUser, mockUser });
    assertFalse("Two users are selected", myCommand.isEnabled());
}
Also used : MockUser(jetbrains.communicator.mock.MockUser)

Example 43 with MockUser

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

the class FoundUsersModelTest method testUserWithoutProject.

public void testUserWithoutProject() throws Exception {
    MockUser bob = new MockUser("BobName", null);
    FoundUsersModel model = createModel(Arrays.asList(new User[] { bob }));
    assertEquals("One (unnamed) project expected", 1, getRoot(model).getChildCount());
    TreeNode projectNode = getRoot(model).getChildAt(0);
    assertEquals("Invalid project node", "<no project>", projectNode.toString());
    assertEquals("One user in group expected", 1, projectNode.getChildCount());
    assertEquals("Invalid user node", bob.getName(), projectNode.getChildAt(0).toString());
}
Also used : User(jetbrains.communicator.core.users.User) MockUser(jetbrains.communicator.mock.MockUser) TreeNode(javax.swing.tree.TreeNode) MockUser(jetbrains.communicator.mock.MockUser)

Example 44 with MockUser

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

the class FoundUsersModelTest method test2Users2Projects.

public void test2Users2Projects() throws Exception {
    MockUser bob = new MockUser("bob", null);
    MockUser alice = new MockUser("alice", null);
    bob.setProjects(new String[] { "bobProject" });
    alice.setProjects(new String[] { "aliceProject" });
    FoundUsersModel model = createModel(Arrays.asList(new User[] { bob, alice }));
    assertEquals("Two projects expected", 2, getRoot(model).getChildCount());
    assertEquals("One user per project expected", 1, getRoot(model).getChildAt(0).getChildCount());
    assertEquals("One user per project expected", 1, getRoot(model).getChildAt(1).getChildCount());
}
Also used : User(jetbrains.communicator.core.users.User) MockUser(jetbrains.communicator.mock.MockUser) MockUser(jetbrains.communicator.mock.MockUser)

Example 45 with MockUser

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

the class UserModelImplTest method testAddUser.

public void testAddUser() throws Exception {
    MockUser user = new MockUser("user", null);
    myUserModel.addUser(user);
    assertTrue(myUserModel.hasUser(user));
    myListener.assertLog("Expect messages", "BeforeAfter");
    myUserModel.addUser(user);
    myListener.assertLog("Expect no messages when already in model", "");
}
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