[Figleaf-developer] Mutable Integration tests
Status: Alpha
Brought to you by:
steckman
|
From: <sam...@ma...> - 2004-07-14 14:04:53
|
i wrote some simple integration tests for the Mutable/Validation stuff I've been
working on (had trouble getting it into CVS, I'll try again later). Anyway, I've
created a sample Mutable object Employee, which the following requirements:
1. A name that must be non-null
2. A non-null start date that must be before the end date, if defined
3. An end date that must be after the start date, but can be null
4. A home and mobile number, at least one of which needs to be defined. Must
match the pattern XXXX-XXXXXXX
5. A non-null postcode that has to match the pattern XXX XXX
6. An age that must be above 18 and less that 65
So far validating non-null fields works, as does regexp matching for postcode
and phone numbers, and integer ranges. Next up I'll add the code to handle
object invariant validation - this will catch cross-property changes, such as
the end date being after the start date.
The EmployeeMutable class looks like this (simple code cut for the sake of brevity):
public class EmployeeMutable implements Mutable {
public EmployeeMutable() {
setupMutableImpl();
}
//delegates to mutableImpl
public void commit(ChangeSet set) throws ValidationException {
mutableSupport.commit(set);
}
public boolean isValidChange(ChangeSet set, ValidationCallback callback) {
return mutableSupport.isValidChange(set, callback);
}
|