public void testValidateForSaveMandatoryAttributeMissing() throws Exception {
DataContext context = createDataContext();
Artist artist = (Artist) context.newObject("Artist");
ValidationResult result = new ValidationResult();
artist.validateForSave(result);
assertTrue("Validation of 'artistName' should've failed.", result.hasFailures());
assertTrue(result.hasFailures(artist));
List failures = result.getFailures();
assertEquals(1, failures.size());
BeanValidationFailure failure = (BeanValidationFailure) failures.get(0);
assertEquals(Artist.ARTIST_NAME_PROPERTY, failure.getProperty());
// fix the problem and see if it goes away
artist.setArtistName("aa");
result = new ValidationResult();
artist.validateForSave(result);
assertFalse(result.hasFailures());
}