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

DTSCCI-434 Remove Spring context from unit test #5101

Merged
merged 38 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
5db5ea8
DTSCCI-434 Remove Spring context from unit test
tiagreaney Jul 17, 2024
e9821b7
Merge branch 'master' into DTSCCI-434
tiagreaney Jul 17, 2024
2434a4a
Merge branch 'master' into DTSCCI-434
tiagreaney Jul 17, 2024
96a8b6d
Merge branch 'master' into DTSCCI-434
tiagreaney Jul 17, 2024
cbe1b8d
checkstyleTest
tiagreaney Jul 17, 2024
f5409f7
Merge remote-tracking branch 'origin/DTSCCI-434' into DTSCCI-434
tiagreaney Jul 17, 2024
5ddb0f7
Remove Spring context, fix deserialization
tiagreaney Jul 18, 2024
5e6c6fb
Merge branch 'master' into DTSCCI-434
tiagreaney Jul 18, 2024
d057963
checkstyleTest
tiagreaney Jul 18, 2024
81948ff
Merge branch 'master' into DTSCCI-434
tiagreaney Jul 18, 2024
74d093c
Merge branch 'master' into DTSCCI-434
tiagreaney Jul 18, 2024
b1d7b34
Merge remote-tracking branch 'origin/DTSCCI-434' into DTSCCI-434
tiagreaney Jul 18, 2024
37f96fe
Remove spring context
tiagreaney Jul 18, 2024
67d8fb7
Fix deserialization issue
tiagreaney Jul 18, 2024
2e29d9f
remove spring context
tiagreaney Jul 18, 2024
1a7b4e8
remove spring context
tiagreaney Jul 18, 2024
117d453
remove comment
tiagreaney Jul 18, 2024
1aa3ba1
remove comment
tiagreaney Jul 18, 2024
1019166
remove spring context
tiagreaney Jul 18, 2024
34229e3
remove spring context
tiagreaney Jul 18, 2024
593b32d
Merge branch 'master' into DTSCCI-434
tiagreaney Jul 18, 2024
c66109d
Remove spring context from unit tests
tiagreaney Jul 22, 2024
75fdb28
Merge branch 'master' into DTSCCI-434
tiagreaney Jul 22, 2024
7b2e516
Get rid of unnecessary stubbing
tiagreaney Jul 22, 2024
d38a744
Merge branch 'master' into DTSCCI-434
tiagreaney Jul 23, 2024
6e791a7
Merge branch 'master' into DTSCCI-434
tiagreaney Jul 23, 2024
7563e27
Test
tiagreaney Jul 24, 2024
e09a957
Merge branch 'master' into DTSCCI-434
tiagreaney Jul 24, 2024
aeb81ff
Remove spring context
tiagreaney Jul 24, 2024
79ab2b8
Merge branch 'master' into DTSCCI-434
tiagreaney Jul 24, 2024
a1c0012
Merge branch 'master' into DTSCCI-434
tiagreaney Jul 25, 2024
5648a85
checkstyleTest
tiagreaney Jul 25, 2024
c5601e6
Merge branch 'master' into DTSCCI-434
tiagreaney Jul 25, 2024
eb3022f
Fix files before merge
tiagreaney Jul 25, 2024
5d0b5b1
Merge branch 'master' into DTSCCI-434
tiagreaney Jul 25, 2024
50770c2
Fix files before merge
tiagreaney Jul 25, 2024
09f9069
Merge branch 'master' into DTSCCI-434
tiagreaney Jul 25, 2024
65e472f
Merge branch 'master' into DTSCCI-434
tiagreaney Jul 25, 2024
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 @@ -2,9 +2,9 @@

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import uk.gov.hmcts.reform.civil.enums.CaseRole;

