Search in sources :

Example 1 with Future

use of jakarta.validation.constraints.Future in project eclipselink by eclipse-ee4j.

the class BeanValidationBindingsTestCase method testFacetCustomizationsAndCustomFacets.

/**
 * Tests customizations, i.e. facet customizations + custom facets, i.e.
 * Future, Past, AssertTrue, AssertFalse.
 */
public void testFacetCustomizationsAndCustomFacets() throws Throwable {
    pkg = "cs";
    xjcGenerateJavaSourcesWithCustomizations(CUSTOMIZED_SCHEMA_PATH);
    compileGeneratedSources(createCompileList(pkg));
    Class<?> custom = loadCompiledClasses(createLoadList(pkg))[0];
    Field generic = custom.getDeclaredField("generic");
    Size s = generic.getAnnotation(Size.class);
    assertEquals(s.message(), "Hello, world!");
    assertEquals(s.groups()[0], BindingTeam.class);
    assertEquals(s.groups()[1], RocketTeam.class);
    assertEquals(s.max(), 4);
    Pattern p1 = generic.getAnnotation(Pattern.List.class).value()[0];
    Pattern p2 = generic.getAnnotation(Pattern.List.class).value()[1];
    assertEquals(p1.message(), p2.message());
    assertTrue(Arrays.equals(p1.groups(), p2.groups()));
    assertEquals(p1.message(), "Hello.");
    assertEquals(p1.groups()[0], Object.class);
    assertEquals(p1.regexp(), "10");
    Future f = generic.getAnnotation(Future.class);
    assertEquals(f.message(), "Welcome to the Future!");
    assertEquals(f.groups()[0], BindingTeam.class);
    Past p = generic.getAnnotation(Past.class);
    assertEquals(p.message(), "Farewell from the ancestors.");
    assertEquals(p.groups()[0], Ancestors.class);
    AssertTrue at = generic.getAnnotation(AssertTrue.class);
    assertEquals(at.message(), "True fan of the team!");
    assertEquals(at.groups()[0], BindingTeam.class);
    AssertFalse af = generic.getAnnotation(AssertFalse.class);
    assertEquals(af.message(), "false");
    assertEquals(af.groups()[0], Object.class);
    // To test a user custom annotation.
    CustomAnnotation xmlKey = generic.getAnnotation(CustomAnnotation.class);
    assertNotNull(xmlKey);
}
Also used : Field(java.lang.reflect.Field) Pattern(jakarta.validation.constraints.Pattern) Size(jakarta.validation.constraints.Size) Past(jakarta.validation.constraints.Past) AssertTrue(jakarta.validation.constraints.AssertTrue) Future(jakarta.validation.constraints.Future) AssertFalse(jakarta.validation.constraints.AssertFalse)

Aggregations

AssertFalse (jakarta.validation.constraints.AssertFalse)1 AssertTrue (jakarta.validation.constraints.AssertTrue)1 Future (jakarta.validation.constraints.Future)1 Past (jakarta.validation.constraints.Past)1 Pattern (jakarta.validation.constraints.Pattern)1 Size (jakarta.validation.constraints.Size)1 Field (java.lang.reflect.Field)1