Skip to content

Commit

Permalink
GRAD2-2377
Browse files Browse the repository at this point in the history
HD-22859 (GRAD) YE Distribution run should direct Certificates to School at Graduation, not School of Record
  • Loading branch information
arybakov-cgi committed Apr 22, 2024
1 parent 3ac6672 commit 8c7d09d
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -483,19 +483,22 @@ private School populateSchoolObjectByReportGradStudentData(ReportGradStudentData
String mincode = StringUtils.isBlank(reportGradStudentData.getMincodeAtGrad()) ? reportGradStudentData.getMincode() : reportGradStudentData.getMincodeAtGrad();
SchoolTrax traxSchool = schoolService.getTraxSchoolDetails(mincode);
School school = new School();
school.setDistno(StringUtils.substring(traxSchool.getMinCode(), 0, 3));
school.setMincode(traxSchool.getMinCode());
school.setName(traxSchool.getSchoolName());
school.setTypeBanner("Principal");
Address address = new Address();
address.setStreetLine1(traxSchool.getAddress1());
address.setStreetLine2(traxSchool.getAddress2());
address.setCity(traxSchool.getCity());
address.setRegion(traxSchool.getProvCode());
address.setCountry(traxSchool.getCountryName());
address.setCode(traxSchool.getPostal());
school.setAddress(address);
school.setStudents(new ArrayList<>());
if(traxSchool != null) {
school.setDistno(StringUtils.substring(traxSchool.getMinCode(), 0, 3));
school.setMincode(traxSchool.getMinCode());
school.setName(traxSchool.getSchoolName());
school.setTypeBanner("Principal");
Address address = new Address();
address.setStreetLine1(traxSchool.getAddress1());
address.setStreetLine2(traxSchool.getAddress2());
address.setCity(traxSchool.getCity());
address.setRegion(traxSchool.getProvCode());
address.setCountry(traxSchool.getCountryName());
address.setCode(traxSchool.getPostal());
school.setAddress(address);
return school;
}
return school;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1802,6 +1802,17 @@ public void testReportDataByPen() throws Exception {
when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock);
when(this.responseMock.bodyToMono(SchoolTrax.class)).thenReturn(Mono.just(schtrax));

DistrictTrax disttrax = new DistrictTrax();
disttrax.setDistrictNumber("005");
disttrax.setDistrictName("My District");
disttrax.setAddress1("My Address");

when(this.webClient.get()).thenReturn(this.requestHeadersUriMock);
when(this.requestHeadersUriMock.uri(String.format(constants.getDistrictDetails(),schtrax.getMinCode()))).thenReturn(this.requestHeadersMock);
when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock);
when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock);
when(this.responseMock.bodyToMono(DistrictTrax.class)).thenReturn(Mono.just(disttrax));

List<ProgramRequirementCode> programRequirementCodes = new ArrayList<>();

