enumeratedValues.add(QuantityUnits.INCHES);
unitType.setEnumeratedConstraint(enumeratedConstraint);
quantityType.setUnitType(unitType);
// normal case
MutableQuantityValue quantityValue = VALUE_FACTORY.createQuantityValue();
final MutableNumberValue magnitudeValue =
VALUE_FACTORY.createNumberValue();
magnitudeValue.setValue(new Integer(123));
quantityValue.setMagnitudeValue(magnitudeValue);
quantityValue.setUnitValue(QuantityUnits.CENTIMETERS);
Collection errors = quantityType.verify(quantityValue);
assertEquals(0, errors.size());
// invalid magnitude type
magnitudeValue.setValue(new Byte((byte) 42));
quantityValue.setMagnitudeValue(magnitudeValue);
errors = quantityType.verify(quantityValue);
assertEquals(1, errors.size());
VerificationError error = (VerificationError) errors.iterator().next();
assertEquals(VerificationError.TYPE_CONSTRAINT_VIOLATION,
error.getType());
assertEquals("[@magnitude]", error.getLocation());
assertEquals(magnitudeValue, error.getInvalidValue());
assertEquals(subTypeConstraint, error.getConstraint());
// invalid unit type
magnitudeValue.setValue(new Integer(42));
quantityValue.setMagnitudeValue(magnitudeValue);
quantityValue.setUnitValue(QuantityUnits.PIXELS);
errors = quantityType.verify(quantityValue);
assertEquals(1, errors.size());
error = (VerificationError) errors.iterator().next();
assertEquals(VerificationError.TYPE_CONSTRAINT_VIOLATION,
error.getType());