Package rocks.xmpp.extensions.data.model

Examples of rocks.xmpp.extensions.data.model.DataForm$Item


                "  </validate>\n" +
                "  <value>2003-10-06T11:22:00-07:00</value>\n" +
                "</field>" +
                "</x>";

        DataForm dataForm = unmarshal(xml, DataForm.class);

        Assert.assertNotNull(dataForm);
        Validation validation = dataForm.getFields().get(0).getValidation();
        Assert.assertNotNull(validation);
        Assert.assertEquals(validation.getDataType(), "xs:dateTime");
        Assert.assertTrue(validation.getValidationMethod() instanceof Validation.ValidationMethod.Range);
        Assert.assertEquals(((Validation.ValidationMethod.Range) validation.getValidationMethod()).getMin(), "2003-10-05T00:00:00-07:00");
        Assert.assertEquals(((Validation.ValidationMethod.Range) validation.getValidationMethod()).getMax(), "2003-10-24T23:59:59-07:00");
View Full Code Here


                "    <regex>([0-9]{3})-([0-9]{2})-([0-9]{4})</regex>\n" +
                "  </validate>\n" +
                "</field>\n" +
                "</x>";

        DataForm dataForm = unmarshal(xml, DataForm.class);

        Assert.assertNotNull(dataForm);
        Validation validation = dataForm.getFields().get(0).getValidation();
        Assert.assertNotNull(validation);
        Assert.assertEquals(validation.getDataType(), "xs:string");
        Assert.assertTrue(validation.getValidationMethod() instanceof Validation.ValidationMethod.Regex);
        Assert.assertEquals(((Validation.ValidationMethod.Regex) validation.getValidationMethod()).getRegex(), "([0-9]{3})-([0-9]{2})-([0-9]{4})");
    }
View Full Code Here

                "  <option><value>home phone</value></option>\n" +
                "  <option><value>cell phone</value></option>\n" +
                "</field>\n" +
                "</x>";

        DataForm dataForm = unmarshal(xml, DataForm.class);

        Assert.assertNotNull(dataForm);
        Validation validation = dataForm.getFields().get(0).getValidation();

        Assert.assertNotNull(validation);
        Assert.assertEquals(validation.getDataType(), "xs:string");
        Assert.assertTrue(validation.getValidationMethod() instanceof Validation.ValidationMethod.Basic);
        Assert.assertNotNull(validation.getListRange());
View Full Code Here

                "      <field var='muc#register_faqentry'>\n" +
                "        <value>Just another witch.</value>\n" +
                "      </field>\n" +
                "    </x>\n";

        DataForm dataForm = unmarshal(xml, DataForm.class);

        RoomRegistrationForm roomRegistrationForm = new RoomRegistrationForm(dataForm);

        Assert.assertEquals(roomRegistrationForm.getGivenName(), "Brunhilde");
        Assert.assertEquals(roomRegistrationForm.getFamilyName(), "Entwhistle-Throckmorton");
