.findForId("org.apache.bval.example.Address");
// 1. validate a bean
BusinessObjectAddress adr = new BusinessObjectAddress();
BeanValidator<ValidationResults> validator = new BeanValidator<ValidationResults>();
ValidationResults results = validator.validate(adr, mb);
assertEquals(2,
results.getErrorsByReason().get(Features.Property.MANDATORY).size());
// 2. validate a map with the same metabean
validator.setTreatMapsLikeBeans(true);
results = validator.validate(new HashMap<String, Object>(), mb);
assertFalse(results.isEmpty());
assertEquals(2,
results.getErrorsByReason().get(Features.Property.MANDATORY).size());
// 3. validate as empty map (jsr303 behavior)
validator.setTreatMapsLikeBeans(false);
results = validator.validate(new HashMap<Object, Object>(), mb);
assertTrue(results.isEmpty());
}