Skip to content

Commit

Permalink
IDVA3-2626 Fix merge patch int. tests
Browse files Browse the repository at this point in the history
- fix NPE in PscVerificationControllerImpl#clearNameMismatchReasonIfRequired
- replace old name_mismatch_reason: "MAIDEN_NAME" with correct Enum value in PscVerificationControllerImplMergeIT
- add logging of Jackson merge errors to help diagnose future problems
- do not include error details in JSON response (sensitive data)
  • Loading branch information
hepsimo committed Jan 10, 2025
1 parent da42d05 commit ec68ad2
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ private static void clearNameMismatchReasonIfRequired(PscVerification pscVerific
VerificationDetails verificationDetails = pscVerification.getData().verificationDetails();

if (verificationDetails != null) {
Map<String, Object> mergeVerificationDetails = (Map<String, Object>) mergePatch.get("verification_details");
String mergeUvid = (String) mergeVerificationDetails.get("uvid");
final var mergeVerificationDetails = (Map<String, Object>) mergePatch.get("verification_details");
final var mergeUvid = mergeVerificationDetails != null ? (String) mergeVerificationDetails.get("uvid") : null;

if (verificationDetails.uvid() != null && mergeUvid != null
&& !verificationDetails.uvid().equals(mergeUvid)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ public ApiErrors handleInvalidFilingException(final InvalidFilingException ex,
@ResponseBody
public ResponseEntity<Object> handleMergePatchException(final MergePatchException ex,
final WebRequest request) {
logError(chLogger, request, "Invalid patch data", ex, null);
return createRedactedErrorResponseEntity(ex, request, ex.getCause(),
validation.get("patch-merge-error-prefix"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
*/
public class MergePatchException extends RuntimeException {

public MergePatchException(final Throwable cause) {
super(cause);
public MergePatchException(final String message, final Throwable cause) {
super(message, cause);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public PatchResult patch(final String filingId, final Map<String, Object> patchM
patchResult = patchEntity(filingId, pscVerificationFilingProvider, patchMap,
mergeProcessor, postMergeProcessor, pscVerificationPatchValidator);
} catch (final IOException e) {
throw new MergePatchException(e);
throw new MergePatchException(e.getMessage(), e);
}

return patchResult;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
class PscVerificationControllerImplMergeIT extends BaseControllerIT {
private static final URI SELF = URI.create(
"/transactions/" + TRANS_ID + "/persons-with-significant-control-verification/" + FILING_ID);
private static final URI VALID = URI.create(SELF.toString() + "/validation_status");
private static final URI VALID = URI.create(SELF + "/validation_status");
private static final LocalDate DATE_OF_BIRTH = LocalDate.of(1970, 1, 1);
private static final String DOB_STRING = DATE_OF_BIRTH.toString();

Expand Down Expand Up @@ -102,7 +102,7 @@ void updatePscVerificationWhenReplacingFields() throws Exception {
.append("1990-11-11")
.append("\"},")
.append("\"verification_details\":{")
.append("\"name_mismatch_reason\":\"MAIDEN_NAME\",")
.append("\"name_mismatch_reason\":\"LEGAL_NAME_CHANGE\",")
.append("\"verification_statements\":[")
.append("\"RO_IDENTIFIED\",")
.append("\"RO_VERIFIED\",")
Expand Down Expand Up @@ -194,7 +194,7 @@ void updatePscVerificationWhenAddingFields() throws Exception {
.append("1990-11-11")
.append("\"},")
.append("\"verification_details\":{")
.append("\"name_mismatch_reason\":\"MAIDEN_NAME\",")
.append("\"name_mismatch_reason\":\"LEGAL_NAME_CHANGE\",")
.append("\"verification_statements\":[")
.append("\"RO_IDENTIFIED\",")
.append("\"RO_VERIFIED\",")
Expand Down Expand Up @@ -278,7 +278,7 @@ void updatePscVerificationWhenDeletingFields() throws Exception {
.append("\"surname\": null},")
.append("\"date_of_birth\": null},")
.append("\"verification_details\":{")
.append("\"name_mismatch_reason\":\"MAIDEN_NAME\",")
.append("\"name_mismatch_reason\":\"LEGAL_NAME_CHANGE\",")
.append("\"verification_statements\": null}")
.append("}")
.toString();
Expand Down

0 comments on commit ec68ad2

Please sign in to comment.