diff --git a/api/pom.xml b/api/pom.xml index 3aa6cc17..5a8bd573 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -6,7 +6,7 @@ ca.bc.gov.educ educ-grad-data-conversion-api - 1.8.50 + 1.8.51 educ-grad-data-conversion-api Ministry of Education GRAD DATA CONVERSION API diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/config/BatchJobConfig.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/config/BatchJobConfig.java index 626f21c4..f061ad96 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/config/BatchJobConfig.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/config/BatchJobConfig.java @@ -16,7 +16,6 @@ import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.core.launch.support.RunIdIncrementer; -import org.springframework.batch.core.launch.support.SimpleJobLauncher; import org.springframework.batch.core.launch.support.TaskExecutorJobLauncher; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.builder.StepBuilder; diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/process/CourseProcess.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/process/CourseProcess.java index a8830c17..4a17170b 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/process/CourseProcess.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/process/CourseProcess.java @@ -44,6 +44,9 @@ public class CourseProcess { private static final String ZFRAL_STR = "ZFRAL"; private static final String IBFAS_STR = "IBFAS"; private static final String QFRAP_STR = "QFRAP"; + private static final String CPWE_STR = "CPWE"; + private static final String CPCOW_STR = "CPCOW"; + private static final String CPSSA_STR = "CPSSA"; private static final String ERR_MSG_FORMAT = "For {} : {}"; @@ -627,7 +630,7 @@ public void createCourseRequirements(ConversionCourseSummaryDTO summary) { createCourseRequirement(populate(LTSTF_STR, "11", "201"), summary); // Adult Work Experience - createCourseRequirement(populate("CPWE", "12", "506"), summary); + createCourseRequirement(populate(CPWE_STR, "12", "506"), summary); createCourseRequirement(populate("SSA", "12A", "506"), summary); createCourseRequirement(populate("SSA", "12B", "506"), summary); createCourseRequirement(populate("WEX", "12A", "506"), summary); @@ -1145,13 +1148,24 @@ public void createCourseRequirements(ConversionCourseSummaryDTO summary) { createCourseRequirement(populate("ELNMF", "11", "201"), summary); createCourseRequirement(populate("ELSLF", "11", "201"), summary); createCourseRequirement(populate("EFLSF", "11", "201"), summary); - createCourseRequirement(populate(FRALP_STR, "11", "201"), summary); // GRAD2-2402: Rule 202 createCourseRequirement(populate(QFRAP_STR, "10", "202"), summary); createCourseRequirement(populate("LANMF", "10", "202"), summary); createCourseRequirement(populate("LAEOF", "10", "202"), summary); createCourseRequirement(populate("LACWF", "10", "202"), summary); - createCourseRequirement(populate(FRALP_STR, "10", "202"), summary); + // GRAD2-2386: Rule 600 + createCourseRequirement(populate(CPWE_STR, "12", "600"), summary); + createCourseRequirement(populate(CPWE_STR, "12A", "600"), summary); + createCourseRequirement(populate(CPWE_STR, "12B", "600"), summary); + createCourseRequirement(populate(CPWE_STR, "12C", "600"), summary); + createCourseRequirement(populate(CPWE_STR, "12D", "600"), summary); + createCourseRequirement(populate(CPCOW_STR, "12", "600"), summary); + createCourseRequirement(populate(CPCOW_STR, "12A", "600"), summary); + createCourseRequirement(populate(CPCOW_STR, "12B", "600"), summary); + createCourseRequirement(populate(CPSSA_STR, "11A", "600"), summary); + createCourseRequirement(populate(CPSSA_STR, "11B", "600"), summary); + createCourseRequirement(populate(CPSSA_STR, "12A", "600"), summary); + createCourseRequirement(populate(CPSSA_STR, "12B", "600"), summary); } private CourseRequirement populate(String courseCode, String courseLevel, String courseRequirementCode) { diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/process/StudentProcess.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/process/StudentProcess.java index c22d53fa..c6308121 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/process/StudentProcess.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/process/StudentProcess.java @@ -923,9 +923,11 @@ private ConversionResultType processProgramCodes(GraduationStudentRecord student private Pair handleProgramCode(String programCode, GraduationStudentRecord student, StudentLoadType studentLoadType, StudentLoadType originalStudentLoadType, ConversionStudentSummaryDTO summary) { ConversionResultType resultType; boolean isCareerProgramCreated = false; + if (isStudentSCCPForTwoPrograms(student.getProgram(), originalStudentLoadType)) { + return Pair.of(ConversionResultType.SUCCESS, isCareerProgramCreated); + } if (isOptionalProgramCode(programCode)) { - resultType = isStudentSCCPForTwoPrograms(student.getProgram(), originalStudentLoadType)? ConversionResultType.SUCCESS : - createStudentOptionalProgram(programCode, student, studentLoadType, summary); + resultType = createStudentOptionalProgram(programCode, student, studentLoadType, summary); } else { resultType = createStudentCareerProgram(programCode, student, summary); if (ConversionResultType.SUCCESS == resultType) { diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/repository/EventRepository.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/repository/EventRepository.java index fe10a968..3ae6a28d 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/repository/EventRepository.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/repository/EventRepository.java @@ -2,8 +2,12 @@ import ca.bc.gov.educ.api.dataconversion.entity.Event; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Modifying; +import org.springframework.data.jpa.repository.Query; import org.springframework.stereotype.Repository; +import org.springframework.transaction.annotation.Transactional; +import java.time.LocalDateTime; import java.util.List; import java.util.Optional; import java.util.UUID; @@ -13,4 +17,9 @@ public interface EventRepository extends JpaRepository { Optional findByEventId(UUID eventId); List findAllByEventStatusOrderByCreateDate(String eventStatus); + + @Transactional + @Modifying + @Query("delete from Event where createDate <= :createDate") + void deleteByCreateDateBefore(LocalDateTime createDate); } diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/scheduler/PurgeOldRecordsScheduler.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/scheduler/PurgeOldRecordsScheduler.java new file mode 100644 index 00000000..c1928df3 --- /dev/null +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/scheduler/PurgeOldRecordsScheduler.java @@ -0,0 +1,41 @@ +package ca.bc.gov.educ.api.dataconversion.scheduler; + +import ca.bc.gov.educ.api.dataconversion.repository.EventRepository; +import ca.bc.gov.educ.api.dataconversion.util.EducGradDataConversionApiConstants; +import jakarta.transaction.Transactional; +import lombok.extern.slf4j.Slf4j; +import net.javacrumbs.shedlock.core.LockAssert; +import net.javacrumbs.shedlock.spring.annotation.SchedulerLock; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +import java.time.LocalDateTime; + +@Component +@Slf4j +public class PurgeOldRecordsScheduler { + private final EventRepository eventRepository; + private final EducGradDataConversionApiConstants constants; + + public PurgeOldRecordsScheduler(final EventRepository eventRepository, + final EducGradDataConversionApiConstants constants) { + this.eventRepository = eventRepository; + this.constants = constants; + } + + @Scheduled(cron = "${cron.scheduled.process.purge-old-records.run}") + @SchedulerLock(name = "PurgeOldRecordsLock", + lockAtLeastFor = "PT1H", lockAtMostFor = "PT1H") //midnight job so lock for an hour + @Transactional + public void purgeOldRecords() { + LockAssert.assertLocked(); + final LocalDateTime createDateToCompare = this.calculateCreateDateBasedOnStaleEventInDays(); + this.eventRepository.deleteByCreateDateBefore(createDateToCompare); + } + + + private LocalDateTime calculateCreateDateBasedOnStaleEventInDays() { + final LocalDateTime currentTime = LocalDateTime.now(); + return currentTime.minusDays(this.constants.getRecordsStaleInDays()); + } +} diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentDemographicsUpdateEventService.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentDemographicsUpdateEventService.java index 57943f7e..40d6df5c 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentDemographicsUpdateEventService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentDemographicsUpdateEventService.java @@ -70,41 +70,25 @@ public void processStudentDemographics(TraxDemographicsUpdateDTO updateDemog, St boolean isChanged = false; // Last Name if (!StringUtils.equals(updateDemog.getLastName(), currentStudent.getLastName())) { - // Transcript - currentStudent.setNewRecalculateGradStatus("Y"); - // TVR - currentStudent.setNewRecalculateProjectedGrad("Y"); - + populateNewBatchFlags(currentStudent); isChanged = true; log.info(" => student last name : current = {}, request = {}", currentStudent.getLastName(), updateDemog.getLastName()); } // First Name if (!StringUtils.equals(updateDemog.getFirstName(), currentStudent.getFirstName())) { - // Transcript - currentStudent.setNewRecalculateGradStatus("Y"); - // TVR - currentStudent.setNewRecalculateProjectedGrad("Y"); - + populateNewBatchFlags(currentStudent); isChanged = true; log.info(" => student first name : current = {}, request = {}", currentStudent.getFirstName(), updateDemog.getFirstName()); } // Middle Names if (!StringUtils.equals(updateDemog.getMiddleNames(), currentStudent.getMiddleName())) { - // Transcript - currentStudent.setNewRecalculateGradStatus("Y"); - // TVR - currentStudent.setNewRecalculateProjectedGrad("Y"); - + populateNewBatchFlags(currentStudent); isChanged = true; log.info(" => student middle name : current = {}, request = {}", currentStudent.getMiddleName(), updateDemog.getMiddleNames()); } // Date of Birth if (!StringUtils.equals(updateDemog.getBirthday(), currentStudent.getBirthday())) { - // Transcript - currentStudent.setNewRecalculateGradStatus("Y"); - // TVR - currentStudent.setNewRecalculateProjectedGrad("Y"); - + populateNewBatchFlags(currentStudent); isChanged = true; log.info(" => student dob : current = {}, request = {}", currentStudent.getBirthday(), updateDemog.getBirthday()); } @@ -115,6 +99,18 @@ public void processStudentDemographics(TraxDemographicsUpdateDTO updateDemog, St } } + private void populateNewBatchFlags(StudentGradDTO currentStudent) { + if ("ARC".equalsIgnoreCase(currentStudent.getStudentStatus())) { + // Transcript + currentStudent.setNewRecalculateGradStatus("Y"); + } else { + // Transcript + currentStudent.setNewRecalculateGradStatus("Y"); + // TVR + currentStudent.setNewRecalculateProjectedGrad("Y"); + } + } + @Override public String getEventType() { return UPD_DEMOG.toString(); diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentGraduationUpdateEventService.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentGraduationUpdateEventService.java index a292f5e5..e9e55814 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentGraduationUpdateEventService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentGraduationUpdateEventService.java @@ -73,6 +73,9 @@ public void processStudent(TraxGraduationUpdateDTO updateGrad, StudentGradDTO cu boolean isChanged = false; log.info(" Process Student : studentID = {}, pen = {}", currentStudent.getStudentID(), updateGrad.getPen()); + if ("ARC".equalsIgnoreCase(currentStudent.getStudentStatus())) { + return; + } // Order is important for first 3 items below!!! // 1. School of record if (!StringUtils.equals(updateGrad.getSchoolOfRecord(), currentStudent.getSchoolOfRecord())) { diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/util/EducGradDataConversionApiConstants.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/util/EducGradDataConversionApiConstants.java index 4bf19040..97d3a817 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/util/EducGradDataConversionApiConstants.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/util/EducGradDataConversionApiConstants.java @@ -222,4 +222,7 @@ public class EducGradDataConversionApiConstants { @Value("${cron.scheduled.process.events.stan.threshold}") private int traxToGradProcessingThreshold; + + @Value("${cron.scheduled.process.purge-old-records.staleInDays}") + private int recordsStaleInDays; } diff --git a/api/src/main/resources/application.yaml b/api/src/main/resources/application.yaml index 7eb3f960..56869e1a 100644 --- a/api/src/main/resources/application.yaml +++ b/api/src/main/resources/application.yaml @@ -13,7 +13,7 @@ spring: username: ${CONV_USERNAME} password: ${CONV_PASSWORD} url: ${CONNECTION_STRING} - driver-class: oracle.jdbc.driver.OracleDriver + driver-class-name: oracle.jdbc.driver.OracleDriver jpa: show-sql: ${SHOW_SQL_LOGS} database-platform: org.hibernate.dialect.Oracle12cDialect @@ -177,6 +177,9 @@ cron: lockAtLeastFor: ${CRON_SCHEDULED_PROCESS_EVENTS_STAN_LOCK_AT_LEAST_FOR} lockAtMostFor: ${CRON_SCHEDULED_PROCESS_EVENTS_STAN_LOCK_AT_MOST_FOR} threshold: ${CRON_SCHEDULED_PROCESS_EVENTS_STAN_THRESHOLD} + purge-old-records: + run: ${CRON_SCHEDULED_PURGE_OLD_RECORDS} + staleInDays: ${RECORDS_STALE_IN_DAYS} #Endpoints endpoint: diff --git a/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentAssessmentUpdateEventServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentAssessmentUpdateEventServiceTest.java index 008cfca8..9b8c48d3 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentAssessmentUpdateEventServiceTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentAssessmentUpdateEventServiceTest.java @@ -82,7 +82,7 @@ public void testProcessStudentAssessmentForGrad2018ENProgram_givenUpdated_STUDEN currentStudent.setStudentID(studentID); currentStudent.setProgram(program); currentStudent.setStudentGrade("12"); - currentStudent.setStudentStatus("A"); + currentStudent.setStudentStatus("CUR"); currentStudent.setSchoolOfRecord(mincode); currentStudent.setSchoolAtGrad(mincode); // Optional Program Codes diff --git a/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentCourseUpdateEventServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentCourseUpdateEventServiceTest.java index 0bace558..d65d1258 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentCourseUpdateEventServiceTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentCourseUpdateEventServiceTest.java @@ -82,7 +82,7 @@ public void testProcessStudentCourseForGrad2018ENProgram_givenUpdated_STUDENT_re currentStudent.setStudentID(studentID); currentStudent.setProgram(program); currentStudent.setStudentGrade("12"); - currentStudent.setStudentStatus("A"); + currentStudent.setStudentStatus("CUR"); currentStudent.setSchoolOfRecord(mincode); currentStudent.setSchoolAtGrad(mincode); // Optional Program Codes diff --git a/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentDemographicsUpdateEventServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentDemographicsUpdateEventServiceTest.java index 6c1f0f06..8c904691 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentDemographicsUpdateEventServiceTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentDemographicsUpdateEventServiceTest.java @@ -86,7 +86,53 @@ public void testProcessStudentDemographicsForGrad2018ENProgram_givenUpdated_UPD_ currentStudent.setStudentID(studentID); currentStudent.setProgram(program); currentStudent.setStudentGrade("12"); - currentStudent.setStudentStatus("A"); + currentStudent.setStudentStatus("CUR"); + currentStudent.setSchoolOfRecord(mincode); + currentStudent.setSchoolAtGrad(mincode); + + when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); + when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); + + studentDemographicsUpdateEventService.processEvent(traxDemogUpdate, event); + + assertThat(event).isNotNull(); + assertThat(event.getEventStatus()).isEqualTo(EventStatus.PROCESSED.name()); + } + + @Test + public void testProcessStudentDemographicsForArchivedGrad2018ENProgram_givenUpdated_UPD_DEMOG_then_returnsAPICallSuccess() { + // ID + UUID studentID = UUID.randomUUID(); + String pen = "111222333"; + + // Program & School + String program = "2018-EN"; + String mincode = "222333"; + + String updateType = "UPD_DEMOG"; + + // TraxUpdateInGrad + TraxDemographicsUpdateDTO traxDemogUpdate = new TraxDemographicsUpdateDTO(); + traxDemogUpdate.setPen(pen); + traxDemogUpdate.setFirstName("Test"); + traxDemogUpdate.setMiddleNames("and"); + traxDemogUpdate.setLastName("QA"); + traxDemogUpdate.setBirthday("19960601"); + + // Event + Event event = new Event(); + event.setEventType(EventType.UPD_DEMOG.name()); + event.setEventStatus(EventStatus.DB_COMMITTED.name()); + event.setActivityCode(updateType); + event.setEventId(UUID.randomUUID()); + + // current GRAD Student + StudentGradDTO currentStudent = new StudentGradDTO(); + // GraduationStudentRecord + currentStudent.setStudentID(studentID); + currentStudent.setProgram(program); + currentStudent.setStudentGrade("12"); + currentStudent.setStudentStatus("ARC"); currentStudent.setSchoolOfRecord(mincode); currentStudent.setSchoolAtGrad(mincode); diff --git a/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentFrenchImmersionEventServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentFrenchImmersionEventServiceTest.java index b50a78d6..699a86d8 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentFrenchImmersionEventServiceTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentFrenchImmersionEventServiceTest.java @@ -82,7 +82,7 @@ public void testProcessStudentForGrad2018ENProgram_givenUpdated_FI10ADD_whenNewC currentStudent.setStudentID(studentID); currentStudent.setProgram(program); currentStudent.setStudentGrade("12"); - currentStudent.setStudentStatus("A"); + currentStudent.setStudentStatus("CUR"); currentStudent.setSchoolOfRecord(mincode); currentStudent.setSchoolAtGrad(mincode); // Optional Program Codes @@ -141,7 +141,7 @@ public void testProcessStudentForGrad2018ENProgram_givenUpdated_FI10DELETE_whenC currentStudent.setStudentID(studentID); currentStudent.setProgram(program); currentStudent.setStudentGrade("12"); - currentStudent.setStudentStatus("A"); + currentStudent.setStudentStatus("CUR"); currentStudent.setSchoolOfRecord(mincode); currentStudent.setSchoolAtGrad(mincode); // Optional Program Codes diff --git a/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentGraduationUpdateEventServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentGraduationUpdateEventServiceTest.java index caf2272a..c3ac6d2c 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentGraduationUpdateEventServiceTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentGraduationUpdateEventServiceTest.java @@ -178,6 +178,68 @@ public void testProcessStudentForGrad2018ENProgram_givenUpdated_STUDENT_whenGrad assertThat(event.getEventStatus()).isEqualTo(EventStatus.PROCESSED.name()); } + @Test + public void testProcessStudentForGrad2018ENProgram_givenUpdated_Archived_STUDENT_whenGradeAndSchoolAreChanged_then_returnsAPICallSuccess() { + // ID + UUID studentID = UUID.randomUUID(); + String pen = "111222333"; + + // Program & School + String program = "2018-EN"; + String mincode = "222333"; + + String newMincode = "333444"; + + String updateType = "UPD_GRAD"; + + // TraxGraduationUpdateDTO + TraxGraduationUpdateDTO traxGraduationUpdate = new TraxGraduationUpdateDTO(); + traxGraduationUpdate.setPen(pen); + traxGraduationUpdate.setGraduationRequirementYear("2018"); + traxGraduationUpdate.setCitizenship("C"); + traxGraduationUpdate.setStudentGrade("11"); + traxGraduationUpdate.setSchoolOfRecord(newMincode); + + // Event + Event event = new Event(); + event.setEventType(EventType.UPD_GRAD.name()); + event.setEventStatus(EventStatus.DB_COMMITTED.name()); + event.setActivityCode(updateType); + event.setEventId(UUID.randomUUID()); + + // current GRAD Student + StudentGradDTO currentStudent = new StudentGradDTO(); + // GraduationStudentRecord + currentStudent.setStudentID(studentID); + currentStudent.setProgram(program); + currentStudent.setStudentGrade("12"); + currentStudent.setStudentStatus("ARC"); + currentStudent.setCitizenship("C"); + currentStudent.setSchoolOfRecord(mincode); + currentStudent.setSchoolAtGrad(mincode); + // Optional Program Codes + currentStudent.getProgramCodes().add("XC"); + currentStudent.getProgramCodes().add("FI"); + // Courses + StudentCourse course1 = new StudentCourse(); + course1.setCourseCode("Test"); + course1.setCourseLevel("12"); + course1.setCourseName("Test Course"); + course1.setCreditsUsedForGrad(Integer.valueOf("4")); + course1.setCompletedCoursePercentage(Double.valueOf("92.00")); + course1.setCredits(Integer.valueOf("4")); + course1.setPen(pen); + currentStudent.getCourses().add(course1); + + when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); + when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); + + studentGraduationUpdateEventService.processEvent(traxGraduationUpdate, event); + + assertThat(event).isNotNull(); + assertThat(event.getEventStatus()).isEqualTo(EventStatus.PROCESSED.name()); + } + @Test public void testProcessStudentForGrad2018ENProgram_givenUpdated_STUDENT_whenSlpDateAndCitizenshipAreChanged_then_returnsAPICallSuccess() { // ID diff --git a/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentXProgramEventServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentXProgramEventServiceTest.java index 133f99fc..7a3aa9b2 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentXProgramEventServiceTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentXProgramEventServiceTest.java @@ -296,7 +296,7 @@ public void testProcessStudentForGrad2018ENProgram_givenUpdated_XPROGRAM_whenCou currentStudent.setStudentID(studentID); currentStudent.setProgram(program); currentStudent.setStudentGrade("12"); - currentStudent.setStudentStatus("A"); + currentStudent.setStudentStatus("CUR"); currentStudent.setSchoolOfRecord(mincode); currentStudent.setSchoolAtGrad(mincode); // Optional Program Codes @@ -374,7 +374,7 @@ public void testProcessStudentForGrad2018ENProgram_givenUpdated_XPROGRAM_whenNew currentStudent.setStudentID(studentID); currentStudent.setProgram(program); currentStudent.setStudentGrade("12"); - currentStudent.setStudentStatus("A"); + currentStudent.setStudentStatus("CUR"); currentStudent.setSchoolOfRecord(mincode); currentStudent.setSchoolAtGrad(mincode); // Optional Program Codes diff --git a/api/src/test/resources/application.yaml b/api/src/test/resources/application.yaml index 6f7080aa..1d5869fa 100644 --- a/api/src/test/resources/application.yaml +++ b/api/src/test/resources/application.yaml @@ -10,7 +10,7 @@ spring: minimum-idle: 1 idle-timeout: 300000 max-lifetime: 600000 - driver-class: org.h2.Driver + driver-class-name: org.h2.Driver url: jdbc:h2:mem:test jpa: show-sql: true @@ -90,6 +90,9 @@ cron: lockAtLeastFor: 800ms lockAtMostFor: 900ms threshold: 100 + purge-old-records: + run: 0 30 0 * * * + staleInDays: 90 #Endpoints endpoint: