Search in sources :

Example 1 with Context

use of jakarta.validation.MessageInterpolator.Context in project hibernate-validator by hibernate.

the class MessageInterpolatorContextTest method testGetPropertyPath.

@Test
@TestForIssue(jiraKey = "HV-1657")
public void testGetPropertyPath() {
    Path pathMock = createMock(Path.class);
    MessageInterpolator.Context context = new MessageInterpolatorContext(null, null, null, pathMock, Collections.<String, Object>emptyMap(), Collections.<String, Object>emptyMap(), ExpressionLanguageFeatureLevel.BEAN_METHODS, false);
    assertSame(context.unwrap(HibernateMessageInterpolatorContext.class).getPropertyPath(), pathMock);
}
Also used : Path(jakarta.validation.Path) Context(jakarta.validation.MessageInterpolator.Context) MessageInterpolatorContext(org.hibernate.validator.internal.engine.MessageInterpolatorContext) HibernateMessageInterpolatorContext(org.hibernate.validator.messageinterpolation.HibernateMessageInterpolatorContext) ResourceBundleMessageInterpolator(org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator) MessageInterpolator(jakarta.validation.MessageInterpolator) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest) TestForIssue(org.hibernate.validator.testutil.TestForIssue)

Example 2 with Context

use of jakarta.validation.MessageInterpolator.Context in project hibernate-validator by hibernate.

the class MessageInterpolatorContextTest method testUnwrapToInterfaceTypesSucceeds.

@Test
public void testUnwrapToInterfaceTypesSucceeds() {
    Context context = new MessageInterpolatorContext(null, null, null, null, Collections.<String, Object>emptyMap(), Collections.<String, Object>emptyMap(), ExpressionLanguageFeatureLevel.BEAN_METHODS, false);
    MessageInterpolator.Context asMessageInterpolatorContext = context.unwrap(MessageInterpolator.Context.class);
    assertSame(asMessageInterpolatorContext, context);
    HibernateMessageInterpolatorContext asHibernateMessageInterpolatorContext = context.unwrap(HibernateMessageInterpolatorContext.class);
    assertSame(asHibernateMessageInterpolatorContext, context);
    Object asObject = context.unwrap(Object.class);
    assertSame(asObject, context);
}
Also used : Context(jakarta.validation.MessageInterpolator.Context) MessageInterpolatorContext(org.hibernate.validator.internal.engine.MessageInterpolatorContext) HibernateMessageInterpolatorContext(org.hibernate.validator.messageinterpolation.HibernateMessageInterpolatorContext) MessageInterpolatorContext(org.hibernate.validator.internal.engine.MessageInterpolatorContext) HibernateMessageInterpolatorContext(org.hibernate.validator.messageinterpolation.HibernateMessageInterpolatorContext) Context(jakarta.validation.MessageInterpolator.Context) HibernateMessageInterpolatorContext(org.hibernate.validator.messageinterpolation.HibernateMessageInterpolatorContext) ResourceBundleMessageInterpolator(org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator) MessageInterpolator(jakarta.validation.MessageInterpolator) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 3 with Context

use of jakarta.validation.MessageInterpolator.Context in project hibernate-validator by hibernate.

the class MessageInterpolatorContextTest method testUnwrapToImplementationCausesValidationException.

@Test(expectedExceptions = ValidationException.class)
public void testUnwrapToImplementationCausesValidationException() {
    Context context = new MessageInterpolatorContext(null, null, null, null, Collections.<String, Object>emptyMap(), Collections.<String, Object>emptyMap(), ExpressionLanguageFeatureLevel.BEAN_METHODS, false);
    context.unwrap(MessageInterpolatorContext.class);
}
Also used : Context(jakarta.validation.MessageInterpolator.Context) MessageInterpolatorContext(org.hibernate.validator.internal.engine.MessageInterpolatorContext) HibernateMessageInterpolatorContext(org.hibernate.validator.messageinterpolation.HibernateMessageInterpolatorContext) MessageInterpolatorContext(org.hibernate.validator.internal.engine.MessageInterpolatorContext) HibernateMessageInterpolatorContext(org.hibernate.validator.messageinterpolation.HibernateMessageInterpolatorContext) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 4 with Context

use of jakarta.validation.MessageInterpolator.Context in project hibernate-validator by hibernate.

the class MessageInterpolatorContextTest method testGetRootBeanType.

@Test
public void testGetRootBeanType() {
    Class<Object> rootBeanType = Object.class;
    MessageInterpolator.Context context = new MessageInterpolatorContext(null, null, rootBeanType, null, Collections.<String, Object>emptyMap(), Collections.<String, Object>emptyMap(), ExpressionLanguageFeatureLevel.BEAN_METHODS, false);
    assertSame(context.unwrap(HibernateMessageInterpolatorContext.class).getRootBeanType(), rootBeanType);
}
Also used : Context(jakarta.validation.MessageInterpolator.Context) MessageInterpolatorContext(org.hibernate.validator.internal.engine.MessageInterpolatorContext) HibernateMessageInterpolatorContext(org.hibernate.validator.messageinterpolation.HibernateMessageInterpolatorContext) ResourceBundleMessageInterpolator(org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator) MessageInterpolator(jakarta.validation.MessageInterpolator) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Aggregations

Context (jakarta.validation.MessageInterpolator.Context)4 MessageInterpolatorContext (org.hibernate.validator.internal.engine.MessageInterpolatorContext)4 HibernateMessageInterpolatorContext (org.hibernate.validator.messageinterpolation.HibernateMessageInterpolatorContext)4 BeforeTest (org.testng.annotations.BeforeTest)4 Test (org.testng.annotations.Test)4 MessageInterpolator (jakarta.validation.MessageInterpolator)3 ResourceBundleMessageInterpolator (org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator)3 Path (jakarta.validation.Path)1 TestForIssue (org.hibernate.validator.testutil.TestForIssue)1