Package org.hibernate.validator.cfg

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


  }

  @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

  }

  @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

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.