Skip to content

Commit

Permalink
Add optional replacedByHref property to replacedSsin issue type (#68)
Browse files Browse the repository at this point in the history
Fix #67.
  • Loading branch information
jpraet authored Jun 7, 2024
1 parent 1fccb25 commit 4d1f5fc
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ public static InputValidationIssue replacedSsin(InEnum in, String name, String s
.additionalProperty("replacedBy", newSsin);
}

public static InputValidationIssue replacedSsin(InEnum in, String name, String ssin, String newSsin, URI newHref) {
return replacedSsin(in, name, ssin, newSsin).additionalProperty("replacedByHref", String.valueOf(newHref));
}

public static InputValidationIssue canceledSsin(InEnum in, String name, String ssin) {
return new InputValidationIssue(ISSUE_TYPE_CANCELED_SSIN, "SSIN has been canceled")
.detail(String.format("SSIN %s has been canceled", ssin))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static org.assertj.core.api.Assertions.*;

import java.net.URI;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.time.OffsetTime;
Expand Down Expand Up @@ -168,6 +169,23 @@ void replacedSsin() {
assertThat(issue).extracting("href", "inputs").allMatch(this::isEmpty);
}

@Test
void replacedSsinWithReplacedByHref() {
InputValidationIssue issue =
InputValidationIssues.replacedSsin(InEnum.BODY, "ssin", "00000000196", "00000000295",
URI.create("https://api.company.com/v1/employees?ssin=00000000295"));
assertThat(issue.getType()).hasToString("urn:problem-type:cbss:input-validation:replacedSsin");
assertThat(issue.getTitle()).isEqualTo("SSIN has been replaced, use new SSIN");
assertThat(issue.getIn()).isEqualTo(InEnum.BODY);
assertThat(issue.getName()).isEqualTo("ssin");
assertThat(issue.getValue()).isEqualTo("00000000196");
assertThat(issue.getDetail()).isEqualTo("SSIN 00000000196 has been replaced by 00000000295");
assertThat(issue.getAdditionalProperties()).containsExactly(
entry("replacedBy", "00000000295"),
entry("replacedByHref", "https://api.company.com/v1/employees?ssin=00000000295"));
assertThat(issue).extracting("href", "inputs").allMatch(this::isEmpty);
}

@Test
void canceledSsin() {
InputValidationIssue issue =
Expand Down
1 change: 1 addition & 0 deletions src/main/asciidoc/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ The library consists of these modules:

* Removed deprecated InvalidParamProblem: use InputValidationProblem, which supports both the legacy invalidParams[] and the new issues[] structure
* Replace specific `urn:problem-type:cbss:input-validation:unknownSsin` issue type by generic `urn:problem-type:cbss:input-validation:referencedResourceNotFound`
* Added optional replacedByHref property to replacedSsin issue type

*belgif-rest-problem-validator:*

Expand Down

0 comments on commit 4d1f5fc

Please sign in to comment.