From 9d25143d5b08c167cededa894172aa48d0d05d2c Mon Sep 17 00:00:00 2001 From: arybakov Date: Wed, 10 Jul 2024 14:56:36 -0600 Subject: [PATCH] GRAD2-2283 Student Archive Process - Backend endpoints To COMPLETE --- .../GraduationStudentRecordRepository.java | 2 +- .../service/GraduationStatusService.java | 2 +- .../service/GraduationStatusServiceTest.java | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/repository/GraduationStudentRecordRepository.java b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/repository/GraduationStudentRecordRepository.java index 58517cd2..646c699c 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/repository/GraduationStudentRecordRepository.java +++ b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/repository/GraduationStudentRecordRepository.java @@ -54,7 +54,7 @@ public interface GraduationStudentRecordRepository extends JpaRepository schoolOfRecords, String studentStatus); + Long countBySchoolOfRecordsAndStudentStatus(List schoolOfRecords, String studentStatus); @Query("select count(*) from GraduationStudentRecordEntity c where c.studentStatus=:studentStatus") Long countByStudentStatus(String studentStatus); diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/GraduationStatusService.java b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/GraduationStatusService.java index 6e4ca6c7..f9d5143f 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/GraduationStatusService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/GraduationStatusService.java @@ -1371,7 +1371,7 @@ public Integer countStudentsForAmalgamatedSchoolReport(String schoolOfRecord) { public Long countBySchoolOfRecordsAndStudentStatus(List schoolOfRecords, String studentStatus) { if(schoolOfRecords != null && !schoolOfRecords.isEmpty()) { - return graduationStatusRepository.countBySchoolOfRecordsAAndStudentStatus(schoolOfRecords, StringUtils.defaultString(studentStatus, "CUR")); + return graduationStatusRepository.countBySchoolOfRecordsAndStudentStatus(schoolOfRecords, StringUtils.defaultString(studentStatus, "CUR")); } else { return graduationStatusRepository.countByStudentStatus(StringUtils.defaultString(studentStatus, "CUR")); } diff --git a/api/src/test/java/ca/bc/gov/educ/api/gradstudent/service/GraduationStatusServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/gradstudent/service/GraduationStatusServiceTest.java index 41ba286b..f1385384 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/gradstudent/service/GraduationStatusServiceTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/gradstudent/service/GraduationStatusServiceTest.java @@ -2891,6 +2891,24 @@ public void testGetStudentsCountForAmalgamatedSchoolReport() { } + @Test + public void testCountBySchoolOfRecordsAndStudentStatus() { + Mockito.when(graduationStatusRepository.countBySchoolOfRecordsAndStudentStatus(List.of("12345678"), "CUR")).thenReturn(1L); + Long count = graduationStatusService.countBySchoolOfRecordsAndStudentStatus(List.of("12345678"), "CUR"); + assertThat(count).isNotNull().isEqualTo(1L); + Mockito.when(graduationStatusRepository.countByStudentStatus("CUR")).thenReturn(2L); + count = graduationStatusService.countBySchoolOfRecordsAndStudentStatus(null, "CUR"); + assertThat(count).isNotNull().isEqualTo(2L); + + } + + @Test + public void testArchiveStudents() { + Mockito.when(graduationStatusRepository.archiveStudents("12345678", "CUR", "ARC", 1L)).thenReturn(1); + Integer count = graduationStatusService.archiveStudents(1L, List.of("12345678"), "CUR"); + assertThat(count).isNotNull().isEqualTo(1L); + } + @Test public void testGetStudentsForAmalgamatedSchoolReport() { List res = amalgamatedReports("TVRNONGRAD",false);