/** * Clone this presence and set a newly generated stanza ID as the clone's ID. * * @return a "clone" of this presence with a different stanza ID. * @since 4.1.2 */ public Presence cloneWithNewId() { Presence clone = clone(); clone.setStanzaId(StanzaIdUtil.newStanzaId()); return clone; }
private static Presence getNewPresence() { Presence presence = new Presence(Presence.Type.available); presence.setStanzaId(null); return presence; } }
presenceModeInConstructor.setStanzaId(null); assertEquals(mode1, presenceModeInConstructor.getMode()); assertXMLEqual(control, presenceModeInConstructor.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
@Test public void presenceTest() { Presence presence = new Presence(Presence.Type.subscribe, null, 0, Mode.away); presence.setStanzaId("presence-id"); String string = presence.toString(); assertEquals("Presence Stanza [id=presence-id,type=subscribe,mode=away,prio=0,]", string); }
@Test public void setPresenceTypeTest() throws IOException, SAXException { Presence.Type type = Presence.Type.unavailable; Presence.Type type2 = Presence.Type.subscribe; StringBuilder controlBuilder = new StringBuilder(); controlBuilder.append("<presence") .append(" type=\"") .append(type) .append("\">") .append("</presence>"); String control = controlBuilder.toString(); Presence presenceTypeInConstructor = new Presence(type); presenceTypeInConstructor.setStanzaId(null); assertEquals(type, presenceTypeInConstructor.getType()); assertXMLEqual(control, presenceTypeInConstructor.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); controlBuilder = new StringBuilder(); controlBuilder.append("<presence") .append(" type=\"") .append(type2) .append("\">") .append("</presence>"); control = controlBuilder.toString(); Presence presenceTypeSet = getNewPresence(); presenceTypeSet.setType(type2); assertEquals(type2, presenceTypeSet.getType()); assertXMLEqual(control, presenceTypeSet.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); }
presence.setTo(ParserUtils.getJidAttribute(parser, "to")); presence.setFrom(ParserUtils.getJidAttribute(parser, "from")); presence.setStanzaId(parser.getAttributeValue("", "id"));
/** * Clone this presence and set a newly generated stanza ID as the clone's ID. * * @return a "clone" of this presence with a different stanza ID. * @since 4.1.2 */ public Presence cloneWithNewId() { Presence clone = clone(); clone.setStanzaId(StanzaIdUtil.newStanzaId()); return clone; }
presence.setTo(ParserUtils.getJidAttribute(parser, "to")); presence.setFrom(ParserUtils.getJidAttribute(parser, "from")); presence.setStanzaId(parser.getAttributeValue("", "id"));