Search in sources :

Example 1 with TestForIssue

use of org.hibernate.validator.testutil.TestForIssue in project hibernate-validator by hibernate.

the class AnnotationTypeValidationTest method testMixDirectAnnotationAndListContainer.

@Test
@TestForIssue(jiraKey = "HV-1275")
public void testMixDirectAnnotationAndListContainer() {
    boolean compilationResult = compilerHelper.compile(new ConstraintValidationProcessor(), diagnostics, compilerHelper.getSourceFile(MixDirectAnnotationAndListContainerAnnotation.class));
    assertFalse(compilationResult);
    assertThatDiagnosticsMatch(diagnostics, new DiagnosticExpectation(Kind.ERROR, 32));
}
Also used : DiagnosticExpectation(org.hibernate.validator.ap.util.DiagnosticExpectation) MixDirectAnnotationAndListContainerAnnotation(org.hibernate.validator.ap.testmodel.crossparameters.MixDirectAnnotationAndListContainerAnnotation) Test(org.testng.annotations.Test) TestForIssue(org.hibernate.validator.testutil.TestForIssue)

Example 2 with TestForIssue

use of org.hibernate.validator.testutil.TestForIssue in project hibernate-validator by hibernate.

the class ConstraintValidationProcessorTest method constraintsAllowedAtJavaMoneyTypes.

@Test
@TestForIssue(jiraKey = "HV-1252")
public void constraintsAllowedAtJavaMoneyTypes() {
    File sourceFile = compilerHelper.getSourceFile(ModelWithJavaMoneyTypes.class);
    EnumSet<Library> libraries = EnumSet.of(Library.VALIDATION_API, Library.HIBERNATE_VALIDATOR, Library.JAVA_MONEY_API);
    boolean compilationResult = compilerHelper.compile(new ConstraintValidationProcessor(), diagnostics, libraries, sourceFile);
    assertTrue(compilationResult, "Java Money API types (MonetaryAmount) fails with constraints annotations.");
}
Also used : Library(org.hibernate.validator.ap.testutil.CompilerTestHelper.Library) File(java.io.File) Test(org.testng.annotations.Test) TestForIssue(org.hibernate.validator.testutil.TestForIssue)

Example 3 with TestForIssue

use of org.hibernate.validator.testutil.TestForIssue in project hibernate-validator by hibernate.

the class ConstraintValidationProcessorTest method hibernateValidatorProvidedCustomConstraints.

@Test
@TestForIssue(jiraKey = "HV-567")
public void hibernateValidatorProvidedCustomConstraints() {
    File sourceFile = compilerHelper.getSourceFile(HibernateValidatorProvidedCustomConstraints.class);
    boolean compilationResult = compilerHelper.compile(new ConstraintValidationProcessor(), diagnostics, sourceFile);
    assertFalse(compilationResult);
    assertThatDiagnosticsMatch(diagnostics, new DiagnosticExpectation(Kind.ERROR, 66), new DiagnosticExpectation(Kind.ERROR, 67), new DiagnosticExpectation(Kind.ERROR, 68), new DiagnosticExpectation(Kind.ERROR, 69), new DiagnosticExpectation(Kind.ERROR, 70), new DiagnosticExpectation(Kind.ERROR, 71), new DiagnosticExpectation(Kind.ERROR, 72), new DiagnosticExpectation(Kind.ERROR, 73), new DiagnosticExpectation(Kind.ERROR, 74), new DiagnosticExpectation(Kind.ERROR, 75), new DiagnosticExpectation(Kind.ERROR, 76), new DiagnosticExpectation(Kind.ERROR, 77), new DiagnosticExpectation(Kind.ERROR, 78), new DiagnosticExpectation(Kind.ERROR, 79), new DiagnosticExpectation(Kind.ERROR, 80), new DiagnosticExpectation(Kind.ERROR, 81), new DiagnosticExpectation(Kind.ERROR, 82), new DiagnosticExpectation(Kind.ERROR, 83), new DiagnosticExpectation(Kind.ERROR, 84));
}
Also used : DiagnosticExpectation(org.hibernate.validator.ap.util.DiagnosticExpectation) File(java.io.File) Test(org.testng.annotations.Test) TestForIssue(org.hibernate.validator.testutil.TestForIssue)

