Package org.hibernate.validator.cfg

Examples of org.hibernate.validator.cfg.ConstraintMapping


  }

  @TestForIssue(jiraKey = "HV-500")
  @Test(expectedExceptions = ValidationException.class, expectedExceptionsMessageRegExp = "HV000171.*")
  public void testSameTypeConfiguredSeveralTimesInSameConstraintMappingCausesException() {
    ConstraintMapping marathonMapping = config.createConstraintMapping();
    marathonMapping
        .type( Marathon.class )
          .defaultGroupSequence( Foo.class, Marathon.class )
        .type( Marathon.class );
  }
View Full Code Here


  }

  @TestForIssue(jiraKey = "HV-500")
  @Test(expectedExceptions = ValidationException.class, expectedExceptionsMessageRegExp = "HV000171.*")
  public void testSameTypeConfiguredSeveralTimesInDifferentConstraintMappingsCausesException() {
    ConstraintMapping marathonMapping1 = config.createConstraintMapping();
    marathonMapping1.type( Marathon.class )
        .defaultGroupSequenceProviderClass( MarathonDefaultGroupSequenceProvider.class );

    ConstraintMapping marathonMapping2 = config.createConstraintMapping();
    marathonMapping2.type( Marathon.class )
        .defaultGroupSequenceProviderClass( MarathonDefaultGroupSequenceProvider.class );

    config.addMapping( marathonMapping1 );
    config.addMapping( marathonMapping2 );

View Full Code Here

  }

  @TestForIssue(jiraKey = "HV-500")
  @Test(expectedExceptions = GroupDefinitionException.class, expectedExceptionsMessageRegExp = "HV000052.*")
  public void testConfigurationOfSequenceProviderAndGroupSequenceCausesException() {
    ConstraintMapping marathonMapping = config.createConstraintMapping();
    marathonMapping.type( Marathon.class )
        .defaultGroupSequence( Foo.class, Marathon.class )
        .defaultGroupSequenceProviderClass( MarathonDefaultGroupSequenceProvider.class );

    config.addMapping( marathonMapping );
    Validator validator = config.buildValidatorFactory().getValidator();
View Full Code Here

    validator.validate( new Marathon() );
  }

  @Test(expectedExceptions = ValidationException.class, expectedExceptionsMessageRegExp = "HV000172.*")
  public void testSamePropertyConfiguredSeveralTimesCausesException() {
    ConstraintMapping marathonMapping = config.createConstraintMapping();
    marathonMapping.type( Marathon.class )
        .property( "name", METHOD )
          .constraint( new NotNullDef() )
        .property( "name", METHOD );
  }
View Full Code Here

        .property( "name", METHOD );
  }

  @Test(expectedExceptions = ValidationException.class, expectedExceptionsMessageRegExp = "HV000173.*")
  public void testSameMethodConfiguredSeveralTimesCausesException() {
    ConstraintMapping marathonMapping = config.createConstraintMapping();
    marathonMapping.type( Marathon.class )
        .method( "setTournamentDate", Date.class )
          .parameter( 0 )
            .constraint( new NotNullDef() )
        .method( "setTournamentDate", Date.class );
  }
View Full Code Here

        .method( "setTournamentDate", Date.class );
  }

  @Test(expectedExceptions = ValidationException.class, expectedExceptionsMessageRegExp = "HV000174.*")
  public void testSameParameterConfiguredSeveralTimesCausesException() {
    ConstraintMapping marathonMapping = config.createConstraintMapping();
    marathonMapping.type( Marathon.class )
        .method( "setTournamentDate", Date.class )
          .parameter( 0 )
            .constraint( new NotNullDef() )
        .parameter( 0 );
  }
View Full Code Here

        .parameter( 0 );
  }

  @Test(expectedExceptions = ValidationException.class, expectedExceptionsMessageRegExp = "HV000175.*")
  public void testReturnValueConfiguredSeveralTimesCausesException() {
    ConstraintMapping marathonMapping = config.createConstraintMapping();
    marathonMapping.type( Marathon.class )
        .method( "addRunner", Runner.class )
          .returnValue()
            .constraint( new AssertFalseDef() )
          .parameter( 0 )
          .returnValue();
View Full Code Here

          .returnValue();
  }

  @Test(expectedExceptions = ValidationException.class, expectedExceptionsMessageRegExp = "HV000177.*")
  public void testCrossParameterConfiguredSeveralTimesCausesException() {
    ConstraintMapping marathonMapping = config.createConstraintMapping();
    marathonMapping.type( Marathon.class )
        .method( "addRunner", Runner.class )
          .crossParameter()
            .constraint(
              new GenericConstraintDef<GenericAndCrossParameterConstraint>(
                GenericAndCrossParameterConstraint.class
View Full Code Here

  @Test
  @TestForIssue(jiraKey = "HV-812")
  public void testProgrammaticMod11Constraint() {
    final HibernateValidatorConfiguration config = getConfiguration( HibernateValidator.class );
    ConstraintMapping mapping = config.createConstraintMapping();
    mapping.type( Product.class )
        .property( "productNumber", FIELD )
        .constraint(
            new Mod10CheckDef()
                .multiplier( 3 )
                .weight( 1 )
View Full Code Here

  @Test
  @TestForIssue(jiraKey = "HV-406")
  public void explicit_regular_expression_can_be_specified_via_programmatic_configuration() {
    // now the same test with programmatic configuration
    HibernateValidatorConfiguration config = ValidatorUtil.getConfiguration( HibernateValidator.class );
    ConstraintMapping mapping = config.createConstraintMapping();
    mapping.type( URLContainer.class )
        .property( "url", METHOD )
        .constraint( new URLDef().regexp( "^http://\\S+[\\.htm|\\.html]{1}$" ) );
    config.addMapping( mapping );
    Validator validator = config.buildValidatorFactory().getValidator();
View Full Code Here

TOP

Related Classes of org.hibernate.validator.cfg.ConstraintMapping

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.