Examples of MutableMinimumLengthConstraint


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

    public void testVerifyMinimumLengthConstraint() {

        final MutableStringType stringType =
            (MutableStringType) getMutableInhibitor();

        final MutableMinimumLengthConstraint minimumLengthConstraint =
            CONSTRAINT_FACTORY.createMinimumLengthConstraint();
        minimumLengthConstraint.setLimit(5);
        stringType.setMinimumLengthConstraint(minimumLengthConstraint);

        // 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
        minimumLengthConstraint.setLimit(6);
        stringType.setMinimumLengthConstraint(minimumLengthConstraint);
        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.MutableMinimumLengthConstraint

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

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

    }

    // Javadoc inherited.
    public void testEqualsAndHashcodeImplementedCorrectly() {

        MutableMinimumLengthConstraint minimumLengthConstraint1 =
            (MutableMinimumLengthConstraint) getMutableInhibitor();
        MutableMinimumLengthConstraint minimumLengthConstraint2 =
            (MutableMinimumLengthConstraint) getMutableInhibitor();

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

        // ensure that they have the same hash code
        int hashCode1 = minimumLengthConstraint1.hashCode();
        int hashCode2 = minimumLengthConstraint2.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
        minimumLengthConstraint2.setLimit(1);
        assertNotEquals(minimumLengthConstraint1, minimumLengthConstraint2);

        // see if the hashcodes are different
        hashCode1 = minimumLengthConstraint1.hashCode();
        hashCode2 = minimumLengthConstraint2.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.