Assert.assertEquals(roomConfigurationForm.getAdministrators().get(1), Jid.valueOf("hecate@shakespeare.lit"));
}
@Test
public void testEmptyDataForm() {
DataForm dataForm = new DataForm(DataForm.Type.SUBMIT);
RoomConfigurationForm roomConfigurationForm = new RoomConfigurationForm(dataForm);
roomConfigurationForm.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(roomConfigurationForm.getMaxHistoryMessages(), 50);
roomConfigurationForm.setAllowedRolesToSendPrivateMessages(EnumSet.of(Role.MODERATOR, Role.PARTICIPANT));
DataForm.Field fieldAllowPM = dataForm.findField("muc#roomconfig_allowpm");
Assert.assertNotNull(fieldAllowPM);
Assert.assertEquals(fieldAllowPM.getValues().size(), 1);
Assert.assertEquals(fieldAllowPM.getValues().get(0), "anyone");
Assert.assertEquals(roomConfigurationForm.getAllowedRolesToSendPrivateMessages(), EnumSet.of(Role.MODERATOR, Role.PARTICIPANT));
roomConfigurationForm.setAllowInvites(true);
DataForm.Field fieldAllowInvites = dataForm.findField("muc#roomconfig_allowinvites");
Assert.assertNotNull(fieldAllowInvites);
Assert.assertEquals(fieldAllowInvites.getValues().size(), 1);
Assert.assertEquals(fieldAllowInvites.getValues().get(0), "1");
Assert.assertTrue(roomConfigurationForm.isAllowInvites());
roomConfigurationForm.setChangeSubjectAllowed(true);
DataForm.Field fieldAllowChangeSubject = dataForm.findField("muc#roomconfig_changesubject");
Assert.assertNotNull(fieldAllowChangeSubject);
Assert.assertEquals(fieldAllowChangeSubject.getValues().size(), 1);
Assert.assertEquals(fieldAllowChangeSubject.getValues().get(0), "1");
Assert.assertTrue(roomConfigurationForm.isAllowInvites());
roomConfigurationForm.setPublicLoggingEnabled(true);
DataForm.Field fieldEnableLogging = dataForm.findField("muc#roomconfig_enablelogging");
Assert.assertNotNull(fieldEnableLogging);
Assert.assertEquals(fieldEnableLogging.getValues().size(), 1);
Assert.assertEquals(fieldEnableLogging.getValues().get(0), "1");
Assert.assertTrue(roomConfigurationForm.isAllowInvites());
roomConfigurationForm.setRolesWhichMayRetrieveMemberList(EnumSet.of(Role.MODERATOR, Role.PARTICIPANT));
DataForm.Field fieldGetMemberList = dataForm.findField("muc#roomconfig_getmemberlist");
Assert.assertNotNull(fieldGetMemberList);
Assert.assertEquals(fieldGetMemberList.getValues().size(), 2);
Assert.assertEquals(fieldGetMemberList.getValues().get(0), "moderator");
Assert.assertEquals(fieldGetMemberList.getValues().get(1), "participant");
Assert.assertEquals(roomConfigurationForm.getRolesWhichMayRetrieveMemberList(), EnumSet.of(Role.MODERATOR, Role.PARTICIPANT));
roomConfigurationForm.setLanguage("en");
DataForm.Field fieldLanguage = dataForm.findField("muc#roomconfig_lang");
Assert.assertNotNull(fieldLanguage);
Assert.assertEquals(fieldLanguage.getValues().size(), 1);
Assert.assertEquals(fieldLanguage.getValues().get(0), "en");
Assert.assertEquals(roomConfigurationForm.getLanguage(), "en");
roomConfigurationForm.setPubSubNode(URI.create("http://test"));
DataForm.Field fieldPubsub = dataForm.findField("muc#roomconfig_pubsub");
Assert.assertNotNull(fieldPubsub);
Assert.assertEquals(fieldPubsub.getValues().size(), 1);
Assert.assertEquals(fieldPubsub.getValues().get(0), "http://test");
Assert.assertEquals(roomConfigurationForm.getPubSubNode(), URI.create("http://test"));
roomConfigurationForm.setMaxOccupants(30);
DataForm.Field fieldMaxOccupants = dataForm.findField("muc#roomconfig_maxusers");
Assert.assertNotNull(fieldMaxOccupants);
Assert.assertEquals(fieldMaxOccupants.getValues().size(), 1);
Assert.assertEquals(fieldMaxOccupants.getValues().get(0), "30");
Assert.assertEquals(roomConfigurationForm.getMaxOccupants(), 30);
roomConfigurationForm.setMembersOnly(true);
DataForm.Field fieldMembersOnly = dataForm.findField("muc#roomconfig_membersonly");
Assert.assertNotNull(fieldMembersOnly);
Assert.assertEquals(fieldMembersOnly.getValues().size(), 1);
Assert.assertEquals(fieldMembersOnly.getValues().get(0), "1");
Assert.assertTrue(roomConfigurationForm.isMembersOnly());
roomConfigurationForm.setModerated(true);
DataForm.Field fieldModerated = dataForm.findField("muc#roomconfig_moderatedroom");
Assert.assertNotNull(fieldModerated);
Assert.assertEquals(fieldModerated.getValues().size(), 1);
Assert.assertEquals(fieldModerated.getValues().get(0), "1");
Assert.assertTrue(roomConfigurationForm.isMembersOnly());
roomConfigurationForm.setPasswordProtected(true);
DataForm.Field fieldPasswordProtected = dataForm.findField("muc#roomconfig_passwordprotectedroom");
Assert.assertNotNull(fieldPasswordProtected);
Assert.assertEquals(fieldPasswordProtected.getValues().size(), 1);
Assert.assertEquals(fieldPasswordProtected.getValues().get(0), "1");
Assert.assertTrue(roomConfigurationForm.isPasswordProtected());
roomConfigurationForm.setPersistentRoom(true);
DataForm.Field fieldPersistentRoom = dataForm.findField("muc#roomconfig_persistentroom");
Assert.assertNotNull(fieldPersistentRoom);
Assert.assertEquals(fieldPersistentRoom.getValues().size(), 1);
Assert.assertEquals(fieldPersistentRoom.getValues().get(0), "1");
Assert.assertTrue(roomConfigurationForm.isPersistentRoom());
roomConfigurationForm.setRolesForWhichPresenceIsBroadcast(EnumSet.of(Role.MODERATOR, Role.PARTICIPANT));
DataForm.Field fieldPresenceBroadcast = dataForm.findField("muc#roomconfig_presencebroadcast");
Assert.assertNotNull(fieldPresenceBroadcast);
Assert.assertEquals(fieldPresenceBroadcast.getValues().size(), 2);
Assert.assertEquals(fieldPresenceBroadcast.getValues().get(0), "moderator");
Assert.assertEquals(fieldPresenceBroadcast.getValues().get(1), "participant");
Assert.assertEquals(roomConfigurationForm.getRolesForWhichPresenceIsBroadcast(), EnumSet.of(Role.MODERATOR, Role.PARTICIPANT));
roomConfigurationForm.setPublicRoom(true);
DataForm.Field fieldPublicRoom = dataForm.findField("muc#roomconfig_publicroom");
Assert.assertNotNull(fieldPublicRoom);
Assert.assertEquals(fieldPublicRoom.getValues().size(), 1);
Assert.assertEquals(fieldPublicRoom.getValues().get(0), "1");
Assert.assertTrue(roomConfigurationForm.isPublicRoom());
roomConfigurationForm.setAdministrators(Arrays.asList(Jid.valueOf("test1@domain"), Jid.valueOf("test2@domain")));
DataForm.Field fieldAdministrators = dataForm.findField("muc#roomconfig_roomadmins");
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(roomConfigurationForm.getAdministrators(), Arrays.asList(Jid.valueOf("test1@domain"), Jid.valueOf("test2@domain")));
roomConfigurationForm.setRoomDescription("Desc");
DataForm.Field fieldDesc = dataForm.findField("muc#roomconfig_roomdesc");
Assert.assertNotNull(fieldDesc);
Assert.assertEquals(fieldDesc.getValues().size(), 1);
Assert.assertEquals(fieldDesc.getValues().get(0), "Desc");
Assert.assertEquals(roomConfigurationForm.getRoomDescription(), "Desc");
roomConfigurationForm.setRoomName("Name");
DataForm.Field fieldRoomName = dataForm.findField("muc#roomconfig_roomname");
Assert.assertNotNull(fieldRoomName);
Assert.assertEquals(fieldRoomName.getValues().size(), 1);
Assert.assertEquals(fieldRoomName.getValues().get(0), "Name");
Assert.assertEquals(roomConfigurationForm.getRoomName(), "Name");
roomConfigurationForm.setOwners(Arrays.asList(Jid.valueOf("test3@domain"), Jid.valueOf("test4@domain")));
DataForm.Field fieldOwners = dataForm.findField("muc#roomconfig_roomowners");
Assert.assertNotNull(fieldOwners);
Assert.assertEquals(fieldOwners.getValues().size(), 2);
Assert.assertEquals(fieldOwners.getValues().get(0), "test3@domain");
Assert.assertEquals(fieldOwners.getValues().get(1), "test4@domain");
Assert.assertEquals(roomConfigurationForm.getOwners(), Arrays.asList(Jid.valueOf("test3@domain"), Jid.valueOf("test4@domain")));
roomConfigurationForm.setPassword("Pass");
DataForm.Field fieldRoomPassword = dataForm.findField("muc#roomconfig_roomsecret");
Assert.assertNotNull(fieldRoomPassword);
Assert.assertEquals(fieldRoomPassword.getValues().size(), 1);
Assert.assertEquals(fieldRoomPassword.getValues().get(0), "Pass");
Assert.assertEquals(roomConfigurationForm.getPassword(), "Pass");
roomConfigurationForm.setRolesWhichMayDiscoverRealJids(EnumSet.of(Role.MODERATOR));
DataForm.Field fieldWhois = dataForm.findField("muc#roomconfig_whois");
Assert.assertNotNull(fieldWhois);
Assert.assertEquals(fieldWhois.getValues().size(), 1);
Assert.assertEquals(fieldWhois.getValues().get(0), "moderators");
Assert.assertEquals(roomConfigurationForm.getRolesWhichMayDiscoverRealJids(), EnumSet.of(Role.MODERATOR));