diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 0d28b300..85708f49 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -10,3 +10,7 @@ updates: schedule: interval: "daily" target-branch: "grad-release" + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" diff --git a/api/src/main/java/ca/bc/gov/educ/api/trax/model/dto/institute/SchoolDetail.java b/api/src/main/java/ca/bc/gov/educ/api/trax/model/dto/institute/SchoolDetail.java index 9047504e..07452198 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/trax/model/dto/institute/SchoolDetail.java +++ b/api/src/main/java/ca/bc/gov/educ/api/trax/model/dto/institute/SchoolDetail.java @@ -1,6 +1,5 @@ package ca.bc.gov.educ.api.trax.model.dto.institute; -import ca.bc.gov.educ.api.trax.model.dto.BaseModel; import ca.bc.gov.educ.api.trax.model.dto.SchoolContact; import lombok.Data; import lombok.EqualsAndHashCode; @@ -11,27 +10,8 @@ @Data @EqualsAndHashCode(callSuper = true) @Component("SchoolDetail") -public class SchoolDetail extends BaseModel { +public class SchoolDetail extends School { - 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; List contacts; List addresses; List notes; diff --git a/api/src/main/java/ca/bc/gov/educ/api/trax/model/entity/institute/SchoolEntity.java b/api/src/main/java/ca/bc/gov/educ/api/trax/model/entity/institute/SchoolEntity.java index 16ce9d58..d97849c4 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/trax/model/entity/institute/SchoolEntity.java +++ b/api/src/main/java/ca/bc/gov/educ/api/trax/model/entity/institute/SchoolEntity.java @@ -8,6 +8,7 @@ @Data @NoArgsConstructor @AllArgsConstructor +@Builder @RedisHash("School") public class SchoolEntity { diff --git a/api/src/main/java/ca/bc/gov/educ/api/trax/model/transformer/institute/SchoolDetailTransformer.java b/api/src/main/java/ca/bc/gov/educ/api/trax/model/transformer/institute/SchoolDetailTransformer.java index 071f1d98..b1dd1214 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/trax/model/transformer/institute/SchoolDetailTransformer.java +++ b/api/src/main/java/ca/bc/gov/educ/api/trax/model/transformer/institute/SchoolDetailTransformer.java @@ -1,6 +1,5 @@ package ca.bc.gov.educ.api.trax.model.transformer.institute; -import ca.bc.gov.educ.api.trax.model.dto.institute.School; import ca.bc.gov.educ.api.trax.model.dto.institute.SchoolDetail; import ca.bc.gov.educ.api.trax.model.entity.institute.SchoolDetailEntity; import ca.bc.gov.educ.api.trax.model.entity.institute.SchoolEntity; @@ -16,9 +15,37 @@ @Component("SchoolDetailTransformer") public class SchoolDetailTransformer { - @Autowired ModelMapper modelMapper; + @Autowired + public SchoolDetailTransformer(ModelMapper modelMapper) { + this.modelMapper = modelMapper; + } + + public SchoolEntity transformToSchoolEntity(final SchoolDetail schoolDetail) { + return SchoolEntity.builder() + .schoolId(schoolDetail.getSchoolId()) + .districtId(schoolDetail.getDistrictId()) + .mincode(schoolDetail.getMincode()) + .independentAuthorityId(schoolDetail.getIndependentAuthorityId()) + .schoolNumber(schoolDetail.getSchoolNumber()) + .faxNumber(schoolDetail.getFaxNumber()) + .phoneNumber(schoolDetail.getPhoneNumber()) + .email(schoolDetail.getEmail()) + .website(schoolDetail.getWebsite()) + .displayName(schoolDetail.getDisplayName()) + .displayNameNoSpecialChars(schoolDetail.getDisplayNameNoSpecialChars()) + .schoolReportingRequirementCode(schoolDetail.getSchoolReportingRequirementCode()) + .schoolOrganizationCode(schoolDetail.getSchoolOrganizationCode()) + .schoolCategoryCode(schoolDetail.getSchoolCategoryCode()) + .facilityTypeCode(schoolDetail.getFacilityTypeCode()) + .openedDate(schoolDetail.getOpenedDate()) + .closedDate(schoolDetail.getClosedDate()) + .canIssueTranscripts(schoolDetail.isCanIssueTranscripts()) + .canIssueCertificates(schoolDetail.isCanIssueCertificates()) + .build(); + } + public SchoolDetail transformToDTO (SchoolDetailEntity schoolDetailEntity) { return modelMapper.map(schoolDetailEntity, SchoolDetail.class); } diff --git a/api/src/main/java/ca/bc/gov/educ/api/trax/service/institute/SchoolService.java b/api/src/main/java/ca/bc/gov/educ/api/trax/service/institute/SchoolService.java index 5d775f73..21cdad6f 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/trax/service/institute/SchoolService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/trax/service/institute/SchoolService.java @@ -144,7 +144,7 @@ public void updateSchoolCache(String schoolId) throws ServiceException { SchoolDetail schoolDetail = this.restService.get(String.format(constants.getSchoolDetailsByIdFromInstituteApiUrl(), schoolId), SchoolDetail.class, webClient); log.debug("Retrieved school: {} from Institute API", schoolDetail.getSchoolId()); - schoolDetailRedisRepository.save(schoolDetailTransformer.transformToEntity(schoolDetail)); + updateSchoolCache(schoolDetail); } /** @@ -153,6 +153,7 @@ public void updateSchoolCache(String schoolId) throws ServiceException { */ public void updateSchoolCache(SchoolDetail schoolDetail) throws ServiceException { schoolDetailRedisRepository.save(schoolDetailTransformer.transformToEntity(schoolDetail)); + schoolRedisRepository.save(schoolDetailTransformer.transformToSchoolEntity(schoolDetail)); } /** diff --git a/api/src/test/java/ca/bc/gov/educ/api/trax/service/institute/intstituteSchoolServiceTestToo.java b/api/src/test/java/ca/bc/gov/educ/api/trax/service/institute/intstituteSchoolServiceTestToo.java index 56f437a5..88e0bf15 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/trax/service/institute/intstituteSchoolServiceTestToo.java +++ b/api/src/test/java/ca/bc/gov/educ/api/trax/service/institute/intstituteSchoolServiceTestToo.java @@ -101,6 +101,8 @@ public class intstituteSchoolServiceTestToo { @MockBean private Subscriber subscriber; + @Autowired + private ca.bc.gov.educ.api.trax.model.transformer.SchoolTransformer schoolTransformer; @TestConfiguration static class TestConfigInstitute { @@ -120,14 +122,17 @@ public void updateSchoolCache_givenValidShcoolId_shouldUpdate() { SchoolDetail schoolDetail = TestUtils.createSchoolDetail(); SchoolDetailEntity schoolDetailEntity = schoolDetailTransformer.transformToEntity(schoolDetail); Optional schoolDetailEntityOptional = Optional.of(schoolDetailEntity); + Optional schoolEntityOptional = Optional.of(schoolDetailTransformer.transformToSchoolEntity(schoolDetail)); when(this.restServiceMock.get(String.format(constants.getSchoolDetailsByIdFromInstituteApiUrl(), schoolDetail.getSchoolId()), SchoolDetail.class, this.webClientMock)).thenReturn(schoolDetail); when(this.schoolDetailRedisRepository.findById(schoolDetail.getSchoolId())).thenReturn(schoolDetailEntityOptional); + when(this.schoolRedisRepository.findById(schoolDetail.getSchoolId())).thenReturn(schoolEntityOptional); doNothing().when(this.schoolService).updateSchoolCache(schoolDetail.getSchoolId()); this.schoolService.updateSchoolCache(schoolDetail.getSchoolId()); Optional response = this.schoolDetailRedisRepository.findById(schoolDetail.getSchoolId()); + Optional schoolResponse = this.schoolRedisRepository.findById(schoolDetail.getSchoolId()); if (response.isPresent()) { - Assert.assertEquals(response.get().getSchoolId(), schoolDetail.getSchoolId()); + Assert.assertEquals(response.get().getSchoolId(), schoolResponse.get().getSchoolId()); } else { Assert.fail(); } diff --git a/tools/config/update-configmap.sh b/tools/config/update-configmap.sh index 0179aa5f..156f7900 100644 --- a/tools/config/update-configmap.sh +++ b/tools/config/update-configmap.sh @@ -76,6 +76,11 @@ oc create -n "$GRAD_NAMESPACE"-"$envValue" configmap "$APP_NAME"-config-map \ --from-literal=MAX_RETRY_ATTEMPTS="3" \ --from-literal=SCHOOL_CACHE_EXPIRY_IN_MINS="240" \ --from-literal=STUDENT_ADMIN_URL_ROOT="$STUDENT_ADMIN_URL_ROOT" \ + --from-literal=CONNECTION_TIMEOUT='30000' \ + --from-literal=MAXIMUM_POOL_SIZE='15' \ + --from-literal=MIN_IDLE='15' \ + --from-literal=IDLE_TIMEOUT='600000' \ + --from-literal=MAX_LIFETIME='1500000' \ --dry-run=client -o yaml | oc apply -f - echo Creating config map "$APP_NAME"-flb-sc-config-map