Package org.hibernate.validator.cfg

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


  @Test
  public void testProgrammaticConstraint() {
    final HibernateValidatorConfiguration config = getConfiguration( HibernateValidator.class );
    ConstraintMapping mapping = config.createConstraintMapping();
    mapping.type( Product.class )
        .property( "ean", FIELD )
        .constraint( new EANDef().type( EAN.Type.EAN13 ) );
    config.addMapping( mapping );
    Validator validator = config.buildValidatorFactory().getValidator();
View Full Code Here


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

  @Test
  @TestForIssue(jiraKey = "HV-433")
  public void testProgrammaticCascadingValidationMethodAccess() {
    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 testProgrammaticConstraint() {
    final HibernateValidatorConfiguration config = getConfiguration( HibernateValidator.class );
    ConstraintMapping mapping = config.createConstraintMapping();
    mapping.type( Product.class )
        .property( "ean", FIELD )
        .constraint( new EANDef().type( EAN.Type.EAN8 ) );
    config.addMapping( mapping );
    Validator validator = config.buildValidatorFactory().getValidator();
View Full Code Here

  @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

  }

  @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

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.