// persons[1]
cvb.addNode("person").addNode(null).inIterable().atIndex(1)
.addConstraintViolation();
Error error = cvc.getErrorMessages().iterator().next();
PathImpl errorPath = (PathImpl) error.getOwner();
Assert.assertEquals("Incorrect path created", "person[1]", errorPath.toString());
resetConstraintValidatorContext();
// persons[lawyer].name
cvb.addNode("person").addNode("name").inIterable().atKey("john")
.addConstraintViolation();
error = cvc.getErrorMessages().iterator().next();
errorPath = (PathImpl) error.getOwner();
Assert.assertEquals("Incorrect path created", "person[john].name", errorPath.toString());
resetConstraintValidatorContext();
// [0].name[]
cvb.addNode(null).addNode("name").inIterable().atIndex(0).addNode(null)
.inIterable().addConstraintViolation();
error = cvc.getErrorMessages().iterator().next();
errorPath = (PathImpl) error.getOwner();
Assert.assertEquals("Incorrect path created", "[0].name[]", errorPath.toString());
resetConstraintValidatorContext();
// []
cvb.addNode(null).addNode(null).inIterable().addConstraintViolation();
error = cvc.getErrorMessages().iterator().next();
errorPath = (PathImpl) error.getOwner();
Assert.assertEquals("Incorrect path created", "[]", errorPath.toString());
resetConstraintValidatorContext();
// Adding only nulls should still give a root path
cvb.addNode(null).addNode(null).addNode(null).addNode(null).addConstraintViolation();
error = cvc.getErrorMessages().iterator().next();
errorPath = (PathImpl) error.getOwner();
Assert.assertTrue("Created path must be a root path", errorPath.isRootPath());
}