Package org.hibernate.validator.internal.constraintvalidators.hv

Examples of org.hibernate.validator.internal.constraintvalidators.hv.Mod11CheckValidator


*/
public class Mod11CheckValidatorTest {

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void testInvalidStartIndex() {
    Mod11CheckValidator validator = new Mod11CheckValidator();
    Mod11Check modCheck = createMod11CheckAnnotation(
        -1,
        Integer.MAX_VALUE,
        -1,
        false,
        '0',
        '0',
        ProcessingDirection.RIGHT_TO_LEFT
    );
    validator.initialize( modCheck );
  }
View Full Code Here


    validator.initialize( modCheck );
  }

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void testInvalidEndIndex() {
    Mod11CheckValidator validator = new Mod11CheckValidator();
    Mod11Check modCheck = createMod11CheckAnnotation(
        0,
        -1,
        -1,
        false,
        '0',
        '0',
        ProcessingDirection.RIGHT_TO_LEFT
    );
    validator.initialize( modCheck );
  }
View Full Code Here

    validator.initialize( modCheck );
  }

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void testEndIndexLessThanStartIndex() {
    Mod11CheckValidator validator = new Mod11CheckValidator();
    Mod11Check modCheck = createMod11CheckAnnotation(
        5,
        0,
        -1,
        false,
        '0',
        '0',
        ProcessingDirection.RIGHT_TO_LEFT
    );
    validator.initialize( modCheck );
  }
View Full Code Here

    validator.initialize( modCheck );
  }

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void testInvalidcheckDigitIndex() {
    Mod11CheckValidator validator = new Mod11CheckValidator();
    Mod11Check modCheck = createMod11CheckAnnotation(
        0,
        10,
        5,
        false,
        '0',
        '0',
        ProcessingDirection.RIGHT_TO_LEFT
    );
    validator.initialize( modCheck );
  }
View Full Code Here

    validator.initialize( modCheck );
  }

  @Test
  public void testFailOnNonNumeric() throws Exception {
    Mod11CheckValidator validator = new Mod11CheckValidator();
    Mod11Check modCheck = createMod11CheckAnnotation(
        0,
        Integer.MAX_VALUE,
        -1,
        false,
        '0',
        '0',
        ProcessingDirection.RIGHT_TO_LEFT
    );
    validator.initialize( modCheck );

    assertFalse( validator.isValid( new MyCustomStringImpl( "Z54679542616" ), null ) );
  }
View Full Code Here

    assertFalse( validator.isValid( new MyCustomStringImpl( "Z54679542616" ), null ) );
  }

  @Test
  public void testIgnoreNonNumeric() throws Exception {
    Mod11CheckValidator validator = new Mod11CheckValidator();
    Mod11Check modCheck = createMod11CheckAnnotation(
        0,
        Integer.MAX_VALUE,
        -1,
        true,
        '0',
        '0',
        ProcessingDirection.RIGHT_TO_LEFT
    );
    validator.initialize( modCheck );

    assertTrue( validator.isValid( new MyCustomStringImpl( "Z54679542616" ), null ) );
  }
View Full Code Here

    assertTrue( validator.isValid( new MyCustomStringImpl( "Z54679542616" ), null ) );
  }

  @Test
  public void testIgnoreNonNumericWithCharCheckDigit() throws Exception {
    Mod11CheckValidator validator = new Mod11CheckValidator();
    Mod11Check modCheck = createMod11CheckAnnotation(
        0,
        12,
        -1,
        true,
        '0',
        'X',
        ProcessingDirection.LEFT_TO_RIGHT
    );
    validator.initialize( modCheck );

    assertTrue( validator.isValid( "123-456-789-X", null ) );
  }
View Full Code Here

    assertTrue( validator.isValid( "123-456-789-X", null ) );
  }

  @Test
  public void testValidMod11() throws Exception {
    Mod11CheckValidator validator = new Mod11CheckValidator();
    Mod11Check modCheck = createMod11CheckAnnotation(
        0,
        Integer.MAX_VALUE,
        -1,
        true,
        '0',
        '0',
        ProcessingDirection.RIGHT_TO_LEFT
    );
    validator.initialize( modCheck );

    assertTrue( validator.isValid( "23322023583", null ) );
    assertTrue( validator.isValid( "378.796.950-01", null ) );
    assertTrue( validator.isValid( "331.814.296-43", null ) );
  }
View Full Code Here

    assertTrue( validator.isValid( "331.814.296-43", null ) );
  }

  @Test
  public void testInvalidMod11() throws Exception {
    Mod11CheckValidator validator = new Mod11CheckValidator();
    Mod11Check modCheck = createMod11CheckAnnotation(
        0,
        Integer.MAX_VALUE,
        -1,
        true,
        '0',
        '0',
        ProcessingDirection.RIGHT_TO_LEFT
    );
    validator.initialize( modCheck );

    assertFalse( validator.isValid( "23322023584", null ) );
    assertFalse( validator.isValid( "378.796.950-02", null ) );
    assertFalse( validator.isValid( "331.814.296-52", null ) );
  }
View Full Code Here

    assertFalse( validator.isValid( "331.814.296-52", null ) );
  }

  @Test
  public void testValidMod11CharCheckDigit() throws Exception {
    Mod11CheckValidator validator = new Mod11CheckValidator();
    Mod11Check modCheck = createMod11CheckAnnotation(
        0,
        Integer.MAX_VALUE,
        -1,
        false,
        'X',
        'Z',
        ProcessingDirection.RIGHT_TO_LEFT
    );
    validator.initialize( modCheck );

    assertTrue( validator.isValid( "123456Z", null ) );
    assertTrue( validator.isValid( "1234575X", null ) );
  }
View Full Code Here

TOP

Related Classes of org.hibernate.validator.internal.constraintvalidators.hv.Mod11CheckValidator

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.