Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dfr 3515 seal orders add court stamp #2086

Open
wants to merge 491 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
491 commits
Select commit Hold shift + click to select a range
bfa132c
clear refusalOrderIdsToBeSent on about-to-start
Dec 10, 2024
8c2fc6d
throw exception instead
hamzahtahirhmcts Dec 10, 2024
5b7ccca
Merge remote-tracking branch 'origin/DFR-3334-Approves-or-Changesv2' …
hamzahtahirhmcts Dec 10, 2024
08d2d0a
EL
Dec 10, 2024
a0f4eba
Remove test
hamzahtahirhmcts Dec 10, 2024
def5e8c
revert
Dec 10, 2024
d6c31c7
revert
Dec 10, 2024
863db32
revert comment
Dec 10, 2024
38a0e04
Email notification logic.
Dec 10, 2024
348472f
use @JsonIgnore
hamzahtahirhmcts Dec 10, 2024
8874655
Merge branch 'master' into DFR-3332-Judge-Approve-Orders---starting-page
Dec 10, 2024
fcc3710
Merge branch 'DFR-3332-Judge-Approve-Orders---starting-page' into DFR…
Dec 10, 2024
2e2512f
Merge branch 'DFR-3334-Approves-or-Changesv2' into DFR-3335-refuseOrR…
Dec 10, 2024
68220c5
javadoc
Dec 10, 2024
d02fd67
Fix NPE
Dec 10, 2024
72309e4
Fix NPE
Dec 10, 2024
91135f3
use @JsonIgnore for getters
hamzahtahirhmcts Dec 10, 2024
255a19b
Merge remote-tracking branch 'origin/DFR-3334-Approves-or-Changesv2' …
hamzahtahirhmcts Dec 10, 2024
2daa260
Merge branch 'DFR-3334-Approves-or-Changesv2' into DFR-3335-refuseOrR…
Dec 10, 2024
77f8e70
Use fixedDateTime
Dec 10, 2024
609bdf8
code format
Dec 10, 2024
b72cd08
Renamed
Dec 10, 2024
1cd1694
add test case
Dec 10, 2024
3633d70
Merge branch 'DFR-3334-Approves-or-Changesv2' into DFR-3335-refuseOrR…
Dec 10, 2024
83a8b34
checkstyle
Dec 10, 2024
0038afa
Add a TODO for sending notification by post.
Dec 10, 2024
fa70644
JavaDoc
Dec 10, 2024
b2a71f3
Java docs
Dec 10, 2024
8b5e3ba
JavaDoc
Dec 10, 2024
c68b36a
JavaDoc
Dec 10, 2024
bcb8ff7
remove extra spaces
Dec 10, 2024
d80c167
Merge branch 'DFR-3334-Approves-or-Changesv2' into DFR-3335-refuseOrR…
Dec 10, 2024
1e3ce56
tidy up
Dec 11, 2024
437f4f0
Rename
Dec 11, 2024
b40c255
Renamed
Dec 11, 2024
448f5fb
missing colon
Dec 11, 2024
1ce9649
Test case fixed.
Dec 11, 2024
c3a415c
add a comment.
Dec 11, 2024
0fc30ad
Merge branch 'master' into DFR-3332-Judge-Approve-Orders---starting-page
so99y Dec 11, 2024
2f96d88
Merge branch 'DFR-3332-Judge-Approve-Orders---starting-page' into DFR…
Dec 11, 2024
e7c0edf
Merge branch 'DFR-3334-Approves-or-Changesv2' into DFR-3335-refuseOrR…
Dec 11, 2024
953d352
Sending Post Logic (WIP)
Dec 11, 2024
1a7b3ea
Refactoring CaseDataService - deprecating methods and making use of F…
Dec 11, 2024
8c4435d
Merge branch 'master' into refactoring-caseDataService
so99y Dec 11, 2024
e3b5bda
checkstyle
Dec 11, 2024
7dff6e8
checkstyle
Dec 11, 2024
bbc1aa9
Merge branch 'master' into DFR-3332-Judge-Approve-Orders---starting-page
so99y Dec 11, 2024
2e71fe7
update test case
Dec 11, 2024
b8795a9
Added test cases
Dec 11, 2024
8838aeb
Merge branch 'master' into refactoring-caseDataService
so99y Dec 12, 2024
54bbc22
Add test cases
Dec 12, 2024
c7ef996
tidy up
Dec 12, 2024
7289693
Merge branch 'refactoring-caseDataService' of github.com:hmcts/finrem…
Dec 12, 2024
8dfe54e
fix
Dec 12, 2024
d3a9ffe
Change to assertEquals
Dec 12, 2024
ea18ea9
Update test cases
Dec 12, 2024
faab2a6
Use anyMap()
Dec 12, 2024
15a0828
Use anyMap()
Dec 12, 2024
987592a
tidy up
Dec 12, 2024
bdc6986
tidy up
Dec 12, 2024
4dea649
Add test case.
Dec 12, 2024
72bb4c4
increase code coverage.
Dec 12, 2024
7eebf95
Merge branch 'master' into refactoring-caseDataService
so99y Dec 12, 2024
c1324c5
Merge branch 'master' into DFR-3332-Judge-Approve-Orders---starting-page
Dec 12, 2024
1d4a633
Merge branch 'DFR-3332-Judge-Approve-Orders---starting-page' into DFR…
Dec 12, 2024
2e58627
Merge branch 'DFR-3334-Approves-or-Changesv2' into DFR-3335-refuseOrR…
Dec 12, 2024
8c86c14
Use anyMap()
Dec 12, 2024
3033bad
anyMap()
Dec 12, 2024
0f03e5b
checkstyle
Dec 12, 2024
93fd1e5
Merge branch 'refactoring-caseDataService' into DFR-3335-refuseOrRevi…
Dec 12, 2024
b4cf163
Enable bulkprint
Dec 12, 2024
17f5b50
missing import
Dec 12, 2024
0cf4969
Merge branch 'refactoring-caseDataService' into DFR-3335-refuseOrRevi…
Dec 12, 2024
fb721d6
DFR-3334 Add Hearing Judge to Approve Orders Page.
Dec 12, 2024
b6e3e7f
NL
Dec 12, 2024
d0fd5cd
Remove notification by post logic
Dec 13, 2024
9eed41b
Check PSA for validating attachments
Dec 13, 2024
376b3a6
Remove unused imports
Dec 13, 2024
49ec0ed
Merge branch 'master' into DFR-3332-Judge-Approve-Orders---starting-page
Dec 13, 2024
4fde6bc
Merge branch 'DFR-3332-Judge-Approve-Orders---starting-page' into DFR…
Dec 13, 2024
70f2e55
Merge branch 'DFR-3334-Approves-or-Changesv2' into DFR-3335-refuseOrR…
Dec 13, 2024
bc71904
Merge branch 'DFR-3334-Approves-or-Changesv2' into DFR-3334-1-add_jud…
Dec 13, 2024
06c3622
Add test case
Dec 13, 2024
1a58440
Test case for DraftOrdersNotificationRequestMapperTest
Dec 13, 2024
16bc4a0
Remove unused injections.
Dec 13, 2024
430cfc9
Update test case to increase code coverage.
Dec 13, 2024
3b6ad97
Test case in NotificationServiceTest
Dec 13, 2024
eab13b5
checkstyle
Dec 13, 2024
92c866b
Test case for refusal order generation
Dec 13, 2024
fcf35d9
Merge branch 'master' into DFR-3332-Judge-Approve-Orders---starting-page
so99y Dec 16, 2024
2df75b1
Merge branch 'DFR-3332-Judge-Approve-Orders---starting-page' into DFR…
so99y Dec 16, 2024
972da56
Merge branch 'DFR-3334-Approves-or-Changesv2' into DFR-3335-refuseOrR…
so99y Dec 16, 2024
21125cb
Merge branch 'DFR-3334-Approves-or-Changesv2' into DFR-3334-1-add_jud…
so99y Dec 16, 2024
9d9e4e6
Merge branch 'master' into DFR-3332-Judge-Approve-Orders---starting-page
so99y Dec 16, 2024
f5cd4c6
Merge branch 'DFR-3332-Judge-Approve-Orders---starting-page' into DFR…
so99y Dec 16, 2024
ae4c23d
Merge branch 'master' into DFR-3335-refuseOrReviewLater
so99y Dec 16, 2024
c4b99bc
Merge branch 'DFR-3334-Approves-or-Changesv2' into DFR-3334-1-add_jud…
so99y Dec 16, 2024
bbde3d2
update test cases.
Dec 16, 2024
c1da279
checkstyle
Dec 16, 2024
1ba2a7b
typo
Dec 16, 2024
3496ceb
Comment updated.
Dec 16, 2024
877b2c8
Method renamed
Dec 16, 2024
518fa6b
java doc
Dec 16, 2024
1f5cead
Revert "java doc"
Dec 16, 2024
a2190ac
Merge branch 'DFR-3334-Approves-or-Changesv2' into DFR-3335-refuseOrR…
so99y Dec 16, 2024
04ea29c
renamed
Dec 16, 2024
8319ec7
Merge branch 'DFR-3334-1-add_judge_name_under_hearing' into DFR-3335-…
Dec 16, 2024
5de4183
missing personalisation
Dec 16, 2024
3c586a2
update test case.
Dec 16, 2024
633719c
missing hearingDate
Dec 16, 2024
e4cfda7
refactoring
Dec 16, 2024
286282b
DFR-3494 Add Hearing Judge to Approve Orders Page (#2028)
so99y Dec 16, 2024
dfdddc0
Merge branch 'DFR-3334-Approves-or-Changesv2' into DFR-3335-refuseOrR…
so99y Dec 16, 2024
aa1b822
Remove an extra blank line.
Dec 16, 2024
b4b364a
Move Approvable, HasSubmittedInfo, RefusalOrderConvertible and HasApp…
Dec 17, 2024
9cde7ba
Merge branch 'master' into DFR-3332-Judge-Approve-Orders---starting-page
Dec 17, 2024
59d82a2
Merge branch 'DFR-3332-Judge-Approve-Orders---starting-page' into DFR…
Dec 17, 2024
6fede52
Merge branch 'DFR-3334-Approves-or-Changesv2' into DFR-3335-refuseOrR…
Dec 17, 2024
f2c8e5f
checkstyle
Dec 17, 2024
bf3fcd2
Merge branch 'master' into DFR-3332-Judge-Approve-Orders---starting-page
so99y Dec 17, 2024
432670c
Merge branch 'DFR-3332-Judge-Approve-Orders---starting-page' into DFR…
so99y Dec 17, 2024
9745900
Merge branch 'DFR-3334-Approves-or-Changesv2' into DFR-3335-refuseOrR…
so99y Dec 17, 2024
8af4913
DFR-3495 Capturing Refusal Order Judge Title
Dec 17, 2024
a9e8ac8
Update test case.
Dec 17, 2024
36e075e
update unit test
Dec 17, 2024
53c1c95
enhanced readibility
Dec 17, 2024
a5d3c0f
Merge branch 'DFR-3335-refuseOrReviewLater' into DFR-3495-capture_jud…
Dec 17, 2024
1909123
Fix test case
Dec 18, 2024
8e8843e
Linked with the class by calling Class.getSimpleName()
Dec 18, 2024
1098114
Remove an extra blank line.
Dec 18, 2024
7ec4d57
typo
Dec 18, 2024
0c60cf0
auto configuration
Dec 18, 2024
77cdb15
checkstyle
Dec 18, 2024
946cc38
Auto Resolving Complex Type
Dec 18, 2024
02e817d
readability
Dec 18, 2024
54e1cea
compare it in lowercase
Dec 18, 2024
27860dc
reverting all
Dec 18, 2024
7618d49
Merge branch 'auto-resolving' into DFR-3495-capture_judge_type
Dec 18, 2024
b5d59f5
Fix NPE
Dec 18, 2024
7f23169
Merge branch 'auto-resolving' into DFR-3495-capture_judge_type
Dec 18, 2024
b07f947
Bug fix
Dec 18, 2024
b3a4c0e
Merge branch 'auto-resolving' into DFR-3495-capture_judge_type
Dec 18, 2024
08c91b8
NPE
Dec 18, 2024
85843f8
Merge branch 'auto-resolving' into DFR-3495-capture_judge_type
Dec 18, 2024
797aa4e
Bug fix
Dec 18, 2024
a76611f
Merge branch 'auto-resolving' into DFR-3495-capture_judge_type
Dec 18, 2024
ee9173b
add test case for example.txt.txt
Dec 18, 2024
3bdd0c5
simplifying
Dec 18, 2024
2cc4c8e
Merge branch 'auto-resolving' into DFR-3495-capture_judge_type
Dec 18, 2024
e05419a
Merge branch 'master' into DFR-3332-Judge-Approve-Orders---starting-page
so99y Dec 18, 2024
6c19a2c
Merge branch 'DFR-3332-Judge-Approve-Orders---starting-page' into DFR…
so99y Dec 18, 2024
d109f4d
Merge branch 'DFR-3334-Approves-or-Changesv2' into DFR-3335-refuseOrR…
so99y Dec 18, 2024
c3fb4e1
Merge branch 'DFR-3335-refuseOrReviewLater' into DFR-3495-capture_jud…
so99y Dec 18, 2024
0f05984
Merge branch 'master' into auto-resolving
so99y Dec 18, 2024
e73d425
Merge branch 'master' into DFR-3332-Judge-Approve-Orders---starting-page
so99y Dec 18, 2024
c2a8987
Merge branch 'DFR-3332-Judge-Approve-Orders---starting-page' into DFR…
so99y Dec 18, 2024
8d9641e
Merge branch 'DFR-3334-Approves-or-Changesv2' into DFR-3335-refuseOrR…
so99y Dec 18, 2024
dd94f5a
Merge branch 'DFR-3335-refuseOrReviewLater' into DFR-3495-capture_jud…
so99y Dec 18, 2024
8b2d073
Add a warning message.
Dec 18, 2024
5b61155
Trigger build
Dec 18, 2024
e426762
underscore missing
Dec 18, 2024
fba912c
change to info
Dec 19, 2024
683f5bd
warning message bug
Dec 19, 2024
4fbecba
Merge branch 'master' into auto-resolving
so99y Dec 19, 2024
b24cdeb
Merge branch 'master' into DFR-3332-Judge-Approve-Orders---starting-page
so99y Dec 19, 2024
ea2ee36
Merge branch 'DFR-3332-Judge-Approve-Orders---starting-page' into DFR…
so99y Dec 19, 2024
4a5cc63
Merge branch 'DFR-3334-Approves-or-Changesv2' into DFR-3335-refuseOrR…
so99y Dec 19, 2024
743d944
update warning message
Dec 19, 2024
651e5c7
Merge branch 'master' into auto-resolving
so99y Dec 19, 2024
73f68da
Merge branch 'master' into DFR-3335-refuseOrReviewLater
so99y Dec 19, 2024
b3b6212
Fix
Dec 19, 2024
9fc52ba
Fix merge conflicts
Dec 19, 2024
34e1447
checkstyle
Dec 19, 2024
b2e9a5b
Remove extra line
Dec 19, 2024
fed2471
Merge branch 'DFR-3335-refuseOrReviewLater' into DFR-3495-capture_jud…
Dec 19, 2024
9d7abb7
Merge branch 'auto-resolving' into DFR-3495-capture_judge_type
Dec 19, 2024
c68b0ec
Merge branch 'master' into DFR-3335-refuseOrReviewLater
so99y Dec 19, 2024
902865f
Merge branch 'DFR-3335-refuseOrReviewLater' into DFR-3495-capture_jud…
so99y Dec 19, 2024
e17d3a5
Enhance code readability
Dec 19, 2024
45b9afb
Remove extra blank line.
Dec 19, 2024
e90ce4b
Fix
Dec 19, 2024
31a3cc2
Bug fix
Dec 19, 2024
40a77de
update test cases
Dec 19, 2024
9531975
missing assert
Dec 19, 2024
a1b7502
Fix test case
Dec 19, 2024
0326c6e
Merge branch 'master' into DFR-3335-refuseOrReviewLater
so99y Dec 20, 2024
e132407
Merge branch 'DFR-3335-refuseOrReviewLater' into DFR-3495-capture_jud…
so99y Dec 20, 2024
ae9e849
Merge branch 'DFR-3495-capture_judge_type' into DFR-3401-Test_remaining
so99y Dec 20, 2024
22abd78
Update test case.
Dec 20, 2024
5a5fb20
Checkstyle
Dec 20, 2024
e48a91a
update tests
Dec 20, 2024
83ef629
checkstyle fix
Dec 20, 2024
ca2cf01
update test
Dec 20, 2024
0fe0b51
add comments
Dec 20, 2024
fd920b9
Added buildIsFinalOrderDynamicMultiSelectList
Dec 20, 2024
7152a62
remove duplication
Dec 20, 2024
0fae955
Fine tuning
Dec 20, 2024
b66edc2
DFR-3495 capture judge type (#2050)
so99y Dec 23, 2024
68d6fe4
Merge branch 'DFR-3335-refuseOrReviewLater' into DFR-3401-Test_remaining
so99y Dec 23, 2024
8836c35
Refactoring - HasApprovableCollectionReader (#2056)
so99y Dec 23, 2024
ed3ea32
Merge branch 'master' into DFR-3335-refuseOrReviewLater
jthmcts Jan 2, 2025
cfa8e3e
Merge branch 'DFR-3335-refuseOrReviewLater' into DFR-3401-Test_remaining
so99y Jan 2, 2025
7e91346
Merge branch 'master' into DFR-3401-Test_remaining
so99y Jan 2, 2025
8c79225
Checkstyle
Jan 2, 2025
d52a7a8
Merge branch 'master' into DFR-3401-Test_remaining
so99y Jan 3, 2025
989481c
DFR-3501+3512 Process Order (Before Refactoring)
Jan 3, 2025
4ac16e3
Merge branch 'master' into DFR-3401-Test_remaining
jthmcts Jan 3, 2025
25e8a77
Refactoring
Jan 3, 2025
7af5c5f
Merge branch 'DFR-3401-Test_remaining' into DFR-3501+3512_V2
so99y Jan 3, 2025
940951b
Add test case on stamping new documents from unprocessedApprovedDocument
Jan 3, 2025
2abf0ed
Merge branch 'master' into DFR-3501+3512_V2
so99y Jan 6, 2025
ef65633
update test case
Jan 6, 2025
d772626
Merge branch 'master' into DFR-3501+3512_V2
so99y Jan 6, 2025
628c090
Merge branch 'master' into DFR-3501+3512_V2
so99y Jan 7, 2025
91ee4df
Merge branch 'master' into DFR-3501+3512_V2
so99y Jan 7, 2025
7ef70ca
Remove unused errors.
Jan 7, 2025
a75c85b
Tidy up
Jan 7, 2025
cc3bdf6
Tidy up
Jan 7, 2025
a2f97e0
Chained
Jan 7, 2025
79a6a2d
Chain it
Jan 7, 2025
448fcd3
Merge branch 'master' into DFR-3501+3512_V2
so99y Jan 7, 2025
79906ea
Merge branch 'master' into DFR-3501+3512_V2
so99y Jan 8, 2025
75e6a64
Fix duplicated event type.
Jan 8, 2025
8e51f2d
Merge branch 'master' into DFR-3501+3512_V2
so99y Jan 13, 2025
1a8cf7b
Merge branch 'master' into DFR-3501+3512_V2
so99y Jan 14, 2025
a2759fd
clear the unprocessedApprovedDocuments by setting it null.
Jan 14, 2025
697cce1
Merge branch 'master' into DFR-3501+3512_V2
so99y Jan 15, 2025
9b6ad83
Merge branch 'master' into DFR-3501+3512_V2
so99y Jan 16, 2025
3185b9f
Add convertToPdfAndStampDocument method
hamzahtahirhmcts Jan 16, 2025
8b8c93a
call convertToPdfAndStampDocument in AboutToSubmit to update review c…
hamzahtahirhmcts Jan 16, 2025
ed28688
merge DFR-3501+3512_V2 branch
hamzahtahirhmcts Jan 16, 2025
7819676
update unit tests
hamzahtahirhmcts Jan 16, 2025
0de594d
improve tests
hamzahtahirhmcts Jan 16, 2025
bcb3533
Add mocks
hamzahtahirhmcts Jan 16, 2025
fc962ff
Merge branch 'master' into DFR-3501+3512_V2
so99y Jan 16, 2025
3d0075b
Improve tests
hamzahtahirhmcts Jan 17, 2025
fb27153
Update AgreedDraftOrdersCollection and improve tests
hamzahtahirhmcts Jan 17, 2025
f2ae3fd
remove categorisation from convertToPdfAndStampDocument
hamzahtahirhmcts Jan 17, 2025
9d9a706
return immediately
hamzahtahirhmcts Jan 17, 2025
86a1f4a
Add test for convertToPdfAndStampDocument
hamzahtahirhmcts Jan 17, 2025
1f978d8
Merge branch 'DFR-3501+3512_V2' into DFR-3515-Seal-Orders---Add-Court…
hamzahtahirhmcts Jan 17, 2025
286d30e
remove empty line
hamzahtahirhmcts Jan 17, 2025
13029a9
remove assertNotNull
hamzahtahirhmcts Jan 17, 2025
f53f608
Merge remote-tracking branch 'origin/DFR-3515-Seal-Orders---Add-Court…
hamzahtahirhmcts Jan 17, 2025
74487e3
refactor solution to use method directly in GenericDocumentService
hamzahtahirhmcts Jan 17, 2025
774c3b2
checkstyle fix
hamzahtahirhmcts Jan 17, 2025
9670210
revert empty line
hamzahtahirhmcts Jan 20, 2025
f78a589
merge master
hamzahtahirhmcts Jan 20, 2025
4eb4096
Merge branch 'master' into DFR-3515-Seal-Orders---Add-Court-Stamp
al-hmcts Jan 20, 2025
2707362
Merge branch 'master' into DFR-3515-Seal-Orders---Add-Court-Stamp
tomfairclough1 Jan 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import uk.gov.hmcts.reform.finrem.caseorchestration.ccd.callback.CallbackType;
import uk.gov.hmcts.reform.finrem.caseorchestration.controllers.GenericAboutToStartOrSubmitCallbackResponse;
import uk.gov.hmcts.reform.finrem.caseorchestration.error.CourtDetailsParseException;
import uk.gov.hmcts.reform.finrem.caseorchestration.helper.DocumentHelper;
import uk.gov.hmcts.reform.finrem.caseorchestration.mapper.FinremCaseDetailsMapper;
import uk.gov.hmcts.reform.finrem.caseorchestration.model.EventType;
import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument;
Expand All @@ -19,7 +20,10 @@
import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.draftorders.review.DraftOrderDocReviewCollection;
import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.draftorders.review.PsaDocReviewCollection;
import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.DraftOrdersWrapper;
import uk.gov.hmcts.reform.finrem.caseorchestration.model.document.DocumentCategory;
import uk.gov.hmcts.reform.finrem.caseorchestration.service.AdditionalHearingDocumentService;
import uk.gov.hmcts.reform.finrem.caseorchestration.service.GenericDocumentService;
import uk.gov.hmcts.reform.finrem.caseorchestration.service.StampType;
import uk.gov.hmcts.reform.finrem.caseorchestration.service.draftorders.HasApprovableCollectionReader;

import java.util.ArrayList;
Expand All @@ -41,12 +45,19 @@ public class DirectionUploadOrderAboutToSubmitHandler extends FinremCallbackHand

private final HasApprovableCollectionReader hasApprovableCollectionReader;

private final DocumentHelper documentHelper;

private final GenericDocumentService genericDocumentService;

public DirectionUploadOrderAboutToSubmitHandler(FinremCaseDetailsMapper finremCaseDetailsMapper,
AdditionalHearingDocumentService additionalHearingDocumentService,
HasApprovableCollectionReader hasApprovableCollectionReader) {
HasApprovableCollectionReader hasApprovableCollectionReader,
DocumentHelper documentHelper, GenericDocumentService genericDocumentService) {
super(finremCaseDetailsMapper);
this.additionalHearingDocumentService = additionalHearingDocumentService;
this.hasApprovableCollectionReader = hasApprovableCollectionReader;
this.genericDocumentService = genericDocumentService;
this.documentHelper = documentHelper;
}

@Override
Expand Down Expand Up @@ -75,9 +86,9 @@ public GenericAboutToStartOrSubmitCallbackResponse<FinremCaseData> handle(Finrem
.data(caseData).errors(List.of("There was an unexpected error")).build();
}

handleDraftOrderDocuments(caseData);
handlePsaDocuments(caseData);
handleAgreedDraftOrdersCollection(caseData);
handleDraftOrderDocuments(caseDetails, userAuthorisation);
handlePsaDocuments(caseDetails, userAuthorisation);
handleAgreedDraftOrdersCollection(caseDetails, userAuthorisation);
clearTemporaryFields(caseData);

return GenericAboutToStartOrSubmitCallbackResponse.<FinremCaseData>builder().data(caseData).errors(errors).build();
Expand All @@ -95,47 +106,76 @@ private void handleNewDocumentInUnprocessedApprovedDocuments(FinremCaseData case
});
}

private void handleDraftOrderDocuments(FinremCaseData caseData) {
private void handleDraftOrderDocuments(FinremCaseDetails caseDetails, String authorisation) {
FinremCaseData caseData = caseDetails.getData();

List<DraftOrderDocReviewCollection> collector = new ArrayList<>();
hasApprovableCollectionReader.filterAndCollectDraftOrderDocs(caseData.getDraftOrdersWrapper().getDraftOrdersReviewCollection(),
collector, APPROVED_BY_JUDGE::equals);

getApprovedDocumentsToProcess(caseData)
.forEach(unprocessedApprovedOrder ->
collector.stream().filter(psa -> doesDocumentMatch(psa, unprocessedApprovedOrder)).forEach(toBeUpdated -> {

StampType stampType = documentHelper.getStampType(caseData);
CaseDocument stampedDoc = genericDocumentService.stampDocument(
unprocessedApprovedOrder.getValue().getUploadDraftDocument(), authorisation, stampType,
String.valueOf(caseDetails.getId()));
stampedDoc.setCategoryId(
DocumentCategory.APPROVED_ORDERS.getDocumentCategoryId());

toBeUpdated.getValue().setOrderStatus(PROCESSED);
toBeUpdated.getValue().setDraftOrderDocument(unprocessedApprovedOrder.getValue().getUploadDraftDocument());
toBeUpdated.getValue().setDraftOrderDocument(stampedDoc);
}));
}

private void handlePsaDocuments(FinremCaseData caseData) {
private void handlePsaDocuments(FinremCaseDetails caseDetails, String authorisation) {
FinremCaseData caseData = caseDetails.getData();
List<PsaDocReviewCollection> psaCollector = new ArrayList<>();

hasApprovableCollectionReader.filterAndCollectPsaDocs(caseData.getDraftOrdersWrapper().getDraftOrdersReviewCollection(),
psaCollector, APPROVED_BY_JUDGE::equals);

getApprovedDocumentsToProcess(caseData)
.forEach(unprocessedApprovedOrder ->
psaCollector.stream().filter(psa -> doesDocumentMatch(psa, unprocessedApprovedOrder)).forEach(toBeUpdated -> {

StampType stampType = documentHelper.getStampType(caseData);
CaseDocument stampedDoc = genericDocumentService.stampDocument(
unprocessedApprovedOrder.getValue().getUploadDraftDocument(), authorisation, stampType,
String.valueOf(caseDetails.getId()));
stampedDoc.setCategoryId(
DocumentCategory.APPROVED_ORDERS.getDocumentCategoryId());

toBeUpdated.getValue().setOrderStatus(PROCESSED);
toBeUpdated.getValue().setPsaDocument(unprocessedApprovedOrder.getValue().getUploadDraftDocument());
toBeUpdated.getValue().setPsaDocument(stampedDoc);
}));
}

private void handleAgreedDraftOrdersCollection(FinremCaseData caseData) {
private void handleAgreedDraftOrdersCollection(FinremCaseDetails caseDetails, String authorisation) {
FinremCaseData caseData = caseDetails.getData();
hamzahtahirhmcts marked this conversation as resolved.
Show resolved Hide resolved
List<AgreedDraftOrderCollection> agreedOrderCollector = new ArrayList<>();

hasApprovableCollectionReader.collectAgreedDraftOrders(caseData.getDraftOrdersWrapper().getAgreedDraftOrderCollection(),
agreedOrderCollector, APPROVED_BY_JUDGE::equals);

getApprovedDocumentsToProcess(caseData)
.forEach(unprocessedApprovedOrder ->
agreedOrderCollector.stream().filter(agreedDraftOrder -> doesDocumentMatch(agreedDraftOrder, unprocessedApprovedOrder))
.forEach(toBeUpdated -> {

StampType stampType = documentHelper.getStampType(caseData);
CaseDocument stampedDoc = genericDocumentService.stampDocument(
unprocessedApprovedOrder.getValue().getUploadDraftDocument(), authorisation, stampType,
String.valueOf(caseDetails.getId()));
stampedDoc.setCategoryId(unprocessedApprovedOrder.getValue().getUploadDraftDocument().getCategoryId());

toBeUpdated.getValue().setOrderStatus(PROCESSED);
// replace the document by the new uploaded approved document
// replace the document by the new stamped document
if (toBeUpdated.getValue().getPensionSharingAnnex() != null) {
toBeUpdated.getValue().setPensionSharingAnnex(unprocessedApprovedOrder.getValue().getUploadDraftDocument());
toBeUpdated.getValue().setPensionSharingAnnex(stampedDoc);
} else if (toBeUpdated.getValue().getDraftOrder() != null) {
toBeUpdated.getValue().setDraftOrder(unprocessedApprovedOrder.getValue().getUploadDraftDocument());
toBeUpdated.getValue().setDraftOrder(stampedDoc);
}
}));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import uk.gov.hmcts.reform.finrem.caseorchestration.FinremCallbackRequestFactory;
import uk.gov.hmcts.reform.finrem.caseorchestration.controllers.GenericAboutToStartOrSubmitCallbackResponse;
import uk.gov.hmcts.reform.finrem.caseorchestration.error.CourtDetailsParseException;
import uk.gov.hmcts.reform.finrem.caseorchestration.helper.DocumentHelper;
import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument;
import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.DirectionOrder;
import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.DirectionOrderCollection;
Expand All @@ -28,6 +29,8 @@
import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.draftorders.review.PsaDocumentReview;
import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.DraftOrdersWrapper;
import uk.gov.hmcts.reform.finrem.caseorchestration.service.AdditionalHearingDocumentService;
import uk.gov.hmcts.reform.finrem.caseorchestration.service.GenericDocumentService;
import uk.gov.hmcts.reform.finrem.caseorchestration.service.StampType;
import uk.gov.hmcts.reform.finrem.caseorchestration.service.draftorders.HasApprovableCollectionReader;

import java.util.ArrayList;
Expand All @@ -40,14 +43,17 @@
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.lenient;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static uk.gov.hmcts.reform.finrem.caseorchestration.TestConstants.AUTH_TOKEN;
import static uk.gov.hmcts.reform.finrem.caseorchestration.ccd.callback.CallbackType.ABOUT_TO_SUBMIT;
import static uk.gov.hmcts.reform.finrem.caseorchestration.model.EventType.DIRECTION_UPLOAD_ORDER;
import static uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseType.CONTESTED;
import static uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.draftorders.review.OrderStatus.APPROVED_BY_JUDGE;
import static uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.draftorders.review.OrderStatus.PROCESSED;
import static uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.draftorders.review.OrderStatus.TO_BE_REVIEWED;
import static uk.gov.hmcts.reform.finrem.caseorchestration.service.StampType.FAMILY_COURT_STAMP;
import static uk.gov.hmcts.reform.finrem.caseorchestration.test.Assertions.assertCanHandle;

@ExtendWith(MockitoExtension.class)
Expand All @@ -70,6 +76,12 @@ class DirectionUploadOrderAboutToSubmitHandlerTest {
@Mock
private AdditionalHearingDocumentService additionalHearingDocumentService;

@Mock
private GenericDocumentService genericDocumentService;

@Mock
private DocumentHelper documentHelper;

@Test
void testCanHandle() {
assertCanHandle(underTest, ABOUT_TO_SUBMIT, CONTESTED, DIRECTION_UPLOAD_ORDER);
Expand Down Expand Up @@ -172,6 +184,14 @@ void shouldMarkDraftOrdersReviewCollectionProcessed() {
AgreedDraftOrderCollection test4 = null;
AgreedDraftOrderCollection test5 = null;
AgreedDraftOrderCollection test6 = null;
CaseDocument stampedDocumentA = CaseDocument.builder().documentFilename("stampedA.pdf").build();
CaseDocument stampedDocumentB = CaseDocument.builder().documentFilename("stampedB.pdf").build();

when(documentHelper.getStampType(any(FinremCaseData.class))).thenReturn(FAMILY_COURT_STAMP);
when(genericDocumentService.stampDocument(eq(TARGET_DOCUMENT_1), eq(AUTH_TOKEN), eq(FAMILY_COURT_STAMP), any(String.class)))
.thenReturn(stampedDocumentA);
when(genericDocumentService.stampDocument(eq(TARGET_DOCUMENT_2), eq(AUTH_TOKEN), eq(FAMILY_COURT_STAMP), any(String.class)))
.thenReturn(stampedDocumentB);

FinremCallbackRequest finremCallbackRequest = FinremCallbackRequestFactory.from(FinremCaseData.builder()
.draftOrdersWrapper(DraftOrdersWrapper.builder()
Expand Down Expand Up @@ -212,10 +232,20 @@ void shouldMarkDraftOrdersReviewCollectionProcessed() {

underTest.handle(finremCallbackRequest, AUTH_TOKEN);

verify(genericDocumentService, times(4)).stampDocument(any(CaseDocument.class), eq(AUTH_TOKEN),
eq(StampType.FAMILY_COURT_STAMP), any(String.class));
//Check DraftOrderDocReviewCollection is updated
assertEquals(stampedDocumentA, test1.getValue().getDraftOrderDocument());
assertEquals(PROCESSED, test1.getValue().getOrderStatus());
assertEquals(stampedDocumentB, test2.getValue().getDraftOrderDocument());
assertEquals(PROCESSED, test2.getValue().getOrderStatus());

//Check AgreedDraftOrderCollection is updated
assertEquals(stampedDocumentA, test3.getValue().getDraftOrder());
assertEquals(PROCESSED, test3.getValue().getOrderStatus());
assertEquals(stampedDocumentB, test4.getValue().getDraftOrder());
assertEquals(PROCESSED, test4.getValue().getOrderStatus());

assertEquals(APPROVED_BY_JUDGE, test5.getValue().getOrderStatus());
assertEquals(TO_BE_REVIEWED, test6.getValue().getOrderStatus());
}
Expand All @@ -227,6 +257,14 @@ void shouldMarkPsaCollectionProcessed() {
AgreedDraftOrderCollection test3 = null;
AgreedDraftOrderCollection test4 = null;
AgreedDraftOrderCollection test5 = null;
CaseDocument stampedDocumentA = CaseDocument.builder().documentFilename("stampedA.pdf").build();
CaseDocument stampedDocumentB = CaseDocument.builder().documentFilename("stampedB.pdf").build();

when(documentHelper.getStampType(any(FinremCaseData.class))).thenReturn(FAMILY_COURT_STAMP);
when(genericDocumentService.stampDocument(eq(TARGET_DOCUMENT_1), eq(AUTH_TOKEN), eq(FAMILY_COURT_STAMP), any(String.class)))
.thenReturn(stampedDocumentA);
when(genericDocumentService.stampDocument(eq(TARGET_DOCUMENT_2), eq(AUTH_TOKEN), eq(FAMILY_COURT_STAMP), any(String.class)))
.thenReturn(stampedDocumentB);

FinremCallbackRequest finremCallbackRequest = FinremCallbackRequestFactory.from(FinremCaseData.builder()
.draftOrdersWrapper(DraftOrdersWrapper.builder()
Expand Down Expand Up @@ -267,10 +305,20 @@ void shouldMarkPsaCollectionProcessed() {

underTest.handle(finremCallbackRequest, AUTH_TOKEN);

verify(genericDocumentService, times(4)).stampDocument(any(CaseDocument.class), eq(AUTH_TOKEN),
eq(StampType.FAMILY_COURT_STAMP), any(String.class));
//Check PsaDocReviewCollection is updated
assertEquals(stampedDocumentA, test1.getValue().getPsaDocument());
assertEquals(PROCESSED, test1.getValue().getOrderStatus());
assertEquals(stampedDocumentB, test2.getValue().getPsaDocument());
assertEquals(PROCESSED, test2.getValue().getOrderStatus());

//Check AgreedDraftOrderCollection is updated
assertEquals(stampedDocumentA, test3.getValue().getPensionSharingAnnex());
assertEquals(PROCESSED, test3.getValue().getOrderStatus());
assertEquals(stampedDocumentB, test4.getValue().getPensionSharingAnnex());
assertEquals(PROCESSED, test4.getValue().getOrderStatus());

assertEquals(APPROVED_BY_JUDGE, test5.getValue().getOrderStatus());
}

Expand All @@ -281,6 +329,15 @@ void shouldReplaceApprovedDocumentAndMarkAsProcessed() {
AgreedDraftOrderCollection test3 = null;
AgreedDraftOrderCollection test4 = null;

CaseDocument stampedDocumentA = CaseDocument.builder().documentFilename("stampedA.pdf").build();
CaseDocument stampedDocumentB = CaseDocument.builder().documentFilename("stampedB.pdf").build();

when(documentHelper.getStampType(any(FinremCaseData.class))).thenReturn(FAMILY_COURT_STAMP);
when(genericDocumentService.stampDocument(eq(TARGET_DOCUMENT_3), eq(AUTH_TOKEN), eq(FAMILY_COURT_STAMP), any(String.class)))
.thenReturn(stampedDocumentA);
when(genericDocumentService.stampDocument(eq(TARGET_DOCUMENT_4), eq(AUTH_TOKEN), eq(FAMILY_COURT_STAMP), any(String.class)))
.thenReturn(stampedDocumentB);

FinremCallbackRequest finremCallbackRequest = FinremCallbackRequestFactory.from(FinremCaseData.builder()
.draftOrdersWrapper(DraftOrdersWrapper.builder()
.unprocessedApprovedDocuments(List.of(
Expand Down Expand Up @@ -316,12 +373,18 @@ void shouldReplaceApprovedDocumentAndMarkAsProcessed() {

underTest.handle(finremCallbackRequest, AUTH_TOKEN);

verify(genericDocumentService, times(4)).stampDocument(any(CaseDocument.class), eq(AUTH_TOKEN),
eq(StampType.FAMILY_COURT_STAMP), any(String.class));
//Check PsaDocReviewCollection is updated
assertEquals(PROCESSED, test1.getValue().getOrderStatus());
assertEquals(TARGET_DOCUMENT_3, test1.getValue().getPsaDocument());
assertEquals(stampedDocumentA, test1.getValue().getPsaDocument());
assertEquals(PROCESSED, test2.getValue().getOrderStatus());
assertEquals(TARGET_DOCUMENT_4, test2.getValue().getPsaDocument());
assertEquals(stampedDocumentB, test2.getValue().getPsaDocument());

assertEquals(PROCESSED, test3.getValue().getOrderStatus());
assertEquals(stampedDocumentA, test1.getValue().getPsaDocument());
assertEquals(PROCESSED, test4.getValue().getOrderStatus());
assertEquals(stampedDocumentA, test1.getValue().getPsaDocument());
}

private DraftOrderDocReviewCollection buildDraftOrderDocReviewCollection(OrderStatus orderStatus) {
Expand Down