Skip to content

Commit 20b28b5

Browse files
committed
Update migration tests
1 parent 856457f commit 20b28b5

File tree

4 files changed

+19
-122
lines changed

4 files changed

+19
-122
lines changed

src/test/java/uk/gov/hmcts/reform/migration/CaseMigrationProcessorTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
public class CaseMigrationProcessorTest {
3030

3131
private static final String USER_TOKEN = "Bearer eeeejjjttt";
32-
private static final String EVENT_ID = "system-migrate-organisation-policies";
33-
private static final String EVENT_SUMMARY = "Data Migration - Set default organisation policies for NoC";
34-
private static final String EVENT_DESCRIPTION = "Data Migration - Set default organisation policies for NoC";
32+
private static final String EVENT_ID = "system-set-time-to-live";
33+
private static final String EVENT_SUMMARY = "Data Migration - Set retain and dispose time to live";
34+
private static final String EVENT_DESCRIPTION = "Data Migration - Set retain and dispose time to live";
3535
private static final String CASE_TYPE = "Test_Case_Type";
3636

3737
@InjectMocks

src/test/java/uk/gov/hmcts/reform/migration/query/ElasticSearchQueryTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public void shouldReturnQuery() {
4646
"reference.keyword": "asc"
4747
}
4848
]
49-
}""", query);
49+
} """, query);
5050
}
5151

5252
@Test
@@ -84,6 +84,6 @@ public void shouldReturnSearchAfterQuery() {
8484
"reference.keyword": "asc"
8585
}
8686
],"search_after": [1677777777]
87-
}""", query);
87+
} """, query);
8888
}
8989
}

src/test/java/uk/gov/hmcts/reform/migration/repository/ElasticSearchRepositoryTest.java

