Package jetbrains.communicator.core.users

Examples of jetbrains.communicator.core.users.User


    assertFalse(user1.canAccessMyFiles());
    assertFalse(user2.canAccessMyFiles());
  }

  public void testMultipleSelection_OfflineUsersHidden() throws Exception {
    final User user1 = myUserModel.createUser("user1", MockTransport.NAME);
    final User user2 = myUserModel.createUser("user2", MockTransport.NAME);

    Pico.getInstance().unregisterComponent(Pico.getInstance().getComponentInstanceOfType(Transport.class));
    MockTransport mockTransport = new MockTransport() {
      @Override
      public UserPresence getUserPresence(User user) {
        return user == user1 ? new UserPresence(true) : new UserPresence(false);
      }
    };
    Pico.getInstance().registerComponentInstance(mockTransport);

    myUserListComponent.stubs().method("getSelectedNodes")
        .will(returnValue(new Object[]{"grp", user2}));

    myUserModel.addUser(user1);
    myUserModel.addUser(user2);
    user1.setGroup("grp", myUserModel);

    user2.setCanAccessMyFiles(true, myUserModel);
    assertFalse("Different state of canAccess flag", myCommand.isEnabled());

    OptionFlag.OPTION_HIDE_OFFLINE_USERS.change(true);
    assertTrue("Only online user should be considered", myCommand.isEnabled());

    myCommand.execute();
    assertTrue("Should change online user", user1.canAccessMyFiles());
    assertTrue("Should keep offline user", user2.canAccessMyFiles());
  }
View Full Code Here


  public void testExecute_LocalMessage() throws Exception {
    addEventListener();

    final CodePointer codePointerToSend = new CodePointer(0, 0);
    final VFile fileToSend = VFile.create("a path");
    User user = UserImpl.create("user", MockTransport.NAME);

    myCommand.setCodePointer(codePointerToSend);
    myCommand.setVFile(fileToSend);
    myCommand.setUser(user);
View Full Code Here

        event.accept(new EventVisitor(){

          @SuppressWarnings({"RefusedBequest"})
          @Override
          public void visitTransportEvent(TransportEvent event) {
            User user = event.createUser(myUserModel);
            expandAndRepaintUserNode(user);
          }

          @SuppressWarnings({"RefusedBequest"})
          @Override
View Full Code Here

  public void visitTransportEvent(TransportEvent event) {
    if (IdeaFlags.SOUND_ON_MESSAGE.isSet()) {
      Applet.newAudioClip(getClass().getResource(INCOMING_MESSAGE_WAV)).play();
    }

    User user = myUserModel.findUser(event.getRemoteUser(), event.getTransport().getName());
    if (user != null) {
      myMessagesWindow.newMessageAvailable(user, event);
    }

    if (IdeaFlags.EXPAND_ON_MESSAGE.isSet()) {
View Full Code Here

    XMPPConnection contact = createLocalConnectionWithJabberUser(userName, null);

    Roster roster = myTransport.getFacade().getConnection().getRoster();
    String jabberUser = getUser(contact);

    final User bob = UserImpl.create(jabberUser, myTransport.getName());

    myEvents.clear();
    roster.createEntry(jabberUser, "Bob", new String[0]);
    new WaitFor(TIMEOUT) {
      @Override
      protected boolean condition() {
        return myEvents.size() == 2;
      }
    };
    assertTrue("Bob should be online", bob.isOnline());
    assertEquals("/ideTalk/jabber.png", myTransport.getIcon(bob.getPresence()));

    assertEquals("One user in UserModel expected:" + Arrays.asList(myUserModel.getAllUsers()),
        1, myUserModel.getAllUsers().length);
    UserEvent.Online online = ((UserEvent.Online) myEvents.get(1));
    assertEquals("Online event expected", bob, online.getUser());

    myEvents.clear();

    Presence presence = new Presence(Presence.Type.unavailable);
    contact.sendPacket(presence);

    new WaitFor(TIMEOUT){
      @Override
      protected boolean condition() {
        return  myEvents.size() == 1;
      }
    };
    assertFalse("Should become offline", bob.isOnline());
    assertEquals("/ideTalk/offline.png", myTransport.getIcon(myTransport.getUserPresence(bob)));
    assertEquals("Bob should go offline", bob, ((UserEvent.Offline) checkEvent(true)).getUser());
  }
View Full Code Here

    assertEquals("Should add bob as a contact too", RosterPacket.ItemType.BOTH, getBobEntry(bobUserName).getType());
  }

  public void testSyncronizeWithRosterWhileWaitingForSubscription() throws Throwable {
    User bob = myUserModel.createUser("bob@localhost", JabberTransport.CODE);
    myUserModel.addUser(bob);

    myTransport.synchronizeRoster(false);

    assertNotNull("Bob should not be deleted",
        myUserModel.findUser(bob.getName(), bob.getTransportCode()));
  }
View Full Code Here

        return myEvents.size() > 2;
      }
    };
    myEvents.clear();
    bob.sendPacket(new Presence(Presence.Type.available, "", 0, Presence.Mode.dnd));
    final User bobUser = myUserModel.findUser(getUser(bob), myTransport.getName());

    new WaitFor(TIMEOUT) {
      @Override
      protected boolean condition() {
        return PresenceMode.DND == bobUser.getPresence().getPresenceMode();
      }
    };

    assertSame("Should take bob's presence", PresenceMode.DND, bobUser.getPresence().getPresenceMode());
    UserEvent.Updated event = (UserEvent.Updated) checkEvent(true);
    assertEquals(bobUser, event.getUser());
    assertEquals("presence", event.getPropertyName());
    assertEquals(PresenceMode.DND, event.getNewValue());
    assertEquals(PresenceMode.AVAILABLE, event.getOldValue());

    // Now, change bob's presence + set time
    bob.sendPacket(new Presence(Presence.Type.available, "some status", 0, Presence.Mode.xa));

    new WaitFor(TIMEOUT) {
      @Override
      protected boolean condition() {
        return PresenceMode.EXTENDED_AWAY == bobUser.getPresence().getPresenceMode();
      }
    };

    assertSame("Should take bob's presence", PresenceMode.EXTENDED_AWAY, bobUser.getPresence().getPresenceMode());
  }