ProgramRequirementCode programRequirementCode = new ProgramRequirementCode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ public class SchooReportsServiceTest {
@MockBean
RESTService restService;

@MockBean
SchoolService schoolService;

@MockBean
private TokenUtils tokenUtils;

Expand Down Expand Up @@ -148,6 +151,7 @@ public void testSchoolReports() {
traxSchool.setAddress1("1231");

when(this.restService.get(any(String.class), any(), any())).thenReturn(traxSchool);
when(this.schoolService.getTraxSchoolDetails(traxSchool.getMinCode())).thenReturn(traxSchool);

mockTokenResponseObject();

Expand All @@ -157,6 +161,14 @@ public void testSchoolReports() {
reportsCount = schoolReportsService.createAndStoreSchoolReports(DISTREP_SC, "accessToken");
assertTrue(reportsCount > 0);

DistrictTrax disttrax = new DistrictTrax();
disttrax.setDistrictNumber("005");
disttrax.setDistrictName("My District");
disttrax.setAddress1("My Address");

when(this.schoolService.getTraxSchoolDetails(traxSchool.getMinCode())).thenReturn(traxSchool);
when(this.schoolService.getTraxDistrictDetails(disttrax.getDistrictNumber())).thenReturn(disttrax);

reportsCount = schoolReportsService.createAndStoreDistrictReports(DISTREP_YE_SD, "accessToken");
assertTrue(reportsCount > 0);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package ca.bc.gov.educ.api.graduation.service;

import ca.bc.gov.educ.api.graduation.model.dto.ExceptionMessage;
import ca.bc.gov.educ.api.graduation.model.dto.GraduationStudentRecord;
import ca.bc.gov.educ.api.graduation.model.dto.ResponseObj;
import ca.bc.gov.educ.api.graduation.model.dto.SchoolTrax;
import ca.bc.gov.educ.api.graduation.model.dto.*;
import ca.bc.gov.educ.api.graduation.util.EducGraduationApiConstants;
import ca.bc.gov.educ.api.graduation.util.GradValidation;
import org.junit.After;
Expand Down Expand Up @@ -98,6 +95,19 @@ public void testGetSchoolDetailsNoToken() {
assertEquals(res.getMinCode(),mincode);
}

@Test
public void testGetDistrictDetailsNoToken() {
String mincode = "213";
DistrictTrax schtrax = new DistrictTrax();
schtrax.setDistrictNumber(mincode);
schtrax.setAddress1("1231");
mockTokenResponseObject();
when(this.restService.get(any(String.class), any(), any())).thenReturn(schtrax);
DistrictTrax res = schoolService.getTraxDistrictDetails(mincode);
assertNotNull(res);
assertEquals(res.getDistrictNumber(),mincode);
}

private String mockTokenResponseObject() {
final ResponseObj tokenObject = new ResponseObj();
String mockToken = "eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJtbUhsTG4tUFlpdTl3MlVhRnh5Yk5nekQ3d2ZIb3ZBRFhHSzNROTk0cHZrIn0.eyJleHAiOjE2NjMxODg1MzMsImlhdCI6MTY2MzE4ODIzMywianRpIjoiZjA2ZWJmZDUtMzRlMi00NjY5LTg0MDktOThkNTc3OGZiYmM3IiwiaXNzIjoiaHR0cHM6Ly9zb2FtLWRldi5hcHBzLnNpbHZlci5kZXZvcHMuZ292LmJjLmNhL2F1dGgvcmVhbG1zL21hc3RlciIsImF1ZCI6ImFjY291bnQiLCJzdWIiOiI4ZGFjNmM3Yy0xYjU5LTQ5ZDEtOTMwNC0wZGRkMTdlZGE0YWQiLCJ0eXAiOiJCZWFyZXIiLCJhenAiOiJncmFkLWFkbWluLWNsaWVudCIsImFjciI6IjEiLCJhbGxvd2VkLW9yaWdpbnMiOlsiaHR0cHM6Ly9kZXYuZ3JhZC5nb3YuYmMuY2EiXSwicmVhbG1fYWNjZXNzIjp7InJvbGVzIjpbIm9mZmxpbmVfYWNjZXNzIiwidW1hX2F1dGhvcml6YXRpb24iXX0sInJlc291cmNlX2FjY2VzcyI6eyJhY2NvdW50Ijp7InJvbGVzIjpbIm1hbmFnZS1hY2NvdW50IiwibWFuYWdlLWFjY291bnQtbGlua3MiLCJ2aWV3LXByb2ZpbGUiXX19LCJzY29wZSI6IldSSVRFX1NUVURFTlQgR1JBRF9CVVNJTkVTU19SIENSRUFURV9TVFVERU5UX1hNTF9UUkFOU0NSSVBUX1JFUE9SVCBDUkVBVEVfR1JBRF9BU1NFU1NNRU5UX1JFUVVJUkVNRU5UX0RBVEEgUkVBRF9TVFVERU5UIFJFQURfU0NIT09MIGVtYWlsIHByb2ZpbGUiLCJjbGllbnRJZCI6ImdyYWQtYWRtaW4tY2xpZW50IiwiZW1haWxfdmVyaWZpZWQiOmZhbHNlLCJjbGllbnRIb3N0IjoiMTQyLjMxLjQwLjE1NiIsInByZWZlcnJlZF91c2VybmFtZSI6InNlcnZpY2UtYWNjb3VudC1ncmFkLWFkbWluLWNsaWVudCIsImNsaWVudEFkZHJlc3MiOiIxNDIuMzEuNDAuMTU2In0.AqSxYzfanjhxCEuxLVHcJWA528AglXezS0-6EBohLsAJ4W1prdcrcS7p6yv1mSBs9GEkCu7SZhjl97xWaNXf7Emd4O0ieawgfXhDdgCtWtpLc0X2NjRTcZmv9kCpr__LmX4Zl3temUShNLVsSI95iBD7GKQmx_qTMpf3fiXdmmBvpZIibEly9RBbrio5DirqdYKuj0CO3x7xruBdBQnutr_GK7_vkmpw-X4RAyxsCwxSDequot1cCgMcJvPb6SxOL0BHx01OjM84FPwf2DwDrLvhXXhh4KucykUJ7QfiA5unmlLQ0wfG-bBJDwpjlXazF8jOQNEcasABVTftW6s8NA";
Expand Down
2 changes: 2 additions & 0 deletions api/src/test/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ endpoint:
grad-trax-api:
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-min-code:
url: https://educ-grad-trax-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/trax/district/%s

#Splunk LogHelper
splunk:
Expand Down

0 comments on commit 8c7d09d

Please sign in to comment.