Package com.calclab.emite.core.stanzas

Examples of com.calclab.emite.core.stanzas.IQ


  }

  @Override
  public void requestUpdateItem(final RosterItem item) {
    if (getItemByJID(item.getJID()) != null) {
      final IQ iq = new IQ(IQ.Type.set);
      item.addStanzaTo(iq.addQuery(XmppNamespaces.ROSTER));

      session.sendIQ("roster", iq, new IQCallback() {
        @Override
        public void onIQSuccess(final IQ iq) {
          eventBus.fireEventFromSource(new RequestFailedEvent("rosterItemUpdate", "update roster item failed", iq), this);
View Full Code Here


    }
  }

  @Override
  public void requestUpdateItems(final Collection<RosterItem> items) {
    final IQ iq = new IQ(IQ.Type.set);
    final XMLPacket rosterQuery = iq.addQuery(XmppNamespaces.ROSTER);
    for (final RosterItem item : items) {
      item.addStanzaTo(rosterQuery);
    }

    session.sendIQ("roster", iq, new IQCallback() {
View Full Code Here

  }

  @Override
  public void reRequestRoster() {
    if (session.getCurrentUserURI() != null) {
      final IQ iq = new IQ(IQ.Type.get);
      iq.addQuery(XmppNamespaces.ROSTER);

      session.sendIQ("roster", iq, new IQCallback() {
        @Override
        public void onIQSuccess(final IQ iq) {
          clearGroupAll();

          for (final XMLPacket child : iq.getQuery(XmppNamespaces.ROSTER).getChildren()) {
            final RosterItem item = RosterItem.parse(child);
            storeItem(item);
          }

          if (!rosterReady) {
View Full Code Here

  }

  private void addOrUpdateItem(final XmppURI jid, final String name, final SubscriptionState subscriptionState, final String... groups) {
    final RosterItem item = new RosterItem(jid, subscriptionState, name, null);
    item.setGroups(groups);
    final IQ iq = new IQ(IQ.Type.set);
    item.addStanzaTo(iq.addQuery(XmppNamespaces.ROSTER));

    session.sendIQ("roster", iq, new IQCallback() {
      @Override
      public void onIQSuccess(final IQ iq) {
        eventBus.fireEventFromSource(new RequestFailedEvent("rosterItem", "roster item can't be updated", iq), this);
View Full Code Here

  @Test
  public void shouldRequestAndReceiveSearchFields() {
    final ResultListener<SearchFields> result = Mockito.mock(ResultListener.class);
    manager.requestSearchFields(result);
    session.verifyIQSent("<iq type='get' from='romeo@montague.net/home' to='search.service'" + "xml:lang='en'> <query xmlns='jabber:iq:search'/> </iq>");
    session.answerSuccess(new IQ(XMLBuilder.fromXML(XEP_0055_2_1_SAMPLE_2)));
    Mockito.verify(result, Mockito.never()).onFailure(Matchers.anyString());
    Mockito.verify(result).onSuccess(Matchers.argThat(new ArgumentMatcher<SearchFields>() {
      @Override
      public boolean matches(final Object arg0) {
        final SearchFields response = (SearchFields) arg0;
View Full Code Here

  @SuppressWarnings("unchecked")
  @Test
  public void shouldRequestAndReceiveSearchForm() {
    final ResultListener<Form> result = Mockito.mock(ResultListener.class);
    manager.requestSearchForm(result);
    session.answerSuccess(new IQ(XMLBuilder.fromXML(XEP_0055_3_SAMPLE_7)));
    Mockito.verify(result, Mockito.never()).onFailure(Matchers.anyString());
    Mockito.verify(result).onSuccess(Matchers.argThat(new ArgumentMatcher<Form>() {
      @Override
      public boolean matches(final Object arg0) {
        final Form response = (Form) arg0;
View Full Code Here

  @SuppressWarnings("unchecked")
  @Test
  public void shouldRequestAndReceiveSearchFormWhenNoFormReturned() {
    final ResultListener<Form> result = Mockito.mock(ResultListener.class);
    manager.requestSearchForm(result);
    session.answerSuccess(new IQ(XMLBuilder.fromXML(XEP_0055_2_1_SAMPLE_2)));
    Mockito.verify(result, Mockito.never()).onFailure(Matchers.anyString());
    Mockito.verify(result).onSuccess(Matchers.argThat(new ArgumentMatcher<Form>() {
      @Override
      public boolean matches(final Object arg0) {
        final Form response = (Form) arg0;
View Full Code Here

  @SuppressWarnings("unchecked")
  @Test
  public void shouldReturnAnEmptyListIfNotResultFounded() {
    final ResultListener<List<SearchResultItem>> result = Mockito.mock(ResultListener.class);
    manager.search(new HashMap<String, String>(), result);
    session.answerSuccess(new IQ(XMLBuilder.fromXML("<iq type='result' from='characters.shakespeare.lit' to='romeo@montague.net/home' id='search2' xml:lang='en'>"
        + "<query xmlns='jabber:iq:search'/></iq>")));
    Mockito.verify(result, Mockito.never()).onFailure(Matchers.anyString());
    Mockito.verify(result).onSuccess(Matchers.argThat(new ArgumentMatcher<List<SearchResultItem>>() {
      @Override
      public boolean matches(final Object arg0) {
View Full Code Here

    final ResultListener<List<SearchResultItem>> result = Mockito.mock(ResultListener.class);
    manager.search(query, result);

    session.verifyIQSent("<iq type='set' from='romeo@montague.net/home' to='search.service' xml:lang='en'>"
        + "<query xmlns='jabber:iq:search'> <last>Capulet</last> </query></iq>");
    session.answerSuccess(new IQ(XMLBuilder.fromXML("<iq type='result' from='characters.shakespeare.lit' to='romeo@montague.net/home' id='search2' xml:lang='en'>"
        + "<query xmlns='jabber:iq:search'><item jid='juliet@capulet.com'>" + "<first>Juliet</first><last>Capulet</last><nick>JuliC</nick>"
        + "<email>juliet@shakespeare.lit</email></item>" + "<item jid='tybalt@shakespeare.lit'><first>Tybalt</first>"
        + "<last>Capulet</last><nick>ty</nick>" + "<email>tybalt@shakespeare.lit</email></item></query></iq>")));
    Mockito.verify(result, Mockito.never()).onFailure(Matchers.anyString());
    Mockito.verify(result).onSuccess(Matchers.argThat(new ArgumentMatcher<List<SearchResultItem>>() {
View Full Code Here

    session.verifyIQSent("<iq type='set' from='romeo@montague.net/home' to='search.service' xml:lang='en'>"
        + "<query xmlns='jabber:iq:search'><x xmlns='jabber:x:data' type='submit'>"
        + "<field type='hidden' var='FORM_TYPE'><value>jabber:iq:search</value>"
        + "</field><field var='x-gender'><value>male</value></field></x></query></iq>");
    session.answerSuccess(new IQ(XMLBuilder.fromXML("<iq type='result'     from='characters.shakespeare.lit'    to='juliet@capulet.com/balcony'    id='search4'    xml:lang='en'>  <query xmlns='jabber:iq:search'>    <x xmlns='jabber:x:data' type='result'>      <field type='hidden' var='FORM_TYPE'>        <value>jabber:iq:search</value>      </field>      <reported>        <field var='first' label='Given Name' type='text-single'/>        <field var='last' label='Family Name' type='text-single'/>        <field var='jid' label='Jabber ID' type='jid-single'/>        <field var='x-gender' label='Gender' type='list-single'/>      </reported>      <item>        <field var='first'><value>Benvolio</value></field>        <field var='last'><value>Montague</value></field>        <field var='jid'><value>benvolio@montague.net</value></field>        <field var='x-gender'><value>male</value></field>      </item>      <item>        <field var='first'><value>Romeo</value></field>        <field var='last'><value>Montague</value></field>        <field var='jid'><value>romeo@montague.net</value></field>        <field var='x-gender'><value>male</value></field>      </item>    </x>  </query></iq>")));
    Mockito.verify(result, Mockito.never()).onFailure(Matchers.anyString());
    Mockito.verify(result).onSuccess(Matchers.argThat(new ArgumentMatcher<Form>() {
      @Override
      public boolean matches(final Object arg0) {
        final Form response = (Form) arg0;
View Full Code Here

TOP

Related Classes of com.calclab.emite.core.stanzas.IQ

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.