From 08e24b170b2ea0dbf451ea250d378fa11938322a Mon Sep 17 00:00:00 2001 From: AbuSalam22 <136581242+AbuSalam22@users.noreply.github.com> Date: Thu, 18 Jul 2024 15:45:29 +0100 Subject: [PATCH 1/2] DTSCCI-480 Remove Spring context --- .../model/CaseDocument.java | 17 ++--- .../reform/civil/model/RespondToClaim.java | 12 ++-- .../civil/model/ServedDocumentFiles.java | 4 ++ .../reform/civil/model/common/Element.java | 6 +- .../dq/DisclosureOfElectronicDocuments.java | 10 ++- .../DisclosureOfNonElectronicDocuments.java | 10 ++- .../hmcts/reform/civil/model/dq/Experts.java | 12 ++-- .../model/dq/FileDirectionsQuestionnaire.java | 12 ++-- .../civil/model/dq/FixedRecoverableCosts.java | 2 + .../civil/model/dq/FurtherInformation.java | 12 ++-- .../hmcts/reform/civil/model/dq/Hearing.java | 14 +++-- .../reform/civil/model/dq/HearingSupport.java | 16 +++-- .../reform/civil/model/dq/RequestedCourt.java | 18 +++--- .../model/dq/VulnerabilityQuestions.java | 6 +- .../model/dq/WelshLanguageRequirements.java | 10 ++- .../reform/civil/model/dq/Witnesses.java | 8 ++- .../ResubmitClaimCallbackHandlerTest.java | 34 +++++----- .../SetAsideJudgmentCallbackHandlerTest.java | 47 +++++--------- ...eClaimMarkPaidFullCallbackHandlerTest.java | 22 ++++--- .../TakeCaseOfflineCallbackHandlerTest.java | 25 ++++---- ...TransferOnlineCaseCallbackHandlerTest.java | 40 +++++++----- .../TrialReadinessCallbackHandlerTest.java | 59 ++++++++++-------- .../TrialReadyCheckCallbackHandlerTest.java | 25 +++----- ...lReadyNotificationCallbackHandlerTest.java | 25 ++++---- ...MediationDocumentsCallbackHandlerTest.java | 37 ++++++----- .../UploadTranslatedDocumentHandlerTest.java | 62 +++++++++---------- .../WithdrawClaimCallbackHandlerTest.java | 27 +++++--- 27 files changed, 314 insertions(+), 258 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/civil/documentmanagement/model/CaseDocument.java b/src/main/java/uk/gov/hmcts/reform/civil/documentmanagement/model/CaseDocument.java index d66a5251234..c562107e9c5 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/documentmanagement/model/CaseDocument.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/documentmanagement/model/CaseDocument.java @@ -4,21 +4,24 @@ import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; +import lombok.NoArgsConstructor; import uk.gov.hmcts.reform.civil.enums.CaseRole; + import java.time.LocalDateTime; @Data @Builder(toBuilder = true) +@NoArgsConstructor @AllArgsConstructor public class CaseDocument { - private final Document documentLink; - private final String documentName; - private final DocumentType documentType; - private final long documentSize; - private final LocalDateTime createdDatetime; - private final String createdBy; - private final CaseRole ownedBy; + private Document documentLink; + private String documentName; + private DocumentType documentType; + private long documentSize; + private LocalDateTime createdDatetime; + private String createdBy; + private CaseRole ownedBy; @JsonIgnore public static CaseDocument toCaseDocument(Document document, DocumentType documentType) { diff --git a/src/main/java/uk/gov/hmcts/reform/civil/model/RespondToClaim.java b/src/main/java/uk/gov/hmcts/reform/civil/model/RespondToClaim.java index deaecdf25c5..0ff18756495 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/model/RespondToClaim.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/model/RespondToClaim.java @@ -2,8 +2,10 @@ import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; +import lombok.NoArgsConstructor; import uk.gov.hmcts.reform.civil.validation.groups.PaymentDateGroup; import java.math.BigDecimal; @@ -12,18 +14,20 @@ @Data @Builder +@NoArgsConstructor +@AllArgsConstructor public class RespondToClaim { /** * money amount in pence. */ @JsonFormat(shape = JsonFormat.Shape.STRING) - private final BigDecimal howMuchWasPaid; + private BigDecimal howMuchWasPaid; @PastOrPresent(message = "Date for when amount was paid must be today or in the past", groups = PaymentDateGroup.class) - private final LocalDate whenWasThisAmountPaid; - private final PaymentMethod howWasThisAmountPaid; - private final String howWasThisAmountPaidOther; + private LocalDate whenWasThisAmountPaid; + private PaymentMethod howWasThisAmountPaid; + private String howWasThisAmountPaidOther; @JsonIgnore public String getExplanationOnHowTheAmountWasPaid() { diff --git a/src/main/java/uk/gov/hmcts/reform/civil/model/ServedDocumentFiles.java b/src/main/java/uk/gov/hmcts/reform/civil/model/ServedDocumentFiles.java index 4e7f9ee4403..84db2840843 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/model/ServedDocumentFiles.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/model/ServedDocumentFiles.java @@ -1,8 +1,10 @@ package uk.gov.hmcts.reform.civil.model; import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; +import lombok.NoArgsConstructor; import uk.gov.hmcts.reform.civil.model.common.Element; import uk.gov.hmcts.reform.civil.documentmanagement.model.Document; @@ -13,6 +15,8 @@ @Data @Builder +@NoArgsConstructor +@AllArgsConstructor public class ServedDocumentFiles { private List> other; diff --git a/src/main/java/uk/gov/hmcts/reform/civil/model/common/Element.java b/src/main/java/uk/gov/hmcts/reform/civil/model/common/Element.java index 198c2358cb3..2e2062369e9 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/model/common/Element.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/model/common/Element.java @@ -4,6 +4,7 @@ import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; +import lombok.NoArgsConstructor; import java.util.UUID; import javax.validation.Valid; @@ -11,12 +12,13 @@ @Data @Builder +@NoArgsConstructor @AllArgsConstructor @JsonIgnoreProperties(ignoreUnknown = true) public class Element { - private final UUID id; + private UUID id; @NotNull @Valid - private final T value; + private T value; } diff --git a/src/main/java/uk/gov/hmcts/reform/civil/model/dq/DisclosureOfElectronicDocuments.java b/src/main/java/uk/gov/hmcts/reform/civil/model/dq/DisclosureOfElectronicDocuments.java index 8372ad3c9d3..518183c6844 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/model/dq/DisclosureOfElectronicDocuments.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/model/dq/DisclosureOfElectronicDocuments.java @@ -1,14 +1,18 @@ package uk.gov.hmcts.reform.civil.model.dq; +import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; +import lombok.NoArgsConstructor; import uk.gov.hmcts.reform.civil.enums.YesOrNo; @Data @Builder +@NoArgsConstructor +@AllArgsConstructor public class DisclosureOfElectronicDocuments { - private final YesOrNo reachedAgreement; - private final YesOrNo agreementLikely; - private final String reasonForNoAgreement; + private YesOrNo reachedAgreement; + private YesOrNo agreementLikely; + private String reasonForNoAgreement; } diff --git a/src/main/java/uk/gov/hmcts/reform/civil/model/dq/DisclosureOfNonElectronicDocuments.java b/src/main/java/uk/gov/hmcts/reform/civil/model/dq/DisclosureOfNonElectronicDocuments.java index 3fb383fb251..e2fdb2a5b09 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/model/dq/DisclosureOfNonElectronicDocuments.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/model/dq/DisclosureOfNonElectronicDocuments.java @@ -1,14 +1,18 @@ package uk.gov.hmcts.reform.civil.model.dq; +import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; +import lombok.NoArgsConstructor; import uk.gov.hmcts.reform.civil.enums.YesOrNo; @Data @Builder +@NoArgsConstructor +@AllArgsConstructor public class DisclosureOfNonElectronicDocuments { - private final YesOrNo directionsForDisclosureProposed; - private final YesOrNo standardDirectionsRequired; - private final String bespokeDirections; + private YesOrNo directionsForDisclosureProposed; + private YesOrNo standardDirectionsRequired; + private String bespokeDirections; } diff --git a/src/main/java/uk/gov/hmcts/reform/civil/model/dq/Experts.java b/src/main/java/uk/gov/hmcts/reform/civil/model/dq/Experts.java index e84d4c19a26..061919492c5 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/model/dq/Experts.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/model/dq/Experts.java @@ -1,7 +1,9 @@ package uk.gov.hmcts.reform.civil.model.dq; +import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; +import lombok.NoArgsConstructor; import uk.gov.hmcts.reform.civil.enums.ExpertReportsSent; import uk.gov.hmcts.reform.civil.enums.YesOrNo; import uk.gov.hmcts.reform.civil.model.common.Element; @@ -10,10 +12,12 @@ @Data @Builder(toBuilder = true) +@NoArgsConstructor +@AllArgsConstructor public class Experts { - private final YesOrNo expertRequired; - private final ExpertReportsSent expertReportsSent; - private final YesOrNo jointExpertSuitable; - private final List> details; + private YesOrNo expertRequired; + private ExpertReportsSent expertReportsSent; + private YesOrNo jointExpertSuitable; + private List> details; } diff --git a/src/main/java/uk/gov/hmcts/reform/civil/model/dq/FileDirectionsQuestionnaire.java b/src/main/java/uk/gov/hmcts/reform/civil/model/dq/FileDirectionsQuestionnaire.java index 76dda3ebfa2..1eba71f3a02 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/model/dq/FileDirectionsQuestionnaire.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/model/dq/FileDirectionsQuestionnaire.java @@ -1,17 +1,21 @@ package uk.gov.hmcts.reform.civil.model.dq; +import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; +import lombok.NoArgsConstructor; import uk.gov.hmcts.reform.civil.enums.YesOrNo; import java.util.List; @Data @Builder +@NoArgsConstructor +@AllArgsConstructor public class FileDirectionsQuestionnaire { - private final List explainedToClient; - private final YesOrNo oneMonthStayRequested; - private final YesOrNo reactionProtocolCompliedWith; - private final String reactionProtocolNotCompliedWithReason; + private List explainedToClient; + private YesOrNo oneMonthStayRequested; + private YesOrNo reactionProtocolCompliedWith; + private String reactionProtocolNotCompliedWithReason; } diff --git a/src/main/java/uk/gov/hmcts/reform/civil/model/dq/FixedRecoverableCosts.java b/src/main/java/uk/gov/hmcts/reform/civil/model/dq/FixedRecoverableCosts.java index 15b580210f6..51db9cc8186 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/model/dq/FixedRecoverableCosts.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/model/dq/FixedRecoverableCosts.java @@ -2,6 +2,7 @@ import lombok.AllArgsConstructor; import lombok.Data; +import lombok.NoArgsConstructor; import lombok.experimental.SuperBuilder; import uk.gov.hmcts.reform.civil.documentmanagement.model.Document; @@ -10,6 +11,7 @@ @Data @SuperBuilder(toBuilder = true) +@NoArgsConstructor @AllArgsConstructor public class FixedRecoverableCosts { diff --git a/src/main/java/uk/gov/hmcts/reform/civil/model/dq/FurtherInformation.java b/src/main/java/uk/gov/hmcts/reform/civil/model/dq/FurtherInformation.java index 89805e0450e..5ed41205299 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/model/dq/FurtherInformation.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/model/dq/FurtherInformation.java @@ -1,15 +1,19 @@ package uk.gov.hmcts.reform.civil.model.dq; +import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; +import lombok.NoArgsConstructor; import uk.gov.hmcts.reform.civil.enums.YesOrNo; @Data @Builder(toBuilder = true) +@NoArgsConstructor +@AllArgsConstructor public class FurtherInformation { - private final YesOrNo futureApplications; - private final YesOrNo intentionToMakeFutureApplications; - private final String reasonForFutureApplications; - private final String otherInformationForJudge; + private YesOrNo futureApplications; + private YesOrNo intentionToMakeFutureApplications; + private String reasonForFutureApplications; + private String otherInformationForJudge; } diff --git a/src/main/java/uk/gov/hmcts/reform/civil/model/dq/Hearing.java b/src/main/java/uk/gov/hmcts/reform/civil/model/dq/Hearing.java index ea5e839df0e..4dd49a9e2f1 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/model/dq/Hearing.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/model/dq/Hearing.java @@ -1,7 +1,9 @@ package uk.gov.hmcts.reform.civil.model.dq; +import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; +import lombok.NoArgsConstructor; import uk.gov.hmcts.reform.civil.enums.YesOrNo; import uk.gov.hmcts.reform.civil.enums.dq.HearingLength; import uk.gov.hmcts.reform.civil.model.UnavailableDate; @@ -11,12 +13,14 @@ @Data @Builder(toBuilder = true) +@NoArgsConstructor +@AllArgsConstructor public class Hearing { - private final HearingLength hearingLength; - private final String hearingLengthHours; - private final String hearingLengthDays; - private final YesOrNo unavailableDatesRequired; - private final List> unavailableDates; + private HearingLength hearingLength; + private String hearingLengthHours; + private String hearingLengthDays; + private YesOrNo unavailableDatesRequired; + private List> unavailableDates; } diff --git a/src/main/java/uk/gov/hmcts/reform/civil/model/dq/HearingSupport.java b/src/main/java/uk/gov/hmcts/reform/civil/model/dq/HearingSupport.java index 1c8ac1b70a6..556211044d5 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/model/dq/HearingSupport.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/model/dq/HearingSupport.java @@ -1,7 +1,9 @@ package uk.gov.hmcts.reform.civil.model.dq; +import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; +import lombok.NoArgsConstructor; import uk.gov.hmcts.reform.civil.enums.YesOrNo; import uk.gov.hmcts.reform.civil.enums.dq.SupportRequirements; @@ -9,13 +11,15 @@ @Data @Builder(toBuilder = true) +@NoArgsConstructor +@AllArgsConstructor public class HearingSupport { // CIV-5557 to be removed - private final List requirements; - private final String signLanguageRequired; - private final String languageToBeInterpreted; - private final String otherSupport; - private final YesOrNo supportRequirements; - private final String supportRequirementsAdditional; + private List requirements; + private String signLanguageRequired; + private String languageToBeInterpreted; + private String otherSupport; + private YesOrNo supportRequirements; + private String supportRequirementsAdditional; } diff --git a/src/main/java/uk/gov/hmcts/reform/civil/model/dq/RequestedCourt.java b/src/main/java/uk/gov/hmcts/reform/civil/model/dq/RequestedCourt.java index bfb7bb33d96..bf6b17f4b85 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/model/dq/RequestedCourt.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/model/dq/RequestedCourt.java @@ -1,13 +1,17 @@ package uk.gov.hmcts.reform.civil.model.dq; +import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; +import lombok.NoArgsConstructor; import uk.gov.hmcts.reform.civil.enums.YesOrNo; import uk.gov.hmcts.reform.civil.model.common.DynamicList; import uk.gov.hmcts.reform.civil.model.defaultjudgment.CaseLocationCivil; @Data @Builder(toBuilder = true) +@NoArgsConstructor +@AllArgsConstructor public class RequestedCourt { /** @@ -16,11 +20,11 @@ public class RequestedCourt { * @deprecated location is mandatory for all parties now */ @Deprecated(forRemoval = true) - private final YesOrNo requestHearingAtSpecificCourt; - private final String otherPartyPreferredSite; - private final String responseCourtCode; - private final String reasonForHearingAtSpecificCourt; - private final DynamicList responseCourtLocations; - private final CaseLocationCivil caseLocation; - private final String responseCourtName; + private YesOrNo requestHearingAtSpecificCourt; + private String otherPartyPreferredSite; + private String responseCourtCode; + private String reasonForHearingAtSpecificCourt; + private DynamicList responseCourtLocations; + private CaseLocationCivil caseLocation; + private String responseCourtName; } diff --git a/src/main/java/uk/gov/hmcts/reform/civil/model/dq/VulnerabilityQuestions.java b/src/main/java/uk/gov/hmcts/reform/civil/model/dq/VulnerabilityQuestions.java index 811aaa0527f..ee0010da92c 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/model/dq/VulnerabilityQuestions.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/model/dq/VulnerabilityQuestions.java @@ -2,14 +2,16 @@ import lombok.Builder; import lombok.Data; +import lombok.NoArgsConstructor; import uk.gov.hmcts.reform.civil.enums.YesOrNo; @Data @Builder(toBuilder = true) +@NoArgsConstructor public class VulnerabilityQuestions { - final YesOrNo vulnerabilityAdjustmentsRequired; - final String vulnerabilityAdjustments; + private YesOrNo vulnerabilityAdjustmentsRequired; + private String vulnerabilityAdjustments; public VulnerabilityQuestions(YesOrNo vulnerabilityAdjustmentsRequired, String vulnerabilityAdjustments) { this.vulnerabilityAdjustmentsRequired = vulnerabilityAdjustmentsRequired; diff --git a/src/main/java/uk/gov/hmcts/reform/civil/model/dq/WelshLanguageRequirements.java b/src/main/java/uk/gov/hmcts/reform/civil/model/dq/WelshLanguageRequirements.java index b0d8934d52c..4d9393daead 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/model/dq/WelshLanguageRequirements.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/model/dq/WelshLanguageRequirements.java @@ -1,14 +1,18 @@ package uk.gov.hmcts.reform.civil.model.dq; +import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; +import lombok.NoArgsConstructor; import uk.gov.hmcts.reform.civil.enums.dq.Language; @Data @Builder(toBuilder = true) +@NoArgsConstructor +@AllArgsConstructor public class WelshLanguageRequirements { - private final Language evidence; - private final Language court; - private final Language documents; + private Language evidence; + private Language court; + private Language documents; } diff --git a/src/main/java/uk/gov/hmcts/reform/civil/model/dq/Witnesses.java b/src/main/java/uk/gov/hmcts/reform/civil/model/dq/Witnesses.java index ad8eb632202..803ee12c947 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/model/dq/Witnesses.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/model/dq/Witnesses.java @@ -1,7 +1,9 @@ package uk.gov.hmcts.reform.civil.model.dq; +import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; +import lombok.NoArgsConstructor; import uk.gov.hmcts.reform.civil.enums.YesOrNo; import uk.gov.hmcts.reform.civil.model.common.Element; @@ -9,8 +11,10 @@ @Data @Builder(toBuilder = true) +@NoArgsConstructor +@AllArgsConstructor public class Witnesses { - private final YesOrNo witnessesToAppear; - private final List> details; + private YesOrNo witnessesToAppear; + private List> details; } diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/ResubmitClaimCallbackHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/ResubmitClaimCallbackHandlerTest.java index 68fb1c0022e..211364dd8eb 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/ResubmitClaimCallbackHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/ResubmitClaimCallbackHandlerTest.java @@ -1,21 +1,20 @@ package uk.gov.hmcts.reform.civil.handler.callback.user; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; import uk.gov.hmcts.reform.ccd.client.model.AboutToStartOrSubmitCallbackResponse; import uk.gov.hmcts.reform.ccd.client.model.SubmittedCallbackResponse; import uk.gov.hmcts.reform.civil.callback.CallbackParams; -import uk.gov.hmcts.reform.civil.config.ExitSurveyConfiguration; import uk.gov.hmcts.reform.civil.handler.callback.BaseCallbackHandlerTest; -import uk.gov.hmcts.reform.civil.helpers.CaseDetailsConverter; -import uk.gov.hmcts.reform.civil.service.FeatureToggleService; import uk.gov.hmcts.reform.civil.model.CaseData; import uk.gov.hmcts.reform.civil.sampledata.CaseDataBuilder; import uk.gov.hmcts.reform.civil.service.ExitSurveyContentService; +import uk.gov.hmcts.reform.civil.service.FeatureToggleService; import static org.assertj.core.api.Assertions.assertThat; import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_SUBMIT; @@ -25,24 +24,23 @@ import static uk.gov.hmcts.reform.civil.enums.CaseCategory.SPEC_CLAIM; import static uk.gov.hmcts.reform.civil.enums.YesOrNo.NO; -@SpringBootTest(classes = { - ResubmitClaimCallbackHandler.class, - ExitSurveyConfiguration.class, - ExitSurveyContentService.class, - JacksonAutoConfiguration.class, - CaseDetailsConverter.class -}) +@ExtendWith(MockitoExtension.class) class ResubmitClaimCallbackHandlerTest extends BaseCallbackHandlerTest { - @Autowired - ResubmitClaimCallbackHandler handler; + private ResubmitClaimCallbackHandler handler; - @Autowired + @Mock private ExitSurveyContentService exitSurveyContentService; - @MockBean + @Mock private FeatureToggleService toggleService; + @BeforeEach + void setup() { + ObjectMapper mapper = new ObjectMapper().registerModule(new com.fasterxml.jackson.datatype.jsr310.JavaTimeModule()); + handler = new ResubmitClaimCallbackHandler(exitSurveyContentService, mapper, toggleService); + } + @Nested class AboutToSubmitCallback { diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/SetAsideJudgmentCallbackHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/SetAsideJudgmentCallbackHandlerTest.java index 0dcbe0b7a3b..27ccc6ff7f6 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/SetAsideJudgmentCallbackHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/SetAsideJudgmentCallbackHandlerTest.java @@ -1,16 +1,14 @@ package uk.gov.hmcts.reform.civil.handler.callback.user; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.test.context.junit.jupiter.SpringExtension; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; import uk.gov.hmcts.reform.ccd.client.model.AboutToStartOrSubmitCallbackResponse; import uk.gov.hmcts.reform.ccd.client.model.SubmittedCallbackResponse; import uk.gov.hmcts.reform.civil.callback.CallbackParams; @@ -24,7 +22,6 @@ import uk.gov.hmcts.reform.civil.model.judgmentonline.JudgmentState; import uk.gov.hmcts.reform.civil.sampledata.CaseDataBuilder; import uk.gov.hmcts.reform.civil.service.DeadlinesCalculator; -import uk.gov.hmcts.reform.civil.service.Time; import java.time.LocalDate; import java.time.LocalDateTime; @@ -37,26 +34,22 @@ import static uk.gov.hmcts.reform.civil.callback.CallbackType.MID; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.SET_ASIDE_JUDGMENT; -@ExtendWith(SpringExtension.class) -@SpringBootTest(classes = { - SetAsideJudgmentOnlineMapper.class, - SetAsideJudgmentCallbackHandler.class, - JacksonAutoConfiguration.class, - DeadlinesCalculator.class -}) +@ExtendWith(MockitoExtension.class) class SetAsideJudgmentCallbackHandlerTest extends BaseCallbackHandlerTest { - @Autowired private SetAsideJudgmentCallbackHandler handler; - @Autowired - private ObjectMapper objectMapper; + private SetAsideJudgmentOnlineMapper setAsideJudgmentOnlineMapper; - @MockBean + @Mock private DeadlinesCalculator deadlinesCalculator; - @MockBean - private Time time; + @BeforeEach + void setup() { + ObjectMapper objectMapper = new ObjectMapper().registerModule(new com.fasterxml.jackson.datatype.jsr310.JavaTimeModule()); + setAsideJudgmentOnlineMapper = new SetAsideJudgmentOnlineMapper(); + handler = new SetAsideJudgmentCallbackHandler(objectMapper, setAsideJudgmentOnlineMapper, deadlinesCalculator); + } @Test void handleEventsReturnsTheExpectedCallbackEvents() { @@ -70,20 +63,16 @@ class AboutToSubmitCallback { @BeforeEach void setup() { + ObjectMapper objectMapper = new ObjectMapper().registerModule(new com.fasterxml.jackson.datatype.jsr310.JavaTimeModule()); + objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); + handler = new SetAsideJudgmentCallbackHandler(objectMapper, setAsideJudgmentOnlineMapper, deadlinesCalculator); timeExtensionDate = LocalDateTime.of(2020, 1, 1, 12, 0, 0); - when(time.now()).thenReturn(timeExtensionDate); respondent1ResponseDeadline = now().plusDays(28); - when(deadlinesCalculator.calculateFirstWorkingDay(respondent1ResponseDeadline)) - .thenReturn(respondent1ResponseDeadline); - } @Test void shouldPopulateSetAsideDate() { //Given : Casedata in All_FINAL_ORDERS_ISSUED State - LocalDateTime nextDeadline = respondent1ResponseDeadline.atTime(16, 0); - when(deadlinesCalculator.plus28DaysAt4pmDeadline(now().atStartOfDay())) - .thenReturn(nextDeadline); CaseData caseData = CaseDataBuilder.builder().buildJudmentOnlineCaseDataWithPaymentByInstalment(); caseData.setJoSetAsideReason(JudgmentSetAsideReason.JUDGE_ORDER); caseData.setJoSetAsideOrderType(JudgmentSetAsideOrderType.ORDER_AFTER_APPLICATION); @@ -107,9 +96,6 @@ void shouldPopulateSetAsideDate() { @Test void shouldPopulateDefenceReceivedDate() { //Given : Casedata in All_FINAL_ORDERS_ISSUED State - LocalDateTime nextDeadline = respondent1ResponseDeadline.atTime(16, 0); - when(deadlinesCalculator.plus28DaysAt4pmDeadline(now().atStartOfDay())) - .thenReturn(nextDeadline); CaseData caseData = CaseDataBuilder.builder().buildJudmentOnlineCaseDataWithPaymentByInstalment(); caseData.setJoSetAsideReason(JudgmentSetAsideReason.JUDGE_ORDER); caseData.setJoSetAsideOrderType(JudgmentSetAsideOrderType.ORDER_AFTER_DEFENCE); @@ -132,9 +118,6 @@ void shouldPopulateDefenceReceivedDate() { @Test void shouldPopulateSetAsideJudgmentErrorText() { //Given : Casedata in All_FINAL_ORDERS_ISSUED State - LocalDateTime nextDeadline = respondent1ResponseDeadline.atTime(16, 0); - when(deadlinesCalculator.plus28DaysAt4pmDeadline(now().atStartOfDay())) - .thenReturn(nextDeadline); CaseData caseData = CaseDataBuilder.builder().buildJudmentOnlineCaseDataWithPaymentByInstalment(); caseData.setJoSetAsideReason(JudgmentSetAsideReason.JUDGMENT_ERROR); caseData.setJoSetAsideJudgmentErrorText("Some text"); diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/SettleClaimMarkPaidFullCallbackHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/SettleClaimMarkPaidFullCallbackHandlerTest.java index 7c6534258a3..ffcbae070f4 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/SettleClaimMarkPaidFullCallbackHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/SettleClaimMarkPaidFullCallbackHandlerTest.java @@ -2,11 +2,11 @@ import com.fasterxml.jackson.databind.ObjectMapper; import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; import uk.gov.hmcts.reform.ccd.client.model.AboutToStartOrSubmitCallbackResponse; import uk.gov.hmcts.reform.ccd.client.model.SubmittedCallbackResponse; import uk.gov.hmcts.reform.civil.callback.CallbackParams; @@ -27,17 +27,19 @@ import static uk.gov.hmcts.reform.civil.callback.CaseEvent.SETTLE_CLAIM_MARKED_PAID_IN_FULL; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.SETTLE_CLAIM_MARK_PAID_FULL; -@SpringBootTest(classes = { - SettleClaimMarkPaidFullCallbackHandler.class, - JacksonAutoConfiguration.class -}) +@ExtendWith(MockitoExtension.class) class SettleClaimMarkPaidFullCallbackHandlerTest extends BaseCallbackHandlerTest { - @Autowired private SettleClaimMarkPaidFullCallbackHandler handler; - @Autowired - private final ObjectMapper objectMapper = new ObjectMapper(); + private ObjectMapper objectMapper; + + @BeforeEach + void setup() { + objectMapper = new ObjectMapper().registerModule(new com.fasterxml.jackson.datatype.jsr310.JavaTimeModule()); + handler = new SettleClaimMarkPaidFullCallbackHandler(objectMapper); + } + public static final String REQUEST_BEING_REVIEWED_NEXT_STEPS = """ ### Next step diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/TakeCaseOfflineCallbackHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/TakeCaseOfflineCallbackHandlerTest.java index 4d7f36f2eaa..f7084410479 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/TakeCaseOfflineCallbackHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/TakeCaseOfflineCallbackHandlerTest.java @@ -1,14 +1,13 @@ package uk.gov.hmcts.reform.civil.handler.callback.user; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.test.context.junit.jupiter.SpringExtension; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; import uk.gov.hmcts.reform.ccd.client.model.AboutToStartOrSubmitCallbackResponse; import uk.gov.hmcts.reform.civil.callback.CallbackParams; import uk.gov.hmcts.reform.civil.handler.callback.BaseCallbackHandlerTest; @@ -25,19 +24,21 @@ import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_SUBMIT; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.TAKE_CASE_OFFLINE; -@ExtendWith(SpringExtension.class) -@SpringBootTest(classes = { - TakeCaseOfflineCallbackHandler.class, - JacksonAutoConfiguration.class -}) +@ExtendWith(MockitoExtension.class) class TakeCaseOfflineCallbackHandlerTest extends BaseCallbackHandlerTest { - @MockBean + @Mock private Time time; - @Autowired private TakeCaseOfflineCallbackHandler handler; + @BeforeEach + void setup() { + ObjectMapper mapper = new ObjectMapper().registerModule(new com.fasterxml.jackson.datatype.jsr310.JavaTimeModule()); + mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); + handler = new TakeCaseOfflineCallbackHandler(mapper, time); + } + @Nested class AboutToStartCallback { diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/TransferOnlineCaseCallbackHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/TransferOnlineCaseCallbackHandlerTest.java index 41f5f90fd8f..ebbc051f04b 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/TransferOnlineCaseCallbackHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/TransferOnlineCaseCallbackHandlerTest.java @@ -7,11 +7,8 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.CsvSource; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.test.context.junit.jupiter.SpringExtension; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; import uk.gov.hmcts.reform.ccd.client.model.AboutToStartOrSubmitCallbackResponse; import uk.gov.hmcts.reform.ccd.client.model.SubmittedCallbackResponse; import uk.gov.hmcts.reform.civil.callback.CallbackParams; @@ -39,26 +36,29 @@ import static uk.gov.hmcts.reform.civil.enums.YesOrNo.NO; import static uk.gov.hmcts.reform.civil.enums.YesOrNo.YES; -@ExtendWith(SpringExtension.class) -@SpringBootTest(classes = { - TransferOnlineCaseCallbackHandler.class, - JacksonAutoConfiguration.class}) +@ExtendWith(MockitoExtension.class) class TransferOnlineCaseCallbackHandlerTest extends BaseCallbackHandlerTest { private static final String CONFIRMATION_HEADER = "# Case transferred to new location"; - @Autowired private TransferOnlineCaseCallbackHandler handler; - @Autowired + private ObjectMapper objectMapper; - @MockBean + @Mock protected LocationReferenceDataService locationRefDataService; - @MockBean + @Mock protected CourtLocationUtils courtLocationUtils; - @MockBean + @Mock protected FeatureToggleService featureToggleService; + @BeforeEach + void setup() { + objectMapper = new ObjectMapper().registerModule(new com.fasterxml.jackson.datatype.jsr310.JavaTimeModule()); + handler = new TransferOnlineCaseCallbackHandler(objectMapper, locationRefDataService, courtLocationUtils, + featureToggleService); + } + @Nested class AboutToStartCallback extends LocationRefSampleDataBuilder { @@ -233,12 +233,16 @@ void shouldPopulateWhiteListing_whenCourtTransferredIsWhitelisted(Boolean isLoca @CsvSource({"true", "false"}) void shouldPopulateWhiteListing_whenNationalRolloutEnabled(Boolean isNationalRolloutEnabled) { when(featureToggleService.isNationalRolloutEnabled()).thenReturn(isNationalRolloutEnabled); - when(featureToggleService.isPartOfNationalRollout(any())).thenReturn(isNationalRolloutEnabled); given(courtLocationUtils.findPreferredLocationData(any(), any())) .willReturn(LocationRefData.builder().siteName("") .epimmsId("222") .siteName("Site 2").courtAddress("Adr 2").postcode("BBB 222") .courtLocationCode("other code").build()); + + if (isNationalRolloutEnabled) { + when(featureToggleService.isPartOfNationalRollout("222")).thenReturn(true); + } + CaseData caseData = CaseDataBuilder.builder().atStateApplicantRespondToDefenceAndProceed() .caseManagementLocation(CaseLocationCivil.builder() .region("2") @@ -250,7 +254,11 @@ void shouldPopulateWhiteListing_whenNationalRolloutEnabled(Boolean isNationalRol var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); CaseData responseCaseData = objectMapper.convertValue(response.getData(), CaseData.class); - assertThat(responseCaseData.getEaCourtLocation()).isEqualTo(isNationalRolloutEnabled ? YES : null); + if (isNationalRolloutEnabled) { + assertThat(responseCaseData.getEaCourtLocation()).isEqualTo(YES); + } else { + assertThat(responseCaseData.getEaCourtLocation()).isNull(); + } } } diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/TrialReadinessCallbackHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/TrialReadinessCallbackHandlerTest.java index 02c7e4f201e..5c24f9ee7e7 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/TrialReadinessCallbackHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/TrialReadinessCallbackHandlerTest.java @@ -1,14 +1,12 @@ package uk.gov.hmcts.reform.civil.handler.callback.user; +import com.fasterxml.jackson.databind.ObjectMapper; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.test.context.junit.jupiter.SpringExtension; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; import uk.gov.hmcts.reform.ccd.client.model.AboutToStartOrSubmitCallbackResponse; import uk.gov.hmcts.reform.ccd.client.model.SubmittedCallbackResponse; import uk.gov.hmcts.reform.civil.callback.CallbackParams; @@ -21,6 +19,7 @@ import uk.gov.hmcts.reform.civil.sampledata.CallbackParamsBuilder; import uk.gov.hmcts.reform.civil.sampledata.CaseDataBuilder; import uk.gov.hmcts.reform.civil.service.CoreCaseUserService; +import uk.gov.hmcts.reform.civil.service.UserService; import uk.gov.hmcts.reform.idam.client.models.UserInfo; import java.time.LocalDate; @@ -33,34 +32,44 @@ import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_SUBMIT; import static uk.gov.hmcts.reform.civil.callback.CallbackType.SUBMITTED; -@ExtendWith(SpringExtension.class) -@SpringBootTest(classes = { - TrialReadinessCallbackHandler.class, - JacksonAutoConfiguration.class -}) - +@ExtendWith(MockitoExtension.class) public class TrialReadinessCallbackHandlerTest extends BaseCallbackHandlerTest { - @Autowired private TrialReadinessCallbackHandler handler; - @MockBean + @Mock private CoreCaseUserService coreCaseUserService; + @Mock + private UserService userService; + + @BeforeEach + void setup() { + ObjectMapper objectMapper = new ObjectMapper().registerModule(new com.fasterxml.jackson.datatype.jsr310.JavaTimeModule()); + handler = new TrialReadinessCallbackHandler(objectMapper, userService, coreCaseUserService); + } + public static final String READY_HEADER = "## You have said this case is ready for trial or hearing"; - public static final String READY_BODY = "### What happens next \n\n" - + "You can view your and other party's trial arrangements in documents in the case details.\n\n " - + "If there are any additional changes between now and the hearing date, " - + "you will need to make an application as soon as possible and pay the appropriate fee."; + public static final String READY_BODY = """ + ### What happens next\s + + You can view your and other party's trial arrangements in documents in the case details. + + \ + If there are any additional changes between now and the hearing date, \ + you will need to make an application as soon as possible and pay the appropriate fee."""; public static final String NOT_READY_HEADER = "## You have said this case is not ready for trial or hearing"; - public static final String NOT_READY_BODY = "### What happens next \n\n" - + "You can view your and other party's trial arrangements in documents in the case details. " - + "If there are any additional changes between now and the hearing date, " - + "you will need to make an application as soon as possible and pay the appropriate fee.\n\n" - + "The trial will go ahead on the specified date " - + "unless a judge makes an order changing the date of the hearing. " - + "If you want the date of the hearing to be changed (or any other order to make the case ready for trial)" - + "you will need to make an application to the court and pay the appropriate fee."; + public static final String NOT_READY_BODY = """ + ### What happens next\s + + You can view your and other party's trial arrangements in documents in the case details. \ + If there are any additional changes between now and the hearing date, \ + you will need to make an application as soon as possible and pay the appropriate fee. + + The trial will go ahead on the specified date \ + unless a judge makes an order changing the date of the hearing. \ + If you want the date of the hearing to be changed (or any other order to make the case ready for trial)\ + you will need to make an application to the court and pay the appropriate fee."""; @Nested class AboutToStartCallback { diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/TrialReadyCheckCallbackHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/TrialReadyCheckCallbackHandlerTest.java index 05622e41353..e272baf0d84 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/TrialReadyCheckCallbackHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/TrialReadyCheckCallbackHandlerTest.java @@ -1,36 +1,31 @@ package uk.gov.hmcts.reform.civil.handler.callback.user; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.test.context.junit.jupiter.SpringExtension; +import org.mockito.junit.jupiter.MockitoExtension; import uk.gov.hmcts.reform.ccd.client.model.AboutToStartOrSubmitCallbackResponse; import uk.gov.hmcts.reform.civil.callback.CallbackParams; import uk.gov.hmcts.reform.civil.handler.callback.BaseCallbackHandlerTest; import uk.gov.hmcts.reform.civil.model.CaseData; import uk.gov.hmcts.reform.civil.sampledata.CaseDataBuilder; -import uk.gov.hmcts.reform.civil.service.Time; import static org.assertj.core.api.Assertions.assertThat; import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_SUBMIT; -@ExtendWith(SpringExtension.class) -@SpringBootTest(classes = { - TrialReadyCheckCallbackHandler.class, - JacksonAutoConfiguration.class -}) +@ExtendWith(MockitoExtension.class) class TrialReadyCheckCallbackHandlerTest extends BaseCallbackHandlerTest { - @MockBean - private Time time; - - @Autowired private TrialReadyCheckCallbackHandler handler; + @BeforeEach + void setup() { + ObjectMapper objectMapper = new ObjectMapper().registerModule(new com.fasterxml.jackson.datatype.jsr310.JavaTimeModule()); + handler = new TrialReadyCheckCallbackHandler(objectMapper); + } + @Nested class AboutToStartCallback { diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/TrialReadyNotificationCallbackHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/TrialReadyNotificationCallbackHandlerTest.java index 254107ee64a..5ee95c305bc 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/TrialReadyNotificationCallbackHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/TrialReadyNotificationCallbackHandlerTest.java @@ -1,14 +1,12 @@ package uk.gov.hmcts.reform.civil.handler.callback.user; +import com.fasterxml.jackson.databind.ObjectMapper; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.test.context.junit.jupiter.SpringExtension; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; import uk.gov.hmcts.reform.ccd.client.model.AboutToStartOrSubmitCallbackResponse; import uk.gov.hmcts.reform.civil.callback.CallbackParams; import uk.gov.hmcts.reform.civil.handler.callback.BaseCallbackHandlerTest; @@ -19,24 +17,24 @@ import java.time.LocalDateTime; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.when; import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_START; import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_SUBMIT; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.TRIAL_READY_NOTIFICATION; -@ExtendWith(SpringExtension.class) -@SpringBootTest(classes = { - TrialReadyNotificationCallbackHandler.class, - JacksonAutoConfiguration.class -}) +@ExtendWith(MockitoExtension.class) class TrialReadyNotificationCallbackHandlerTest extends BaseCallbackHandlerTest { - @MockBean + @Mock private Time time; - @Autowired private TrialReadyNotificationCallbackHandler handler; + @BeforeEach + void setup() { + ObjectMapper objectMapper = new ObjectMapper().registerModule(new com.fasterxml.jackson.datatype.jsr310.JavaTimeModule()); + handler = new TrialReadyNotificationCallbackHandler(objectMapper, time); + } + @Nested class AboutToStartCallback { @@ -58,7 +56,6 @@ class AboutToSubmitCallback { @BeforeEach void setup() { now = LocalDateTime.now(); - when(time.now()).thenReturn(now); } @Test diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/UploadMediationDocumentsCallbackHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/UploadMediationDocumentsCallbackHandlerTest.java index eb831f639db..f6b4da37cf0 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/UploadMediationDocumentsCallbackHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/UploadMediationDocumentsCallbackHandlerTest.java @@ -5,11 +5,8 @@ import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.test.context.junit.jupiter.SpringExtension; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; import uk.gov.hmcts.reform.ccd.client.model.AboutToStartOrSubmitCallbackResponse; import uk.gov.hmcts.reform.civil.callback.CallbackParams; import uk.gov.hmcts.reform.civil.documentmanagement.model.Document; @@ -25,6 +22,7 @@ import uk.gov.hmcts.reform.civil.sampledata.CaseDataBuilder; import uk.gov.hmcts.reform.civil.service.CoreCaseUserService; import uk.gov.hmcts.reform.civil.service.Time; +import uk.gov.hmcts.reform.civil.service.UserService; import uk.gov.hmcts.reform.civil.service.mediation.UploadMediationService; import uk.gov.hmcts.reform.civil.utils.AssignCategoryId; import uk.gov.hmcts.reform.idam.client.models.UserInfo; @@ -54,32 +52,33 @@ import static uk.gov.hmcts.reform.civil.utils.UploadMediationDocumentsUtils.DEFENDANT_ONE_ID; import static uk.gov.hmcts.reform.civil.utils.UploadMediationDocumentsUtils.DEFENDANT_TWO_ID; -@ExtendWith(SpringExtension.class) -@SpringBootTest(classes = { - UploadMediationDocumentsCallbackHandler.class, - JacksonAutoConfiguration.class, - AssignCategoryId.class -}) +@ExtendWith(MockitoExtension.class) class UploadMediationDocumentsCallbackHandlerTest extends BaseCallbackHandlerTest { - @Autowired private UploadMediationDocumentsCallbackHandler handler; - @Autowired private ObjectMapper objectMapper; - @Autowired - private AssignCategoryId assignCategoryId; - - @MockBean + @Mock private CoreCaseUserService coreCaseUserService; - @MockBean + @Mock private UploadMediationService uploadMediationService; - @MockBean + @Mock + private UserService userService; + + @Mock private Time time; + @BeforeEach + void setUp() { + objectMapper = new ObjectMapper().registerModule(new com.fasterxml.jackson.datatype.jsr310.JavaTimeModule()); + AssignCategoryId assignCategoryId = new AssignCategoryId(); + handler = new UploadMediationDocumentsCallbackHandler(coreCaseUserService, userService, objectMapper, time, + assignCategoryId, uploadMediationService); + } + private static final String PARTY_OPTIONS_PAGE = "populate-party-options"; private static final String VALIDATE_DATES = "validate-dates"; private static final String APPLICANT_SOLICITOR_ROLE = "[APPLICANTSOLICITORONE]"; diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/UploadTranslatedDocumentHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/UploadTranslatedDocumentHandlerTest.java index ffdb2871a36..24900b7c484 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/UploadTranslatedDocumentHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/UploadTranslatedDocumentHandlerTest.java @@ -1,16 +1,15 @@ package uk.gov.hmcts.reform.civil.handler.callback.user; import com.fasterxml.jackson.databind.ObjectMapper; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.test.context.junit.jupiter.SpringExtension; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; import uk.gov.hmcts.reform.ccd.client.model.AboutToStartOrSubmitCallbackResponse; import uk.gov.hmcts.reform.civil.callback.CallbackParams; +import uk.gov.hmcts.reform.civil.documentmanagement.model.Document; import uk.gov.hmcts.reform.civil.enums.CaseState; import uk.gov.hmcts.reform.civil.handler.callback.BaseCallbackHandlerTest; import uk.gov.hmcts.reform.civil.handler.callback.user.strategy.translateddocuments.UploadTranslatedDocumentDefaultStrategy; @@ -21,49 +20,46 @@ import uk.gov.hmcts.reform.civil.model.citizenui.TranslatedDocument; import uk.gov.hmcts.reform.civil.model.common.Element; import uk.gov.hmcts.reform.civil.sampledata.CaseDataBuilder; - -import static org.assertj.core.api.AssertionsForClassTypes.assertThat; -import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_SUBMIT; -import static uk.gov.hmcts.reform.civil.model.citizenui.TranslatedDocumentType.DEFENDANT_RESPONSE; -import static uk.gov.hmcts.reform.civil.utils.ElementUtils.element; - -import uk.gov.hmcts.reform.civil.documentmanagement.model.Document; import uk.gov.hmcts.reform.civil.service.FeatureToggleService; import uk.gov.hmcts.reform.civil.service.SystemGeneratedDocumentService; import java.util.ArrayList; import java.util.List; -@ExtendWith(SpringExtension.class) -@SpringBootTest(classes = { - UploadTranslatedDocumentHandler.class, - UploadTranslatedDocumentStrategyFactory.class, - UploadTranslatedDocumentDefaultStrategy.class, - UploadTranslatedDocumentV1Strategy.class, - SystemGeneratedDocumentService.class, - JacksonAutoConfiguration.class, -}) +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; +import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_SUBMIT; +import static uk.gov.hmcts.reform.civil.model.citizenui.TranslatedDocumentType.DEFENDANT_RESPONSE; +import static uk.gov.hmcts.reform.civil.utils.ElementUtils.element; + +@ExtendWith(MockitoExtension.class) class UploadTranslatedDocumentHandlerTest extends BaseCallbackHandlerTest { - @Autowired private UploadTranslatedDocumentHandler handler; - @MockBean + @Mock private FeatureToggleService featureToggleService; - @Autowired - private UploadTranslatedDocumentStrategyFactory uploadTranslatedDocumentStrategyFactory; + @Mock + private UploadTranslatedDocumentV1Strategy uploadTranslatedDocumentV1Strategy; - @Autowired - private UploadTranslatedDocumentDefaultStrategy uploadTranslatedDocumentDefaultStrategy; - - @Autowired - private SystemGeneratedDocumentService systemGeneratedDocumentService; - - @Autowired - private ObjectMapper objectMapper; private static final String FILE_NAME_1 = "Some file 1"; + @BeforeEach + void setup() { + ObjectMapper objectMapper = new ObjectMapper().registerModule(new com.fasterxml.jackson.datatype.jsr310.JavaTimeModule()); + SystemGeneratedDocumentService systemGeneratedDocumentService = new SystemGeneratedDocumentService(); + UploadTranslatedDocumentDefaultStrategy uploadTranslatedDocumentDefaultStrategy = new UploadTranslatedDocumentDefaultStrategy( + systemGeneratedDocumentService, + objectMapper, + featureToggleService + ); + UploadTranslatedDocumentStrategyFactory uploadTranslatedDocumentStrategyFactory = new UploadTranslatedDocumentStrategyFactory( + uploadTranslatedDocumentDefaultStrategy, + uploadTranslatedDocumentV1Strategy + ); + handler = new UploadTranslatedDocumentHandler(uploadTranslatedDocumentStrategyFactory); + } + @Nested class AboutToSubmitCallback { diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/WithdrawClaimCallbackHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/WithdrawClaimCallbackHandlerTest.java index 88d6fc9d8d9..85dbfa98c44 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/WithdrawClaimCallbackHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/WithdrawClaimCallbackHandlerTest.java @@ -1,10 +1,11 @@ package uk.gov.hmcts.reform.civil.handler.callback.user; +import org.hibernate.validator.messageinterpolation.ParameterMessageInterpolator; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; import uk.gov.hmcts.reform.ccd.client.model.AboutToStartOrSubmitCallbackResponse; import uk.gov.hmcts.reform.ccd.client.model.CaseDetails; import uk.gov.hmcts.reform.civil.callback.CallbackParams; @@ -15,21 +16,31 @@ import uk.gov.hmcts.reform.civil.sampledata.CaseDataBuilder; import uk.gov.hmcts.reform.civil.sampledata.CaseDetailsBuilder; +import javax.validation.Validation; +import javax.validation.Validator; +import javax.validation.ValidatorFactory; import java.time.LocalDate; import static org.assertj.core.api.Assertions.assertThat; import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_START; import static uk.gov.hmcts.reform.civil.callback.CallbackType.MID; -@SpringBootTest(classes = { - WithdrawClaimCallbackHandler.class, - ValidationAutoConfiguration.class -}) +@ExtendWith(MockitoExtension.class) class WithdrawClaimCallbackHandlerTest extends BaseCallbackHandlerTest { - @Autowired private WithdrawClaimCallbackHandler handler; + @BeforeEach + void setUp() { + ValidatorFactory validatorFactory = Validation.byDefaultProvider() + .configure() + .messageInterpolator(new ParameterMessageInterpolator()) + .buildValidatorFactory(); + + Validator validator = validatorFactory.getValidator(); + handler = new WithdrawClaimCallbackHandler(validator); + } + @Nested class AboutToStartCallback { From bbb117fda1d204fc2d7b9b0569cef2af7597904b Mon Sep 17 00:00:00 2001 From: AbuSalamHMCTS <138011124+AbuSalamHMCTS@users.noreply.github.com> Date: Mon, 22 Jul 2024 10:13:29 +0100 Subject: [PATCH 2/2] Remove public from TrialReadinessCallbackHandlerTest.java --- .../callback/user/TrialReadinessCallbackHandlerTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/TrialReadinessCallbackHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/TrialReadinessCallbackHandlerTest.java index 5c24f9ee7e7..3128793e52f 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/TrialReadinessCallbackHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/TrialReadinessCallbackHandlerTest.java @@ -33,7 +33,7 @@ import static uk.gov.hmcts.reform.civil.callback.CallbackType.SUBMITTED; @ExtendWith(MockitoExtension.class) -public class TrialReadinessCallbackHandlerTest extends BaseCallbackHandlerTest { +class TrialReadinessCallbackHandlerTest extends BaseCallbackHandlerTest { private TrialReadinessCallbackHandler handler;