Skip to content

Commit

Permalink
chore(person): introduce incomplete date of death
Browse files Browse the repository at this point in the history
  • Loading branch information
laurensdeb committed Aug 12, 2024
1 parent 24201bc commit c341730
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,21 @@ public NodeDetailedRelatedPerson(Node node) {
}

@Override
@Deprecated(forRemoval = true)
public Optional<LocalDate> deathDate() {
return node.get("Overlijden/Datum")
.flatMap(Node::getValue)
.map(LocalDate::parse);
}

@Override
public Optional<IncompleteDate> incompleteDateOfDeath() {
return node.get("Overlijden/Datum")
.flatMap(Node::getValue)
.map(IncompleteDate::fromString);
}


@Override
public Address mainResidence() {
return node.get("Adressen/Hoofdverblijfplaats")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ interface DetailedRelatedPerson extends RelatedPerson {
*/
Optional<LocalDate> deathDate();

/**
* The person's (potentially incomplete) date of death
*/
Optional<IncompleteDate> incompleteDateOfDeath();

/**
* The address of the person's main residence.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ void deathDateNull_whenMissing() {
assertThat(self.deathDate().isEmpty(), is(true));
}

@Test
void incompleteDeathDateNull_whenMissing() {
assertThat(self.incompleteDateOfDeath().isEmpty(), is(true));
}

@Test
void mapsNISCodeCountry() { assertThat(self.mainResidence().nisCodeCountry(), is(Optional.of("150"))); }

Expand All @@ -76,6 +81,11 @@ void mapsDeathDate() {
MatcherAssert.assertThat(person("65712399877").self().deathDate().get(), is(equalTo(LocalDate.of(2002, 1, 1))));
}

@Test
void mapsIncompleteDeathDate(){
MatcherAssert.assertThat(person("65712399877").self().incompleteDateOfDeath().get().toLocalDate(), is(equalTo(LocalDate.of(2002, 1, 1))));
}

@Test
void mapsMainResidence_caseA() {
var address = person("78721626143").self().mainResidence();
Expand Down

0 comments on commit c341730

Please sign in to comment.