Skip to content

Commit

Permalink
Merge branch 'refs/heads/grad-release'
Browse files Browse the repository at this point in the history
  • Loading branch information
chris.ditcher authored and chris.ditcher committed Nov 1, 2024
2 parents bf4c9be + 8b4f022 commit 9eff95d
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 25 deletions.
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@ updates:
schedule:
interval: "daily"
target-branch: "grad-release"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<SchoolContact> contacts;
List<SchoolAddress> addresses;
List<Note> notes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@RedisHash("School")
public class SchoolEntity {

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand All @@ -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));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -120,14 +122,17 @@ public void updateSchoolCache_givenValidShcoolId_shouldUpdate() {
SchoolDetail schoolDetail = TestUtils.createSchoolDetail();
SchoolDetailEntity schoolDetailEntity = schoolDetailTransformer.transformToEntity(schoolDetail);
Optional<SchoolDetailEntity> schoolDetailEntityOptional = Optional.of(schoolDetailEntity);
Optional<SchoolEntity> 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<SchoolDetailEntity> response = this.schoolDetailRedisRepository.findById(schoolDetail.getSchoolId());
Optional<SchoolEntity> 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();
}
Expand Down
5 changes: 5 additions & 0 deletions tools/config/update-configmap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9eff95d

Please sign in to comment.