Search in sources :

Example 36 with AttrTO

use of org.apache.syncope.common.lib.to.AttrTO in project syncope by apache.

the class ConfigurationLogic method get.

@PreAuthorize("hasRole('" + StandardEntitlement.CONFIGURATION_GET + "')")
@Transactional(readOnly = true)
public AttrTO get(final String schema) {
    AttrTO result;
    Optional<? extends CPlainAttr> conf = confDAO.find(schema);
    if (conf.isPresent()) {
        result = binder.getAttrTO(conf.get());
    } else {
        PlainSchema plainSchema = plainSchemaDAO.find(schema);
        if (plainSchema == null) {
            throw new NotFoundException("Configuration schema " + schema);
        }
        result = new AttrTO();
        result.setSchema(schema);
    }
    return result;
}
Also used : AttrTO(org.apache.syncope.common.lib.to.AttrTO) NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) PlainSchema(org.apache.syncope.core.persistence.api.entity.PlainSchema) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) Transactional(org.springframework.transaction.annotation.Transactional)

Example 37 with AttrTO

use of org.apache.syncope.common.lib.to.AttrTO in project syncope by apache.

the class AnyObjectITCase method readAttrs.

@Test
public void readAttrs() {
    AnyObjectTO anyObjectTO = getSampleTO("readAttrs");
    anyObjectTO = createAnyObject(anyObjectTO).getEntity();
    assertNotNull(anyObjectTO);
    Set<AttrTO> attrs = anyObjectService.read(anyObjectTO.getKey(), SchemaType.PLAIN);
    assertEquals(anyObjectTO.getPlainAttrs(), attrs);
    AttrTO location = anyObjectService.read(anyObjectTO.getKey(), SchemaType.PLAIN, "location");
    assertEquals(anyObjectTO.getPlainAttr("location").get(), location);
}
Also used : AnyObjectTO(org.apache.syncope.common.lib.to.AnyObjectTO) AttrTO(org.apache.syncope.common.lib.to.AttrTO) Test(org.junit.jupiter.api.Test)

Example 38 with AttrTO

use of org.apache.syncope.common.lib.to.AttrTO in project syncope by apache.

the class AnyObjectITCase method updateAttr.

@Test
public void updateAttr() {
    AnyObjectTO anyObjectTO = getSampleTO("updateAttr");
    anyObjectTO = createAnyObject(anyObjectTO).getEntity();
    assertNotNull(anyObjectTO);
    AttrTO updated = attrTO("location", "newlocation");
    anyObjectService.update(anyObjectTO.getKey(), SchemaType.PLAIN, updated);
    AttrTO location = anyObjectService.read(anyObjectTO.getKey(), SchemaType.PLAIN, "location");
    // need to remove schemaInfo which is included when reading the any object
    location.setSchemaInfo(null);
    assertEquals(updated, location);
}
Also used : AnyObjectTO(org.apache.syncope.common.lib.to.AnyObjectTO) AttrTO(org.apache.syncope.common.lib.to.AttrTO) Test(org.junit.jupiter.api.Test)

Example 39 with AttrTO

use of org.apache.syncope.common.lib.to.AttrTO in project syncope by apache.

the class ConfigurationITCase method create.

@Test
public void create() {
    PlainSchemaTO testKey = new PlainSchemaTO();
    testKey.setKey("testKey" + getUUIDString());
    testKey.setType(AttrSchemaType.String);
    createSchema(SchemaType.PLAIN, testKey);
    AttrTO conf = new AttrTO.Builder().schema(testKey.getKey()).value("testValue").build();
    configurationService.set(conf);
    AttrTO actual = configurationService.get(conf.getSchema());
    actual.setSchemaInfo(null);
    assertEquals(actual, conf);
}
Also used : PlainSchemaTO(org.apache.syncope.common.lib.to.PlainSchemaTO) AttrTO(org.apache.syncope.common.lib.to.AttrTO) Test(org.junit.jupiter.api.Test)

Example 40 with AttrTO

use of org.apache.syncope.common.lib.to.AttrTO in project syncope by apache.

the class ConfigurationITCase method list.

@Test
public void list() {
    List<AttrTO> wholeConf = configurationService.list();
    assertNotNull(wholeConf);
    for (AttrTO conf : wholeConf) {
        assertNotNull(conf);
    }
}
Also used : AttrTO(org.apache.syncope.common.lib.to.AttrTO) Test(org.junit.jupiter.api.Test)

Aggregations

AttrTO (org.apache.syncope.common.lib.to.AttrTO)70 Test (org.junit.jupiter.api.Test)31 UserTO (org.apache.syncope.common.lib.to.UserTO)30 MembershipTO (org.apache.syncope.common.lib.to.MembershipTO)19 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)17 Map (java.util.Map)15 GroupTO (org.apache.syncope.common.lib.to.GroupTO)15 ArrayList (java.util.ArrayList)14 UserPatch (org.apache.syncope.common.lib.patch.UserPatch)14 List (java.util.List)13 Collections (java.util.Collections)11 StringUtils (org.apache.commons.lang3.StringUtils)11 AnyTO (org.apache.syncope.common.lib.to.AnyTO)10 Optional (java.util.Optional)9 Set (java.util.Set)9 Autowired (org.springframework.beans.factory.annotation.Autowired)9 HashMap (java.util.HashMap)8 Collectors (java.util.stream.Collectors)8 EntityTOUtils (org.apache.syncope.common.lib.EntityTOUtils)8 AnyObjectTO (org.apache.syncope.common.lib.to.AnyObjectTO)8