9
9
import org .junit .After ;
10
10
import org .junit .Before ;
11
11
import org .junit .Test ;
12
+ import org .junit .jupiter .params .ParameterizedTest ;
13
+ import org .junit .jupiter .params .provider .CsvSource ;
12
14
import org .junit .runner .RunWith ;
13
15
import org .mockito .Mock ;
14
16
import org .slf4j .Logger ;
@@ -331,36 +333,56 @@ public void testGetStudentData_withlist() {
331
333
assertThat (resList ).hasSize (1 );
332
334
}
333
335
334
- @ Test
335
- public void testProcessDistribution () {
336
+ @ ParameterizedTest
337
+ @ CsvSource ({
338
+ "SCHOOL_AT_GRAD, , schoolAtGrad" ,
339
+ ", RC, schoolAtGrad" ,
340
+ ", , schoolOfRecord"
341
+ })
342
+ void testProcessDistribution_schoolIdIsNullAndReportingSchoolType_addsCorrectSchool (String reportingSchoolTypeCode , String credentialType , String expectedSchoolType ) {
336
343
337
344
final UUID studentID = UUID .randomUUID ();
338
- final String pen = "123456789" ;
339
345
final Long batchId = 9879L ;
340
- final String mincode = "123121111" ;
346
+ final UUID schoolId = UUID .randomUUID ();
347
+ final UUID schoolOfRecordId = UUID .randomUUID ();
341
348
List <StudentCredentialDistribution > globalList = new ArrayList <>();
342
349
343
350
StudentCredentialDistribution scd = new StudentCredentialDistribution ();
344
351
scd .setStudentGrade ("12" );
345
352
scd .setId (UUID .randomUUID ());
346
353
scd .setPaperType ("YED4" );
347
- scd .setSchoolOfRecord ( mincode );
354
+ scd .setReportingSchoolTypeCode ( reportingSchoolTypeCode );
348
355
scd .setStudentID (studentID );
349
- globalList .add (scd );
356
+
357
+ GraduationStudentRecordDistribution grd = new GraduationStudentRecordDistribution ();
358
+ grd .setStudentID (studentID );
359
+ grd .setProgram ("2018-EN" );
360
+ grd .setStudentGrade ("12" );
361
+ grd .setSchoolAtGradId (schoolId );
362
+ grd .setSchoolOfRecordId (schoolOfRecordId );
363
+
364
+ mockTokenResponseObject ();
365
+
366
+ when (this .restService .get (String .format (constants .getStudentInfo (),studentID ), GraduationStudentRecordDistribution .class )).thenReturn (grd );
350
367
351
368
DistributionSummaryDTO summary = new DistributionSummaryDTO ();
352
369
summary .setBatchId (batchId );
353
370
summary .setGlobalList (globalList );
371
+ summary .setCredentialType (credentialType );
354
372
355
373
StudentCredentialDistribution res = this .restUtils .processDistribution (scd ,summary );
356
374
assertNotNull (res );
375
+ if (expectedSchoolType .equals ("schoolAtGrad" )) {
376
+ assertEquals (schoolId , res .getSchoolId ());
377
+ } else {
378
+ assertEquals (schoolOfRecordId , res .getSchoolId ());
379
+ }
357
380
}
358
381
359
382
@ Test
360
- public void testProcessDistribution_elsecase () {
383
+ public void testProcessDistribution_schoolIdIsNullAndRC_addsCorrectSchool () {
361
384
362
385
final UUID studentID = UUID .randomUUID ();
363
- final UUID studentID2 = UUID .randomUUID ();
364
386
final Long batchId = 9879L ;
365
387
final UUID schoolId = UUID .randomUUID ();
366
388
List <StudentCredentialDistribution > globalList = new ArrayList <>();
@@ -369,36 +391,65 @@ public void testProcessDistribution_elsecase() {
369
391
scd .setStudentGrade ("12" );
370
392
scd .setId (UUID .randomUUID ());
371
393
scd .setPaperType ("YED4" );
372
- scd .setSchoolId (schoolId );
373
394
scd .setStudentID (studentID );
374
- globalList .add (scd );
375
395
376
- StudentCredentialDistribution scd2 = new StudentCredentialDistribution ();
377
- scd2 . setStudentGrade ( "12" );
378
- scd2 . setId ( UUID . randomUUID () );
379
- scd2 . setPaperType ( "YED4 " );
380
- scd2 . setSchoolId (schoolId );
381
- scd2 . setStudentID ( studentID2 );
396
+ GraduationStudentRecordDistribution grd = new GraduationStudentRecordDistribution ();
397
+ grd . setStudentID ( studentID );
398
+ grd . setProgram ( "2018-EN" );
399
+ grd . setStudentGrade ( "12 " );
400
+ grd . setSchoolAtGradId (schoolId );
401
+ grd . setSchoolOfRecordId ( UUID . randomUUID () );
382
402
403
+ mockTokenResponseObject ();
404
+
405
+ when (this .restService .get (String .format (constants .getStudentInfo (),studentID ), GraduationStudentRecordDistribution .class )).thenReturn (grd );
406
+
407
+ DistributionSummaryDTO summary = new DistributionSummaryDTO ();
408
+ summary .setBatchId (batchId );
409
+ summary .setGlobalList (globalList );
410
+ summary .setCredentialType ("RC" );
411
+
412
+ StudentCredentialDistribution res = this .restUtils .processDistribution (scd ,summary );
413
+ assertNotNull (res );
414
+ assertEquals (schoolId , res .getSchoolId ());
415
+ }
416
+
417
+ @ Test
418
+ public void testProcessDistribution_schoolIdIsNull_addsCorrectSchool () {
419
+
420
+ final UUID studentID = UUID .randomUUID ();
421
+ final Long batchId = 9879L ;
422
+ final UUID schoolId = UUID .randomUUID ();
423
+ final UUID schoolOfRecordId = UUID .randomUUID ();
424
+ List <StudentCredentialDistribution > globalList = new ArrayList <>();
425
+
426
+ StudentCredentialDistribution scd = new StudentCredentialDistribution ();
427
+ scd .setStudentGrade ("12" );
428
+ scd .setId (UUID .randomUUID ());
429
+ scd .setPaperType ("YED4" );
430
+ scd .setStudentID (studentID );
383
431
384
432
GraduationStudentRecordDistribution grd = new GraduationStudentRecordDistribution ();
385
- grd .setStudentID (studentID2 );
433
+ grd .setStudentID (studentID );
386
434
grd .setProgram ("2018-EN" );
387
435
grd .setStudentGrade ("12" );
388
- grd .setSchoolOfRecordId (schoolId );
436
+ grd .setSchoolAtGradId (schoolId );
437
+ grd .setSchoolOfRecordId (schoolOfRecordId );
389
438
390
439
mockTokenResponseObject ();
391
440
392
- when (this .restService .get (String .format (constants .getStudentInfo (),studentID2 ), GraduationStudentRecordDistribution .class )).thenReturn (grd );
441
+ when (this .restService .get (String .format (constants .getStudentInfo (),studentID ), GraduationStudentRecordDistribution .class )).thenReturn (grd );
393
442
394
443
DistributionSummaryDTO summary = new DistributionSummaryDTO ();
395
444
summary .setBatchId (batchId );
396
445
summary .setGlobalList (globalList );
397
446
398
- StudentCredentialDistribution res = this .restUtils .processDistribution (scd2 ,summary );
447
+ StudentCredentialDistribution res = this .restUtils .processDistribution (scd ,summary );
399
448
assertNotNull (res );
449
+ assertEquals (schoolOfRecordId , res .getSchoolId ());
400
450
}
401
451
452
+
402
453
@ Test
403
454
public void testProcessDistribution_elsecase_null () {
404
455
0 commit comments