Search in sources :

Example 51 with DataForm

use of org.jivesoftware.smackx.xdata.packet.DataForm in project Smack by igniterealtime.

the class FiltersTest method checkStartDateFilter.

@Test
public void checkStartDateFilter() throws Exception {
    Date date = new Date();
    MamQueryArgs mamQueryArgs = MamQueryArgs.builder().limitResultsSince(date).build();
    DataForm dataForm = mamQueryArgs.getDataForm(MamVersion.MAM2);
    List<String> fields = new ArrayList<>();
    fields.add("start");
    List<String> values = new ArrayList<>();
    values.add(XmppDateTime.formatXEP0082Date(date));
    assertEquals(getMamXMemberWith(fields, values), dataForm.toXML().toString());
}
Also used : DataForm(org.jivesoftware.smackx.xdata.packet.DataForm) ArrayList(java.util.ArrayList) Date(java.util.Date) MamQueryArgs(org.jivesoftware.smackx.mam.MamManager.MamQueryArgs) Test(org.junit.jupiter.api.Test)

Example 52 with DataForm

use of org.jivesoftware.smackx.xdata.packet.DataForm in project Smack by igniterealtime.

the class PagingTest method checkPageQueryStanza.

@Test
public void checkPageQueryStanza() throws Exception {
    DataForm dataForm = getNewMamForm();
    int max = 10;
    RSMSet rsmSet = new RSMSet(max);
    MamQueryIQ mamQueryIQ = new MamQueryIQ(MamVersion.MAM2, queryId, dataForm);
    mamQueryIQ.setStanzaId("sarasa");
    mamQueryIQ.setType(IQ.Type.set);
    mamQueryIQ.addExtension(rsmSet);
    assertEquals(mamQueryIQ.getDataForm(), dataForm);
    assertEquals(mamQueryIQ.getDataForm().getFields().get(0).getValues().get(0).toString(), "urn:xmpp:mam:2");
    assertEquals(pagingStanza, mamQueryIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
}
Also used : RSMSet(org.jivesoftware.smackx.rsm.packet.RSMSet) DataForm(org.jivesoftware.smackx.xdata.packet.DataForm) MamQueryIQ(org.jivesoftware.smackx.mam.element.MamQueryIQ) Test(org.junit.jupiter.api.Test)

Example 53 with DataForm

use of org.jivesoftware.smackx.xdata.packet.DataForm in project Smack by igniterealtime.

the class QueryArchiveTest method checkMamQueryIQ.

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

Example 54 with DataForm

use of org.jivesoftware.smackx.xdata.packet.DataForm in project Smack by igniterealtime.

the class MamQueryIQProviderTest method checkMamQueryIQProvider.

@Test
public void checkMamQueryIQProvider() throws Exception {
    // example 1
    IQ iq1 = PacketParserUtils.parseStanza(exampleMamQueryIQ1);
    MamQueryIQ mamQueryIQ1 = (MamQueryIQ) iq1;
    assertEquals(mamQueryIQ1.getType(), IQ.Type.set);
    assertEquals(mamQueryIQ1.getQueryId(), "test");
    DataForm dataForm1 = (DataForm) mamQueryIQ1.getExtension(DataForm.NAMESPACE);
    assertEquals(dataForm1.getType(), DataForm.Type.submit);
    List<FormField> fields1 = dataForm1.getFields();
    assertEquals(fields1.get(0).getType(), FormField.Type.hidden);
    assertEquals(fields1.get(1).getType(), FormField.Type.text_single);
    assertEquals(fields1.get(1).getValues().get(0).toString(), "Where arth thou, my Juliet?");
    assertEquals(fields1.get(2).getValues().get(0).toString(), "{http://jabber.org/protocol/mood}mood/lonely");
    // example2
    IQ iq2 = PacketParserUtils.parseStanza(exampleMamQueryIQ2);
    MamQueryIQ mamQueryIQ2 = (MamQueryIQ) iq2;
    assertEquals(mamQueryIQ2.getType(), IQ.Type.result);
    assertNull(mamQueryIQ2.getQueryId());
    DataForm dataForm2 = (DataForm) mamQueryIQ2.getExtension(DataForm.NAMESPACE);
    assertEquals(dataForm2.getType(), DataForm.Type.form);
    List<FormField> fields2 = dataForm2.getFields();
    assertEquals(fields2.get(0).getValues().get(0).toString(), "urn:xmpp:mam:2");
    assertTrue(fields2.get(0).getValues().size() == 1);
    assertEquals(fields2.get(1).getType(), FormField.Type.jid_single);
    assertEquals(fields2.get(2).getType(), FormField.Type.text_single);
    assertEquals(fields2.get(2).getValues(), new ArrayList<>());
    assertEquals(fields2.get(4).getFieldName(), "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.jupiter.api.Test)

Example 55 with DataForm

use of org.jivesoftware.smackx.xdata.packet.DataForm in project Smack by igniterealtime.

the class MamTest method getNewMamForm.

protected DataForm getNewMamForm() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
    Method methodGetNewMamForm = MamManager.class.getDeclaredMethod("getNewMamForm", MamVersion.class);
    methodGetNewMamForm.setAccessible(true);
    DataForm.Builder dataFormBuilder = (DataForm.Builder) methodGetNewMamForm.invoke(mamManager, MamVersion.MAM2);
    return dataFormBuilder.build();
}
Also used : DataForm(org.jivesoftware.smackx.xdata.packet.DataForm) Method(java.lang.reflect.Method)

Aggregations

DataForm (org.jivesoftware.smackx.xdata.packet.DataForm)65 FormField (org.jivesoftware.smackx.xdata.FormField)23 Test (org.junit.jupiter.api.Test)13 DiscoverInfo (org.jivesoftware.smackx.disco.packet.DiscoverInfo)12 Feature (com.xabber.xmpp.ssn.Feature)7 MamQueryIQ (org.jivesoftware.smackx.mam.element.MamQueryIQ)7 Date (java.util.Date)5 MamQueryArgs (org.jivesoftware.smackx.mam.MamManager.MamQueryArgs)5 OtrMode (com.xabber.xmpp.archive.OtrMode)4 LoggingValue (com.xabber.xmpp.ssn.LoggingValue)4 ArrayList (java.util.ArrayList)4 TreeSet (java.util.TreeSet)4 FillableForm (org.jivesoftware.smackx.xdata.form.FillableForm)4 LinkedList (java.util.LinkedList)3 IQ (org.jivesoftware.smack.packet.IQ)3 XmlPullParser (org.jivesoftware.smack.xml.XmlPullParser)3 Identity (org.jivesoftware.smackx.disco.packet.DiscoverInfo.Identity)3 DiscoverInfoBuilder (org.jivesoftware.smackx.disco.packet.DiscoverInfoBuilder)3 Form (org.jivesoftware.smackx.xdata.form.Form)3 DisclosureValue (com.xabber.xmpp.ssn.DisclosureValue)2