Search in sources :

Example 16 with MessageInterpolatorContext

use of org.hibernate.validator.internal.engine.MessageInterpolatorContext in project hibernate-validator by hibernate.

the class ResourceBundleMessageInterpolatorTest method testUnSuccessfulInterpolation.

@Test
public void testUnSuccessfulInterpolation() {
    interpolator = new ResourceBundleMessageInterpolator(new TestResourceBundleLocator());
    MessageInterpolatorContext messageInterpolatorContext = createMessageInterpolatorContext(notNullDescriptor);
    // missing {}
    String expected = "foo";
    String actual = interpolator.interpolate("foo", messageInterpolatorContext);
    assertEquals(actual, expected, "Wrong substitution");
    expected = "#{foo  {}";
    actual = interpolator.interpolate("#{foo  {}", messageInterpolatorContext);
    assertEquals(actual, expected, "Wrong substitution");
}
Also used : MessageInterpolatorContext(org.hibernate.validator.internal.engine.MessageInterpolatorContext) ResourceBundleMessageInterpolator(org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Aggregations

MessageInterpolatorContext (org.hibernate.validator.internal.engine.MessageInterpolatorContext)16 ResourceBundleMessageInterpolator (org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator)13 BeforeTest (org.testng.annotations.BeforeTest)13 Test (org.testng.annotations.Test)13 MessageInterpolator (jakarta.validation.MessageInterpolator)5 HibernateMessageInterpolatorContext (org.hibernate.validator.messageinterpolation.HibernateMessageInterpolatorContext)5 Context (jakarta.validation.MessageInterpolator.Context)4 Path (jakarta.validation.Path)2 Locale (java.util.Locale)2 ConstraintDescriptorImpl (org.hibernate.validator.internal.metadata.descriptor.ConstraintDescriptorImpl)2 ConstraintAnnotationDescriptor (org.hibernate.validator.internal.util.annotation.ConstraintAnnotationDescriptor)2 TestForIssue (org.hibernate.validator.testutil.TestForIssue)2 ResultPath (graphql.execution.ResultPath)1 ConstraintViolation (jakarta.validation.ConstraintViolation)1 Validator (jakarta.validation.Validator)1 NotNull (jakarta.validation.constraints.NotNull)1 BeanDescriptor (jakarta.validation.metadata.BeanDescriptor)1 ConstraintDescriptor (jakarta.validation.metadata.ConstraintDescriptor)1 PropertyDescriptor (jakarta.validation.metadata.PropertyDescriptor)1 HashMap (java.util.HashMap)1