Package org.hibernate.validator.cfg

Examples of org.hibernate.validator.cfg.ConstraintMapping.type()


    public void testCustomMessageInterpolation() {

        HibernateValidatorConfiguration configuration = Validation.byProvider(HibernateValidator.class).configure();
        Assert.assertNotNull(configuration);
        ConstraintMapping mapping = new ConstraintMapping();
        mapping.type(Employee.class).property("firstName", FIELD)
                .constraint(new EmailDef().message("Invalid Email!You have entered:--\\{${validatedValue}\\}"));

        final MessageInterpolator messageInterpolator = new ValueFormatterMessageInterpolator();
        configuration.messageInterpolator(messageInterpolator);
        configuration.addMapping(mapping);
View Full Code Here


  @Test
  @TestForIssue(jiraKey = "HV-500")
  public void testMultipleConstraintMappings() {
    ConstraintMapping marathonMapping = config.createConstraintMapping();
    marathonMapping.type( Marathon.class )
        .property( "name", METHOD )
        .constraint( new NotNullDef() );

    ConstraintMapping runnerMapping = config.createConstraintMapping();
    runnerMapping.type( Runner.class )
View Full Code Here

    marathonMapping.type( Marathon.class )
        .property( "name", METHOD )
        .constraint( new NotNullDef() );

    ConstraintMapping runnerMapping = config.createConstraintMapping();
    runnerMapping.type( Runner.class )
        .property( "name", METHOD )
        .constraint( new NotNullDef() );

    config.addMapping( marathonMapping );
    config.addMapping( runnerMapping );
View Full Code Here

  @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 );
View Full Code Here

    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

  }

  @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

  }

  @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

  }

  @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

TOP
Copyright © 2018 www.massapi.com. 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.