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());
}
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());
}
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);
}
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");
}
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();
}
Aggregations