diff --git a/src/main/java/uk/gov/companieshouse/pscverificationapi/controller/impl/PscVerificationControllerImpl.java b/src/main/java/uk/gov/companieshouse/pscverificationapi/controller/impl/PscVerificationControllerImpl.java index dc7fac4..d7498a5 100644 --- a/src/main/java/uk/gov/companieshouse/pscverificationapi/controller/impl/PscVerificationControllerImpl.java +++ b/src/main/java/uk/gov/companieshouse/pscverificationapi/controller/impl/PscVerificationControllerImpl.java @@ -159,8 +159,8 @@ private static void clearNameMismatchReasonIfRequired(PscVerification pscVerific VerificationDetails verificationDetails = pscVerification.getData().verificationDetails(); if (verificationDetails != null) { - Map mergeVerificationDetails = (Map) mergePatch.get("verification_details"); - String mergeUvid = (String) mergeVerificationDetails.get("uvid"); + final var mergeVerificationDetails = (Map) mergePatch.get("verification_details"); + final var mergeUvid = mergeVerificationDetails != null ? (String) mergeVerificationDetails.get("uvid") : null; if (verificationDetails.uvid() != null && mergeUvid != null && !verificationDetails.uvid().equals(mergeUvid) diff --git a/src/main/java/uk/gov/companieshouse/pscverificationapi/error/RestExceptionHandler.java b/src/main/java/uk/gov/companieshouse/pscverificationapi/error/RestExceptionHandler.java index 866ea89..3f716ab 100644 --- a/src/main/java/uk/gov/companieshouse/pscverificationapi/error/RestExceptionHandler.java +++ b/src/main/java/uk/gov/companieshouse/pscverificationapi/error/RestExceptionHandler.java @@ -122,6 +122,7 @@ public ApiErrors handleInvalidFilingException(final InvalidFilingException ex, @ResponseBody public ResponseEntity 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")); } diff --git a/src/main/java/uk/gov/companieshouse/pscverificationapi/exception/MergePatchException.java b/src/main/java/uk/gov/companieshouse/pscverificationapi/exception/MergePatchException.java index c02b72c..db62103 100644 --- a/src/main/java/uk/gov/companieshouse/pscverificationapi/exception/MergePatchException.java +++ b/src/main/java/uk/gov/companieshouse/pscverificationapi/exception/MergePatchException.java @@ -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); } - } diff --git a/src/main/java/uk/gov/companieshouse/pscverificationapi/service/impl/PscVerificationServiceImpl.java b/src/main/java/uk/gov/companieshouse/pscverificationapi/service/impl/PscVerificationServiceImpl.java index 61c561d..0f93da9 100644 --- a/src/main/java/uk/gov/companieshouse/pscverificationapi/service/impl/PscVerificationServiceImpl.java +++ b/src/main/java/uk/gov/companieshouse/pscverificationapi/service/impl/PscVerificationServiceImpl.java @@ -71,7 +71,7 @@ public PatchResult patch(final String filingId, final Map 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; diff --git a/src/test/java/uk/gov/companieshouse/pscverificationapi/controller/impl/PscVerificationControllerImplMergeIT.java b/src/test/java/uk/gov/companieshouse/pscverificationapi/controller/impl/PscVerificationControllerImplMergeIT.java index 5319e34..076ad49 100644 --- a/src/test/java/uk/gov/companieshouse/pscverificationapi/controller/impl/PscVerificationControllerImplMergeIT.java +++ b/src/test/java/uk/gov/companieshouse/pscverificationapi/controller/impl/PscVerificationControllerImplMergeIT.java @@ -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(); @@ -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\",") @@ -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\",") @@ -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();