use of org.jivesoftware.smackx.muclight.element.MUCLightBlockingIQ 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.jivesoftware.smackx.muclight.element.MUCLightBlockingIQ 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.jivesoftware.smackx.muclight.element.MUCLightBlockingIQ 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.jivesoftware.smackx.muclight.element.MUCLightBlockingIQ in project Smack by igniterealtime.
the class MUCLightBlockingTest method checkGetBlockingListResponse.
@Test
public void checkGetBlockingListResponse() throws Exception {
IQ iqInfoResult = (IQ) PacketParserUtils.parseStanza(getBlockingListIQResponse);
MUCLightBlockingIQ mucLightBlockingIQ = (MUCLightBlockingIQ) iqInfoResult;
Assert.assertEquals(2, mucLightBlockingIQ.getRooms().size());
Assert.assertEquals(1, mucLightBlockingIQ.getUsers().size());
Assert.assertEquals(false, mucLightBlockingIQ.getRooms().get(JidCreate.from("coven@muclight.shakespeare.lit")));
Assert.assertEquals(false, mucLightBlockingIQ.getRooms().get(JidCreate.from("sarasa@muclight.shakespeare.lit")));
Assert.assertEquals(false, mucLightBlockingIQ.getUsers().get(JidCreate.from("hag77@shakespeare.lit")));
}
use of org.jivesoftware.smackx.muclight.element.MUCLightBlockingIQ in project Smack by igniterealtime.
the class MUCLightBlockingIQProvider method parse.
@Override
public MUCLightBlockingIQ parse(XmlPullParser parser, int initialDepth) throws Exception {
HashMap<Jid, Boolean> rooms = null;
HashMap<Jid, Boolean> users = null;
outerloop: while (true) {
int eventType = parser.next();
if (eventType == XmlPullParser.START_TAG) {
if (parser.getName().equals("room")) {
rooms = parseBlocking(parser, rooms);
}
if (parser.getName().equals("user")) {
users = parseBlocking(parser, users);
}
} else if (eventType == XmlPullParser.END_TAG) {
if (parser.getDepth() == initialDepth) {
break outerloop;
}
}
}
MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(rooms, users);
mucLightBlockingIQ.setType(Type.result);
return mucLightBlockingIQ;
}
Aggregations