-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow secure account number to be used with any account number class
- Loading branch information
Showing
5 changed files
with
81 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/test/java/us/fatehi/test/utility/AccountNumbersTestUtility.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package us.fatehi.test.utility; | ||
|
||
import us.fatehi.creditcardnumber.AccountNumber; | ||
|
||
public class AccountNumbersTestUtility { | ||
|
||
public static boolean equivalent(final AccountNumber pan1, final AccountNumber pan2) { | ||
if (pan1 == pan2) { | ||
return true; | ||
} | ||
if (pan1 == null || pan2 == null) { | ||
return false; | ||
} | ||
|
||
// Compare metadata | ||
if (pan1.getCardBrand() != pan2.getCardBrand()) { | ||
return false; | ||
} | ||
if (pan1.getMajorIndustryIdentifier() != pan2.getMajorIndustryIdentifier()) { | ||
return false; | ||
} | ||
if (pan1.passesLuhnCheck() != pan2.passesLuhnCheck()) { | ||
return false; | ||
} | ||
if (pan1.getAccountNumberLength() != pan2.getAccountNumberLength()) { | ||
return false; | ||
} | ||
if (pan1.isLengthValid() != pan2.isLengthValid()) { | ||
return false; | ||
} | ||
if (pan1.isPrimaryAccountNumberValid() != pan2.isPrimaryAccountNumberValid()) { | ||
return false; | ||
} | ||
if (pan1.exceedsMaximumLength() != pan2.exceedsMaximumLength()) { | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
private AccountNumbersTestUtility() { | ||
// Prevent instantation | ||
} | ||
} |