Package org.hibernate.validator.cfg.defs

Examples of org.hibernate.validator.cfg.defs.NotNullDef


  public void testParameterConstraint() {
    ConstraintMapping mapping = config.createConstraintMapping();
    mapping.type( GreetingService.class )
        .method( "greet", User.class )
        .parameter( 0 )
        .constraint( new NotNullDef() );
    config.addMapping( mapping );

    try {
      GreetingService service = getValidatingProxy(
          wrappedObject,
View Full Code Here


  public void testConstraintAtCascadedParameter() {
    ConstraintMapping mapping = config.createConstraintMapping();
    mapping.type( GreetingService.class )
        .method( "greet", User.class )
        .parameter( 0 )
        .constraint( new NotNullDef() )
        .valid();
    config.addMapping( mapping );

    GreetingService service = getValidatingProxy( wrappedObject, config.buildValidatorFactory().getValidator() );
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 {
      GreetingService service = getValidatingProxy(
          wrappedObject,
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() );
    assertNull( service.getHello() );
  }
View Full Code Here

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

    Validator validator = config.buildValidatorFactory().getValidator();
    Set<ConstraintViolation<GreetingServiceImpl>> violations = validator.validateProperty(
        new GreetingServiceImpl(), "hello"
View Full Code Here

    ConstraintMapping constraintMapping = configuration.createConstraintMapping();

    constraintMapping
      .type( Car.class )
        .property( "manufacturer", FIELD )
          .constraint( new NotNullDef() )
        .property( "licensePlate", FIELD )
          .ignoreAnnotations()
          .constraint( new NotNullDef() )
          .constraint( new SizeDef().min( 2 ).max( 14 ) )
      .type( RentalCar.class )
        .property( "rentalStation", METHOD )
          .constraint( new NotNullDef() );

    Validator validator = configuration.addMapping( constraintMapping )
        .buildValidatorFactory()
        .getValidator();
  }
View Full Code Here

    ConstraintMapping constraintMapping = configuration.createConstraintMapping();

    constraintMapping
      .type( Car.class )
        .property( "driver", FIELD )
          .constraint( new NotNullDef() )
          .valid()
          .convertGroup( Default.class ).to( PersonDefault.class )
      .type( Person.class )
        .property( "name", FIELD )
          .constraint( new NotNullDef().groups( PersonDefault.class ) );
  }
View Full Code Here

                  "piecesOfLuggagePerPassenger", 2
                )
            )
        .method( "getDriver" )
          .returnValue()
            .constraint( new NotNullDef() )
            .valid();
  }
View Full Code Here

TOP

Related Classes of org.hibernate.validator.cfg.defs.NotNullDef

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.