}
@Test
public void update() {
// get global password
PasswordPolicyTO globalPolicy = policyService.read(PolicyType.PASSWORD, 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
Response response = createPolicy(policyService, PolicyType.PASSWORD, policy);
policy = getObject(response, PasswordPolicyTO.class, policyService);
// read new password policy
policy = policyService.read(PolicyType.PASSWORD, policy.getId());
assertNotNull("find to update did not work", policy);
PasswordPolicySpec policySpec = policy.getSpecification();
policySpec.setMaxLength(22);
policy.setSpecification(policySpec);
// update new password policy
policyService.update(PolicyType.PASSWORD, policy.getId(), policy);
policy = policyService.read(PolicyType.PASSWORD, policy.getId());
assertNotNull(policy);
assertEquals(PolicyType.PASSWORD, policy.getType());
assertEquals(22, policy.getSpecification().getMaxLength());
assertEquals(8, policy.getSpecification().getMinLength());
}