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

Examples of org.hibernate.validator.internal.constraintvalidators.hv.LuhnCheckValidator.initialize()


  @Test(expectedExceptions = IllegalArgumentException.class)
  public void testInvalidStartIndex() {
    LuhnCheckValidator validator = new LuhnCheckValidator();
    LuhnCheck modCheck = createLuhnCheckAnnotation( -1, Integer.MAX_VALUE, -1, false );
    validator.initialize( modCheck );
  }

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void testInvalidEndIndex() {
    LuhnCheckValidator validator = new LuhnCheckValidator();
View Full Code Here


  @Test(expectedExceptions = IllegalArgumentException.class)
  public void testInvalidEndIndex() {
    LuhnCheckValidator validator = new LuhnCheckValidator();
    LuhnCheck modCheck = createLuhnCheckAnnotation( 0, -1, -1, false );
    validator.initialize( modCheck );
  }

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void testEndIndexLessThanStartIndex() {
    LuhnCheckValidator validator = new LuhnCheckValidator();
View Full Code Here

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void testEndIndexLessThanStartIndex() {
    LuhnCheckValidator validator = new LuhnCheckValidator();
    LuhnCheck modCheck = createLuhnCheckAnnotation( 5, 0, -1, false );
    validator.initialize( modCheck );
  }

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void testInvalidCheckDigitIndex() {
    LuhnCheckValidator validator = new LuhnCheckValidator();
View Full Code Here

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void testInvalidCheckDigitIndex() {
    LuhnCheckValidator validator = new LuhnCheckValidator();
    LuhnCheck modCheck = createLuhnCheckAnnotation( 0, 10, 5, false );
    validator.initialize( modCheck );
  }

  @Test
  public void testFailOnNonNumeric() throws Exception {
    LuhnCheckValidator validator = new LuhnCheckValidator();
View Full Code Here

  @Test
  public void testFailOnNonNumeric() throws Exception {
    LuhnCheckValidator validator = new LuhnCheckValidator();
    LuhnCheck modCheck = createLuhnCheckAnnotation( 0, Integer.MAX_VALUE, -1, false );
    validator.initialize( modCheck );

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

  @Test
View Full Code Here

  @Test
  public void testIgnoreNonNumeric() throws Exception {
    LuhnCheckValidator validator = new LuhnCheckValidator();
    LuhnCheck modCheck = createLuhnCheckAnnotation( 0, Integer.MAX_VALUE, -1, true );
    validator.initialize( modCheck );

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

  @Test
View Full Code Here

  @Test
  public void testValidMod10() throws Exception {
    LuhnCheckValidator validator = new LuhnCheckValidator();
    LuhnCheck modCheck = createLuhnCheckAnnotation( 0, Integer.MAX_VALUE, -1, false );
    validator.initialize( modCheck );

    assertTrue( validator.isValid( "79927398713", null ) );
  }

  @Test
View Full Code Here

  @Test
  public void testValidMod10WithGivenRange() throws Exception {
    LuhnCheckValidator validator = new LuhnCheckValidator();
    LuhnCheck modCheck = createLuhnCheckAnnotation( 3, 15, -1, true );
    validator.initialize( modCheck );

    assertTrue( validator.isValid( "123-7992739871-3", null ) );
  }

  @Test
View Full Code Here

  @Test
  public void testValidMod10WithGivenRangeAndCheckDigitIndex() throws Exception {
    LuhnCheckValidator validator = new LuhnCheckValidator();
    LuhnCheck modCheck = createLuhnCheckAnnotation( 3, 13, 15, true );
    validator.initialize( modCheck );

    assertTrue( validator.isValid( "123-7992739871-3-456", null ) );
  }

  @Test
View Full Code Here

  @Test
  public void testInvalidMod10() throws Exception {
    LuhnCheckValidator validator = new LuhnCheckValidator();
    LuhnCheck modCheck = createLuhnCheckAnnotation( 0, Integer.MAX_VALUE, -1, false );
    validator.initialize( modCheck );

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

  private LuhnCheck createLuhnCheckAnnotation(int start, int end, int checkDigitIndex, boolean ignoreNonDigits) {
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.