use of org.jivesoftware.smackx.sid.element.OriginIdElement in project Smack by igniterealtime.
the class RetractedElementProvider method parse.
@Override
public RetractedElement parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException, ParseException {
Date date = ParserUtils.getDateFromXep82String(parser.getAttributeValue("", RetractedElement.ATTR_STAMP));
OriginIdElement originIdElement = null;
while (originIdElement == null) {
XmlPullParser.TagEvent tag = parser.nextTag();
if (tag == XmlPullParser.TagEvent.START_ELEMENT && OriginIdElement.ELEMENT.equals(parser.getName()) && StableUniqueStanzaIdManager.NAMESPACE.equals(parser.getNamespace())) {
originIdElement = OriginIdProvider.INSTANCE.parse(parser);
}
}
return new RetractedElement(date, originIdElement);
}
use of org.jivesoftware.smackx.sid.element.OriginIdElement in project Smack by igniterealtime.
the class MessageFasteningElementsTest method fasteningDeserializationTest.
@ParameterizedTest
@EnumSource(SmackTestUtil.XmlPullParserKind.class)
public void fasteningDeserializationTest(SmackTestUtil.XmlPullParserKind parserKind) throws XmlPullParserException, IOException, SmackParsingException {
String xml = "<apply-to xmlns='urn:xmpp:fasten:0' id='origin-id-1'>" + " <i-like-this xmlns='urn:example:like'/>" + " <external name='custom' element-namespace='urn:example:custom'/>" + " <external name='body'/>" + "</apply-to>";
FasteningElement parsed = SmackTestUtil.parse(xml, FasteningElementProvider.class, parserKind);
assertNotNull(parsed);
assertEquals(new OriginIdElement("origin-id-1"), parsed.getReferencedStanzasOriginId());
assertFalse(parsed.isRemovingElement());
assertFalse(parsed.isShellElement());
assertEquals(1, parsed.getWrappedPayloads().size());
assertEquals("i-like-this", parsed.getWrappedPayloads().get(0).getElementName());
assertEquals("urn:example:like", parsed.getWrappedPayloads().get(0).getNamespace());
assertEquals(2, parsed.getExternalPayloads().size());
ExternalElement custom = parsed.getExternalPayloads().get(0);
assertEquals("custom", custom.getName());
assertEquals("urn:example:custom", custom.getElementNamespace());
ExternalElement body = parsed.getExternalPayloads().get(1);
assertEquals("body", body.getName());
assertNull(body.getElementNamespace());
}
use of org.jivesoftware.smackx.sid.element.OriginIdElement in project Smack by igniterealtime.
the class MessageFasteningElementsTest method createShellElementSharesOriginIdTest.
@Test
public void createShellElementSharesOriginIdTest() {
OriginIdElement originIdElement = new OriginIdElement("sensitive-stanza-1");
FasteningElement sensitiveFastening = FasteningElement.builder().setOriginId(originIdElement).build();
FasteningElement shellElement = FasteningElement.createShellElementForSensitiveElement(sensitiveFastening);
assertEquals(originIdElement, shellElement.getReferencedStanzasOriginId());
}
use of org.jivesoftware.smackx.sid.element.OriginIdElement in project Smack by igniterealtime.
the class StableUniqueStanzaIdTest method originIdProviderTest.
@Test
public void originIdProviderTest() throws Exception {
String xml = "<origin-id xmlns='urn:xmpp:sid:0' id='de305d54-75b4-431b-adb2-eb6b9e546013' />";
OriginIdElement element = new OriginIdElement("de305d54-75b4-431b-adb2-eb6b9e546013");
assertEquals("de305d54-75b4-431b-adb2-eb6b9e546013", element.getId());
assertXmlSimilar(xml, element.toXML().toString());
OriginIdElement parsed = OriginIdProvider.INSTANCE.parse(TestUtils.getParser(xml));
assertEquals(element.getId(), parsed.getId());
}
use of org.jivesoftware.smackx.sid.element.OriginIdElement in project Smack by igniterealtime.
the class StableUniqueStanzaIdTest method createOriginIdTest.
@Test
public void createOriginIdTest() {
OriginIdElement element = new OriginIdElement();
assertNotNull(element);
assertEquals(StableUniqueStanzaIdManager.NAMESPACE, element.getNamespace());
assertEquals(16, element.getId().length());
}
Aggregations