}
@Test
public void update() {
// get global password
PasswordPolicyTO globalPolicy = restTemplate.getForObject(BASE_URL + "policy/read/{id}",
PasswordPolicyTO.class, 2L);
PasswordPolicyTO policy = new PasswordPolicyTO();
policy.setDescription("A simple password policy");
policy.setSpecification(globalPolicy.getSpecification());
// create a new password policy using global password as a template
policy = restTemplate.postForObject(BASE_URL + "policy/password/create", policy, PasswordPolicyTO.class);
// read new password policy
policy = restTemplate.getForObject(BASE_URL + "policy/read/{id}", PasswordPolicyTO.class, policy.getId());
assertNotNull("find to update did not work", policy);
PasswordPolicySpec policySpec = ((PasswordPolicyTO) policy).getSpecification();
policySpec.setMaxLength(22);
policy.setSpecification(policySpec);
// update new password policy
policy = restTemplate.postForObject(BASE_URL + "policy/password/update", policy, PasswordPolicyTO.class);
assertNotNull(policy);
assertEquals(PolicyType.PASSWORD, policy.getType());
assertEquals(22, ((PasswordPolicyTO) policy).getSpecification().getMaxLength());
assertEquals(8, ((PasswordPolicyTO) policy).getSpecification().getMinLength());
}