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);
}
Aggregations