import java.time.LocalDateTime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ public class GenerateClaimFormCallbackHandler extends CallbackHandler {
@Value("${stitching.enabled}")
private boolean stitchEnabled;

public void setStitchEnabled(boolean stitchEnabled) {
this.stitchEnabled = stitchEnabled;
}

@Override
public String camundaActivityId(CallbackParams callbackParams) {
return TASK_ID;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
import uk.gov.hmcts.reform.civil.model.caseflags.Flags;

@Data
@lombok.NoArgsConstructor
@lombok.AllArgsConstructor
@Builder(toBuilder = true)
public class PartyFlagStructure {

private final String partyID;
private final String firstName;
private final String lastName;
private final String email;
private final String phone;
private final Flags flags;
private String partyID;
private String firstName;
private String lastName;
private String email;
private String phone;
private Flags flags;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
import static java.util.Optional.ofNullable;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class ServedDocumentFiles {

private List<Element<DocumentWithRegex>> other;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import uk.gov.hmcts.reform.civil.enums.YesOrNo;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class DisclosureOfNonElectronicDocuments {

private YesOrNo directionsForDisclosureProposed;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
import java.util.List;

@Data
@Builder(toBuilder = true)
@NoArgsConstructor
@AllArgsConstructor
@NoArgsConstructor
@Builder(toBuilder = true)
public class Experts {

private YesOrNo expertRequired;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
import java.util.List;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class FileDirectionsQuestionnaire {

private List<String> explainedToClient;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import uk.gov.hmcts.reform.civil.enums.YesOrNo;

@Data
@Builder(toBuilder = true)
@NoArgsConstructor
@AllArgsConstructor
@NoArgsConstructor
@Builder(toBuilder = true)
public class FurtherInformation {

private YesOrNo futureApplications;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
import java.util.List;

@Data
@Builder(toBuilder = true)
@NoArgsConstructor
@AllArgsConstructor
@NoArgsConstructor
@Builder(toBuilder = true)
public class Hearing {

private HearingLength hearingLength;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
import java.util.List;

@Data
@Builder(toBuilder = true)
@NoArgsConstructor
@AllArgsConstructor
@NoArgsConstructor
@Builder(toBuilder = true)
public class HearingSupport {

// CIV-5557 to be removed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
import uk.gov.hmcts.reform.civil.model.defaultjudgment.CaseLocationCivil;

@Data
@Builder(toBuilder = true)
@NoArgsConstructor
@AllArgsConstructor
@NoArgsConstructor
@Builder(toBuilder = true)
public class RequestedCourt {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
@NoArgsConstructor
public class VulnerabilityQuestions {

private YesOrNo vulnerabilityAdjustmentsRequired;
private String vulnerabilityAdjustments;
YesOrNo vulnerabilityAdjustmentsRequired;
String vulnerabilityAdjustments;

public VulnerabilityQuestions(YesOrNo vulnerabilityAdjustmentsRequired, String vulnerabilityAdjustments) {
this.vulnerabilityAdjustmentsRequired = vulnerabilityAdjustmentsRequired;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

@Data
@Builder(toBuilder = true)
@NoArgsConstructor
@AllArgsConstructor
@NoArgsConstructor
public class WelshLanguageRequirements {

private Language evidence;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
import java.util.List;

@Data
@Builder(toBuilder = true)
@NoArgsConstructor
@AllArgsConstructor
@NoArgsConstructor
@Builder(toBuilder = true)
public class Witnesses {

private YesOrNo witnessesToAppear;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package uk.gov.hmcts.reform.civil.handler.callback.camunda.docmosis;

import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentMatchers;
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.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.test.util.ReflectionTestUtils;
import uk.gov.hmcts.reform.ccd.client.model.AboutToStartOrSubmitCallbackResponse;
import uk.gov.hmcts.reform.civil.documentmanagement.model.CaseDocument;
Expand Down Expand Up @@ -42,31 +41,34 @@
import static uk.gov.hmcts.reform.civil.service.docmosis.DocmosisTemplates.N1;
import static uk.gov.hmcts.reform.civil.utils.ElementUtils.element;

@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = {
GenerateCUIResponseSealedFormCallBackHandler.class,
JacksonAutoConfiguration.class,
AssignCategoryId.class
})
@ExtendWith(MockitoExtension.class)
class GenerateCUIResponseSealedFormCallBackHandlerTest extends BaseCallbackHandlerTest {

@Autowired
private final ObjectMapper mapper = new ObjectMapper();
@Autowired
@Mock
private ObjectMapper mapper;
@InjectMocks
private GenerateCUIResponseSealedFormCallBackHandler handler;
@MockBean
@Mock
private SealedClaimLipResponseFormGenerator formGenerator;

@MockBean
@Mock
private SystemGeneratedDocumentService systemGeneratedDocumentService;
@MockBean
@Mock
private CivilDocumentStitchingService civilDocumentStitchingService;
@MockBean
@Mock
private FeatureToggleService featureToggleService;

@MockBean
@Mock
private AssignCategoryId assignCategoryId;

@BeforeEach
void setUp() {
mapper = new ObjectMapper();
handler = new GenerateCUIResponseSealedFormCallBackHandler(mapper, formGenerator, systemGeneratedDocumentService,
assignCategoryId, civilDocumentStitchingService, featureToggleService);
mapper.registerModule(new JavaTimeModule());
}

private static final CaseDocument FORM =
CaseDocument.builder()
.createdBy("John")
Expand Down Expand Up @@ -108,14 +110,9 @@ class GenerateCUIResponseSealedFormCallBackHandlerTest extends BaseCallbackHandl
.build();
private static final String BEARER_TOKEN = "BEARER_TOKEN";

@BeforeEach
void setup() {
when(featureToggleService.isLipVLipEnabled()).thenReturn(false);
ReflectionTestUtils.setField(handler, "stitchEnabled", false);
}

@Test
void shouldGenerateForm_whenAboutToSubmitCalled() {
ReflectionTestUtils.setField(handler, "stitchEnabled", false);
given(formGenerator.generate(any(CaseData.class), anyString())).willReturn(FORM);
CaseData caseData = CaseData.builder().build();
handler.handle(callbackParamsOf(caseData, ABOUT_TO_SUBMIT));
Expand All @@ -127,7 +124,6 @@ void shouldGenerateForm_whenIsLipVLipEnabledStitchingDisabled() {
//Given
given(formGenerator.generate(any(CaseData.class), anyString())).willReturn(FORM);
CaseData caseData = CaseData.builder().build();
when(featureToggleService.isLipVLipEnabled()).thenReturn(true);

//When
handler.handle(callbackParamsOf(caseData, ABOUT_TO_SUBMIT));
Expand All @@ -139,6 +135,8 @@ void shouldGenerateForm_whenIsLipVLipEnabledStitchingDisabled() {
@Test
void shouldGenerateForm_whenIsLipVLipEnabledStitchingEnabled() {
//Given
when(featureToggleService.isLipVLipEnabled()).thenReturn(false);
ReflectionTestUtils.setField(handler, "stitchEnabled", false);
List<Element<CaseDocument>> documents = List.of(
element(CaseDocument.builder().documentName("Stitched document").build()),
element(CaseDocument.builder().documentName("document name").build()));
Expand Down
Loading
Loading