@Test
public void saveWithEncrypted() throws Exception {
SyncopeUser user = userDAO.find(1L);
final USchema obscureSchema = userSchemaDAO.find("obscure", USchema.class);
assertNotNull(obscureSchema);
assertNotNull(obscureSchema.getSecretKey());
assertNotNull(obscureSchema.getCipherAlgorithm());
UAttr attribute = new UAttr();
attribute.setSchema(obscureSchema);
attribute.addValue("testvalue", AttributableUtil.getInstance(AttributableType.USER));
attribute.setOwner(user);
user.addAttr(attribute);
userDAO.save(user);
UAttr obscure = user.getAttr("obscure");
assertNotNull(obscure);
assertEquals(1, obscure.getValues().size());
assertEquals(Encryptor.getInstance(obscureSchema.getSecretKey()).
encode("testvalue", obscureSchema.getCipherAlgorithm()), obscure.getValues().get(0).getStringValue());
}