View Full Code Here

    myFacade.setConnected(false);
    myTransport.initializeProject(null, myProjectContainer);
  }

  public void testThreadIdPreserving() throws Exception {
    final User kir = createUser("kir");
    final String threadId = myTransport.getThreadId(kir);
    assertEquals(threadId, myTransport.getThreadId(kir));

    final String t2 = myTransport.getThreadId(createUser("some@other.user"));
    assertTrue("Another user - expect another threadId", !t2.equals(threadId));
View Full Code Here

    assertEquals("User group should be expanded", 2, getTree().getRowCount());
  }

  public void testExpandGroupMessageReceived() throws Exception {
    MockTransport transport = new MockTransport();
    User user = UserImpl.create("nick", transport.getName());
    user.setGroup("some non-default group", myUserModel);
    myUserModel.addUser(user);
    TreeUtils.collapseAll(getTree());
    assertEquals("Sanity check", 1, getTree().getRowCount());

    myBroadcaster.fireEvent(new TransportEvent(transport, "nick"){});
View Full Code Here

    assertEquals(0, myTree.getSelectionRows()[0]);
  }

  public void testUserNameChanged() throws Exception {

    final User user = myUserModel.getAllUsers()[0];
    assertEquals("aaa", user.getName());

    TreePath path = new TreePath(new DefaultMutableTreeNode(user));
    myUsersTreeModel.valueForPathChanged(path, "new name");

    assertEquals("new name", user.getDisplayName());
  }
View Full Code Here

TOP

Related Classes of jetbrains.communicator.core.users.User

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.