Package org.hibernate.validator.cfg

Examples of org.hibernate.validator.cfg.ConstraintMapping


  }

  @Test
  @TestForIssue(jiraKey = "HV-433")
  public void testProgrammaticCascadingMethodValidation() {
    ConstraintMapping newMapping = config.createConstraintMapping();
    newMapping
        .type( C.class )
        .property( "string", METHOD )
        .constraint( new NotNullDef() )
        .type( A.class )
        .property( "c", METHOD )
View Full Code Here


  }

  @Test
  public void shouldUnwrapPropertyValueBasedOnProgrammaticConfiguration() {
    HibernateValidatorConfiguration configuration = ValidatorUtil.getConfiguration();
    ConstraintMapping mapping = configuration.createConstraintMapping();
    mapping.type( OrderLine.class )
        .property( "id", ElementType.FIELD )
          .unwrapValidatedValue( true );

    Validator validator = configuration.addMapping( mapping )
        .addValidatedValueHandler( new PropertyValueUnwrapper() )
View Full Code Here

  }

  @Test(expectedExceptions = UnexpectedTypeException.class, expectedExceptionsMessageRegExp = "HV000030.*")
  public void explicitly_skipping_unwrapping_leads_to_exception_due_to_missing_constraint_validator() {
    HibernateValidatorConfiguration configuration = ValidatorUtil.getConfiguration();
    ConstraintMapping mapping = configuration.createConstraintMapping();
    mapping.type( OrderLine.class )
        .property( "id", ElementType.FIELD )
          .unwrapValidatedValue( false );

    Validator validator = configuration.addMapping( mapping )
        .addValidatedValueHandler( new PropertyValueUnwrapper() )
View Full Code Here

  }

  @Test
  public void shouldUnwrapParameterValueBasedOnProgrammaticConfiguration() throws Exception {
    HibernateValidatorConfiguration configuration = ValidatorUtil.getConfiguration();
    ConstraintMapping mapping = configuration.createConstraintMapping();
    mapping.type( OrderLine.class )
        .method( "setId", Property.class )
          .parameter( 0 )
            .unwrapValidatedValue( true );

    Validator validator = configuration.addMapping( mapping )
View Full Code Here

  }

  @Test
  public void shouldUnwrapReturnValueBasedOnProgrammaticConfiguration() throws Exception {
    HibernateValidatorConfiguration configuration = ValidatorUtil.getConfiguration();
    ConstraintMapping mapping = configuration.createConstraintMapping();
    mapping.type( OrderLine.class )
        .method( "getId" )
          .returnValue()
            .unwrapValidatedValue( true );

    Validator validator = configuration.addMapping( mapping )
View Full Code Here

    config = getConfiguration( HibernateValidator.class );
  }

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

    }
  }

  @Test
  public void testCascadingMethodReturnDefinitionWithGroupConversion() {
    ConstraintMapping mapping = config.createConstraintMapping();
    mapping.type( GreetingService.class )
        .method( "greet", User.class )
        .returnValue()
        .valid()
        .convertGroup( Default.class ).to( TestGroup.class )
        .type( Message.class )
View Full Code Here

    }
  }

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

  @Test(
      expectedExceptions = IllegalArgumentException.class,
      expectedExceptionsMessageRegExp = "HV[0-9]*: Type .*GreetingService doesn't have a method greet().*"
  )
  public void testCascadingDefinitionOnMissingMethod() {
    ConstraintMapping mapping = config.createConstraintMapping();
    mapping.type( GreetingService.class )
        .method( "greet" )
        .returnValue()
        .valid();

    config.buildValidatorFactory().getValidator();
View Full Code Here

  @Test(
      expectedExceptions = IllegalArgumentException.class,
      expectedExceptionsMessageRegExp = "HV000056.*"
  )
  public void testCascadingDefinitionOnInvalidMethodParameter() {
    ConstraintMapping mapping = config.createConstraintMapping();
    mapping.type( GreetingService.class )
        .method( "greet", User.class )
        .parameter( 1 )
        .valid();

    config.buildValidatorFactory().getValidator();
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.