Examples of MutableMaximumLengthConstraint


Examples of com.volantis.shared.metadata.type.constraint.mutable.MutableMaximumLengthConstraint

    public void testVerifyMaximumLengthConstraint() {

        final MutableStringType stringType =
            (MutableStringType) getMutableInhibitor();

        final MutableMaximumLengthConstraint maximumLengthConstraint =
            CONSTRAINT_FACTORY.createMaximumLengthConstraint();
        maximumLengthConstraint.setLimit(5);
        stringType.setMaximumLengthConstraint(maximumLengthConstraint);

        // check constraint with right value
        final MutableStringValue stringValue = VALUE_FACTORY.createStringValue();
        stringValue.setValue("hello");
        Collection errors = stringType.verify(stringValue);
        assertEquals(0, errors.size());

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

Examples of com.volantis.shared.metadata.type.constraint.mutable.MutableMaximumLengthConstraint

    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();
View Full Code Here

Examples of com.volantis.shared.metadata.type.constraint.mutable.MutableMaximumLengthConstraint

    }

    // Javadoc inherited.
    public void testEqualsAndHashcodeImplementedCorrectly() {

        MutableMaximumLengthConstraint maximumLengthConstraint1 =
            (MutableMaximumLengthConstraint) getMutableInhibitor();
        MutableMaximumLengthConstraint maximumLengthConstraint2 =
            (MutableMaximumLengthConstraint) getMutableInhibitor();

        // ensure that the two objects are equal
        assertEquals("Object 1 should  be equal to object 2",
            maximumLengthConstraint1, maximumLengthConstraint2);

        // ensure that they have the same hash code
        int hashCode1 = maximumLengthConstraint1.hashCode();
        int hashCode2 = maximumLengthConstraint2.hashCode();
        assertTrue("Objects which are equal should have the same hash codes. " +
                "Were : " + hashCode1 + " and " + hashCode2,
            hashCode1 == hashCode2);

        // now change the externally visible field and ensure that the two
        // objects are different
        maximumLengthConstraint2.setLimit(1);
        assertNotEquals(maximumLengthConstraint1, maximumLengthConstraint2);

        // see if the hashcodes are different
        hashCode1 = maximumLengthConstraint1.hashCode();
        hashCode2 = maximumLengthConstraint2.hashCode();
        assertFalse("Objects which are not equal should ideally not have the " +
                "same hash codes. Were : " + hashCode1 + " and " + hashCode2,
            hashCode1 == hashCode2);
    }
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.