use of org.apache.syncope.core.persistence.api.entity.conf.CPlainAttr in project syncope by apache.
the class ConfTest method update.
@Test
public void update() {
CPlainAttr expireTime = confDAO.find("token.expireTime").get();
assertNotNull(expireTime);
long value = expireTime.getValues().get(0).getLongValue();
value++;
CPlainAttr attr = entityFactory.newEntity(CPlainAttr.class);
attr.setSchema(plainSchemaDAO.find("token.expireTime"));
add(attr, String.valueOf(value));
confDAO.save(expireTime);
confDAO.flush();
CPlainAttr actual = confDAO.find("token.expireTime").get();
assertEquals(expireTime, actual);
}
use of org.apache.syncope.core.persistence.api.entity.conf.CPlainAttr in project syncope by apache.
the class ConfigurationDataBinderImpl method getAttr.
@Override
public CPlainAttr getAttr(final AttrTO attrTO) {
PlainSchema schema = getPlainSchema(attrTO.getSchema());
if (schema == null) {
throw new NotFoundException("Conf schema " + attrTO.getSchema());
} else {
SyncopeClientException invalidValues = SyncopeClientException.build(ClientExceptionType.InvalidValues);
CPlainAttr attr = entityFactory.newEntity(CPlainAttr.class);
attr.setSchema(schema);
fillAttr(attrTO.getValues(), schema, attr, invalidValues);
if (!invalidValues.isEmpty()) {
throw invalidValues;
}
return attr;
}
}
use of org.apache.syncope.core.persistence.api.entity.conf.CPlainAttr in project syncope by apache.
the class ConfTest method setAndDelete.
@Test
public void setAndDelete() {
// 1. create CSChema
PlainSchema useless = entityFactory.newEntity(PlainSchema.class);
useless.setKey("useless");
useless.setType(AttrSchemaType.Date);
useless.setConversionPattern("yyyy-MM-dd");
useless = plainSchemaDAO.save(useless);
// 2. create conf
CPlainAttr newConf = entityFactory.newEntity(CPlainAttr.class);
newConf.setOwner(confDAO.get());
newConf.setSchema(useless);
add(newConf, "2014-06-20");
confDAO.save(newConf);
Optional<? extends CPlainAttr> actual = confDAO.find("useless");
assertEquals(actual.get().getValuesAsStrings(), newConf.getValuesAsStrings());
// 3. update conf
newConf.getValues().clear();
add(newConf, "2014-06-20");
confDAO.save(newConf);
actual = confDAO.find("useless");
assertEquals(actual.get().getValuesAsStrings(), newConf.getValuesAsStrings());
// 4. delete conf
confDAO.delete("useless");
assertFalse(confDAO.find("useless").isPresent());
}
Aggregations