Add unit tests for BaseHyphenatedIdentifierValidator#6124
Open
JasonWang-0401 wants to merge 1 commit into
Open
Add unit tests for BaseHyphenatedIdentifierValidator#6124JasonWang-0401 wants to merge 1 commit into
JasonWang-0401 wants to merge 1 commit into
Conversation
The abstract base class for hyphenated check-digit identifier validators had no direct test; its logic was only exercised indirectly through the Luhn and Verhoeff subclass tests, where it is tangled with each subclass's check-digit algorithm. This adds a focused unit test that uses a stub subclass with a fixed, caller-controlled check digit to verify the base-class contract in isolation: hyphen/check-digit parsing, the 0-9 <-> A-J mapping (including the out-of-range 'X' default), case-insensitive check letters, and the allowed-character rules (null/empty/whitespace/disallowed). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Description of what I changed
Adds
BaseHyphenatedIdentifierValidatorTest, a unit test for the abstract base classBaseHyphenatedIdentifierValidatorthat all of the "hyphenated check-digit" patient-identifiervalidators (
LuhnIdentifierValidator,VerhoeffIdentifierValidator) inherit from. The baseclass previously had no direct test — its behaviour was only exercised indirectly through the
two subclass tests, where it is entangled with each subclass's own check-digit algorithm
(
LuhnIdentifierValidatorTesteven carries a// TODO split this into multiple testsnote).The new test uses a tiny stub subclass with a fixed, caller-controlled check digit so the shared
base-class contract can be verified in isolation, independent of any real check-digit math:
getValidIdentifierappends-+ the correct check letter (the full0→A … 9→Jmapping,and
Xfor an out-of-range digit)isValidreturnstrue/falsecorrectly, accepts the check letter case-insensitively, andworks whether the check digit is supplied as a letter (
id-D) or an integer (id-3)UnallowedIdentifierException(no hyphen, trailing hyphen, multi-charactercheck digit, a check character that is neither
A–Jnor a digit)null/ empty / whitespace / disallowed charactersPure JUnit 5; no Spring context and no database, so it runs in milliseconds. No production code is
changed.
Issue I worked on
Test-coverage improvement for a previously-untested base class. This change is purely additive
test code with no production changes.
see https://issues.openmrs.org/browse/TRUNK-
Checklist: I completed these to help reviewers :)
line length ≤ 125, and import ordering match the surrounding test files.)
mvn clean packageright before creating this pull request. (Verified the change with./mvnw -pl api test -Dtest=BaseHyphenatedIdentifierValidatorTest→Tests run: 10, Failures: 0, Errors: 0.)🤖 Generated with Claude Code