@@ -54,6 +54,9 @@ class SdcSchoolCollectionServiceTest {
54
54
@ Mock
55
55
SdcDuplicateRepository sdcDuplicateRepository ;
56
56
57
+ @ Mock
58
+ SagaRepository sagaRepository ;
59
+
57
60
@ Mock
58
61
SdcSchoolCollectionStudentStorageService sdcSchoolCollectionStudentStorageService ;
59
62
@@ -355,18 +358,14 @@ void testReprocessSchoolCollection_indySchool() {
355
358
}
356
359
357
360
@ Test
358
- void testReprocessSchoolCollection_withStudents_ShouldProcessNonDeletedStudents () {
361
+ void testReprocessSchoolCollection_withStudents_notLoadedStudents_ShouldProcessNonDeletedStudents () {
359
362
UUID sdcSchoolCollectionID = UUID .randomUUID ();
360
363
String updateUser = "TEST_USER" ;
361
364
362
365
SdcSchoolCollectionEntity sdcSchoolCollectionEntity = new SdcSchoolCollectionEntity ();
363
366
sdcSchoolCollectionEntity .setSdcSchoolCollectionID (sdcSchoolCollectionID );
364
367
sdcSchoolCollectionEntity .setSdcSchoolCollectionStatusCode (SdcSchoolCollectionStatus .NEW .getCode ());
365
368
366
- SdcSchoolCollectionStudentEntity loadedStudent = new SdcSchoolCollectionStudentEntity ();
367
- loadedStudent .setSdcSchoolCollectionStudentID (UUID .randomUUID ());
368
- loadedStudent .setSdcSchoolCollectionStudentStatusCode (SdcSchoolStudentStatus .LOADED .getCode ());
369
-
370
369
SdcSchoolCollectionStudentEntity errorStudent = new SdcSchoolCollectionStudentEntity ();
371
370
errorStudent .setSdcSchoolCollectionStudentID (UUID .randomUUID ());
372
371
errorStudent .setSdcSchoolCollectionStudentStatusCode (SdcSchoolStudentStatus .ERROR .getCode ());
@@ -376,7 +375,6 @@ void testReprocessSchoolCollection_withStudents_ShouldProcessNonDeletedStudents(
376
375
deletedStudent .setSdcSchoolCollectionStudentStatusCode (SdcSchoolStudentStatus .DELETED .getCode ());
377
376
378
377
Set <SdcSchoolCollectionStudentEntity > students = new HashSet <>();
379
- students .add (loadedStudent );
380
378
students .add (errorStudent );
381
379
students .add (deletedStudent );
382
380
sdcSchoolCollectionEntity .setSdcSchoolStudentEntities (students );
@@ -390,9 +388,7 @@ void testReprocessSchoolCollection_withStudents_ShouldProcessNonDeletedStudents(
390
388
.build ()
391
389
);
392
390
393
- assertEquals (SdcSchoolStudentStatus .LOADED .getCode (), loadedStudent .getSdcSchoolCollectionStudentStatusCode ());
394
391
assertEquals (SdcSchoolStudentStatus .LOADED .getCode (), errorStudent .getSdcSchoolCollectionStudentStatusCode ());
395
- assertEquals (updateUser , loadedStudent .getUpdateUser ());
396
392
assertEquals (updateUser , errorStudent .getUpdateUser ());
397
393
398
394
assertEquals (SdcSchoolStudentStatus .DELETED .getCode (), deletedStudent .getSdcSchoolCollectionStudentStatusCode ());
@@ -401,6 +397,42 @@ void testReprocessSchoolCollection_withStudents_ShouldProcessNonDeletedStudents(
401
397
verify (sdcSchoolCollectionStudentStorageService , times (1 )).saveAllSDCStudentsWithHistory (any ());
402
398
}
403
399
400
+ @ Test
401
+ void testReprocessSchoolCollection_withLoadedStudents_ShouldThrowLoadedStudentException () {
402
+ UUID sdcSchoolCollectionID = UUID .randomUUID ();
403
+
404
+ SdcSchoolCollectionEntity sdcSchoolCollectionEntity = new SdcSchoolCollectionEntity ();
405
+ sdcSchoolCollectionEntity .setSdcSchoolCollectionID (sdcSchoolCollectionID );
406
+ sdcSchoolCollectionEntity .setSdcSchoolCollectionStatusCode (SdcSchoolCollectionStatus .NEW .getCode ());
407
+
408
+ SdcSchoolCollectionStudentEntity loadedStudent = new SdcSchoolCollectionStudentEntity ();
409
+ loadedStudent .setSdcSchoolCollectionStudentID (UUID .randomUUID ());
410
+ loadedStudent .setSdcSchoolCollectionStudentStatusCode (SdcSchoolStudentStatus .LOADED .getCode ());
411
+
412
+ SdcSchoolCollectionStudentEntity errorStudent = new SdcSchoolCollectionStudentEntity ();
413
+ errorStudent .setSdcSchoolCollectionStudentID (UUID .randomUUID ());
414
+ errorStudent .setSdcSchoolCollectionStudentStatusCode (SdcSchoolStudentStatus .ERROR .getCode ());
415
+
416
+ SdcSchoolCollectionStudentEntity deletedStudent = new SdcSchoolCollectionStudentEntity ();
417
+ deletedStudent .setSdcSchoolCollectionStudentID (UUID .randomUUID ());
418
+ deletedStudent .setSdcSchoolCollectionStudentStatusCode (SdcSchoolStudentStatus .DELETED .getCode ());
419
+
420
+ Set <SdcSchoolCollectionStudentEntity > students = new HashSet <>();
421
+ students .add (loadedStudent );
422
+ students .add (errorStudent );
423
+ students .add (deletedStudent );
424
+ sdcSchoolCollectionEntity .setSdcSchoolStudentEntities (students );
425
+
426
+ when (sdcSchoolCollectionRepository .findById (sdcSchoolCollectionID )).thenReturn (Optional .of (sdcSchoolCollectionEntity ));
427
+
428
+ ReprocessSdcSchoolCollection sdcSchoolCollectionReprocess = ReprocessSdcSchoolCollection .builder ()
429
+ .sdcSchoolCollectionID (sdcSchoolCollectionID )
430
+ .updateUser ("USER" )
431
+ .build ();
432
+
433
+ assertThrows (InvalidPayloadException .class , () -> sdcSchoolCollectionService .reprocessSchoolCollection (sdcSchoolCollectionReprocess ));
434
+ }
435
+
404
436
@ Test
405
437
void testReprocessSchoolCollection_withOnlyDeletedStudents_ShouldNotProcessAnyStudents () {
406
438
UUID sdcSchoolCollectionID = UUID .randomUUID ();
0 commit comments