@Test
public void testUpdateSecurityRules() throws Exception {

	long resourceId = createResource("name1", "description1", "MAP");
	
	List<SecurityRule> writtenRules = resourceService.getSecurityRules(resourceId);
	assertEquals(0, writtenRules.size());
	
	List<SecurityRule> rules = new ArrayList<SecurityRule>();
	
ng userId = createUser("user1", Role.USER, "password");
er user = new User();
er.setId(userId);
ng groupId = createGroup("group1");
erGroup group = new UserGroup();
oup.setId(groupId);
ng otherGroupId = createGroup("group2");
erGroup othergroup = new UserGroup();
hergroup.setId(otherGroupId);
	SecurityRule rule = new SecurityRule();
	rule.setUser(user);
	rule.setCanRead(true);
	rules.add(rule);
	
	rule = new SecurityRule();
	rule.setCanRead(true);
	rule.setCanWrite(true);
	rule.setGroup(group);
	rules.add(rule);
	
	resourceService.updateSecurityRules(resourceId, rules);
	
	writtenRules = resourceService.getSecurityRules(resourceId);
	assertEquals(2, writtenRules.size());
	
	rules.clear();
	
	rule = new SecurityRule();
	rule.setUser(user);
	rule.setCanRead(true);
	rules.add(rule);
	
	rule = new SecurityRule();
	rule.setCanRead(true);
	rule.setCanWrite(true);
	rule.setGroup(group);
	rules.add(rule);
	rule = new SecurityRule();
	rule.setCanRead(true);
	rule.setCanWrite(true);
	rule.setGroup(othergroup);
	rules.add(rule);
	
	resourceService.updateSecurityRules(resourceId, rules);
	
	writtenRules = resourceService.getSecurityRules(resourceId);
	assertEquals(3, writtenRules.size());
}