Package org.hibernate.validator.cfg

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


  }

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


  }

  @Test
  public void testGenericParameterConstraint() throws Exception {
    ConstraintMapping mapping = config.createConstraintMapping();
    mapping.type( GreetingService.class )
        .constructor( 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() throws Exception {
    ConstraintMapping mapping = config.createConstraintMapping();
    mapping.type( GreetingService.class )
        .constructor( 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() throws Exception {
    ConstraintMapping mapping = config.createConstraintMapping();
    mapping.type( GreetingService.class )
        .constructor( 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() throws Exception {
    ConstraintMapping mapping = config.createConstraintMapping();
    mapping.type( GreetingService.class )
        .constructor( CharSequence.class )
        .parameter( 0 )
        .constraint( new SizeDef().min( 2 ).max( 10 ) );
    config.addMapping( mapping );
View Full Code Here

  }

  @Test
  public void testReturnValueConstraint() throws Exception {
    ConstraintMapping mapping = config.createConstraintMapping();
    mapping.type( GreetingService.class )
        .constructor( String.class )
        .returnValue()
        .constraint(
            new GenericConstraintDef<ValidGreetingService>( ValidGreetingService.class ).message(
                "invalid"
View Full Code Here

  }

  @Test
  public void testMultipleReturnValueConstraints() throws Exception {
    ConstraintMapping mapping = config.createConstraintMapping();
    mapping.type( GreetingService.class )
        .constructor( String.class )
        .returnValue()
        .constraint(
            new GenericConstraintDef<ValidGreetingService>( ValidGreetingService.class ).message(
                "invalid 1"
View Full Code Here

  }

  @Test
  public void testProgrammaticAndAnnotationReturnValueConstraintsAddUp() throws Exception {
    ConstraintMapping mapping = config.createConstraintMapping();
    mapping.type( GreetingService.class )
        .constructor( CharSequence.class )
        .returnValue()
        .constraint(
            new GenericConstraintDef<ValidGreetingService>( ValidGreetingService.class ).message(
                "invalid 2"
View Full Code Here

  }

  @Test
  public void shouldDetermineConstraintTargetForReturnValueConstraint() throws Exception {
    ConstraintMapping mapping = config.createConstraintMapping();
    mapping.type( GreetingService.class )
        .constructor( String.class, String.class )
        .returnValue()
        .constraint(
            new GenericConstraintDef<GenericAndCrossParameterConstraint>(
                GenericAndCrossParameterConstraint.class
View Full Code Here

  }

  @Test
  public void crossParameterConstraint() throws Exception {
    ConstraintMapping mapping = config.createConstraintMapping();
    mapping.type( GreetingService.class )
        .constructor( String.class, String.class )
        .crossParameter()
        .constraint(
            new GenericConstraintDef<GenericAndCrossParameterConstraint>(
                GenericAndCrossParameterConstraint.class
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.