Package rocks.xmpp.extensions.privacy.model

Examples of rocks.xmpp.extensions.privacy.model.PrivacyList


        Assert.assertEquals(privacy.getPrivacyLists().get(2).getName(), "special");
    }

    @Test
    public void marshalPrivacyListRequest() throws XMLStreamException, JAXBException {
        IQ iq = new IQ(IQ.Type.GET, new Privacy(new PrivacyList("public")));
        iq.setFrom(Jid.valueOf("romeo@example.net/orchard"));
        iq.setId("getlist1");
        String xml = marshal(iq);
        Assert.assertEquals(xml, "<iq from=\"romeo@example.net/orchard\" id=\"getlist1\" type=\"get\"><query xmlns=\"jabber:iq:privacy\"><list name=\"public\"></list></query></iq>");
    }
View Full Code Here


        Assert.assertEquals(xml, "<iq from=\"romeo@example.net/orchard\" id=\"getlist1\" type=\"get\"><query xmlns=\"jabber:iq:privacy\"><default></default></query></iq>");
    }

    @Test
    public void marshalPrivacyRule() throws XMLStreamException, JAXBException {
        PrivacyList privacyList = new PrivacyList("test", Arrays.asList(new PrivacyRule(PrivacyRule.Action.ALLOW, 0, Contact.Subscription.BOTH)));
        String xml = marshal(new Privacy(privacyList));
        Assert.assertEquals(xml, "<query xmlns=\"jabber:iq:privacy\"><list name=\"test\"><item type=\"subscription\" value=\"both\" action=\"allow\" order=\"0\"></item></list></query>");
    }
View Full Code Here

        Assert.assertEquals(xml, "<query xmlns=\"jabber:iq:privacy\"><list name=\"test\"><item type=\"subscription\" value=\"both\" action=\"allow\" order=\"0\"></item></list></query>");
    }

    @Test
    public void marshalInvisibilityList() throws XMLStreamException, JAXBException {
        PrivacyList privacyList = PrivacyList.createInvisibilityList();
        String xml = marshal(new Privacy(privacyList));
        Assert.assertEquals(xml, "<query xmlns=\"jabber:iq:privacy\"><list name=\"invisible\"><item action=\"deny\" order=\"1\"><presence-out></presence-out></item></list></query>");
    }
View Full Code Here

        Assert.assertEquals(xml, "<query xmlns=\"jabber:iq:privacy\"><list name=\"invisible\"><item action=\"deny\" order=\"1\"><presence-out></presence-out></item></list></query>");
    }

    @Test
    public void marshalInvisibilityListForUsers() throws XMLStreamException, JAXBException {
        PrivacyList privacyList = PrivacyList.createInvisibilityListForUsers("invisible-to-Gandalf", Jid.valueOf("gandalf@tolkien.lit"));
        String xml = marshal(new Privacy(privacyList));
        Assert.assertEquals(xml, "<query xmlns=\"jabber:iq:privacy\"><list name=\"invisible-to-Gandalf\"><item type=\"jid\" value=\"gandalf@tolkien.lit\" action=\"deny\" order=\"1\"><presence-out></presence-out></item><item action=\"allow\" order=\"2\"><presence-out></presence-out></item></list></query>");
    }
View Full Code Here

        Assert.assertEquals(xml, "<query xmlns=\"jabber:iq:privacy\"><list name=\"invisible-to-Gandalf\"><item type=\"jid\" value=\"gandalf@tolkien.lit\" action=\"deny\" order=\"1\"><presence-out></presence-out></item><item action=\"allow\" order=\"2\"><presence-out></presence-out></item></list></query>");
    }

    @Test
    public void marshalInvisibilityListForGroups() throws XMLStreamException, JAXBException {
        PrivacyList privacyList = PrivacyList.createInvisibilityListForGroups("invisible-to-Wizards", "Wizards");
        String xml = marshal(new Privacy(privacyList));
        Assert.assertEquals(xml, "<query xmlns=\"jabber:iq:privacy\"><list name=\"invisible-to-Wizards\"><item type=\"group\" value=\"Wizards\" action=\"deny\" order=\"1\"><presence-out></presence-out></item><item action=\"allow\" order=\"2\"><presence-out></presence-out></item></list></query>");
    }