View Full Code Here

        Assert.assertEquals(roomRegistrationForm.getFaqEntry(), "Just another witch.");
    }

    @Test
    public void testEmptyDataForm() throws MalformedURLException {
        DataForm dataForm = new DataForm(DataForm.Type.SUBMIT);
        RoomRegistrationForm roomRegistrationForm = new RoomRegistrationForm(dataForm);
        roomRegistrationForm.setGivenName("Brunhilde");
        DataForm.Field fieldGivenName = dataForm.findField("muc#register_first");
        Assert.assertNotNull(fieldGivenName);
        Assert.assertEquals(fieldGivenName.getValues().size(), 1);
        Assert.assertEquals(fieldGivenName.getValues().get(0), "Brunhilde");
        Assert.assertEquals(roomRegistrationForm.getGivenName(), "Brunhilde");

        roomRegistrationForm.setFamilyName("Entwhistle-Throckmorton");
        DataForm.Field fieldFamilyName = dataForm.findField("muc#register_last");
        Assert.assertNotNull(fieldFamilyName);
        Assert.assertEquals(fieldFamilyName.getValues().size(), 1);
        Assert.assertEquals(fieldFamilyName.getValues().get(0), "Entwhistle-Throckmorton");
        Assert.assertEquals(roomRegistrationForm.getFamilyName(), "Entwhistle-Throckmorton");

        roomRegistrationForm.setRoomNick("thirdwitch");
        DataForm.Field fieldDescription = dataForm.findField("muc#register_roomnick");
        Assert.assertNotNull(fieldDescription);
        Assert.assertEquals(fieldDescription.getValues().size(), 1);
        Assert.assertEquals(fieldDescription.getValues().get(0), "thirdwitch");
        Assert.assertEquals(roomRegistrationForm.getRoomNick(), "thirdwitch");

        roomRegistrationForm.setWebPage(new URL("http://witchesonline/~hag66/"));
        DataForm.Field fieldLanguage = dataForm.findField("muc#register_url");
        Assert.assertNotNull(fieldLanguage);
        Assert.assertEquals(fieldLanguage.getValues().size(), 1);
        Assert.assertEquals(fieldLanguage.getValues().get(0), "http://witchesonline/~hag66/");
        Assert.assertEquals(roomRegistrationForm.getWebPage(), new URL("http://witchesonline/~hag66/"));

        roomRegistrationForm.setEmail("hag66@witchesonline");
        DataForm.Field fieldLdap = dataForm.findField("muc#register_email");
        Assert.assertNotNull(fieldLdap);
        Assert.assertEquals(fieldLdap.getValues().size(), 1);
        Assert.assertEquals(fieldLdap.getValues().get(0), "hag66@witchesonline");
        Assert.assertEquals(roomRegistrationForm.getEmail(), "hag66@witchesonline");

        roomRegistrationForm.setFaqEntry("Just another witch.");
        DataForm.Field fieldLogs = dataForm.findField("muc#register_faqentry");
        Assert.assertNotNull(fieldLogs);
        Assert.assertEquals(fieldLogs.getValues().size(), 1);
        Assert.assertEquals(fieldLogs.getValues().get(0), "Just another witch.");
        Assert.assertEquals(roomRegistrationForm.getFaqEntry(), "Just another witch.");

        roomRegistrationForm.setRegisterAllowed(true);
        DataForm.Field fieldAllow = dataForm.findField("muc#register_allow");
        Assert.assertNotNull(fieldAllow);
        Assert.assertEquals(fieldAllow.getValues().size(), 1);
        Assert.assertEquals(fieldAllow.getValues().get(0), "1");
        Assert.assertTrue(roomRegistrationForm.isRegisterAllowed());
    }