Lines changed: 12 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -33,71 +33,22 @@ public class ElasticSearchRepositoryTest {
3333
{
3434
"query": {
3535
"bool": {
36-
"must_not": [
36+
"must": [
3737
{
3838
"terms": {
39-
"state.keyword": [
40-
"Draft",
41-
"AwaitingApplicant1Response",
42-
"AwaitingApplicant2Response",
43-
"Applicant2Approved",
44-
"AwaitingPayment",
45-
"AwaitingHWFDecision",
46-
"Withdrawn",
47-
"Archived",
48-
"Rejected",
49-
"NewPaperCase",
50-
"FinalOrderComplete"
51-
]
52-
}
53-
}
54-
],
55-
"should": [
56-
{
57-
"bool": {
58-
"must_not":
59-
{ "exists": {
60-
"field": "data_classification.applicant1SolicitorOrganisationPolicy.value.Organisation"
61-
}
62-
}
63-
}
64-
},
65-
{
66-
"bool": {
67-
"must_not":
68-
{ "exists": {
69-
"field": "data_classification.applicant2SolicitorOrganisationPolicy.value.Organisation"
70-
}
71-
}
72-
}
73-
},
74-
{
75-
"bool": {
76-
"must_not": [
77-
{ "match": {
78-
"data.applicant1SolicitorOrganisationPolicy.OrgPolicyCaseAssignedRole": "[APPONESOLICITOR]"
79-
} }
80-
]
81-
}
82-
},
83-
{
84-
"bool": {
85-
"must_not": [
86-
{ "match": {
87-
"data.applicant2SolicitorOrganisationPolicy.OrgPolicyCaseAssignedRole": "[APPTWOSOLICITOR]"
88-
} }
89-
]
39+
"state.keyword": ["Draft"]
9040
}
9141
}
9242
],
93-
"minimum_should_match": 1
43+
"must_not": [
44+
{ "exists": { "field": "data.TTL" } }
45+
]
9446
}
9547
},
9648
"_source": [
9749
"reference",
9850
"state",
99-
"data.applicant1SolicitorOrganisationPolicy",
100-
"data.applicant2SolicitorOrganisationPolicy"
51+
"data.TTL"
10152
],
10253
"size": 100,
10354
"sort": [
@@ -111,71 +62,22 @@ public class ElasticSearchRepositoryTest {
11162
{
11263
"query": {
11364
"bool": {
114-
"must_not": [
65+
"must": [
11566
{
11667
"terms": {
117-
"state.keyword": [
118-
"Draft",
119-
"AwaitingApplicant1Response",
120-
"AwaitingApplicant2Response",
121-
"Applicant2Approved",
122-
"AwaitingPayment",
123-
"AwaitingHWFDecision",
124-
"Withdrawn",
125-
"Archived",
126-
"Rejected",
127-
"NewPaperCase",
128-
"FinalOrderComplete"
129-
]
130-
}
131-
}
132-
],
133-
"should": [
134-
{
135-
"bool": {
136-
"must_not":
137-
{ "exists": {
138-
"field": "data_classification.applicant1SolicitorOrganisationPolicy.value.Organisation"
139-
}
140-
}
141-
}
142-
},
143-
{
144-
"bool": {
145-
"must_not":
146-
{ "exists": {
147-
"field": "data_classification.applicant2SolicitorOrganisationPolicy.value.Organisation"
148-
}
149-
}
150-
}
151-
},
152-
{
153-
"bool": {
154-
"must_not": [
155-
{ "match": {
156-
"data.applicant1SolicitorOrganisationPolicy.OrgPolicyCaseAssignedRole": "[APPONESOLICITOR]"
157-
} }
158-
]
159-
}
160-
},
161-
{
162-
"bool": {
163-
"must_not": [
164-
{ "match": {
165-
"data.applicant2SolicitorOrganisationPolicy.OrgPolicyCaseAssignedRole": "[APPTWOSOLICITOR]"
166-
} }
167-
]
68+
"state.keyword": ["Draft"]
16869
}
16970
}
17071
],
171-
"minimum_should_match": 1
72+
"must_not": [
73+
{ "exists": { "field": "data.TTL" } }
74+
]
17275
}
17376
},
17477
"_source": [
17578
"reference",
17679
"state",
177-
"data.applicant1SolicitorOrganisationPolicy",
178-
"data.applicant2SolicitorOrganisationPolicy"
80+
"data.TTL"
17981
],
18082
"size": 100,
18183
"sort": [

src/test/java/uk/gov/hmcts/reform/migration/service/DataMigrationServiceImplTest.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
package uk.gov.hmcts.reform.migration.service;
22

3-
import org.junit.Before;
43
import org.junit.Test;
54
import org.junit.runner.RunWith;
65
import org.springframework.beans.factory.annotation.Autowired;
76
import org.springframework.boot.test.context.SpringBootTest;
87
import org.springframework.test.context.junit4.SpringRunner;
9-
import uk.gov.hmcts.ccd.sdk.type.Organisation;
10-
import uk.gov.hmcts.ccd.sdk.type.OrganisationPolicy;
118
import uk.gov.hmcts.reform.ccd.client.model.CaseDetails;
12-
import uk.gov.hmcts.reform.domain.model.UserRole;
139

1410
import java.time.LocalDateTime;
15-
import java.time.format.DateTimeFormatter;
1611
import java.util.HashMap;
1712
import java.util.Map;
1813

@@ -65,11 +60,11 @@ public void shouldReturnNullWhenDataIsNotPassed() {
6560

6661
@Test
6762
public void shouldPopulateTimeToLiveForOldDraftCases() {
68-
Map<String, Object> expectedResult = new HashMap<>();
6963
Map<String, String> ttlMap = new HashMap<>();
7064
ttlMap.put("Suspended", "No");
7165
ttlMap.put("OverrideTTL", null);
7266
ttlMap.put("SystemTTL", "2023-07-03");
67+
Map<String, Object> expectedResult = new HashMap<>();
7368
expectedResult.put("TTL", ttlMap);
7469

7570
CaseDetails inputCaseDetails = CaseDetails.builder()
@@ -85,11 +80,11 @@ public void shouldPopulateTimeToLiveForOldDraftCases() {
8580

8681
@Test
8782
public void shouldPopulateTimeToLiveForNewDraftCases() {
88-
Map<String, Object> expectedResult = new HashMap<>();
8983
Map<String, String> ttlMap = new HashMap<>();
9084
ttlMap.put("Suspended", "No");
9185
ttlMap.put("OverrideTTL", null);
9286
ttlMap.put("SystemTTL", "2025-08-04");
87+
Map<String, Object> expectedResult = new HashMap<>();
9388
expectedResult.put("TTL", ttlMap);
9489

9590
CaseDetails inputCaseDetails = CaseDetails.builder()

0 commit comments

Comments
 (0)