Package com.calclab.emite.im.roster

Examples of com.calclab.emite.im.roster.RosterItem


    assertEquals(0, item.getGroups().size());
  }

  @Test
  public void shouldParseStanza() {
    final RosterItem item = RosterItem.parse(XMLBuilder.fromXML("<item jid='romeo@example.net' ask='subscribe' name='R' subscription='both'>"
        + "<group>Friends</group><group>X</group></item>"));
    assertEquals("R", item.getName());
    assertEquals("R", item.getName());
    assertEquals(Presence.Type.subscribe, item.getAsk());
    assertEquals(2, item.getGroups().size());
    assertTrue(item.getGroups().contains("Friends"));
    assertTrue(item.getGroups().contains("X"));
  }
View Full Code Here


import com.calclab.emite.im.roster.RosterItem;

public class RosterItemHelper {

  public static RosterItem createItem(final String jid, final String name, final boolean isAvailable, final String... groups) {
    final RosterItem item = new RosterItem(XmppURI.uri(jid), null, name, null);
    for (final String group : groups) {
      item.addToGroup(group);
    }
    final String resource = item.getJID().getResource();
    item.setAvailable(isAvailable, resource);
    return item;
  }
View Full Code Here

    session.receives("<iq type='set' from='someone@domain' id='theId'><query xmlns='jabber:iq:roster'>"
        + "<item jid='friend@domain' name='MyFriend'><group>Group1</group><group>Group2</group>" + "</item></query></iq>");
    assertTrue(handler.isCalledOnce());
    assertEquals(1, roster.getItems().size());
    final RosterItem item = asList(roster.getItems()).get(0);
    assertEquals("friend@domain", item.getJID().toString());
    assertEquals("MyFriend", item.getName());
    assertEquals(2, item.getGroups().size());
    session.verifySent("<iq type='result' to='someone@domain' id='theId'/>");
  }
View Full Code Here

  @Test
  public void shouldFindRosterItemByJID() {
    shouldRequestRosterOnLogin();
    session.answerSuccess(serverRoster());

    final RosterItem item = roster.getItemByJID(uri("romeo@example.net"));
    assertNotNull(item);
    assertSame(item, roster.getItemByJID(uri("romeo@example.net/RESOURCE")));
  }
View Full Code Here

  public void shouldHandleInitialPresence() {
    session.receives("<iq type='set'><query xmlns='jabber:iq:roster'>" + "<item jid='friend@domain' name='MyFriend' /></query></iq>");
    final RosterItemChangedTestHandler handler = new RosterItemChangedTestHandler();
    roster.addRosterItemChangedHandler(handler);
    session.receives("<presence from='friend@domain' />");
    final RosterItem item = roster.getItemByJID(uri("friend@domain"));
    assertEquals(item, handler.getLastRosterItem());
    assertTrue(item.isAvailable());
  }
View Full Code Here

    session.receives("<iq type='set'><query xmlns='jabber:iq:roster'>" + "<item jid='friend@domain' name='MyFriend' /></query></iq>");

    final RosterItemChangedTestHandler handler = new RosterItemChangedTestHandler();
    roster.addRosterItemChangedHandler(handler);
    session.receives("<presence from='friend@domain'>" + "<show>dnd</show><status>message</status><priority>3</priority></presence>");
    final RosterItem item = roster.getItemByJID(uri("friend@domain"));
    assertEquals(Presence.Show.dnd, item.getShow());
    assertEquals("message", item.getStatus());
    assertEquals(item, handler.getLastRosterItem());
  }
View Full Code Here

  public void shouldHandleUnavailablePresence() {
    session.receives("<iq type='set'><query xmlns='jabber:iq:roster'>" + "<item jid='friend@domain' name='MyFriend' /></query></iq>");
    final RosterItemChangedTestHandler handler = new RosterItemChangedTestHandler();
    roster.addRosterItemChangedHandler(handler);
    session.receives("<presence type='unavailable' from='friend@domain' />");
    final RosterItem item = roster.getItemByJID(uri("friend@domain"));
    assertEquals(item, handler.getLastRosterItem());
    assertFalse(item.isAvailable());

  }
View Full Code Here

  @Test
  public void shouldRequestUpdateItem() {
    session.receives("<iq type='set' id='theId'><query xmlns='jabber:iq:roster'>"
        + "<item jid='friend@domain' name='MyFriend'><group>Group1</group><group>Group2</group>" + "</item></query></iq>");
    final RosterItem item = roster.getItemByJID(uri("friend@domain"));
    assertNotNull(item);
    RosterItem upd = new RosterItem(uri("no@one"), null, "name", null);
    upd.setGroups("group");
    roster.requestUpdateItem(upd);
    session.verifySent("<iq type='result' id='theId' />");
    upd = new RosterItem(uri("friend@domain"), null, "MyOldFriend", null);
    upd.setGroups("Group1", "Group3");
    roster.requestUpdateItem(upd);
    session.verifyIQSent("<iq type='set'><query xmlns='jabber:iq:roster'>"
        + "<item jid='friend@domain' name='MyOldFriend'><group>Group1</group><group>Group3</group>" + "</item></query></iq>");
  }
View Full Code Here

  }

  @Test
  public void shouldSetPresenceUnavailableOnRosterReception() {
    session.receives("<iq type='set'><query xmlns='jabber:iq:roster'>" + "<item jid='friend@domain' name='MyFriend' /></query></iq>");
    final RosterItem item = roster.getItemByJID(uri("friend@domain"));
    assertNotNull(item);
    // FIXME: not sure of this
    // assertEquals(Presence.Type.unavailable,
    // item.getPresence().getType());
  }
View Full Code Here

public class RosterItemTests {

  @Test
  public void shouldConvertToStanza() {
    final RosterItem item = new RosterItem(uri("name@domain/RESOURCE"), null, "TheName", null);
    item.addToGroup("group1");
    item.addToGroup("group2");
    EmiteAsserts.assertPacketLike("<item jid='name@domain' name='TheName'>" + "<group>group1</group><group>group2</group></item>",
        item.addStanzaTo(XMLBuilder.create("all").getXML()));
  }
View Full Code Here

TOP

Related Classes of com.calclab.emite.im.roster.RosterItem

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.