mutableBooleanType.setEnumeratedConstraint(enumeratedConstraint);
return mutableBooleanType;
}
public void testVerify() {
final MutableBooleanType booleanType = TYPE_FACTORY.createBooleanType();
// normal case
MutableBooleanValue booleanValue = VALUE_FACTORY.createBooleanValue();
Collection errors = booleanType.verify(booleanValue);
assertEquals(0, errors.size());
// invalid type
StringValue stringValue = VALUE_FACTORY.createStringValue();
errors = booleanType.verify(stringValue);
assertEquals(1, errors.size());
VerificationError error = (VerificationError) errors.iterator().next();
assertEquals(VerificationError.TYPE_INVALID_IMPLEMENTATION,
error.getType());
assertEquals("", error.getLocation());
assertEquals(stringValue, error.getInvalidValue());
assertNull(error.getConstraint());
// enumerated constraint
final MutableEnumeratedConstraint enumeratedConstraint =
CONSTRAINT_FACTORY.createEnumeratedConstraint();
final List enumeratedValues =
enumeratedConstraint.getMutableEnumeratedValues();
final MutableBooleanValue constraintValue =
VALUE_FACTORY.createBooleanValue();
constraintValue.setValue(Boolean.FALSE);
enumeratedValues.add(constraintValue);
booleanType.setEnumeratedConstraint(enumeratedConstraint);
// check constraint with right value
booleanValue.setValue(Boolean.FALSE);
errors = booleanType.verify(booleanValue);
assertEquals(0, errors.size());
// check constraint violation
booleanValue.setValue(Boolean.TRUE);
errors = booleanType.verify(booleanValue);
assertEquals(1, errors.size());
error = (VerificationError) errors.iterator().next();
assertEquals(VerificationError.TYPE_CONSTRAINT_VIOLATION,
error.getType());
assertEquals("", error.getLocation());