Search in sources :

Example 1 with CPlainAttr

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);
}
Also used : CPlainAttr(org.apache.syncope.core.persistence.api.entity.conf.CPlainAttr) Test(org.junit.jupiter.api.Test) AbstractTest(org.apache.syncope.core.persistence.jpa.AbstractTest)

Example 2 with CPlainAttr

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;
    }
}
Also used : SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) CPlainAttr(org.apache.syncope.core.persistence.api.entity.conf.CPlainAttr) NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) PlainSchema(org.apache.syncope.core.persistence.api.entity.PlainSchema)

Example 3 with CPlainAttr

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());
}
Also used : CPlainAttr(org.apache.syncope.core.persistence.api.entity.conf.CPlainAttr) PlainSchema(org.apache.syncope.core.persistence.api.entity.PlainSchema) Test(org.junit.jupiter.api.Test) AbstractTest(org.apache.syncope.core.persistence.jpa.AbstractTest)

Aggregations

CPlainAttr (org.apache.syncope.core.persistence.api.entity.conf.CPlainAttr)3 PlainSchema (org.apache.syncope.core.persistence.api.entity.PlainSchema)2 AbstractTest (org.apache.syncope.core.persistence.jpa.AbstractTest)2 Test (org.junit.jupiter.api.Test)2 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)1 NotFoundException (org.apache.syncope.core.persistence.api.dao.NotFoundException)1