Package com.volantis.shared.metadata.type.mutable

Examples of com.volantis.shared.metadata.type.mutable.MutableCollectionType


        assertNull(error.getConstraint());
    }

    public void testVerifyMemberTypeConstraint() {

        final MutableCollectionType collectionType =
            (MutableCollectionType) getMutableInhibitor();

        final MutableMemberTypeConstraint memberTypeConstraint =
            CONSTRAINT_FACTORY.createMemberTypeConstraint();
        memberTypeConstraint.setMemberType(TYPE_FACTORY.createStringType());
        collectionType.setMemberTypeConstraint(memberTypeConstraint);

        // check constraint with right value
        final MutableCollectionValue collectionValue =
            createCollectionValue(new String[]{"one", "two"});
        Collection errors = collectionType.verify(collectionValue);
        assertEquals(0, errors.size());

        // check constraint violation
        memberTypeConstraint.setMemberType(TYPE_FACTORY.createBooleanType());
        collectionType.setMemberTypeConstraint(memberTypeConstraint);
        errors = collectionType.verify(collectionValue);
        assertEquals(4, errors.size());

        MutableStringValue stringValue = VALUE_FACTORY.createStringValue();
        stringValue.setValue("one");
View Full Code Here


        }
    }

    public void testVerifyMinimumLengthConstraint() {

        final MutableCollectionType collectionType =
            (MutableCollectionType) getMutableInhibitor();

        final MutableMinimumLengthConstraint minimumLengthConstraint =
            CONSTRAINT_FACTORY.createMinimumLengthConstraint();
        minimumLengthConstraint.setLimit(2);
        collectionType.setMinimumLengthConstraint(minimumLengthConstraint);

        // check constraint with right value
        final MutableCollectionValue collectionValue =
            createCollectionValue(new String[]{"one", "two"});
        Collection errors = collectionType.verify(collectionValue);
        assertEquals(0, errors.size());

        // check constraint violation
        minimumLengthConstraint.setLimit(3);
        collectionType.setMinimumLengthConstraint(minimumLengthConstraint);
        errors = collectionType.verify(collectionValue);
        assertEquals(1, errors.size());
        final Iterator iter = errors.iterator();
        VerificationError error = (VerificationError) iter.next();
        assertEquals(VerificationError.TYPE_CONSTRAINT_VIOLATION,
            error.getType());
View Full Code Here

        assertEquals(minimumLengthConstraint, error.getConstraint());
    }

    public void testVerifyMaximumLengthConstraint() {

        final MutableCollectionType collectionType =
            (MutableCollectionType) getMutableInhibitor();

        final MutableMaximumLengthConstraint maximumLengthConstraint =
            CONSTRAINT_FACTORY.createMaximumLengthConstraint();
        maximumLengthConstraint.setLimit(2);
        collectionType.setMaximumLengthConstraint(maximumLengthConstraint);

        // check constraint with right value
        final MutableCollectionValue collectionValue =
            createCollectionValue(new String[]{"one", "two"});
        Collection errors = collectionType.verify(collectionValue);
        assertEquals(0, errors.size());

        // check constraint violation
        maximumLengthConstraint.setLimit(1);
        collectionType.setMaximumLengthConstraint(maximumLengthConstraint);
        errors = collectionType.verify(collectionValue);
        assertEquals(1, errors.size());
        final Iterator iter = errors.iterator();
        VerificationError error = (VerificationError) iter.next();
        assertEquals(VerificationError.TYPE_CONSTRAINT_VIOLATION,
            error.getType());
View Full Code Here

TOP

Related Classes of com.volantis.shared.metadata.type.mutable.MutableCollectionType

Copyright © 2018 www.massapicom. 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.