@@ -186,9 +186,13 @@ public void testProcessWithExistingPersonAndCase() throws ExecutionException, In
186
186
getCaseFacade ().save (caze );
187
187
188
188
result = runFlow (externalMessage );
189
- assertThat (result .getStatus (), is (CANCELED ));
190
- assertThat (externalMessage .getStatus (), is (ExternalMessageStatus .UNPROCESSED ));
191
- assertThat (getExternalMessageFacade ().getByUuid (externalMessage .getUuid ()).getStatus (), is (ExternalMessageStatus .UNPROCESSED ));
189
+ assertThat (result .getStatus (), is (DONE ));
190
+ assertThat (externalMessage .getStatus (), is (ExternalMessageStatus .PROCESSED ));
191
+ assertThat (getExternalMessageFacade ().getByUuid (externalMessage .getUuid ()).getStatus (), is (ExternalMessageStatus .PROCESSED ));
192
+ List <CaseDataDto > cases = getCaseFacade ().getAllAfter (new Date (0 ));
193
+ assertThat (cases , hasSize (2 ));
194
+ CaseDataDto newCase = cases .stream ().filter (c -> !DataHelper .isSame (c , caze )).findFirst ().get ();
195
+ assertThat (newCase .getPerson (), is (caze .getPerson ()));
192
196
193
197
// set the case report after the threshold
194
198
caze .setReportDate (DateHelper .subtractDays (new Date (), 5 ));
@@ -201,17 +205,15 @@ public void testProcessWithExistingPersonAndCase() throws ExecutionException, In
201
205
List <PersonDto > persons = getPersonFacade ().getAllAfter (new Date (0 ));
202
206
assertThat (persons , hasSize (1 ));
203
207
assertThat (persons .get (0 ).getUuid (), is (person .getUuid ()));
204
- List <CaseDataDto > cases = getCaseFacade ().getByPersonUuids (persons .stream ().map (PersonDto ::getUuid ).collect (Collectors .toList ()));
205
- assertThat (cases , hasSize (1 ));
206
- assertThat (cases .get (0 ).getUuid (), is (caze .getUuid ()));
207
- List <SampleDto > samples = getSampleFacade ().getByCaseUuids (cases .stream ().map (CaseDataDto ::getUuid ).collect (Collectors .toList ()));
208
- assertThat (samples , hasSize (1 ));
209
- List <PathogenTestDto > pathogenTests = getPathogenTestFacade ().getAllBySample (samples .get (0 ).toReference ());
210
- assertThat (pathogenTests , hasSize (1 ));
208
+ cases = getCaseFacade ().getByPersonUuids (persons .stream ().map (PersonDto ::getUuid ).collect (Collectors .toList ()));
209
+ assertThat (cases , hasSize (2 ));
210
+ // the sample should be added on the new case
211
+ List <SampleDto > samples = getSampleFacade ().getByCaseUuids (Collections .singletonList (newCase .getUuid ()));
212
+ assertThat (samples , hasSize (2 ));
211
213
}
212
214
213
215
@ Test
214
- public void testProcessWithExistingPersonAndCaseWithSample () throws ExecutionException , InterruptedException {
216
+ public void testProcessWithExistingPersonAndCaseWithBySampleDate () throws ExecutionException , InterruptedException {
215
217
ExternalMessageDto externalMessage = createExternalMessage (null );
216
218
217
219
PersonDto person =
@@ -220,6 +222,7 @@ public void testProcessWithExistingPersonAndCaseWithSample() throws ExecutionExc
220
222
});
221
223
222
224
CaseDataDto caze = creator .createCase (reportingUser .toReference (), person .toReference (), rdcf , c -> {
225
+ c .setReportDate (DateHelper .subtractDays (new Date (), 1 ));
223
226
c .setDisease (externalMessage .getDisease ());
224
227
});
225
228
@@ -240,8 +243,13 @@ public void testProcessWithExistingPersonAndCaseWithSample() throws ExecutionExc
240
243
getSampleFacade ().saveSample (sample );
241
244
242
245
result = runFlow (externalMessage );
243
- assertThat (result .getStatus (), is (CANCELED ));
244
- assertThat (externalMessage .getStatus (), is (ExternalMessageStatus .UNPROCESSED ));
246
+ assertThat (result .getStatus (), is (DONE ));
247
+ assertThat (externalMessage .getStatus (), is (ExternalMessageStatus .PROCESSED ));
248
+
249
+ List <PersonDto > persons = getPersonFacade ().getAllAfter (new Date (0 ));
250
+ List <CaseDataDto > cases = getCaseFacade ().getByPersonUuids (persons .stream ().map (PersonDto ::getUuid ).collect (Collectors .toList ()));
251
+ assertThat (cases , hasSize (2 ));
252
+ CaseDataDto newCase = cases .stream ().filter (c -> !DataHelper .isSame (c , caze )).findFirst ().get ();
245
253
246
254
// set the sample date time after the threshold
247
255
sample .setSampleDateTime (DateHelper .subtractDays (new Date (), 5 ));
@@ -251,13 +259,12 @@ public void testProcessWithExistingPersonAndCaseWithSample() throws ExecutionExc
251
259
assertThat (result .getStatus (), is (DONE ));
252
260
assertThat (externalMessage .getStatus (), is (ExternalMessageStatus .PROCESSED ));
253
261
254
- List < PersonDto > persons = getPersonFacade ().getAllAfter (new Date (0 ));
262
+ persons = getPersonFacade ().getAllAfter (new Date (0 ));
255
263
assertThat (persons , hasSize (1 ));
256
264
assertThat (persons .get (0 ).getUuid (), is (person .getUuid ()));
257
- List <CaseDataDto > cases = getCaseFacade ().getByPersonUuids (persons .stream ().map (PersonDto ::getUuid ).collect (Collectors .toList ()));
258
- assertThat (cases , hasSize (1 ));
259
- assertThat (cases .get (0 ).getUuid (), is (caze .getUuid ()));
260
- List <SampleDto > samples = getSampleFacade ().getByCaseUuids (cases .stream ().map (CaseDataDto ::getUuid ).collect (Collectors .toList ()));
265
+ cases = getCaseFacade ().getByPersonUuids (persons .stream ().map (PersonDto ::getUuid ).collect (Collectors .toList ()));
266
+ assertThat (cases , hasSize (2 ));
267
+ List <SampleDto > samples = getSampleFacade ().getByCaseUuids (Collections .singletonList (newCase .getUuid ()));
261
268
assertThat (samples , hasSize (2 ));
262
269
SampleDto processedSample = samples .stream ().filter (s -> !DataHelper .isSame (s , sample )).findFirst ().get ();
263
270
List <PathogenTestDto > pathogenTests = getPathogenTestFacade ().getAllBySample (processedSample .toReference ());
0 commit comments