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());
}