@@ -18,7 +18,20 @@ class SsnValidationUtilsTest : BehaviorSpec({
1818 row("05011399292", "fnr", LocalDate .of(2013, 1, 5)),
1919 row("41011088188", "dnr", LocalDate .of(2010, 1, 1)),
2020 row("01811088188", "tnr", LocalDate .of(2010, 1, 1)),
21+ ) { socialSecurityId, type, expectedDate ->
22+ When ("$socialSecurityId $type") {
23+
24+ val dateOfBirth = SsnValidationUtils .extractBirthDateFromSocialSecurityId(socialSecurityId)
25+
26+ Then ("dateOfBirth ($dateOfBirth) should be as expected ($expectedDate)") {
27+ dateOfBirth shouldBe expectedDate
28+ }
29+ }
30+ }
31+ }
2132
33+ Given ("parseDateWithAutoPivotYear") {
34+ forAll(
2235 row("01015450068", "fnr", LocalDate .of(1854, 1, 1)),
2336 row("31129974810", "fnr", LocalDate .of(1899, 12, 31)),
2437
@@ -30,10 +43,14 @@ class SsnValidationUtilsTest : BehaviorSpec({
3043
3144 row("01010050053", "fnr", LocalDate .of(2000, 1, 1)),
3245 row("31123999854", "fnr", LocalDate .of(2039, 12, 31)),
46+
47+ row("31124588890", "fnr", LocalDate .of(2045, 12, 31)),
48+ row("31123974912", "fnr", LocalDate .of(2039, 12, 31)),
49+ row("01014074912", "fnr", LocalDate .of(2040, 1, 1)),
3350 ) { socialSecurityId, type, expectedDate ->
3451 When ("$socialSecurityId $type") {
3552
36- val dateOfBirth = SsnValidationUtils .extractBirthDateFromSocialSecurityId (socialSecurityId)
53+ val dateOfBirth = SsnValidationUtils .parseDateWithAutoPivotYear (socialSecurityId)
3754
3855 Then ("dateOfBirth ($dateOfBirth) should be as expected ($expectedDate)") {
3956 dateOfBirth shouldBe expectedDate
0 commit comments