diff --git a/belgif-rest-problem/src/main/java/io/github/belgif/rest/problem/api/InputValidationIssues.java b/belgif-rest-problem/src/main/java/io/github/belgif/rest/problem/api/InputValidationIssues.java index e6481664..8a74a035 100644 --- a/belgif-rest-problem/src/main/java/io/github/belgif/rest/problem/api/InputValidationIssues.java +++ b/belgif-rest-problem/src/main/java/io/github/belgif/rest/problem/api/InputValidationIssues.java @@ -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)) diff --git a/belgif-rest-problem/src/test/java/io/github/belgif/rest/problem/api/InputValidationIssuesTest.java b/belgif-rest-problem/src/test/java/io/github/belgif/rest/problem/api/InputValidationIssuesTest.java index 53a6571d..a424af24 100644 --- a/belgif-rest-problem/src/test/java/io/github/belgif/rest/problem/api/InputValidationIssuesTest.java +++ b/belgif-rest-problem/src/test/java/io/github/belgif/rest/problem/api/InputValidationIssuesTest.java @@ -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; @@ -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 = diff --git a/src/main/asciidoc/index.adoc b/src/main/asciidoc/index.adoc index 4cec9d1d..94850bed 100644 --- a/src/main/asciidoc/index.adoc +++ b/src/main/asciidoc/index.adoc @@ -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:*