From 26bd176b2c2ddf752cc20ee52c83dd86a1eb6144 Mon Sep 17 00:00:00 2001 From: IswaryaPepakayala Date: Tue, 26 Nov 2024 21:55:15 +0000 Subject: [PATCH] DTSPB-4293 Fix Sonar issue --- .../transformer/DocumentTransformer.java | 60 +++++-------------- .../transformer/ReprintTransformer.java | 52 +++++----------- 2 files changed, 31 insertions(+), 81 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/probate/transformer/DocumentTransformer.java b/src/main/java/uk/gov/hmcts/probate/transformer/DocumentTransformer.java index 4b0d45d5b5..ec2746b51a 100644 --- a/src/main/java/uk/gov/hmcts/probate/transformer/DocumentTransformer.java +++ b/src/main/java/uk/gov/hmcts/probate/transformer/DocumentTransformer.java @@ -25,57 +25,27 @@ public boolean hasDocumentWithType(List documents, DocumentType docume public void addDocument(CallbackRequest callbackRequest, Document document, Boolean coversheetNotification) { switch (document.getDocumentType()) { - case DIGITAL_GRANT_DRAFT: - case DIGITAL_GRANT: - case DIGITAL_GRANT_REISSUE_DRAFT: - case DIGITAL_GRANT_REISSUE: - case WELSH_DIGITAL_GRANT_REISSUE_DRAFT: - case WELSH_DIGITAL_GRANT_REISSUE: - case INTESTACY_GRANT_DRAFT: - case INTESTACY_GRANT: - case INTESTACY_GRANT_REISSUE_DRAFT: - case INTESTACY_GRANT_REISSUE: - case WELSH_INTESTACY_GRANT_REISSUE_DRAFT: - case WELSH_INTESTACY_GRANT_REISSUE: - case ADMON_WILL_GRANT_DRAFT: - case ADMON_WILL_GRANT: - case ADMON_WILL_GRANT_REISSUE_DRAFT: - case ADMON_WILL_GRANT_REISSUE: - case WELSH_ADMON_WILL_GRANT_REISSUE_DRAFT: - case WELSH_ADMON_WILL_GRANT_REISSUE: - case AD_COLLIGENDA_BONA_GRANT_DRAFT: - case AD_COLLIGENDA_BONA_GRANT: - case AD_COLLIGENDA_BONA_GRANT_REISSUE_DRAFT: - case AD_COLLIGENDA_BONA_GRANT_REISSUE: - case WELSH_AD_COLLIGENDA_BONA_GRANT_REISSUE_DRAFT: - case WELSH_AD_COLLIGENDA_BONA_GRANT_REISSUE: - case SOT_INFORMATION_REQUEST: - case GRANT_COVER: - case ASSEMBLED_LETTER: - case BLANK_LETTER: - case WELSH_DIGITAL_GRANT_DRAFT: - case WELSH_DIGITAL_GRANT: - case WELSH_ADMON_WILL_GRANT_DRAFT: - case WELSH_ADMON_WILL_GRANT: - case WELSH_INTESTACY_GRANT_DRAFT: - case WELSH_INTESTACY_GRANT: - case WELSH_AD_COLLIGENDA_BONA_GRANT_DRAFT: - case WELSH_AD_COLLIGENDA_BONA_GRANT: + case DIGITAL_GRANT_DRAFT, DIGITAL_GRANT, DIGITAL_GRANT_REISSUE_DRAFT, DIGITAL_GRANT_REISSUE, + WELSH_DIGITAL_GRANT_REISSUE_DRAFT, WELSH_DIGITAL_GRANT_REISSUE, INTESTACY_GRANT_DRAFT, + INTESTACY_GRANT, INTESTACY_GRANT_REISSUE_DRAFT, INTESTACY_GRANT_REISSUE, + WELSH_INTESTACY_GRANT_REISSUE_DRAFT, WELSH_INTESTACY_GRANT_REISSUE, ADMON_WILL_GRANT_DRAFT, + ADMON_WILL_GRANT, ADMON_WILL_GRANT_REISSUE_DRAFT, ADMON_WILL_GRANT_REISSUE, + WELSH_ADMON_WILL_GRANT_REISSUE_DRAFT, WELSH_ADMON_WILL_GRANT_REISSUE, + AD_COLLIGENDA_BONA_GRANT_DRAFT, AD_COLLIGENDA_BONA_GRANT, AD_COLLIGENDA_BONA_GRANT_REISSUE_DRAFT, + AD_COLLIGENDA_BONA_GRANT_REISSUE, WELSH_AD_COLLIGENDA_BONA_GRANT_REISSUE_DRAFT, + WELSH_AD_COLLIGENDA_BONA_GRANT_REISSUE, SOT_INFORMATION_REQUEST, GRANT_COVER, ASSEMBLED_LETTER, + BLANK_LETTER, WELSH_DIGITAL_GRANT_DRAFT, WELSH_DIGITAL_GRANT, WELSH_ADMON_WILL_GRANT_DRAFT, + WELSH_ADMON_WILL_GRANT, WELSH_INTESTACY_GRANT_DRAFT, WELSH_INTESTACY_GRANT, + WELSH_AD_COLLIGENDA_BONA_GRANT_DRAFT, WELSH_AD_COLLIGENDA_BONA_GRANT: callbackRequest.getCaseDetails().getData().getProbateDocumentsGenerated() .add(new CollectionMember<>(null, document)); break; - case STATEMENT_OF_TRUTH: - case WELSH_STATEMENT_OF_TRUTH: - case LEGAL_STATEMENT_PROBATE: - case LEGAL_STATEMENT_PROBATE_TRUST_CORPS: - case LEGAL_STATEMENT_INTESTACY: - case LEGAL_STATEMENT_ADMON: + case STATEMENT_OF_TRUTH, WELSH_STATEMENT_OF_TRUTH, LEGAL_STATEMENT_PROBATE, + LEGAL_STATEMENT_PROBATE_TRUST_CORPS, LEGAL_STATEMENT_INTESTACY, LEGAL_STATEMENT_ADMON: callbackRequest.getCaseDetails().getData().getProbateSotDocumentsGenerated() .add(new CollectionMember<>(null, document)); break; - case SENT_EMAIL: - case GRANT_RAISED: - case CAVEAT_STOPPED: + case SENT_EMAIL, GRANT_RAISED, CAVEAT_STOPPED: callbackRequest.getCaseDetails().getData().getProbateNotificationsGenerated() .add(new CollectionMember<>(null, document)); break; diff --git a/src/main/java/uk/gov/hmcts/probate/transformer/ReprintTransformer.java b/src/main/java/uk/gov/hmcts/probate/transformer/ReprintTransformer.java index 903736d850..47dcf48e5b 100644 --- a/src/main/java/uk/gov/hmcts/probate/transformer/ReprintTransformer.java +++ b/src/main/java/uk/gov/hmcts/probate/transformer/ReprintTransformer.java @@ -49,7 +49,7 @@ private DynamicList getDocumentsAsDynamicList(CaseData caseData) { listItems.addAll(caseData.getProbateDocumentsGenerated().stream() .filter(doc -> isFromGeneratedDocuments(doc.getValue())) .map(doc -> buildFromGeneratedDocument(doc.getValue()).get()) - .collect(Collectors.toList())); + .toList()); } if (caseData.getProbateSotDocumentsGenerated() != null && !caseData.getProbateSotDocumentsGenerated() @@ -85,27 +85,16 @@ private boolean isFromScannedDOcuments(ScannedDocument document) { } private boolean isFromGeneratedDocuments(Document document) { - switch (document.getDocumentType()) { - case DIGITAL_GRANT: - case INTESTACY_GRANT: - case ADMON_WILL_GRANT: - case AD_COLLIGENDA_BONA_GRANT: - case WELSH_DIGITAL_GRANT: - case WELSH_INTESTACY_GRANT: - case WELSH_ADMON_WILL_GRANT: - case WELSH_AD_COLLIGENDA_BONA_GRANT: - return true; - case DIGITAL_GRANT_REISSUE: - case INTESTACY_GRANT_REISSUE: - case ADMON_WILL_GRANT_REISSUE: - case AD_COLLIGENDA_BONA_GRANT_REISSUE: - return true; - case STATEMENT_OF_TRUTH: - case WELSH_STATEMENT_OF_TRUTH: - return true; - default: - return false; - } + return switch (document.getDocumentType()) { + case DIGITAL_GRANT, INTESTACY_GRANT, ADMON_WILL_GRANT, AD_COLLIGENDA_BONA_GRANT, WELSH_DIGITAL_GRANT, + WELSH_INTESTACY_GRANT, WELSH_ADMON_WILL_GRANT, WELSH_AD_COLLIGENDA_BONA_GRANT -> + true; + case DIGITAL_GRANT_REISSUE, INTESTACY_GRANT_REISSUE, ADMON_WILL_GRANT_REISSUE, + AD_COLLIGENDA_BONA_GRANT_REISSUE -> + true; + case STATEMENT_OF_TRUTH, WELSH_STATEMENT_OF_TRUTH -> true; + default -> false; + }; } private Optional buildFromScannedDocument(ScannedDocument document) { @@ -115,25 +104,16 @@ private Optional buildFromScannedDocument(ScannedDocument docum private Optional buildFromGeneratedDocument(Document document) { Optional optionalDynamicListItem = Optional.empty(); switch (document.getDocumentType()) { - case DIGITAL_GRANT: - case INTESTACY_GRANT: - case ADMON_WILL_GRANT: - case AD_COLLIGENDA_BONA_GRANT: - case WELSH_DIGITAL_GRANT: - case WELSH_INTESTACY_GRANT: - case WELSH_ADMON_WILL_GRANT: - case WELSH_AD_COLLIGENDA_BONA_GRANT: + case DIGITAL_GRANT, INTESTACY_GRANT, ADMON_WILL_GRANT, AD_COLLIGENDA_BONA_GRANT, WELSH_DIGITAL_GRANT, + WELSH_INTESTACY_GRANT, WELSH_ADMON_WILL_GRANT, WELSH_AD_COLLIGENDA_BONA_GRANT: optionalDynamicListItem = Optional.of(buildListItem(document.getDocumentFileName(), LABEL_GRANT)); break; - case DIGITAL_GRANT_REISSUE: - case INTESTACY_GRANT_REISSUE: - case ADMON_WILL_GRANT_REISSUE: - case AD_COLLIGENDA_BONA_GRANT_REISSUE: + case DIGITAL_GRANT_REISSUE, INTESTACY_GRANT_REISSUE, ADMON_WILL_GRANT_REISSUE, + AD_COLLIGENDA_BONA_GRANT_REISSUE: optionalDynamicListItem = Optional.of(buildListItem(document.getDocumentFileName(), LABEL_REISSUED_GRANT)); break; - case STATEMENT_OF_TRUTH: - case WELSH_STATEMENT_OF_TRUTH: + case STATEMENT_OF_TRUTH, WELSH_STATEMENT_OF_TRUTH: optionalDynamicListItem = Optional.of(buildListItem(document.getDocumentFileName(), LABEL_SOT)); break; default: