Search in sources :

Example 21 with MockUser

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

the class AsyncMessageDispatcherTest method testAddMessagesWhileDispatching.

public void testAddMessagesWhileDispatching() throws Exception {
    NotifyableMessage mockMessage = new NotifyableMessage(true, myLog);
    MockUser user1 = new MockUser("user1", null);
    MockUser user2 = new MockUser("user2", null);
    user1.setOnline(true);
    user2.setOnline(true);
    myDispatcher.sendLater(user1, mockMessage);
    mockMessage.waitUntilDispatchingStarted();
    myDispatcher.sendLater(user2, new MockMessage(true));
    assertEquals("Messages not delivered yet", 2, myDispatcher.getUsersWithMessages().length);
    triggerMessageProcessing(mockMessage);
    new WaitFor(200) {

        @Override
        protected boolean condition() {
            return myDispatcher.getUsersWithMessages().length == 0;
        }
    };
    assertEquals("All messages should be delivered", 0, myDispatcher.getUsersWithMessages().length);
}
Also used : WaitFor(jetbrains.communicator.util.WaitFor) MockMessage(jetbrains.communicator.mock.MockMessage) MockUser(jetbrains.communicator.mock.MockUser)

Example 22 with MockUser

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

the class FoundUsersModelTest method testUserIn2Groups.

public void testUserIn2Groups() throws Exception {
    MockUser bob = new MockUser("BobName", null);
    bob.setProjects(new String[] { "bobProject", "anotherBobProject" });
    FoundUsersModel model = createModel(Arrays.asList(new User[] { bob }));
    assertEquals("2 projects expected", 2, getRoot(model).getChildCount());
    TreeNode projectNode1 = getRoot(model).getChildAt(0);
    assertEquals("Invalid project node", "anotherBobProject", projectNode1.toString());
    TreeNode projectNode2 = getRoot(model).getChildAt(1);
    assertEquals("Invalid project node", "bobProject", projectNode2.toString());
    assertEquals("One user in group expected", 1, projectNode1.getChildCount());
    assertEquals("One user in group expected", 1, projectNode2.getChildCount());
}
Also used : User(jetbrains.communicator.core.users.User) MockUser(jetbrains.communicator.mock.MockUser) TreeNode(javax.swing.tree.TreeNode) MockUser(jetbrains.communicator.mock.MockUser)

Example 23 with MockUser

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

the class FoundUsersModelTest method test2UsersInSameGroup.

public void test2UsersInSameGroup() throws Exception {
    MockUser bob = new MockUser("bob", null);
    MockUser alice = new MockUser("alice", null);
    bob.setProjects(new String[] { "Project" });
    alice.setProjects(new String[] { "Project" });
    FoundUsersModel model = createModel(Arrays.asList(new User[] { bob, alice }));
    assertEquals("One project expected", 1, getRoot(model).getChildCount());
    assertEquals("Two users expected", 2, getRoot(model).getChildAt(0).getChildCount());
    assertEquals("Wrong sorting of users", "alice", getRoot(model).getChildAt(0).getChildAt(0).toString());
    assertEquals("Wrong sorting of users", "bob", getRoot(model).getChildAt(0).getChildAt(1).toString());
}
Also used : User(jetbrains.communicator.core.users.User) MockUser(jetbrains.communicator.mock.MockUser) MockUser(jetbrains.communicator.mock.MockUser)

Example 24 with MockUser

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

the class FoundUsersModelTest method testUserInProject.

public void testUserInProject() throws Exception {
    MockUser bob = new MockUser("BobName", null);
    bob.setProjects(new String[] { "bobProject" });
    FoundUsersModel model = createModel(Arrays.asList(new User[] { bob }));
    assertEquals("One project expected", 1, getRoot(model).getChildCount());
    TreeNode projectNode = getRoot(model).getChildAt(0);
    assertEquals("Invalid project node", "bobProject", 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 25 with MockUser

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

the class PersistentUserModelImplTest method testPersistUser.

public void testPersistUser() throws Exception {
    myUserModel.addUser(new MockUser("user", "group"));
    PersistentUserModelImpl modelInstance = createModelInstance();
    User[] users = modelInstance.getAllUsers();
    assertEquals(1, users.length);
    assertEquals("user", users[0].getName());
    assertEquals("group", users[0].getGroup());
}
Also used : User(jetbrains.communicator.core.users.User) MockUser(jetbrains.communicator.mock.MockUser) 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