Example 4 with TestForIssue

use of org.hibernate.validator.testutil.TestForIssue in project hibernate-validator by hibernate.

the class ConstraintValidationProcessorTest method beanValidationConstraints.

@Test
@TestForIssue(jiraKey = "HV-1297")
public void beanValidationConstraints() {
    File sourceFile = compilerHelper.getSourceFile(BeanValidationConstraints.class);
    boolean compilationResult = compilerHelper.compile(new ConstraintValidationProcessor(), diagnostics, sourceFile);
    assertFalse(compilationResult);
    assertThatDiagnosticsMatch(diagnostics, new DiagnosticExpectation(Kind.ERROR, 43), new DiagnosticExpectation(Kind.ERROR, 44), new DiagnosticExpectation(Kind.ERROR, 45), new DiagnosticExpectation(Kind.ERROR, 46), new DiagnosticExpectation(Kind.ERROR, 47), new DiagnosticExpectation(Kind.ERROR, 50), new DiagnosticExpectation(Kind.ERROR, 51), new DiagnosticExpectation(Kind.ERROR, 52), new DiagnosticExpectation(Kind.ERROR, 55), new DiagnosticExpectation(Kind.ERROR, 56));
}
Also used : DiagnosticExpectation(org.hibernate.validator.ap.util.DiagnosticExpectation) File(java.io.File) Test(org.testng.annotations.Test) TestForIssue(org.hibernate.validator.testutil.TestForIssue)

Example 5 with TestForIssue

use of org.hibernate.validator.testutil.TestForIssue in project hibernate-validator by hibernate.

the class ConstraintValidationProcessorTest method uniqueElementsConstraints.

@Test
@TestForIssue(jiraKey = "HV-1466")
public void uniqueElementsConstraints() {
    File[] sourceFiles = new File[] { compilerHelper.getSourceFile(ModelWithUniqueElementsConstraints.class) };
    boolean compilationResult = compilerHelper.compile(new ConstraintValidationProcessor(), diagnostics, false, true, sourceFiles);
    assertFalse(compilationResult);
    assertThatDiagnosticsMatch(diagnostics, new DiagnosticExpectation(Kind.ERROR, 26));
}
Also used : DiagnosticExpectation(org.hibernate.validator.ap.util.DiagnosticExpectation) File(java.io.File) Test(org.testng.annotations.Test) TestForIssue(org.hibernate.validator.testutil.TestForIssue)

Aggregations

TestForIssue (org.hibernate.validator.testutil.TestForIssue)286 Test (org.testng.annotations.Test)286 Validator (jakarta.validation.Validator)180 ConstraintViolation (jakarta.validation.ConstraintViolation)134 HibernateValidator (org.hibernate.validator.HibernateValidator)80 ConstraintMapping (org.hibernate.validator.cfg.ConstraintMapping)80 ConstraintValidator (jakarta.validation.ConstraintValidator)64 ValidatorUtil.getValidator (org.hibernate.validator.testutils.ValidatorUtil.getValidator)55 HibernateValidatorConfiguration (org.hibernate.validator.HibernateValidatorConfiguration)33 ValidatorFactory (jakarta.validation.ValidatorFactory)29 ConstraintViolationException (jakarta.validation.ConstraintViolationException)26 NotNullDef (org.hibernate.validator.cfg.defs.NotNullDef)22 ExecutableValidator (jakarta.validation.executable.ExecutableValidator)21 SizeDef (org.hibernate.validator.cfg.defs.SizeDef)21 NotNull (jakarta.validation.constraints.NotNull)17 Method (java.lang.reflect.Method)17 Size (jakarta.validation.constraints.Size)15 CountValidationCallsValidator (org.hibernate.validator.testutil.CountValidationCallsValidator)13 File (java.io.File)12 HibernateConstraintViolation (org.hibernate.validator.engine.HibernateConstraintViolation)12