super.resetRestTemplate();
}
@Test
public void update() {
RoleTO roleTO = new RoleTO();
roleTO.setName("latestRole");
roleTO.setParent(8L);
// verify inheritance password and account policies
roleTO.setInheritAccountPolicy(false);
// not inherited so setter execution shouldn't be ignored
roleTO.setAccountPolicy(6L);
roleTO.setInheritPasswordPolicy(true);
// inherited so setter execution should be ignored
roleTO.setPasswordPolicy(2L);
AttributeTO icon = new AttributeTO();
icon.setSchema("icon");
icon.addValue("anIcon");
roleTO.addAttribute(icon);
roleTO = restTemplate.postForObject(BASE_URL + "role/create", roleTO, RoleTO.class);
assertEquals(1, roleTO.getAttributes().size());
assertNotNull(roleTO.getAccountPolicy());
assertEquals(Long.valueOf(6), roleTO.getAccountPolicy());
assertNotNull(roleTO.getPasswordPolicy());
assertEquals(Long.valueOf(4), roleTO.getPasswordPolicy());
AttributeMod attributeMod = new AttributeMod();
attributeMod.setSchema("show");
attributeMod.addValueToBeAdded("FALSE");
RoleMod roleMod = new RoleMod();
roleMod.setId(roleTO.getId());
roleMod.setName("finalRole");
roleMod.addAttributeToBeUpdated(attributeMod);
// change password policy inheritance
roleMod.setInheritPasswordPolicy(Boolean.FALSE);
roleTO = restTemplate.postForObject(BASE_URL + "role/update", roleMod, RoleTO.class);
assertEquals("finalRole", roleTO.getName());
assertEquals(2, roleTO.getAttributes().size());
// changes ignored because not requested (null ReferenceMod)
assertNotNull(roleTO.getAccountPolicy());
assertEquals(6L, (long) roleTO.getAccountPolicy());
// password policy null because not inherited
assertNull(roleTO.getPasswordPolicy());
}