Search in sources :

Example 6 with MamQueryIQ

use of org.jivesoftware.smackx.mam.element.MamQueryIQ in project Smack by igniterealtime.

the class QueryArchiveTest method checkMamQueryIQ.

@Test
public void checkMamQueryIQ() throws Exception {
    DataForm dataForm = getNewMamForm();
    MamQueryIQ mamQueryIQ = new MamQueryIQ(queryId, dataForm);
    mamQueryIQ.setType(IQ.Type.set);
    mamQueryIQ.setStanzaId("sarasa");
    Assert.assertEquals(mamQueryIQ.toXML().toString(), mamSimpleQueryIQ);
}
Also used : DataForm(org.jivesoftware.smackx.xdata.packet.DataForm) MamQueryIQ(org.jivesoftware.smackx.mam.element.MamQueryIQ) Test(org.junit.Test)

Example 7 with MamQueryIQ

use of org.jivesoftware.smackx.mam.element.MamQueryIQ in project Smack by igniterealtime.

the class RetrieveFormFieldsTest method checkRetrieveFormFieldsStanza.

@Test
public void checkRetrieveFormFieldsStanza() throws Exception {
    MamQueryIQ mamQueryIQ = new MamQueryIQ(queryId);
    mamQueryIQ.setStanzaId("sarasa");
    Assert.assertEquals(mamQueryIQ.toXML().toString(), retrieveFormFieldStanza);
}
Also used : MamQueryIQ(org.jivesoftware.smackx.mam.element.MamQueryIQ) Test(org.junit.Test)

Example 8 with MamQueryIQ

use of org.jivesoftware.smackx.mam.element.MamQueryIQ in project Smack by igniterealtime.

the class MamQueryIQProviderTest method checkMamQueryIQProvider.

@Test
public void checkMamQueryIQProvider() throws Exception {
    // example 1
    IQ iq1 = (IQ) PacketParserUtils.parseStanza(exampleMamQueryIQ1);
    MamQueryIQ mamQueryIQ1 = (MamQueryIQ) iq1;
    Assert.assertEquals(mamQueryIQ1.getType(), Type.set);
    Assert.assertEquals(mamQueryIQ1.getQueryId(), "test");
    DataForm dataForm1 = (DataForm) mamQueryIQ1.getExtension(DataForm.NAMESPACE);
    Assert.assertEquals(dataForm1.getType(), DataForm.Type.submit);
    List<FormField> fields1 = dataForm1.getFields();
    Assert.assertEquals(fields1.get(0).getType(), FormField.Type.hidden);
    Assert.assertEquals(fields1.get(1).getType(), FormField.Type.text_single);
    Assert.assertEquals(fields1.get(1).getValues().get(0), "Where arth thou, my Juliet?");
    Assert.assertEquals(fields1.get(2).getValues().get(0), "{http://jabber.org/protocol/mood}mood/lonely");
    // example2
    IQ iq2 = (IQ) PacketParserUtils.parseStanza(exampleMamQueryIQ2);
    MamQueryIQ mamQueryIQ2 = (MamQueryIQ) iq2;
    Assert.assertEquals(mamQueryIQ2.getType(), Type.result);
    Assert.assertNull(mamQueryIQ2.getQueryId());
    DataForm dataForm2 = (DataForm) mamQueryIQ2.getExtension(DataForm.NAMESPACE);
    Assert.assertEquals(dataForm2.getType(), DataForm.Type.form);
    List<FormField> fields2 = dataForm2.getFields();
    Assert.assertEquals(fields2.get(0).getValues().get(0), "urn:xmpp:mam:1");
    Assert.assertTrue(fields2.get(0).getValues().size() == 1);
    Assert.assertEquals(fields2.get(1).getType(), FormField.Type.jid_single);
    Assert.assertEquals(fields2.get(2).getType(), FormField.Type.text_single);
    Assert.assertEquals(fields2.get(2).getValues(), new ArrayList<>());
    Assert.assertEquals(fields2.get(4).getVariable(), "urn:example:xmpp:free-text-search");
}
Also used : MamQueryIQ(org.jivesoftware.smackx.mam.element.MamQueryIQ) IQ(org.jivesoftware.smack.packet.IQ) DataForm(org.jivesoftware.smackx.xdata.packet.DataForm) FormField(org.jivesoftware.smackx.xdata.FormField) MamQueryIQ(org.jivesoftware.smackx.mam.element.MamQueryIQ) Test(org.junit.Test)

Example 9 with MamQueryIQ

use of org.jivesoftware.smackx.mam.element.MamQueryIQ in project Smack by igniterealtime.

the class MamManager method page.

/**
     * Returns a page of the archive.
     * 
     * @param node The Pubsub node name, can be null
     * @param dataForm
     * @param rsmSet
     * @return the MAM query result
     * @throws NoResponseException
     * @throws XMPPErrorException
     * @throws NotConnectedException
     * @throws InterruptedException
     * @throws NotLoggedInException
     */
public MamQueryResult page(String node, DataForm dataForm, RSMSet rsmSet) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, NotLoggedInException {
    MamQueryIQ mamQueryIQ = new MamQueryIQ(UUID.randomUUID().toString(), node, dataForm);
    mamQueryIQ.setType(IQ.Type.set);
    mamQueryIQ.setTo(archiveAddress);
    mamQueryIQ.addExtension(rsmSet);
    return queryArchive(mamQueryIQ);
}
Also used : MamQueryIQ(org.jivesoftware.smackx.mam.element.MamQueryIQ)

Aggregations

MamQueryIQ (org.jivesoftware.smackx.mam.element.MamQueryIQ)9 DataForm (org.jivesoftware.smackx.xdata.packet.DataForm)6 Test (org.junit.Test)5 Method (java.lang.reflect.Method)1 IQ (org.jivesoftware.smack.packet.IQ)1 RSMSet (org.jivesoftware.smackx.rsm.packet.RSMSet)1 FormField (org.jivesoftware.smackx.xdata.FormField)1