Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GRAD2-2507: task is complete. #623

Merged
merged 1 commit into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,8 @@ public GradStudentAlgorithmData getGradStudentAlgorithmData(String studentID,Str
GradSearchStudent gradStudent = gradStudentService.getStudentByStudentIDFromStudentAPI(studentID, accessToken);
GraduationStudentRecord gradStudentRecord = graduationStatusService.getGraduationStatusForAlgorithm(UUID.fromString(studentID));
List<StudentCareerProgram> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<List<GradTraxStudent>> responseType = new ParameterizedTypeReference<>() {
};
List<GradTraxStudent> 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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
18 changes: 7 additions & 11 deletions api/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,17 @@ 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:
log-request-details: ${SPRING_SHOW_REQUEST_DETAILS}
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
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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<List<GradTraxStudent>> 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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<List<GradTraxStudent>> 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
Expand Down
2 changes: 0 additions & 2 deletions api/src/test/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading