public void testVerify() {
final MutableNumberType numberType = TYPE_FACTORY.createNumberType();
// normal case
MutableNumberValue numberValue = VALUE_FACTORY.createNumberValue();
numberValue.setValue(new Integer(5));
Collection errors = numberType.verify(numberValue);
assertEquals(0, errors.size());
// null value
numberValue = VALUE_FACTORY.createNumberValue();
errors = numberType.verify(numberValue);
assertEquals(1, errors.size());
VerificationError error =
(VerificationError) errors.iterator().next();
assertEquals(VerificationError.TYPE_NULL_VALUE,
error.getType());
assertEquals("", error.getLocation());
assertEquals(numberValue, error.getInvalidValue());
assertNull(error.getConstraint());
// invalid type
BooleanValue booleanValue = VALUE_FACTORY.createBooleanValue();
errors = numberType.verify(booleanValue);
assertEquals(1, errors.size());
error = (VerificationError) errors.iterator().next();
assertEquals(VerificationError.TYPE_INVALID_IMPLEMENTATION,
error.getType());
assertEquals("", error.getLocation());
assertEquals(booleanValue, error.getInvalidValue());
assertNull(error.getConstraint());
// enumerated constraint
final MutableEnumeratedConstraint enumeratedConstraint =
CONSTRAINT_FACTORY.createEnumeratedConstraint();
final List enumeratedValues =
enumeratedConstraint.getMutableEnumeratedValues();
final MutableNumberValue constraintValue =
VALUE_FACTORY.createNumberValue();
constraintValue.setValue(new Integer(6));
enumeratedValues.add(constraintValue.createImmutable());
constraintValue.setValue(new Integer(7));
enumeratedValues.add(constraintValue.createImmutable());
numberType.setEnumeratedConstraint(enumeratedConstraint);
// check constraint with right value
numberValue.setValue(new Integer(6));
errors = numberType.verify(numberValue);
assertEquals(0, errors.size());