use of org.jxmpp.jid.Jid in project Smack by igniterealtime.
the class MUCLightAffiliationsChangeExtensionTest method checkAffiliationsChangeExtension.
@Test
public void checkAffiliationsChangeExtension() throws Exception {
Message changeAffiliationsMessage = (Message) PacketParserUtils.parseStanza(exampleMessageStanza);
AffiliationsChangeExtension affiliationsChangeExtension = AffiliationsChangeExtension.from(changeAffiliationsMessage);
HashMap<Jid, MUCLightAffiliation> affiliations = affiliationsChangeExtension.getAffiliations();
Assert.assertEquals(affiliations.size(), 3);
Assert.assertEquals(affiliations.get(JidCreate.from("sarasa2@shakespeare.lit")), MUCLightAffiliation.owner);
Assert.assertEquals(affiliations.get(JidCreate.from("sarasa1@shakespeare.lit")), MUCLightAffiliation.member);
Assert.assertEquals(affiliations.get(JidCreate.from("sarasa3@shakespeare.lit")), MUCLightAffiliation.none);
}
use of org.jxmpp.jid.Jid in project Smack by igniterealtime.
the class MUCLightBlockingTest method checkUnblockUsersAndRoomsIQ.
@Test
public void checkUnblockUsersAndRoomsIQ() throws Exception {
HashMap<Jid, Boolean> users = new HashMap<>();
users.put(JidCreate.from("hag66@shakespeare.lit"), true);
HashMap<Jid, Boolean> rooms = new HashMap<>();
rooms.put(JidCreate.from("coven@muclight.shakespeare.lit"), true);
MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(rooms, users);
mucLightBlockingIQ.setType(Type.set);
mucLightBlockingIQ.setTo(JidCreate.from("muclight.shakespeare.lit"));
mucLightBlockingIQ.setStanzaId("unblock1");
Assert.assertEquals(unblockingUsersAndRoomsExample, mucLightBlockingIQ.toXML().toString());
}
use of org.jxmpp.jid.Jid in project Smack by igniterealtime.
the class MUCLightBlockingTest method checkBlockRoomsIQ.
@Test
public void checkBlockRoomsIQ() throws Exception {
HashMap<Jid, Boolean> rooms = new HashMap<>();
rooms.put(JidCreate.from("coven@muclight.shakespeare.lit"), false);
rooms.put(JidCreate.from("chapel@shakespeare.lit"), false);
MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(rooms, null);
mucLightBlockingIQ.setType(Type.set);
mucLightBlockingIQ.setTo(JidCreate.from("muclight.shakespeare.lit"));
mucLightBlockingIQ.setStanzaId("block1");
Assert.assertEquals(blockingRoomsIQExample, mucLightBlockingIQ.toXML().toString());
}
use of org.jxmpp.jid.Jid in project Smack by igniterealtime.
the class MUCLightBlockingTest method checkBlockUsersIQ.
@Test
public void checkBlockUsersIQ() throws Exception {
HashMap<Jid, Boolean> users = new HashMap<>();
users.put(JidCreate.from("hag77@shakespeare.lit"), false);
users.put(JidCreate.from("hag66@shakespeare.lit"), false);
MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(null, users);
mucLightBlockingIQ.setType(Type.set);
mucLightBlockingIQ.setTo(JidCreate.from("muclight.shakespeare.lit"));
mucLightBlockingIQ.setStanzaId("block2");
Assert.assertEquals(blockingUsersIQExample, mucLightBlockingIQ.toXML().toString());
}
use of org.jxmpp.jid.Jid in project Smack by igniterealtime.
the class MUCParserUtils method parseItem.
public static MUCItem parseItem(XmlPullParser parser) throws XmlPullParserException, IOException {
int initialDepth = parser.getDepth();
MUCAffiliation affiliation = MUCAffiliation.fromString(parser.getAttributeValue("", "affiliation"));
Resourcepart nick = ParserUtils.getResourcepartAttribute(parser, "nick");
MUCRole role = MUCRole.fromString(parser.getAttributeValue("", "role"));
Jid jid = ParserUtils.getJidAttribute(parser);
Jid actor = null;
Resourcepart actorNick = null;
String reason = null;
outerloop: while (true) {
int eventType = parser.next();
switch(eventType) {
case XmlPullParser.START_TAG:
String name = parser.getName();
switch(name) {
case "actor":
actor = ParserUtils.getJidAttribute(parser);
// TODO change to
// actorNick = Resourcepart.from(parser.getAttributeValue("", "nick"));
// once a newer version of JXMPP is used that supports from(null).
String actorNickString = parser.getAttributeValue("", "nick");
if (actorNickString != null) {
actorNick = Resourcepart.from(actorNickString);
}
break;
case "reason":
reason = parser.nextText();
break;
}
break;
case XmlPullParser.END_TAG:
if (parser.getDepth() == initialDepth) {
break outerloop;
}
break;
}
}
return new MUCItem(affiliation, role, actor, reason, jid, nick, actorNick);
}
Aggregations