Search in sources :

Example 1 with AddOnlineUserP2PCommand

use of jetbrains.communicator.p2p.commands.AddOnlineUserP2PCommand in project intellij-plugins by JetBrains.

the class P2PTransportTest method testGetAddress.

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

Example 2 with AddOnlineUserP2PCommand

use of jetbrains.communicator.p2p.commands.AddOnlineUserP2PCommand 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 3 with AddOnlineUserP2PCommand

use of jetbrains.communicator.p2p.commands.AddOnlineUserP2PCommand 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 4 with AddOnlineUserP2PCommand

use of jetbrains.communicator.p2p.commands.AddOnlineUserP2PCommand 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)4 AddOnlineUserP2PCommand (jetbrains.communicator.p2p.commands.AddOnlineUserP2PCommand)4 Vector (java.util.Vector)1