Examples of UAttr


Examples of org.apache.syncope.core.persistence.beans.user.UAttr

        SyncopeUser user = userDAO.find(1L);

        USchema emailSchema = userSchemaDAO.find("email", USchema.class);
        assertNotNull(emailSchema);

        UAttr attribute = new UAttr();
        attribute.setSchema(emailSchema);
        attribute.setOwner(user);

        Exception thrown = null;
        try {
            attribute.addValue("john.doe@gmail.com", AttributableUtil.getInstance(AttributableType.USER));
            attribute.addValue("mario.rossi@gmail.com", AttributableUtil.getInstance(AttributableType.USER));
        } catch (ValidationException e) {
            LOG.error("Unexpected exception", e);
            thrown = e;
        }
        assertNull("no validation exception expected here ", thrown);

        try {
            attribute.addValue("http://www.apache.org", AttributableUtil.getInstance(AttributableType.USER));
        } catch (ValidationException e) {
            thrown = e;
        }
        assertNotNull("validation exception expected here ", thrown);

        InvalidEntityException iee = null;
        try {
            attribute = attrDAO.save(attribute);
        } catch (InvalidEntityException e) {
            iee = e;
        }
        assertNull(iee);

        UAttr actual = attrDAO.find(attribute.getId(), UAttr.class);
        assertNotNull("expected save to work", actual);
        assertEquals(attribute, actual);
    }
View Full Code Here

Examples of org.apache.syncope.core.persistence.beans.user.UAttr

        USchema gender = userSchemaDAO.find("gender", USchema.class);
        assertNotNull(gender);
        assertNotNull(gender.getType());
        assertNotNull(gender.getEnumerationValues());

        UAttr attribute = new UAttr();
        attribute.setSchema(gender);
        attribute.setOwner(user);
        user.addAttribute(attribute);

        Exception thrown = null;

        try {
            attribute.addValue("A", AttributableUtil.getInstance(AttributableType.USER));
        } catch (ValidationException e) {
            thrown = e;
        }
        assertNotNull("validation exception expected here ", thrown);

        attribute.addValue("M", AttributableUtil.getInstance(AttributableType.USER));

        InvalidEntityException iee = null;
        try {
            attribute = attrDAO.save(attribute);
        } catch (InvalidEntityException e) {
            iee = e;
        }
        assertNull(iee);

        UAttr actual = attrDAO.find(attribute.getId(), UAttr.class);
        assertNotNull("expected save to work", actual);
        assertEquals(attribute, actual);
        assertEquals(actual.getSchema(), gender);
        assertEquals(actual.getValues().size(), 1);
    }
View Full Code Here

Examples of org.apache.syncope.core.persistence.beans.user.UAttr

        assertNotNull(emailSchema);

        final USchema fullnameSchema = userSchemaDAO.find("fullname", USchema.class);
        assertNotNull(fullnameSchema);

        UAttr attribute = new UAttr();
        attribute.setSchema(emailSchema);

        UAttrUniqueValue uauv = new UAttrUniqueValue();
        uauv.setAttribute(attribute);
        uauv.setSchema(fullnameSchema);
        uauv.setStringValue("a value");

        attribute.setUniqueValue(uauv);

        InvalidEntityException iee = null;
        try {
            attrDAO.save(attribute);
        } catch (InvalidEntityException e) {
View Full Code Here

Examples of org.apache.syncope.core.persistence.beans.user.UAttr

        assertTrue(iee.hasViolation(EntityViolationType.InvalidUSchema));
    }

    @Test
    public void delete() {
        UAttr attribute = attrDAO.find(200L, UAttr.class);
        String attrSchemaName = attribute.getSchema().getName();

        attrDAO.delete(attribute.getId(), UAttr.class);

        USchema schema = userSchemaDAO.find(attrSchemaName, USchema.class);
        assertNotNull("user attribute schema deleted when deleting values", schema);
    }
View Full Code Here

Examples of org.apache.syncope.core.persistence.beans.user.UAttr

        switch (recipientAttrType) {
            case Username:
                email = user.getUsername();
                break;
            case UserSchema:
                UAttr attr = user.getAttribute(recipientAttrName);
                email = attr == null || attr.getValuesAsStrings().isEmpty() ? null : attr.getValuesAsStrings().get(0);
                break;
            case UserVirtualSchema:
                UVirAttr virAttr = user.getVirtualAttribute(recipientAttrName);
                email = virAttr == null || virAttr.getValues().isEmpty() ? null : virAttr.getValues().get(0);
                break;
View Full Code Here

Examples of org.apache.syncope.core.persistence.beans.user.UAttr

        switch (recipientAttrType) {
            case Username:
                email = user.getUsername();
                break;
            case UserSchema:
                UAttr attr = user.getAttribute(recipientAttrName);
                email = attr == null || attr.getValuesAsStrings().isEmpty() ? null : attr.getValuesAsStrings().get(0);
                break;
            case UserVirtualSchema:
                UVirAttr virAttr = user.getVirtualAttribute(recipientAttrName);
                email = virAttr == null || virAttr.getValues().isEmpty() ? null : virAttr.getValues().get(0);
                break;
View Full Code Here

Examples of org.apache.syncope.core.persistence.beans.user.UAttr

            case Username:
                email = user.getUsername();
                break;

            case UserSchema:
                UAttr attr = user.getAttr(recipientAttrName);
                if (attr != null && !attr.getValuesAsStrings().isEmpty()) {
                    email = attr.getValuesAsStrings().get(0);
                }
                break;

            case UserVirtualSchema:
                UVirAttr virAttr = user.getVirAttr(recipientAttrName);
View Full Code Here

Examples of org.apache.syncope.core.persistence.beans.user.UAttr

        attrValueDAO.flush();

        assertNull(attrValueDAO.find(value.getId(), UAttrValue.class));

        UAttr attribute = attrDAO.find(104L, UAttr.class);
        assertEquals(attribute.getValues().size(), attributeValueNumber - 1);
    }
View Full Code Here

Examples of org.apache.syncope.core.persistence.beans.user.UAttr

    @Autowired
    private SchemaDAO userSchemaDAO;

    @Test
    public void findById() {
        UAttr attribute = attrDAO.find(100L, UAttr.class);
        assertNotNull("did not find expected attribute schema", attribute);
        attribute = attrDAO.find(104L, UAttr.class);
        assertNotNull("did not find expected attribute schema", attribute);
    }
View Full Code Here

Examples of org.apache.syncope.core.persistence.beans.user.UAttr

        assertNotNull("did not find expected attribute schema", attribute);
    }

    @Test
    public void read() {
        UAttr attribute = attrDAO.find(100L, UAttr.class);
        assertNotNull(attribute);

        assertTrue(attribute.getValues().isEmpty());
        assertNotNull(attribute.getUniqueValue());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.