Package org.hibernate.validator.cfg

Examples of org.hibernate.validator.cfg.ConstraintMapping


    }
  }

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


    }
  }

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

    }
  }

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

    }
  }

  @Test
  public void constraintConfiguredOnPropertyIsEvaluatedByMethodValidation() {
    ConstraintMapping mapping = config.createConstraintMapping();
    mapping.type( GreetingService.class )
        .property( "hello", ElementType.METHOD )
        .constraint( new NotNullDef() );
    config.addMapping( mapping );

    try {
View Full Code Here

    }
  }

  @Test
  public void cascadeConfiguredOnPropertyIsEvaluatedByMethodValidation() {
    ConstraintMapping mapping = config.createConstraintMapping();
    mapping.type( GreetingService.class )
        .property( "user", ElementType.METHOD )
        .valid();
    config.addMapping( mapping );

    try {
View Full Code Here

    }
  }

  @Test
  public void constraintConfiguredOnFieldIsNotEvaluatedByMethodValidation() {
    ConstraintMapping mapping = config.createConstraintMapping();
    mapping.type( GreetingServiceImpl.class )
        .property( "hello", ElementType.FIELD )
        .constraint( new NotNullDef() );
    config.addMapping( mapping );

    GreetingService service = getValidatingProxy( wrappedObject, config.buildValidatorFactory().getValidator() );
View Full Code Here

    assertNull( service.getHello() );
  }

  @Test
  public void cascadeConfiguredOnFieldIsNotEvaluatedByMethodValidation() {
    ConstraintMapping mapping = config.createConstraintMapping();
    mapping.type( GreetingServiceImpl.class )
        .property( "user", ElementType.FIELD )
        .valid();
    config.addMapping( mapping );

    GreetingService service = getValidatingProxy( wrappedObject, config.buildValidatorFactory().getValidator() );
View Full Code Here

    assertNull( service.getUser().getName() );
  }

  @Test
  public void constraintConfiguredOnMethodIsEvaluatedByPropertyValidation() {
    ConstraintMapping mapping = config.createConstraintMapping();
    mapping.type( GreetingService.class )
        .method( "getHello" )
        .returnValue()
        .constraint( new NotNullDef() );
    config.addMapping( mapping );
View Full Code Here

    assertCorrectPropertyPaths( violations, "hello" );
  }

  @Test
  public void cascadeConfiguredOnMethodIsEvaluatedByPropertyValidation() {
    ConstraintMapping mapping = config.createConstraintMapping();
    mapping.type( GreetingService.class )
        .method( "getUser" )
        .returnValue()
        .valid();
    config.addMapping( mapping );
View Full Code Here

  }

  @Test
  @TestForIssue(jiraKey = "HV-769")
  public void shouldDetermineConstraintTargetForReturnValueConstraint() {
    ConstraintMapping mapping = config.createConstraintMapping();
    mapping.type( GreetingService.class )
        .method( "greet", String.class, String.class )
        .returnValue()
        .constraint(
            new GenericConstraintDef<GenericAndCrossParameterConstraint>(
                GenericAndCrossParameterConstraint.class
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.