Package org.hibernate.validator.cfg

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


  }

  @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


  }

  @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

  @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

  @Test
  @TestForIssue(jiraKey = "HV-406")
  public void optional_regular_expression_can_be_refined_with_flags_using_programmatic_api() {
    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}$" ).flags( Flag.CASE_INSENSITIVE )
        );
    config.addMapping( mapping );
View Full Code Here

  }

  @Test
  public void testCascadingConstructorReturnDefinition() throws Exception {
    ConstraintMapping mapping = config.createConstraintMapping();
    mapping.type( GreetingService.class )
        .constructor()
        .returnValue()
        .valid();
    config.addMapping( mapping );
View Full Code Here

  }

  @Test
  public void testCascadingConstructorParameterDefinition() throws Exception {
    ConstraintMapping mapping = config.createConstraintMapping();
    mapping.type( GreetingService.class )
        .constructor( User.class )
        .parameter( 0 )
        .valid();
    config.addMapping( mapping );
View Full Code Here

  }

  @Test
  public void testCascadingConstructorParameterDefinitionWithGroupConversion() throws Exception {
    ConstraintMapping mapping = config.createConstraintMapping();
    mapping.type( GreetingService.class )
        .constructor( User.class )
        .parameter( 0 )
        .valid()
        .convertGroup( Default.class ).to( TestGroup.class )
        .type( User.class )
View Full Code Here

      expectedExceptions = ValidationException.class,
      expectedExceptionsMessageRegExp = "HV000133.*"
  )
  public void testCascadingDefinitionOnMissingMethod() {
    ConstraintMapping mapping = config.createConstraintMapping();
    mapping.type( GreetingService.class )
        .constructor( Date.class );
  }

  @Test(
      expectedExceptions = IllegalArgumentException.class,
View Full Code Here

      expectedExceptions = IllegalArgumentException.class,
      expectedExceptionsMessageRegExp = "HV000056.*"
  )
  public void testCascadingDefinitionOnInvalidMethodParameter() {
    ConstraintMapping mapping = config.createConstraintMapping();
    mapping.type( GreetingService.class )
        .constructor( User.class )
        .parameter( 1 );
  }

  @Test
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.