ConstraintReaderImpl implements ConstraintReader { @Override public List<String> getOptionalMessages(Class<?> javaBaseClass, String javaFieldName) { return skippableConstraintResolver.getOptionalMessages(javaFieldName, javaBaseClass); } private  ConstraintReaderImpl(MethodParameterConstraintResolver actualResolver, ObjectMapper objectMapper, SnippetTranslationResolver translationResolver,
            ConstraintDescriptionResolver constraintDescriptionResolver); static ConstraintReaderImpl create(ObjectMapper objectMapper, SnippetTranslationResolver translationResolver, ConstraintDescriptionResolver constraintDescriptionResolver); @Override List<String> getOptionalMessages(Class<?> javaBaseClass, String javaFieldName); @Override String getTypeSpecifier(Class<?> javaBaseClass); @Override List<String> getConstraintMessages(Class<?> javaBaseClass, String javaFieldName); @Override List<String> getConstraintMessages(MethodParameter param);  }
@Test public void getOptionalMessages() { ConstraintReader reader = createWithValidation(); List<String> messages = reader.getOptionalMessages(Constraintz.class, "name"); assertThat(messages).hasSize(1); assertThat(messages.get(0)).isEqualTo("false"); messages = reader.getOptionalMessages(Constraintz.class, "index"); assertThat(messages).hasSize(1); assertThat(messages.get(0)).isEqualTo("false"); messages = reader.getOptionalMessages(Constraintz.class, "items"); assertThat(messages).hasSize(1); assertThat(messages.get(0)).isEqualTo("false"); messages = reader.getOptionalMessages(Constraintz.class, "amount"); assertThat(messages).hasSize(0); messages = reader.getOptionalMessages(Constraintz.class, "type"); assertThat(messages).hasSize(0); messages = reader.getOptionalMessages(Constraintz.class, "amountWithGroup"); assertThat(messages).hasSize(0); messages = reader.getOptionalMessages(Constraintz.class, "indexWithGroup"); assertThat(messages).hasSize(1); assertThat(messages.get(0)).isEqualTo("false (create)"); messages = reader.getOptionalMessages(Constraintz.class, "num"); assertThat(messages).hasSize(0); messages = reader.getOptionalMessages(Constraintz.class, "bool"); assertThat(messages).hasSize(0); messages = reader.getOptionalMessages(Constraintz.class, "str"); assertThat(messages).hasSize(0); messages = reader.getOptionalMessages(Constraintz.class, "enum1"); assertThat(messages).hasSize(0); messages = reader.getOptionalMessages(Constraintz.class, "enum2"); assertThat(messages).hasSize(1); assertThat(messages.get(0)).isEqualTo("false"); messages = reader.getOptionalMessages(Constraintz.class, "optionalEnum"); assertThat(messages).hasSize(0); messages = reader.getOptionalMessages(Constraintz.class, "sizedString"); assertThat(messages).hasSize(0); }