Search in sources :

Example 1 with UserPresence

use of jetbrains.communicator.core.users.UserPresence in project intellij-plugins by JetBrains.

the class UserMonitorThreadTest method testAddRemoteUser_LoopbackAddress.

public void testAddRemoteUser_LoopbackAddress() throws Exception {
    Pico.setUnitTest(false);
    try {
        myUserMonitorClientMock.expects(once()).method("setOnlineUsers").with(eq(new HashSet()));
        myUserMonitorThread.addOnlineUser("localhost", "nick", new Integer(PORT), new HashSet<>(), new UserPresence(PresenceMode.AWAY));
        myUserMonitorThread.flushOnlineUsers();
    } finally {
        Pico.setUnitTest(true);
    }
}
Also used : UserPresence(jetbrains.communicator.core.users.UserPresence)

Example 2 with UserPresence

use of jetbrains.communicator.core.users.UserPresence in project intellij-plugins by JetBrains.

the class UserMonitorThread_WaitingForNextSearch_Test method expectSetOneOnlineUser.

private void expectSetOneOnlineUser() throws UnknownHostException {
    User p2PUser = UserImpl.create("nick", P2PTransport.CODE);
    List<String> projects = new ArrayList<>();
    projects.add("project1");
    OnlineUserInfo onlineUserInfo = new OnlineUserInfo(InetAddress.getByName("localhost"), PORT, projects, new UserPresence(PresenceMode.AWAY));
    myUserMonitorClientMock.expects(once()).method("createUser").with(eq("nick"), eq(onlineUserInfo)).will(returnValue(p2PUser));
    myUserMonitorThread.addOnlineUser("localhost", "nick", new Integer(PORT), projects, new UserPresence(PresenceMode.AWAY));
    myUserMonitorClientMock.expects(once()).method("setOnlineUsers").with(eq(new HashSet(Arrays.asList(p2PUser))));
}
Also used : User(jetbrains.communicator.core.users.User) UserPresence(jetbrains.communicator.core.users.UserPresence)

Example 3 with UserPresence

use of jetbrains.communicator.core.users.UserPresence in project intellij-plugins by JetBrains.

the class UserTest method testIsOnline.

public void testIsOnline() throws Exception {
    assertFalse(myUser.isOnline());
    final MockTransport mockTransport = new MockTransport() {

        @Override
        public UserPresence getUserPresence(User user) {
            return new UserPresence(true);
        }
    };
    Pico.getInstance().registerComponentInstance(mockTransport);
    myUser = UserImpl.create("someUser", MockTransport.NAME);
    assertTrue("Corresponding transport is created - should be online now", myUser.isOnline());
}
Also used : User(jetbrains.communicator.core.users.User) MockTransport(jetbrains.communicator.mock.MockTransport) UserPresence(jetbrains.communicator.core.users.UserPresence)

Example 4 with UserPresence

use of jetbrains.communicator.core.users.UserPresence in project intellij-plugins by JetBrains.

the class JabberFacadeImpl method setOnlinePresence.

public void setOnlinePresence(UserPresence userPresence) {
    final Presence.Mode mode;
    String status = "";
    PresenceMode presenceMode = userPresence.getPresenceMode();
    switch(presenceMode) {
        case AWAY:
            mode = Presence.Mode.away;
            break;
        case EXTENDED_AWAY:
            mode = Presence.Mode.xa;
            break;
        case DND:
            mode = Presence.Mode.dnd;
            break;
        default:
            mode = Presence.Mode.available;
    }
    Presence presence = new Presence(Presence.Type.available, status, 0, mode);
    myConnection.sendPacket(presence);
}
Also used : PresenceMode(jetbrains.communicator.core.users.PresenceMode) Presence(org.jivesoftware.smack.packet.Presence) UserPresence(jetbrains.communicator.core.users.UserPresence)

Example 5 with UserPresence

use of jetbrains.communicator.core.users.UserPresence in project intellij-plugins by JetBrains.

the class UserMonitorThreadTest method expectSetOneOnlineUser.

private void expectSetOneOnlineUser() throws UnknownHostException {
    User p2PUser = UserImpl.create("nick", P2PTransport.CODE);
    List<String> projects = new ArrayList<>();
    projects.add("project1");
    OnlineUserInfo onlineUserInfo = new OnlineUserInfo(InetAddress.getByName("localhost"), PORT, projects, new UserPresence(PresenceMode.AWAY));
    myUserMonitorClientMock.expects(once()).method("createUser").with(eq("nick"), eq(onlineUserInfo)).will(returnValue(p2PUser));
    myUserMonitorThread.addOnlineUser("localhost", "nick", new Integer(PORT), projects, new UserPresence(PresenceMode.AWAY));
    myUserMonitorClientMock.expects(once()).method("setOnlineUsers").with(eq(new HashSet(Arrays.asList(p2PUser))));
}
Also used : User(jetbrains.communicator.core.users.User) UserPresence(jetbrains.communicator.core.users.UserPresence)

Aggregations

UserPresence (jetbrains.communicator.core.users.UserPresence)9 User (jetbrains.communicator.core.users.User)5 Transport (jetbrains.communicator.core.transport.Transport)2 MockTransport (jetbrains.communicator.mock.MockTransport)2 WaitFor (jetbrains.communicator.util.WaitFor)2 Presence (org.jivesoftware.smack.packet.Presence)2 PresenceMode (jetbrains.communicator.core.users.PresenceMode)1 UserEvent (jetbrains.communicator.core.users.UserEvent)1 MockUser (jetbrains.communicator.mock.MockUser)1