org.apache.bval.extras.constraints.checkdigit
Class AbstractCheckDigitTest

java.lang.Object
  extended by org.apache.bval.extras.constraints.checkdigit.AbstractCheckDigitTest
Direct Known Subclasses:
ABANumberValidatorTest, CUSIPValidatorTest, EAN13CheckDigitTest, IBANCheckDigitTest, ISBN10CheckDigitTest, LuhnCheckDigitTest, SedolCheckDigitTest, VerhoeffCheckDigitTest

public abstract class AbstractCheckDigitTest
extends Object


Constructor Summary
AbstractCheckDigitTest()
           
 
Method Summary
protected  String checkDigit(String code)
          Returns the check digit (i.e.
protected  String[] createInvalidCodes(String[] codes)
          Returns an array of codes with invalid check digits.
 int getCheckDigitLth()
           
protected abstract  ConstraintValidator<? extends Annotation,String> getConstraint()
           
protected  String[] getInvalid()
           
 String getMissingMessage()
           
protected abstract  String[] getValid()
           
protected  String getZeroSum()
           
protected  String removeCheckDigit(String code)
          Returns a code with the Check Digit (i.e.
 void setUp()
           
 void tearDown()
          Tear Down - clears routine and valid codes.
 void testIsValidFalse()
          Test isValid() for invalid values.
 void testIsValidTrue()
          Test isValid() for valid values.
 void testMissingCode()
          Test missing code
 void testZeroSum()
          Test zero sum
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractCheckDigitTest

public AbstractCheckDigitTest()
Method Detail

getCheckDigitLth

public int getCheckDigitLth()

getConstraint

protected abstract ConstraintValidator<? extends Annotation,String> getConstraint()

getValid

protected abstract String[] getValid()

getInvalid

protected String[] getInvalid()

getZeroSum

protected String getZeroSum()

getMissingMessage

public String getMissingMessage()

setUp

public void setUp()

tearDown

public void tearDown()
Tear Down - clears routine and valid codes.


testIsValidTrue

public void testIsValidTrue()
Test isValid() for valid values.


testIsValidFalse

public void testIsValidFalse()
Test isValid() for invalid values.


testMissingCode

public void testMissingCode()
Test missing code


testZeroSum

public void testZeroSum()
Test zero sum


createInvalidCodes

protected String[] createInvalidCodes(String[] codes)
Returns an array of codes with invalid check digits.

Parameters:
codes - Codes with valid check digits
Returns:
Codes with invalid check digits

removeCheckDigit

protected String removeCheckDigit(String code)
Returns a code with the Check Digit (i.e. last character) removed.

Parameters:
code - The code
Returns:
The code without the check digit

checkDigit

protected String checkDigit(String code)
Returns the check digit (i.e. last character) for a code.

Parameters:
code - The code
Returns:
The check digit


Copyright © 2010-2012 The Apache Software Foundation. All Rights Reserved.