Examples of MutableRangeConstraint


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

    }

    // Javadoc inherited.
    public void testEqualsAndHashcodeImplementedCorrectly() {

        MutableRangeConstraint rangeConstraint1 =
                (MutableRangeConstraint) getMutableInhibitor();
        MutableRangeConstraint rangeConstraint2 =
                (MutableRangeConstraint) getMutableInhibitor();

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

        // ensure that they have the same hash code
        int listValue1Hashcode = rangeConstraint1.hashCode();
        int listValue2Hashcode = rangeConstraint2.hashCode();
        assertTrue("Objects which are equal should have the same hash codes. Were : "
                + listValue1Hashcode + " and " + listValue2Hashcode,
                listValue1Hashcode == listValue2Hashcode);

        // now change a single externally visible field and ensure that the two
        // objects are different
        rangeConstraint2.setInclusive(true);
        assertNotEquals(rangeConstraint1, rangeConstraint2);

        // see if the hashcodes are different
        listValue1Hashcode = rangeConstraint1.hashCode();
        listValue2Hashcode = rangeConstraint2.hashCode();
        assertFalse("Objects which are not equal should ideally not have the same hash " +
                "codes. Were : " + listValue1Hashcode + " and " + listValue2Hashcode,
                listValue1Hashcode == listValue2Hashcode);

        // reset the object
        rangeConstraint2 =
                (MutableRangeConstraint) getMutableInhibitor();

        // now change another single externally visible field and ensure that they are
        // the two objects are different
        rangeConstraint2.setLimit(new Double(1));
        assertNotEquals(rangeConstraint1, rangeConstraint2);

        // see if the hashcodes are different
        listValue1Hashcode = rangeConstraint1.hashCode();
        listValue2Hashcode = rangeConstraint2.hashCode();
        assertFalse("Objects which are not equal should ideally not have the same hash " +
                "codes. Were : " + listValue1Hashcode + " and " + listValue2Hashcode,
                listValue1Hashcode == listValue2Hashcode);

    }
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.