@Test public void testGetXmlOneUserNoRoles() { DataSourceAclModel model = new DataSourceAclModel(); model.addUser("testUser"); String xml = model.toXml(); assertTrue( xml.contains( " <aces> <recipient>testUser</recipient> <recipientType>0</recipientType>" + " <permissions>4</permissions> <modifiable>false</modifiable> </aces>")); }
@Test public void testGetXmlMultipleRolesNoUsers() { DataSourceAclModel model = new DataSourceAclModel(); model.addRole("testRole"); model.addRole("testRole2"); String xml = model.toXml(); assertTrue( xml.contains( " <aces> <recipient>testRole</recipient> <recipientType>1</recipientType>" + " <permissions>4</permissions> <modifiable>false</modifiable> </aces>")); assertTrue( xml.contains( " <aces> <recipient>testRole2</recipient> <recipientType>1</recipientType>" + " <permissions>4</permissions> <modifiable>false</modifiable> </aces>")); }
@Test public void testGetXmlNoUsersOrRoles() { DataSourceAclModel model = new DataSourceAclModel(); assertNull(model.toXml()); }
@Test public void testCreateAndAddUserRoles() { DataSourceAclModel model = new DataSourceAclModel(); assertNull(model.getRoles()); assertNull(model.getUsers()); model.addRole("testRole"); model.addUser("testUser"); assertEquals("testRole", model.getRoles().get(0)); assertEquals("testUser", model.getUsers().get(0)); model.setUsers(Arrays.asList("otherTestUser")); model.setRoles(Arrays.asList("otherTestRole")); assertEquals("otherTestRole", model.getRoles().get(0)); assertEquals("otherTestUser", model.getUsers().get(0)); }