View Full Code Here

        Assert.assertEquals(xml, "<query xmlns=\"jabber:iq:privacy\"><list name=\"invisible-to-Wizards\"><item type=\"group\" value=\"Wizards\" action=\"deny\" order=\"1\"><presence-out></presence-out></item><item action=\"allow\" order=\"2\"><presence-out></presence-out></item></list></query>");
    }

    @Test
    public void marshalInvisibilityListExceptForUsers() throws XMLStreamException, JAXBException {
        PrivacyList privacyList = PrivacyList.createInvisibilityListExceptForUsers("visible-to-Frodo", Jid.valueOf("frodo@tolkien.lit"));
        String xml = marshal(new Privacy(privacyList));
        Assert.assertEquals(xml, "<query xmlns=\"jabber:iq:privacy\"><list name=\"visible-to-Frodo\"><item type=\"jid\" value=\"frodo@tolkien.lit\" action=\"allow\" order=\"1\"><presence-out></presence-out></item><item action=\"deny\" order=\"2\"><presence-out></presence-out></item></list></query>");
    }
View Full Code Here

        Assert.assertEquals(xml, "<query xmlns=\"jabber:iq:privacy\"><list name=\"visible-to-Frodo\"><item type=\"jid\" value=\"frodo@tolkien.lit\" action=\"allow\" order=\"1\"><presence-out></presence-out></item><item action=\"deny\" order=\"2\"><presence-out></presence-out></item></list></query>");
    }

    @Test
    public void marshalInvisibilityListExceptForGroups() throws XMLStreamException, JAXBException {
        PrivacyList privacyList = PrivacyList.createInvisibilityListExceptForGroups("visible-to-Bagginses", "Bagginses");
        String xml = marshal(new Privacy(privacyList));
        Assert.assertEquals(xml, "<query xmlns=\"jabber:iq:privacy\"><list name=\"visible-to-Bagginses\"><item type=\"group\" value=\"Bagginses\" action=\"allow\" order=\"1\"><presence-out></presence-out></item><item action=\"deny\" order=\"2\"><presence-out></presence-out></item></list></query>");
    }
View Full Code Here

    }

    @Test
    public void testComparePrivacyLists() {

        PrivacyList privacyList1 = new PrivacyList("zzz");
        privacyList1 = privacyList1.asDefault();

        PrivacyList privacyList2 = new PrivacyList("yyy");
        privacyList2 = privacyList2.asActive();

        PrivacyList privacyList3 = new PrivacyList("aaa");
        PrivacyList privacyList4 = new PrivacyList("bbb");
        PrivacyList privacyList5 = new PrivacyList("ccc");

        List<PrivacyList> list = new ArrayList<>();
        list.add(privacyList1);
        list.add(privacyList2);
        list.add(privacyList3);
View Full Code Here

     * @throws rocks.xmpp.core.stanza.model.StanzaException If the entity returned a stanza error.
     * @throws rocks.xmpp.core.session.NoResponseException  If the entity did not respond.
     * @see <a href="http://xmpp.org/extensions/xep-0016.html#protocol-retrieve">2.3 Retrieving One's Privacy Lists</a>
     */
    public PrivacyList getPrivacyList(String name) throws XmppException {
        IQ result = xmppSession.query(new IQ(IQ.Type.GET, new Privacy(new PrivacyList(name))));
        Privacy privacy = result.getExtension(Privacy.class);
        if (privacy != null) {
            return privacy.getPrivacyLists().get(0);
        }
        return null;
View Full Code Here

     * @throws rocks.xmpp.core.stanza.model.StanzaException If the entity returned a stanza error.
     * @throws rocks.xmpp.core.session.NoResponseException  If the entity did not respond.
     * @see <a href="http://xmpp.org/extensions/xep-0016.html#protocol-remove">2.8 Removing a Privacy List</a>
     */
    public void removeList(String name) throws XmppException {
        setPrivacy(new Privacy(new PrivacyList(name)));
    }
View Full Code Here

TOP

Related Classes of rocks.xmpp.extensions.privacy.model.PrivacyList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.