Package org.hibernate.validator.cfg

Examples of org.hibernate.validator.cfg.ConstraintMapping


    config.buildValidatorFactory().getValidator();
  }

  @Test
  public void testOverridingMethodMayDefineSameConstraintsAsOverriddenMethod() {
    ConstraintMapping mapping = config.createConstraintMapping();
    mapping.type( GreetingService.class )
        .method( "greet", String.class )
        .parameter( 0 )
        .constraint( new SizeDef().min( 5 ).max( 10 ) )
        .type( GreetingServiceImpl.class )
        .method( "greet", String.class )
View Full Code Here


    }
  }

  @Test
  public void testParameterCanMarkedAsCascadedSeveralTimesInTheHierarchy() {
    ConstraintMapping mapping = config.createConstraintMapping();
    mapping.type( GreetingService.class )
        .method( "greet", User.class )
        .parameter( 0 )
        .valid()
        .type( GreetingServiceImpl.class )
        .method( "greet", User.class )
View Full Code Here

    }
  }

  @Test(expectedExceptions = ConstraintDeclarationException.class, expectedExceptionsMessageRegExp = "HV000151.*")
  public void testCascadingMethodParameterDefinedOnlyOnSubType() {
    ConstraintMapping mapping = config.createConstraintMapping();
    mapping.type( GreetingServiceImpl.class )
        .method( "greet", User.class )
        .parameter( 0 )
        .valid();
    config.addMapping( mapping );

View Full Code Here

    service.greet( new User( null ) );
  }

  @Test
  public void testParameterConstraint() {
    ConstraintMapping mapping = config.createConstraintMapping();
    mapping.type( GreetingService.class )
        .method( "greet", User.class )
        .parameter( 0 )
        .constraint( new NotNullDef() );
    config.addMapping( mapping );
View Full Code Here

    }
  }

  @Test
  public void testGenericParameterConstraint() {
    ConstraintMapping mapping = config.createConstraintMapping();
    mapping.type( GreetingService.class )
        .method( "greet", String.class )
        .parameter( 0 )
        .constraint( new GenericConstraintDef<Size>( Size.class ).param( "min", 1 ).param( "max", 10 ) );
    config.addMapping( mapping );
View Full Code Here

    }
  }

  @Test
  public void testMultipleParameterConstraintsAtSameParameter() {
    ConstraintMapping mapping = config.createConstraintMapping();
    mapping.type( GreetingService.class )
        .method( "greet", String.class )
        .parameter( 0 )
        .constraint( new SizeDef().min( 1 ).max( 10 ) )
        .constraint( new SizeDef().min( 2 ).max( 10 ) );
    config.addMapping( mapping );
View Full Code Here

    }
  }

  @Test
  public void testMultipleParameterConstraintsAtDifferentParameters() {
    ConstraintMapping mapping = config.createConstraintMapping();
    mapping.type( GreetingService.class )
        .method( "greet", String.class, String.class )
        .parameter( 0 )
        .constraint( new SizeDef().min( 1 ).max( 10 ) )
        .parameter( 1 )
        .constraint( new SizeDef().min( 1 ).max( 10 ) );
View Full Code Here

    }
  }

  @Test
  public void testProgrammaticAndAnnotationParameterConstraintsAddUp() {
    ConstraintMapping mapping = config.createConstraintMapping();
    mapping.type( GreetingService.class )
        .method( "sayHello", String.class )
        .parameter( 0 )
        .constraint( new SizeDef().min( 2 ).max( 10 ) );
    config.addMapping( mapping );
View Full Code Here

    }
  }

  @Test
  public void testConstraintAtCascadedParameter() {
    ConstraintMapping mapping = config.createConstraintMapping();
    mapping.type( GreetingService.class )
        .method( "greet", User.class )
        .parameter( 0 )
        .constraint( new NotNullDef() )
        .valid();
    config.addMapping( mapping );
View Full Code Here

    }
  }

  @Test
  public void testReturnValueConstraint() {
    ConstraintMapping mapping = config.createConstraintMapping();
    mapping.type( GreetingService.class )
        .method( "greet", String.class )
        .returnValue()
        .constraint( new SizeDef().min( 1 ).max( 10 ) );
    config.addMapping( mapping );
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.