Package org.hibernate.validator.cfg

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


  }

  @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

      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

      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

  }

  @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

  }

  @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

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.