public void testValidate() {
MetaBeanFinder finder = XMLMetaBeanManagerFactory.getFinder();
XMLMetaBeanManagerFactory.getRegistry().addLoader(new XMLMetaBeanURLLoader(
BusinessObject.class.getResource("test-beanInfos.xml")));
MetaBean info = finder.findForClass(BusinessObject.class);
BusinessObject object = new BusinessObject();
object.setAddress(new BusinessObjectAddress());
object.getAddress().setOwner(object);
BeanValidator<ValidationResults> validator = new BeanValidator();
ValidationResults results = validator.validate(object, info);
assertTrue(results.hasErrorForReason(Reasons.MANDATORY));
assertTrue(results.hasError(object, null));
assertTrue(results.hasError(object.getAddress(), null));
assertTrue(
validator.validateProperty(object, info.getProperty("firstName")).hasError(
object, "firstName"));
object.setUserId(1L);
object.setFirstName("Hans");
object.setLastName("Tester");