Package org.hibernate.validator.cfg.defs

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


  @TestForIssue(jiraKey = "HV-500")
  public void testMultipleConstraintMappings() {
    ConstraintMapping marathonMapping = config.createConstraintMapping();
    marathonMapping.type( Marathon.class )
        .property( "name", METHOD )
        .constraint( new NotNullDef() );

    ConstraintMapping runnerMapping = config.createConstraintMapping();
    runnerMapping.type( Runner.class )
        .property( "name", METHOD )
        .constraint( new NotNullDef() );

    config.addMapping( marathonMapping );
    config.addMapping( runnerMapping );
    Validator validator = config.buildValidatorFactory().getValidator();
View Full Code Here


  @Test(expectedExceptions = ValidationException.class, expectedExceptionsMessageRegExp = "HV000172.*")
  public void testSamePropertyConfiguredSeveralTimesCausesException() {
    ConstraintMapping marathonMapping = config.createConstraintMapping();
    marathonMapping.type( Marathon.class )
        .property( "name", METHOD )
          .constraint( new NotNullDef() )
        .property( "name", METHOD );
  }
View Full Code Here

  public void testSameMethodConfiguredSeveralTimesCausesException() {
    ConstraintMapping marathonMapping = config.createConstraintMapping();
    marathonMapping.type( Marathon.class )
        .method( "setTournamentDate", Date.class )
          .parameter( 0 )
            .constraint( new NotNullDef() )
        .method( "setTournamentDate", Date.class );
  }
View Full Code Here

  public void testSameParameterConfiguredSeveralTimesCausesException() {
    ConstraintMapping marathonMapping = config.createConstraintMapping();
    marathonMapping.type( Marathon.class )
        .method( "setTournamentDate", Date.class )
          .parameter( 0 )
            .constraint( new NotNullDef() )
        .parameter( 0 );
  }
View Full Code Here

        .parameter( 0 )
        .valid()
        .convertGroup( Default.class ).to( TestGroup.class )
        .type( User.class )
        .property( "name", ElementType.FIELD )
        .constraint( new NotNullDef().message( "name must not be null" ).groups( TestGroup.class ) );
    config.addMapping( mapping );


    Constructor<GreetingService> constructor = GreetingService.class.getConstructor( User.class );
    Object[] parameterValues = new Object[] { new User( null ) };
View Full Code Here

  public void testParameterConstraint() throws Exception {
    ConstraintMapping mapping = config.createConstraintMapping();
    mapping.type( GreetingService.class )
        .constructor( User.class )
        .parameter( 0 )
        .constraint( new NotNullDef() );
    config.addMapping( mapping );

    Constructor<GreetingService> constructor = GreetingService.class.getConstructor( User.class );
    Object[] parameterValues = new Object[] { null };
View Full Code Here

  @Test
  public void testConstraintMappingWithConstraintDefs() {
    mapping.type( Marathon.class )
        .property( "name", METHOD )
        .constraint( new NotNullDef() )
        .property( "numberOfHelpers", FIELD )
        .constraint( new MinDef().value( 1 ) );

    BeanConfiguration<Marathon> beanConfiguration = getBeanConfiguration( Marathon.class );
    assertNotNull( beanConfiguration );
View Full Code Here

  @Test
  public void testSingleConstraint() {
    mapping.type( Marathon.class )
        .property( "name", METHOD )
        .constraint( new NotNullDef() );
    config.addMapping( mapping );
    Validator validator = config.buildValidatorFactory().getValidator();

    Set<ConstraintViolation<Marathon>> violations = validator.validate( new Marathon() );
    assertNumberOfViolations( violations, 1 );
View Full Code Here

  @Test
  public void testInheritedConstraint() {
    mapping.type( Marathon.class )
        .property( "name", METHOD )
        .constraint( new NotNullDef() )
        .type( Tournament.class )
        .property( "tournamentDate", METHOD )
        .constraint( new FutureDef() );
    config.addMapping( mapping );
    Validator validator = config.buildValidatorFactory().getValidator();
View Full Code Here

      expectedExceptionsMessageRegExp = "HV[0-9]*: The class class org.hibernate.validator.test.cfg.Marathon does not have a property 'numberOfHelpers' with access METHOD."
  )
  public void testSingleConstraintWrongAccessType() throws Throwable {
    mapping.type( Marathon.class )
        .property( "numberOfHelpers", METHOD )
        .constraint( new NotNullDef() );
  }
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.