Search in sources :

Example 1 with MUCLightBlockingIQ

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());
}
Also used : Jid(org.jxmpp.jid.Jid) HashMap(java.util.HashMap) MUCLightBlockingIQ(org.jivesoftware.smackx.muclight.element.MUCLightBlockingIQ) Test(org.junit.Test)

Example 2 with MUCLightBlockingIQ

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());
}
Also used : Jid(org.jxmpp.jid.Jid) HashMap(java.util.HashMap) MUCLightBlockingIQ(org.jivesoftware.smackx.muclight.element.MUCLightBlockingIQ) Test(org.junit.Test)

Example 3 with MUCLightBlockingIQ

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());
}
Also used : Jid(org.jxmpp.jid.Jid) HashMap(java.util.HashMap) MUCLightBlockingIQ(org.jivesoftware.smackx.muclight.element.MUCLightBlockingIQ) Test(org.junit.Test)

Example 4 with MUCLightBlockingIQ

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")));
}
Also used : MUCLightBlockingIQ(org.jivesoftware.smackx.muclight.element.MUCLightBlockingIQ) MUCLightBlockingIQ(org.jivesoftware.smackx.muclight.element.MUCLightBlockingIQ) IQ(org.jivesoftware.smack.packet.IQ) Test(org.junit.Test)

Example 5 with MUCLightBlockingIQ

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;
}
Also used : Jid(org.jxmpp.jid.Jid) MUCLightBlockingIQ(org.jivesoftware.smackx.muclight.element.MUCLightBlockingIQ)

Aggregations

MUCLightBlockingIQ (org.jivesoftware.smackx.muclight.element.MUCLightBlockingIQ)14 Jid (org.jxmpp.jid.Jid)7 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 DomainBareJid (org.jxmpp.jid.DomainBareJid)3 EntityBareJid (org.jxmpp.jid.EntityBareJid)3 IQ (org.jivesoftware.smack.packet.IQ)2 IQReplyFilter (org.jivesoftware.smack.filter.IQReplyFilter)1 StanzaFilter (org.jivesoftware.smack.filter.StanzaFilter)1