Skip to content

Commit

Permalink
Merge pull request #340 from bcgov/feature/GRAD2-3000
Browse files Browse the repository at this point in the history
GRAD2-3000: NEWSTUDENT event is retried when it is failed.
  • Loading branch information
infstar authored Oct 10, 2024
2 parents a7f6992 + 8b5981a commit 8a90174
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package ca.bc.gov.educ.api.dataconversion.service.student;

import ca.bc.gov.educ.api.dataconversion.constant.ConversionResultType;
import ca.bc.gov.educ.api.dataconversion.entity.Event;
import ca.bc.gov.educ.api.dataconversion.model.*;
import ca.bc.gov.educ.api.dataconversion.process.StudentProcess;
Expand Down Expand Up @@ -41,6 +42,7 @@ public NewStudentEventService(EventRepository eventRepository,
@Override
public <T extends Object> void processEvent(T request, Event event) {
ConvGradStudent convStudent = (ConvGradStudent) request;
ConvGradStudent result = null;
if (convStudent != null && constants.isGradUpdateEnabled()) {
// Get Access Token
ResponseObj res = restUtils.getTokenResponseObject();
Expand All @@ -51,13 +53,17 @@ public <T extends Object> void processEvent(T request, Event event) {
ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO();
summary.setAccessToken(accessToken);
try {
studentProcess.convertStudent(convStudent, summary, false, true);
result = studentProcess.convertStudent(convStudent, summary, false, true);
} catch (Exception e) {
ConversionAlert error = new ConversionAlert();
error.setItem(convStudent.getPen());
error.setReason("Unexpected Exception is occurred: " + e.getLocalizedMessage());
summary.getErrors().add(error);
log.error("unknown exception: " + e.getLocalizedMessage());
return;
}
if (result == null || ConversionResultType.FAILURE.equals(result.getResult())) {
return;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public class NewStudentEventServiceTest {
private EducGradDataConversionApiConstants constants;

@Test
public void testProcessStudentForGrad2018ENProgram_givenNew_STUDENT_returnsAPICallSuccess() {
public void testProcessStudentForGrad2018ENProgram_givenNew_STUDENT_returnsAPICallSuccess() throws Exception {
// ID
UUID studentID = UUID.randomUUID();
String pen = "111222333";
Expand Down Expand Up @@ -91,6 +91,7 @@ public void testProcessStudentForGrad2018ENProgram_givenNew_STUDENT_returnsAPICa
event.setEventId(UUID.randomUUID());

when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event));
when(this.studentProcess.convertStudent(any(), any(), eq(false), eq(true))).thenReturn(traxNewStudent);

newStudentEventService.processEvent(traxNewStudent, event);

Expand Down Expand Up @@ -132,6 +133,6 @@ public void testProcessStudent_whenException_isThrown_returnsAPICallError() thro
newStudentEventService.processEvent(traxNewStudent, event);

assertThat(event).isNotNull();
assertThat(event.getEventStatus()).isEqualTo(EventStatus.PROCESSED.name());
assertThat(event.getEventStatus()).isNotEqualTo(EventStatus.PROCESSED.name());
}
}

0 comments on commit 8a90174

Please sign in to comment.