Search in sources :

Example 51 with MockUser

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

the class UsersTreeModelTest method testRebuildTreeOnOnlineStatusChange.

public void testRebuildTreeOnOnlineStatusChange() throws Exception {
    myTree.expandRow(2);
    myTree.expandRow(1);
    assertEquals("All expanded, root node is hidden", 8, myTree.getRowCount());
    // rename user aaa
    MockUser mockUser = ((MockUser) myUserModel.getUsers("group1")[1]);
    mockUser.setOnline(true);
    getBroadcaster().fireEvent(new UserEvent.Online(mockUser));
    assertEquals("Nodes expansion should be preserved", 8, myTree.getRowCount());
    assertEquals("Online user should go to the top", "ccc", getUserForRow(myTree, 2).getDisplayName());
}
Also used : UserEvent(jetbrains.communicator.core.users.UserEvent) MockUser(jetbrains.communicator.mock.MockUser)

Example 52 with MockUser

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

the class P2PTransportTest method testGetPort.

public void testGetPort() throws Exception {
    User mockUser = UserImpl.create("mock", P2PTransport.CODE);
    assertEquals("Sanity check", -1, myTransport.getPort(mockUser));
    new AddOnlineUserP2PCommand(myTransport.getUserMonitorThread()).addOnlineUser("localhost", "mock", 3354, null, null);
    myTransport.flushCurrentUsers();
    assertEquals("Port should be set from available online user", 3354, myTransport.getPort(mockUser));
    myTransport.setOnlineUsers(new HashSet<>());
    assertEquals("Port should be reset", -1, myTransport.getPort(mockUser));
}
Also used : AddOnlineUserP2PCommand(jetbrains.communicator.p2p.commands.AddOnlineUserP2PCommand) MockUser(jetbrains.communicator.mock.MockUser)

Example 53 with MockUser

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

the class P2PTransportTest method testGetUserPresence.

public void testGetUserPresence() throws Exception {
    User mockUser = UserImpl.create("mock", P2PTransport.CODE);
    assertEquals("Sanity check", PresenceMode.UNAVAILABLE, myTransport.getUserPresence(mockUser).getPresenceMode());
    new AddOnlineUserP2PCommand(myTransport.getUserMonitorThread()).addOnlineUser("localhost", "mock", 3354, null, new UserPresence(PresenceMode.DND).toVector());
    myTransport.flushCurrentUsers();
    assertEquals("User status should be set from available online user", PresenceMode.DND, myTransport.getUserPresence(mockUser).getPresenceMode());
    myTransport.setOnlineUsers(new HashSet<>());
    assertEquals("Presence should be reset", PresenceMode.UNAVAILABLE, myTransport.getUserPresence(mockUser).getPresenceMode());
}
Also used : AddOnlineUserP2PCommand(jetbrains.communicator.p2p.commands.AddOnlineUserP2PCommand) MockUser(jetbrains.communicator.mock.MockUser)

Example 54 with MockUser

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

the class P2PTransportTest method testOnUserAdd.

public void testOnUserAdd() throws Exception {
    User mockUser = UserImpl.create("user", myTransport.getName());
    getBroadcaster().fireEvent(new UserEvent.Added(mockUser));
    assertEquals("Should send notification", "sendUserAddedCallback" + mockUser, myLog);
}
Also used : MockUser(jetbrains.communicator.mock.MockUser)

Example 55 with MockUser

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

the class P2PTransportTest method testGetProjects.

public void testGetProjects() throws Exception {
    User mockUser = UserImpl.create("mock", P2PTransport.CODE);
    assertEquals("Sanity check", 0, myTransport.getProjects(mockUser).length);
    Vector<String> projects = new Vector<>(Arrays.asList("project1", "project2"));
    new AddOnlineUserP2PCommand(myTransport.getUserMonitorThread()).addOnlineUser("localhost", "mock", 0, projects, null);
    myTransport.flushCurrentUsers();
    assertEquals("Projects should be set from available online user", projects.toString(), Arrays.asList(myTransport.getProjects(mockUser)).toString());
    myTransport.setOnlineUsers(new HashSet<>());
    assertEquals("Projects should be reset", 0, myTransport.getProjects(mockUser).length);
}
Also used : AddOnlineUserP2PCommand(jetbrains.communicator.p2p.commands.AddOnlineUserP2PCommand) MockUser(jetbrains.communicator.mock.MockUser) Vector(java.util.Vector)

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