I don't seem to be able to re-produce the issue. I created a testcase and added it to 5.2 (master) and 5.1 and in both cases the test passes.
The test uses the following setup:
@Test
@TestForIssue(jiraKey = "HV-986")
public void testCustomMessageInterpolationForMapValiation() {
Set<ConstraintViolation<Foobar>> constraintViolations = validator.validate( new Foobar() );
assertNumberOfViolations( constraintViolations, 1 );
assertCorrectPropertyPaths( constraintViolations, "bar[test-key].name" );
assertCorrectConstraintViolationMessages( constraintViolations, "Failure in map validation" );
}
private static class Foobar {
@MapConstraint
private Map<String, java.lang.Object> bar = new HashMap<String, java.lang.Object>();
public Foobar() {
bar.put( "test-key", new java.lang.Object() );
}
}
@Retention(RUNTIME)
@Constraint(validatedBy = MapConstraint.Validator.class)
public @interface MapConstraint {
String message() default "failed";
Class<?>[] groups() default {};
Class<? extends Payload>[] payload() default {};
public static class Validator implements ConstraintValidator<MapConstraint, Map<String, java.lang.Object>> {
@Override
public void initialize(MapConstraint constraintAnnotation) {
}
@Override
public boolean isValid(Map<String, java.lang.Object> value, ConstraintValidatorContext context) {
context.disableDefaultConstraintViolation();
context.buildConstraintViolationWithTemplate( "{ConstraintValidatorContextTest.testCustomMessageInterpolationForMapValiation}" )
.addPropertyNode( null ).inIterable().atKey( "test-key" )
.addPropertyNode( "name" )
.addConstraintViolation();
return false;
}
}
}
and the validation messages contain a entry for ConstraintValidatorContextTest.testCustomMessageInterpolationForMapValiation mapping it to Failure in map validation.
Is there a difference in this setup to your usecase? Are you sure your message bundles and in place and can be found?
|