From cf1e4b5b60f71ddc3a398fbb9588dccb3c756ef8 Mon Sep 17 00:00:00 2001 From: Jinil Sung Date: Wed, 21 Feb 2024 14:25:22 -0800 Subject: [PATCH] GRAD2-2507: task is complete. GRAD2-2507: task is complete. --- .../model/dto/GradTraxStudent.java | 45 ------------------- .../gradstudent/service/CommonService.java | 6 +-- .../service/GradStudentService.java | 19 -------- .../util/EducGradStudentApiConstants.java | 3 -- api/src/main/resources/application.yaml | 18 +++----- .../service/CommonServiceTest.java | 27 +---------- .../service/GradStudentServiceTest.java | 29 ------------ api/src/test/resources/application.yaml | 2 - 8 files changed, 11 insertions(+), 138 deletions(-) delete mode 100644 api/src/main/java/ca/bc/gov/educ/api/gradstudent/model/dto/GradTraxStudent.java diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/model/dto/GradTraxStudent.java b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/model/dto/GradTraxStudent.java deleted file mode 100644 index 6dc21e8d..00000000 --- a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/model/dto/GradTraxStudent.java +++ /dev/null @@ -1,45 +0,0 @@ -package ca.bc.gov.educ.api.gradstudent.model.dto; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.util.Date; - -@Data -@Builder -@AllArgsConstructor -@NoArgsConstructor -@JsonIgnoreProperties(ignoreUnknown = true) -public class GradTraxStudent { - private String pen; - private String program; // inc - private Date programCompletionDate; // inc - private String slpDate; // inc - private String sccDate; - private String gpa; - private String honoursStanding; // inc - private String studentGradData; - private String schoolOfRecord; // inc - private String schoolAtGrad; // inc - private String studentGrade; // inc - private String studentStatus; // inc - private String archiveFlag; // inc - private String frenchCert; - private String englishCert; - private String frenchDogwood; - private String consumerEducationRequirementMet; - private String studentCitizenship; - - // extra - private String graduationRequirementYear; - - // grad or non-grad - private Date distributionDate; - private String transcriptSchoolCategoryCode; - private String certificateSchoolCategoryCode; - // 1950 "AD" - private boolean adult19Rule; -} diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/CommonService.java b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/CommonService.java index 958217f9..86e6d738 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/CommonService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/CommonService.java @@ -206,10 +206,8 @@ public GradStudentAlgorithmData getGradStudentAlgorithmData(String studentID,Str GradSearchStudent gradStudent = gradStudentService.getStudentByStudentIDFromStudentAPI(studentID, accessToken); GraduationStudentRecord gradStudentRecord = graduationStatusService.getGraduationStatusForAlgorithm(UUID.fromString(studentID)); List cpList = getAllGradStudentCareerProgramList(studentID, accessToken); - GradTraxStudent gradTraxStudent = gradStudentService.getTraxStudentMasterDataByPen(gradStudent.getPen(), accessToken); - if(gradTraxStudent != null) { - gradStudent.setStudentCitizenship(gradTraxStudent.getStudentCitizenship()); - gradStudentRecord.setStudentCitizenship(gradTraxStudent.getStudentCitizenship()); + if(gradStudentRecord != null && StringUtils.isNotBlank(gradStudentRecord.getStudentCitizenship())) { + gradStudent.setStudentCitizenship(gradStudentRecord.getStudentCitizenship()); } data.setGradStudent(gradStudent); data.setGraduationStudentRecord(gradStudentRecord); diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/GradStudentService.java b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/GradStudentService.java index 3a3cd492..41179c08 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/GradStudentService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/GradStudentService.java @@ -356,31 +356,12 @@ public GradSearchStudent getStudentByStudentIDFromStudentAPI(String studentID, S return gradStu; } - @Transactional - @Retry(name = "rt-getTraxStudent") - public GradTraxStudent getTraxStudentMasterDataByPen(String pen, String accessToken) { - final ParameterizedTypeReference> responseType = new ParameterizedTypeReference<>() { - }; - List result = this.webClient.get() - .uri(String.format(constants.getTraxStudentMasterDataByPenUrl(), pen)) - .headers(h -> { - h.setBearerAuth(accessToken); - h.set(EducGradStudentApiConstants.CORRELATION_ID, ThreadLocalStateUtil.getCorrelationID()); - }) - .retrieve().bodyToMono(responseType).block(); - if(result != null && !result.isEmpty()) { - return result.get(0); - } - return null; - } - @Transactional @Retry(name = "searchbyid") public GraduationStudentRecordDistribution getStudentByStudentIDFromGrad(String studentID) { return graduationStatusTransformer.tToDForDistribution(graduationStatusRepository.findByStudentID(UUID.fromString(studentID))); } - @Transactional public Student addNewPenFromStudentAPI(StudentCreate student, String accessToken) { return webClient.post() diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/util/EducGradStudentApiConstants.java b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/util/EducGradStudentApiConstants.java index 1c5679ee..6833099c 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/util/EducGradStudentApiConstants.java +++ b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/util/EducGradStudentApiConstants.java @@ -140,9 +140,6 @@ public class EducGradStudentApiConstants { @Value("${endpoint.grad-trax-api.district-by-district-code.url}") private String districtByDistrictCodeUrl; - @Value("${endpoint.grad-trax-api.get-student-master-data.url}") - private String traxStudentMasterDataByPenUrl; - @Value("${endpoint.grad-program-api.career_program-by-career-code.url}") private String careerProgramByCodeUrl; diff --git a/api/src/main/resources/application.yaml b/api/src/main/resources/application.yaml index 4409fd98..7276e085 100644 --- a/api/src/main/resources/application.yaml +++ b/api/src/main/resources/application.yaml @@ -13,10 +13,10 @@ spring: url: ${CONNECTION_STRING} username: ${USERNAME} password: ${PASSWORD} - 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 + database-platform: org.hibernate.dialect.OracleDialect hibernate: ddl-auto: none mvc: @@ -24,8 +24,6 @@ spring: jackson: deserialization: fail-on-unknown-properties: false - #date-format: "yyyy-MM-dd HH:mm:ss" - #time-zone: ${JACKSON_TZ} flyway: enabled: ${ENABLE_FLYWAY} baseline-on-migrate: false @@ -116,35 +114,35 @@ cron: resilience4j.retry: instances: searchbypen: - maxRetryAttempts: ${MAX_RETRY_ATTEMPTS} + maxAttempts: ${MAX_RETRY_ATTEMPTS} waitDuration: 5s retryExceptions: - org.springframework.web.client.HttpServerErrorException ignoreExceptions: - java.lang.NullPointerException advancedsearch: - maxRetryAttempts: ${MAX_RETRY_ATTEMPTS} + maxAttempts: ${MAX_RETRY_ATTEMPTS} waitDuration: 30s retryExceptions: - org.springframework.web.client.HttpServerErrorException ignoreExceptions: - java.lang.NullPointerException searchbyid: - maxRetryAttempts: ${MAX_RETRY_ATTEMPTS} + maxAttempts: ${MAX_RETRY_ATTEMPTS} waitDuration: 5s retryExceptions: - org.springframework.web.client.HttpServerErrorException ignoreExceptions: - java.lang.NullPointerException generalpostcall: - maxRetryAttempts: ${MAX_RETRY_ATTEMPTS} + maxAttempts: ${MAX_RETRY_ATTEMPTS} waitDuration: 3s retryExceptions: - org.springframework.web.client.HttpServerErrorException ignoreExceptions: - java.lang.NullPointerException generalgetcall: - maxRetryAttempts: ${MAX_RETRY_ATTEMPTS} + maxAttempts: ${MAX_RETRY_ATTEMPTS} waitDuration: 3s retryExceptions: - org.springframework.web.client.HttpServerErrorException @@ -154,8 +152,6 @@ resilience4j.retry: #Endpoint properties endpoint: grad-trax-api: - get-student-master-data: - url: ${GRAD_TRAX_API}api/v1/trax/common/student-master/%s school-by-min-code: url: ${GRAD_TRAX_API}api/v1/trax/school/%s district-by-district-code: diff --git a/api/src/test/java/ca/bc/gov/educ/api/gradstudent/service/CommonServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/gradstudent/service/CommonServiceTest.java index 16db484a..97bf0306 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/gradstudent/service/CommonServiceTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/gradstudent/service/CommonServiceTest.java @@ -18,7 +18,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.core.ParameterizedTypeReference; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.web.reactive.function.client.WebClient; @@ -569,6 +568,7 @@ public void testGetGradStudentAlgorithmData() { gradStudentRecord.setStudentID(studentID); gradStudentRecord.setPen(pen); gradStudentRecord.setStudentGrade("12"); + gradStudentRecord.setStudentCitizenship("C"); when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); when(this.requestHeadersUriMock.uri(String.format(constants.getCareerProgramByCodeUrl(), gradCareerProgram.getCode()))).thenReturn(this.requestHeadersMock); @@ -586,34 +586,11 @@ public void testGetGradStudentAlgorithmData() { when(graduationStatusService.getGraduationStatusForAlgorithm(studentID)).thenReturn(gradStudentRecord); when(gradStudentCareerProgramRepository.findByStudentID(studentID)).thenReturn(cpList); - GradTraxStudent sObj = new GradTraxStudent(); - sObj.setPen(pen); - sObj.setStudentCitizenship("C"); - - final ParameterizedTypeReference> responseType = new ParameterizedTypeReference<>() { - }; - - when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); - when(this.requestHeadersUriMock.uri(String.format(constants.getTraxStudentMasterDataByPenUrl(),pen))).thenReturn(this.requestHeadersMock); - when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); - when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); - when(this.responseMock.bodyToMono(responseType)).thenReturn(Mono.just(List.of(sObj))); - - when(gradStudentService.getTraxStudentMasterDataByPen(sObj.getPen(), accessToken)).thenReturn(sObj); - GradStudentAlgorithmData data = commonService.getGradStudentAlgorithmData(studentID.toString(),accessToken); assertThat(data).isNotNull(); assertThat(data.getGraduationStudentRecord().getStudentCitizenship()).isNotNull(); - sObj.setStudentCitizenship(null); - - when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); - when(this.requestHeadersUriMock.uri(String.format(constants.getTraxStudentMasterDataByPenUrl(),pen))).thenReturn(this.requestHeadersMock); - when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); - when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); - when(this.responseMock.bodyToMono(responseType)).thenReturn(Mono.just(List.of())); - - when(gradStudentService.getTraxStudentMasterDataByPen(sObj.getPen(), accessToken)).thenReturn(sObj); + gradStudentRecord.setStudentCitizenship(null); data = commonService.getGradStudentAlgorithmData(studentID.toString(),accessToken); assertThat(data).isNotNull(); diff --git a/api/src/test/java/ca/bc/gov/educ/api/gradstudent/service/GradStudentServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/gradstudent/service/GradStudentServiceTest.java index b4f700c0..5ff85087 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/gradstudent/service/GradStudentServiceTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/gradstudent/service/GradStudentServiceTest.java @@ -633,35 +633,6 @@ public void testGetStudentByStudentIDFromStudentAPI() { assertThat(result.getEmailVerified()).isEqualTo(student.getEmailVerified()); } - @Test - public void testGetTraxStudentMasterDataByPen() { - - String pen = "128385861"; - GradTraxStudent sObj = new GradTraxStudent(); - sObj.setPen(pen); - - final ParameterizedTypeReference> responseType = new ParameterizedTypeReference<>() { - }; - - when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); - when(this.requestHeadersUriMock.uri(String.format(constants.getTraxStudentMasterDataByPenUrl(),pen))).thenReturn(this.requestHeadersMock); - when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); - when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); - when(this.responseMock.bodyToMono(responseType)).thenReturn(Mono.just(List.of(sObj))); - - GradTraxStudent result = gradStudentService.getTraxStudentMasterDataByPen(pen, "accessToken"); - assertNotNull(result); - - when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); - when(this.requestHeadersUriMock.uri(String.format(constants.getTraxStudentMasterDataByPenUrl(),pen))).thenReturn(this.requestHeadersMock); - when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); - when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); - when(this.responseMock.bodyToMono(responseType)).thenReturn(Mono.just(List.of())); - - result = gradStudentService.getTraxStudentMasterDataByPen(pen, "accessToken"); - assertNull(result); - } - @Test public void testAddNewPenFromStudentAPI() { // ID diff --git a/api/src/test/resources/application.yaml b/api/src/test/resources/application.yaml index 46c0efbb..85f9516f 100644 --- a/api/src/test/resources/application.yaml +++ b/api/src/test/resources/application.yaml @@ -102,8 +102,6 @@ cron: #Endpoint properties endpoint: grad-trax-api: - get-student-master-data: - url: https://educ-grad-trax-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/trax/common/student-master/%s school-by-min-code: url: https://educ-grad-trax-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/trax/school/%s district-by-district-code: