public MamQuery queryArchive(MamQueryArgs mamQueryArgs) throws NoResponseException, XMPPErrorException, NotConnectedException, NotLoggedInException, InterruptedException { String queryId = UUID.randomUUID().toString(); String node = mamQueryArgs.node; DataForm dataForm = mamQueryArgs.getDataForm(); MamQueryIQ mamQueryIQ = new MamQueryIQ(queryId, node, dataForm); mamQueryIQ.setType(IQ.Type.set); mamQueryIQ.setTo(archiveAddress); mamQueryArgs.maybeAddRsmSet(mamQueryIQ); return queryArchive(mamQueryIQ); }
@Test public void checkEndDateFilter() throws Exception { Date date = new Date(); MamQueryArgs mamQueryArgs = MamQueryArgs.builder().limitResultsBefore(date).build(); DataForm dataForm = mamQueryArgs.getDataForm(); List<String> fields = new ArrayList<>(); fields.add("end"); List<String> values = new ArrayList<>(); values.add(XmppDateTime.formatXEP0082Date(date)); assertEquals(getMamXMemberWith(fields, values), dataForm.toXML(null).toString()); }
@Test public void checkStartDateFilter() throws Exception { Date date = new Date(); MamQueryArgs mamQueryArgs = MamQueryArgs.builder().limitResultsSince(date).build(); DataForm dataForm = mamQueryArgs.getDataForm(); List<String> fields = new ArrayList<>(); fields.add("start"); List<String> values = new ArrayList<>(); values.add(XmppDateTime.formatXEP0082Date(date)); assertEquals(getMamXMemberWith(fields, values), dataForm.toXML(null).toString()); }
public MamQuery queryArchive(MamQueryArgs mamQueryArgs) throws NoResponseException, XMPPErrorException, NotConnectedException, NotLoggedInException, InterruptedException { String queryId = UUID.randomUUID().toString(); String node = mamQueryArgs.node; DataForm dataForm = mamQueryArgs.getDataForm(); MamQueryIQ mamQueryIQ = new MamQueryIQ(queryId, node, dataForm); mamQueryIQ.setType(IQ.Type.set); mamQueryIQ.setTo(archiveAddress); mamQueryArgs.maybeAddRsmSet(mamQueryIQ); return queryArchive(mamQueryIQ); }
@Test public void checkAddAdditionalFieldsStanza() throws Exception { FormField field1 = new FormField("urn:example:xmpp:free-text-search"); field1.setType(FormField.Type.text_single); field1.addValue("Hi"); FormField field2 = new FormField("urn:example:xmpp:stanza-content"); field2.setType(FormField.Type.jid_single); field2.addValue("Hi2"); MamQueryArgs mamQueryArgs = MamQueryArgs.builder() .withAdditionalFormField(field1) .withAdditionalFormField(field2) .build(); DataForm dataForm = mamQueryArgs.getDataForm(); String dataFormResult = dataForm.toXML(null).toString(); assertXmlSimilar(additionalFieldsStanza, dataFormResult); }
@Test public void checkWithJidFilter() throws Exception { Jid jid = JidTestUtil.BARE_JID_1; MamQueryArgs mamQueryArgs = MamQueryArgs.builder().limitResultsToJid(jid).build(); DataForm dataForm = mamQueryArgs.getDataForm(); List<String> fields = new ArrayList<>(); fields.add("with"); List<CharSequence> values = new ArrayList<>(); values.add(jid); assertEquals(getMamXMemberWith(fields, values), dataForm.toXML(null).toString()); }