return new ImmutableNumberValueImpl(new Double(10.0));
}
// Javadoc inherited.
public void testEqualsAndHashcodeImplementedCorrectly() {
MutableNumberValue numberValue1 = getMutableNumberValueForTestEquals();
MutableNumberValue numberValue2 = getMutableNumberValueForTestEquals();
// test that both the values are equal and they have the same hash codes
assertEquals("Object 1 should be equal to object 2", numberValue1, numberValue2);
assertEquals("Object 2 should be equal to object 1", numberValue2, numberValue1);
int booleanValue1Hashcode = numberValue1.hashCode();
int booleanValue2Hashcode = numberValue2.hashCode();
assertTrue("Objects which are equal should have the same hash codes. Were : "
+ booleanValue1Hashcode + " and " + booleanValue2Hashcode,
booleanValue1Hashcode == booleanValue2Hashcode);
// change a property in one of the objects and ensure they are not equal
numberValue2.setValue(new Double(2.0));
assertNotEquals(numberValue1, numberValue2);
assertNotEquals(numberValue2, numberValue1);
// ensure that the hashcodes are different for these two objects
booleanValue1Hashcode = numberValue1.hashCode();
booleanValue2Hashcode = numberValue2.hashCode();
assertFalse("Objects which are not equal should ideally have different hash codes",
booleanValue1Hashcode == booleanValue2Hashcode);
}