View Full Code Here

    }

    @Test
    public void testSortDataForms() throws XMLStreamException, JAXBException {

        DataForm dataForm1 = new DataForm(DataForm.Type.FORM);
        dataForm1.getFields().add(new DataForm.Field(DataForm.Field.Type.BOOLEAN, "ccc"));
        dataForm1.getFields().add(new DataForm.Field(DataForm.Field.Type.HIDDEN, "FORM_TYPE", "aaa"));

        DataForm dataForm2 = new DataForm(DataForm.Type.FORM);
        dataForm2.getFields().add(new DataForm.Field(DataForm.Field.Type.BOOLEAN, "bbb"));

        DataForm dataForm3 = new DataForm(DataForm.Type.FORM);
        dataForm3.getFields().add(new DataForm.Field(DataForm.Field.Type.HIDDEN, "FORM_TYPE", "bbb"));
        dataForm3.getFields().add(new DataForm.Field(DataForm.Field.Type.BOOLEAN, "aaa"));

        List<DataForm> dataForms = new ArrayList<>();
        dataForms.add(dataForm1);
        dataForms.add(dataForm2);
        dataForms.add(dataForm3);
View Full Code Here

        features.add(new Feature("http://jabber.org/protocol/caps"));
        features.add(new Feature("http://jabber.org/protocol/disco#info"));
        features.add(new Feature("http://jabber.org/protocol/disco#items"));
        features.add(new Feature("http://jabber.org/protocol/muc"));

        DataForm dataForm = new DataForm(DataForm.Type.RESULT);
        dataForm.getFields().add(new DataForm.Field(DataForm.Field.Type.HIDDEN, "FORM_TYPE", "urn:xmpp:dataforms:softwareinfo"));
        dataForm.getFields().add(new DataForm.Field(DataForm.Field.Type.TEXT_SINGLE, "ip_version", "ipv4", "ipv6"));
        dataForm.getFields().add(new DataForm.Field(DataForm.Field.Type.TEXT_SINGLE, "os", "Mac"));
        dataForm.getFields().add(new DataForm.Field(DataForm.Field.Type.TEXT_SINGLE, "os_version", "10.5.1"));
        dataForm.getFields().add(new DataForm.Field(DataForm.Field.Type.TEXT_SINGLE, "software", "Psi"));
        dataForm.getFields().add(new DataForm.Field(DataForm.Field.Type.TEXT_SINGLE, "software_version", "0.11"));

        InfoDiscovery infoDiscovery = new InfoDiscovery();
        infoDiscovery.getFeatures().addAll(features);
        infoDiscovery.getIdentities().addAll(identities);
        infoDiscovery.getExtensions().add(dataForm);
View Full Code Here

        features.add(new Feature("http://jabber.org/protocol/disco#info"));
        features.add(new Feature("http://jabber.org/protocol/disco#items"));
        features.add(new Feature("http://jabber.org/protocol/muc"));
        features.add(new Feature("http://jabber.org/protocol/caps"));

        DataForm dataForm1 = new DataForm(DataForm.Type.FORM);
        dataForm1.getFields().add(new DataForm.Field(DataForm.Field.Type.BOOLEAN, "ccc"));
        dataForm1.getFields().add(new DataForm.Field(DataForm.Field.Type.HIDDEN, "FORM_TYPE"));

        DataForm dataForm2 = new DataForm(DataForm.Type.FORM);
        dataForm2.getFields().add(new DataForm.Field(DataForm.Field.Type.BOOLEAN, "bbb"));

        DataForm dataForm3 = new DataForm(DataForm.Type.FORM);
        dataForm3.getFields().add(new DataForm.Field(DataForm.Field.Type.HIDDEN, "FORM_TYPE"));
        dataForm3.getFields().add(new DataForm.Field(DataForm.Field.Type.BOOLEAN, "aaa"));

        InfoDiscovery infoDiscovery = new InfoDiscovery();
        infoDiscovery.getFeatures().addAll(features);
        infoDiscovery.getIdentities().addAll(identities);
        infoDiscovery.getExtensions().add(dataForm1);
View Full Code Here

                "             label='Associated pubsub node'>\n" +
                "        <value>xmpp:pubsub.shakespeare.lit?;node=the-coven-node</value>\n" +
                "      </field>\n" +
                "    </x>\n";

        DataForm dataForm = unmarshal(xml, DataForm.class);

        RoomInfoForm roomInfoForm = new RoomInfoForm(dataForm);

        Assert.assertEquals(roomInfoForm.getDescription(), "The place for all good witches!");
        Assert.assertTrue(roomInfoForm.isChangeSubjectAllowed());
View Full Code Here

        Assert.assertEquals(roomInfoForm.getMaxHistoryMessages(), 50);
    }

    @Test
    public void testEmptyDataForm() throws MalformedURLException {
        DataForm dataForm = new DataForm(DataForm.Type.SUBMIT);
        RoomInfoForm roomInfoForm = new RoomInfoForm(dataForm);
        roomInfoForm.setMaxHistoryMessages(50);
        DataForm.Field fieldHistoryFetch = dataForm.findField("muc#maxhistoryfetch");
        Assert.assertNotNull(fieldHistoryFetch);
        Assert.assertEquals(fieldHistoryFetch.getValues().size(), 1);
        Assert.assertEquals(fieldHistoryFetch.getValues().get(0), "50");
        Assert.assertEquals(roomInfoForm.getMaxHistoryMessages(), 50);

        roomInfoForm.setContacts(Arrays.asList(Jid.valueOf("test1@domain"), Jid.valueOf("test2@domain")));
        DataForm.Field fieldAdministrators = dataForm.findField("muc#roominfo_contactjid");
        Assert.assertNotNull(fieldAdministrators);
        Assert.assertEquals(fieldAdministrators.getValues().size(), 2);
        Assert.assertEquals(fieldAdministrators.getValues().get(0), "test1@domain");
        Assert.assertEquals(fieldAdministrators.getValues().get(1), "test2@domain");
        Assert.assertEquals(roomInfoForm.getContacts(), Arrays.asList(Jid.valueOf("test1@domain"), Jid.valueOf("test2@domain")));

        roomInfoForm.setDescription("Description");
        DataForm.Field fieldDescription = dataForm.findField("muc#roominfo_description");
        Assert.assertNotNull(fieldDescription);
        Assert.assertEquals(fieldDescription.getValues().size(), 1);
        Assert.assertEquals(fieldDescription.getValues().get(0), "Description");
        Assert.assertEquals(roomInfoForm.getDescription(), "Description");

        roomInfoForm.setLanguage("en");
        DataForm.Field fieldLanguage = dataForm.findField("muc#roominfo_lang");
        Assert.assertNotNull(fieldLanguage);
        Assert.assertEquals(fieldLanguage.getValues().size(), 1);
        Assert.assertEquals(fieldLanguage.getValues().get(0), "en");
        Assert.assertEquals(roomInfoForm.getLanguage(), "en");

        roomInfoForm.setLdapGroup("ldap");
        DataForm.Field fieldLdap = dataForm.findField("muc#roominfo_ldapgroup");
        Assert.assertNotNull(fieldLdap);
        Assert.assertEquals(fieldLdap.getValues().size(), 1);
        Assert.assertEquals(fieldLdap.getValues().get(0), "ldap");
        Assert.assertEquals(roomInfoForm.getLdapGroup(), "ldap");

        roomInfoForm.setLogs(new URL("http://www.example.net"));
        DataForm.Field fieldLogs = dataForm.findField("muc#roominfo_logs");
        Assert.assertNotNull(fieldLogs);
        Assert.assertEquals(fieldLogs.getValues().size(), 1);
        Assert.assertEquals(fieldLogs.getValues().get(0), "http://www.example.net");
        Assert.assertEquals(roomInfoForm.getLogs(), new URL("http://www.example.net"));

        roomInfoForm.setCurrentNumberOfOccupants(4);
        DataForm.Field fieldOccupants = dataForm.findField("muc#roominfo_occupants");
        Assert.assertNotNull(fieldOccupants);
        Assert.assertEquals(fieldOccupants.getValues().size(), 1);
        Assert.assertEquals(fieldOccupants.getValues().get(0), "4");
        Assert.assertEquals(roomInfoForm.getCurrentNumberOfOccupants(), 4);

        roomInfoForm.setSubject("test");
        DataForm.Field fieldSubject = dataForm.findField("muc#roominfo_subject");
        Assert.assertNotNull(fieldSubject);
        Assert.assertEquals(fieldSubject.getValues().size(), 1);
        Assert.assertEquals(fieldSubject.getValues().get(0), "test");
        Assert.assertEquals(roomInfoForm.getSubject(), "test");

        roomInfoForm.setChangeSubjectAllowed(true);
        DataForm.Field fieldMembersOnly = dataForm.findField("muc#roominfo_subjectmod");
        Assert.assertNotNull(fieldMembersOnly);
        Assert.assertEquals(fieldMembersOnly.getValues().size(), 1);
        Assert.assertEquals(fieldMembersOnly.getValues().get(0), "1");
        Assert.assertTrue(roomInfoForm.isChangeSubjectAllowed());
    }
View Full Code Here

TOP

Related Classes of rocks.xmpp.extensions.data.model.DataForm$Item

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.