From 2d0c302ab7e05615d28922e963d6715fb54af196 Mon Sep 17 00:00:00 2001 From: Kamal Mohammed Date: Fri, 29 Nov 2024 17:21:13 -0700 Subject: [PATCH] GRAD2-3098 - Update DTOs, entities and related code in ASSESSMENT-API --- .../api/assessment/model/dto/BaseDTO.java | 13 +++ .../educ/api/assessment/model/dto/School.java | 106 +++++------------- .../service/StudentAssessmentService.java | 2 +- api/src/main/resources/application.yaml | 2 +- .../service/StudentAssessmentServiceTest.java | 12 +- api/src/test/resources/application.yaml | 2 +- 6 files changed, 52 insertions(+), 85 deletions(-) create mode 100644 api/src/main/java/ca/bc/gov/educ/api/assessment/model/dto/BaseDTO.java diff --git a/api/src/main/java/ca/bc/gov/educ/api/assessment/model/dto/BaseDTO.java b/api/src/main/java/ca/bc/gov/educ/api/assessment/model/dto/BaseDTO.java new file mode 100644 index 0000000..85954e2 --- /dev/null +++ b/api/src/main/java/ca/bc/gov/educ/api/assessment/model/dto/BaseDTO.java @@ -0,0 +1,13 @@ +package ca.bc.gov.educ.api.assessment.model.dto; + +import jakarta.validation.constraints.NotBlank; +import lombok.Data; + +@Data +public class BaseDTO { + private String createUser; + private String createDate; + @NotBlank(message = "updateUser must not be null or empty") + private String updateUser; + private String updateDate; +} diff --git a/api/src/main/java/ca/bc/gov/educ/api/assessment/model/dto/School.java b/api/src/main/java/ca/bc/gov/educ/api/assessment/model/dto/School.java index b6b8226..652b136 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/assessment/model/dto/School.java +++ b/api/src/main/java/ca/bc/gov/educ/api/assessment/model/dto/School.java @@ -5,85 +5,39 @@ @Data @Component -public class School { - - private String minCode; - private String schoolName; - private String districtName; - private String transcriptEligibility; - private String certificateEligibility; - private String independentDesignation; - private String mailerType; - private String address1; - private String address2; - private String city; - private String provCode; - private String provinceName; - private String countryCode; - private String countryName; - private String postal; - private String independentAffiliation; - private String openFlag; - private String signatureDistrict; +public class School extends BaseDTO{ + + private String schoolId; + private String districtId; + private String mincode; + private String independentAuthorityId; + private String schoolNumber; + private String faxNumber; + private String phoneNumber; + private String email; + private String website; + private String displayName; + private String displayNameNoSpecialChars; + private String schoolReportingRequirementCode; + private String schoolOrganizationCode; + private String schoolCategoryCode; + private String facilityTypeCode; + private String openedDate; + private String closedDate; + private boolean canIssueTranscripts; + private boolean canIssueCertificates; - public String getSchoolName() { - return schoolName != null ? schoolName.trim(): null; - } - - public String getDistrictName() { - return districtName != null ? districtName.trim(): null; - } - - public String getAddress1() { - return address1 != null ? address1.trim(): null; - } - - public String getAddress2() { - return address2 != null ? address2.trim(): null; - } - - public String getCity() { - return city != null ? city.trim(): null; - } - - public String getProvinceName() { - return provinceName != null ? provinceName.trim(): null; - } - - public String getCountryName() { - return countryName != null ? countryName.trim(): null; - } - - public String getPostal() { - return postal != null ? postal.trim(): null; - } - - public String getIndependentDesignation() { - return independentDesignation != null ? independentDesignation.trim(): null; - } - - public String getIndependentAffiliation() { - return independentAffiliation != null ? independentAffiliation.trim(): null; - } - - public String getOpenFlag() { - return openFlag != null ? openFlag.trim(): null; - } - - public String getSignatureDistrict() { - return signatureDistrict != null ? signatureDistrict.trim(): null; - } - - @Override public String toString() { - return "School [minCode=" + minCode + ", schoolName=" + schoolName + ", districtName=" + districtName - + ", transcriptEligibility=" + transcriptEligibility + ", certificateEligibility=" - + certificateEligibility + ", independentDesignation=" + independentDesignation + ", mailerType=" - + mailerType + ", address1=" + address1 + ", address2=" + address2 + ", city=" + city + ", provCode=" - + provCode + ", provinceName=" + provinceName + ", countryCode=" + countryCode + ", countryName=" - + countryName + ", postal=" + postal + ", independentAffiliation=" + independentAffiliation - + ", openFlag=" + openFlag + ", signatureDistrict=" + signatureDistrict + "]"; + return String.format("School [ schoolId:%s, districtId:%s, mincode:%s, independentAuthorityId:%s, schoolNumber:%s, " + + "faxNumber:%s, phoneNumber:%s, email:%s, website:%s, displayName:%s, displayNameNoSpecialChars:%s, " + + "schoolReportingRequirementCode:%s, schoolOrganizationCode:%s, schoolCategoryCode:%s, facilityTypeCode:%s, " + + "openedDate:%s, closedDate:%s, canIssueTranscripts:%s, canIssueCertificates:%s, createUser:%s, createDate:%s, " + + "updateUser:%s, updateDate:%s ]", + schoolId, districtId, mincode, independentAuthorityId, schoolNumber, faxNumber, phoneNumber, email, website, + displayName, displayNameNoSpecialChars, schoolReportingRequirementCode, schoolOrganizationCode, schoolCategoryCode, + facilityTypeCode, openedDate, closedDate, canIssueTranscripts, canIssueCertificates, getCreateUser(), getCreateDate(), + getUpdateUser(), getUpdateDate()); } diff --git a/api/src/main/java/ca/bc/gov/educ/api/assessment/service/StudentAssessmentService.java b/api/src/main/java/ca/bc/gov/educ/api/assessment/service/StudentAssessmentService.java index ab59343..f44198d 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/assessment/service/StudentAssessmentService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/assessment/service/StudentAssessmentService.java @@ -100,7 +100,7 @@ private void populateFields(List studentAssessmentList, Strin .bodyToMono(School.class) .block(); if (schObj != null) - sA.setMincodeAssessmentName(schObj.getSchoolName()); + sA.setMincodeAssessmentName(schObj.getDisplayName()); sA.setHasMoreInfo(true); } }); diff --git a/api/src/main/resources/application.yaml b/api/src/main/resources/application.yaml index 6ec02a2..c3cb29d 100644 --- a/api/src/main/resources/application.yaml +++ b/api/src/main/resources/application.yaml @@ -92,7 +92,7 @@ springdoc: endpoint: grad-trax-api: school-name-by-mincode: - url: ${GRAD_TRAX_API}api/v1/trax/school/%s + url: ${GRAD_TRAX_API}api/v2/trax/school/search?mincode=%s grad-program-api: rule-detail: url : ${GRAD_PROGRAM_API}api/v1/program/programrules/%s diff --git a/api/src/test/java/ca/bc/gov/educ/api/assessment/service/StudentAssessmentServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/assessment/service/StudentAssessmentServiceTest.java index 4854b0a..93b0a7f 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/assessment/service/StudentAssessmentServiceTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/assessment/service/StudentAssessmentServiceTest.java @@ -85,8 +85,8 @@ public void testGetStudentAssessmentList() { assessment.setAssessmentName("asdas"); School school = new School(); - school.setMinCode("12345678"); - school.setSchoolName("Test School"); + school.setMincode("12345678"); + school.setDisplayName("Test School"); when(studentAssessmentRepo.findByPen(studentAssessmentId.getPen())).thenReturn(List.of(studentAssessmentEntity)); when(assessmentRepo.findByAssessmentCode("LTE10")).thenReturn(Optional.of(assessment)); @@ -103,7 +103,7 @@ public void testGetStudentAssessmentList() { StudentAssessment responseStudentAssessment = result.get(0); assertThat(responseStudentAssessment.getAssessmentCode()).isEqualTo(assessment.getAssessmentCode()); assertThat(responseStudentAssessment.getSpecialCase()).isEqualTo(studentAssessmentEntity.getSpecialCase()); - assertThat(responseStudentAssessment.getMincodeAssessmentName()).isEqualTo(school.getSchoolName()); + assertThat(responseStudentAssessment.getMincodeAssessmentName()).isEqualTo(school.getDisplayName()); } @Test @@ -124,8 +124,8 @@ public void testGetStudentAssessment() { assessment.setAssessmentName("asdas"); School school = new School(); - school.setMinCode("12345678"); - school.setSchoolName("Test School"); + school.setMincode("12345678"); + school.setDisplayName("Test School"); when(studentAssessmentRepo.findByAssessmentKeyPenAndAssessmentKeyAssessmentCode(studentAssessmentId.getPen(), studentAssessmentId.getAssessmentCode())).thenReturn(List.of(studentAssessmentEntity)); when(assessmentRepo.findByAssessmentCode("LTE10")).thenReturn(Optional.of(assessment)); @@ -142,6 +142,6 @@ public void testGetStudentAssessment() { StudentAssessment responseStudentAssessment = result.get(0); assertThat(responseStudentAssessment.getAssessmentCode()).isEqualTo(assessment.getAssessmentCode()); assertThat(responseStudentAssessment.getSpecialCase()).isEqualTo(studentAssessmentEntity.getSpecialCase()); - assertThat(responseStudentAssessment.getMincodeAssessmentName()).isEqualTo(school.getSchoolName()); + assertThat(responseStudentAssessment.getMincodeAssessmentName()).isEqualTo(school.getDisplayName()); } } diff --git a/api/src/test/resources/application.yaml b/api/src/test/resources/application.yaml index ddb74b5..e2e1ffb 100644 --- a/api/src/test/resources/application.yaml +++ b/api/src/test/resources/application.yaml @@ -70,7 +70,7 @@ springdoc: endpoint: grad-trax-api: school-name-by-mincode: - url: https://educ-grad-trax-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/trax/school/%s + url: https://educ-grad-trax-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/trax/school/search?mincode=%s grad-program-api: rule-detail: url : https://educ-grad-program-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/program/programrules/%s