Skip to content

Commit

Permalink
Test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
arybakov-cgi committed Nov 9, 2023
1 parent 660d094 commit a6b9e6b
Show file tree
Hide file tree
Showing 2 changed files with 149 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import ca.bc.gov.educ.grad.report.dao.ReportRequestDataThreadLocal;
import ca.bc.gov.educ.grad.report.entity.CertificateTypeCodeEntity;
import ca.bc.gov.educ.grad.report.entity.TranscriptTypeCodeEntity;
import ca.bc.gov.educ.grad.report.exception.ReportApiServiceException;
import org.apache.commons.lang3.StringUtils;
import org.junit.Before;
import org.junit.Test;
Expand Down Expand Up @@ -79,6 +80,18 @@ public void createSchoolDistributionReport() throws Exception {
LOG.debug(">createSchoolDistributionReport");
}

@Test(expected = ReportApiServiceException.class)
public void createSchoolDistributionReportException() throws Exception {
LOG.debug("<{}.createSchoolDistributionReportException at {}", CLASS_NAME, dateFormat.format(new Date()));
ReportRequest reportRequest = createReportRequest("json/schoolDistributionReportRequest.json");

assertNotNull(reportRequest);
reportRequest.setData(null);

apiReportService.getSchoolDistributionReport(reportRequest);
LOG.debug(">createSchoolDistributionReportException");
}

@Test
public void createDistrictDistributionYearEndReport() throws Exception {
LOG.debug("<{}.createDistrictDistributionYearEndReport at {}", CLASS_NAME, dateFormat.format(new Date()));
Expand Down Expand Up @@ -113,6 +126,19 @@ public void createDistrictDistributionYearEndReport() throws Exception {
LOG.debug(">createDistrictDistributionYearEndReport");
}

@Test(expected = ReportApiServiceException.class)
public void createDistrictDistributionYearEndReportException() throws Exception {
LOG.debug("<{}.createDistrictDistributionYearEndReport at {}", CLASS_NAME, dateFormat.format(new Date()));
ReportRequest reportRequest = createReportRequest("json/districtDistributionYearEndReportRequest.json");

assertNotNull(reportRequest);
reportRequest.setData(null);

apiReportService.getDistrictDistributionReportYearEnd(reportRequest);

LOG.debug(">createDistrictDistributionYearEndReport");
}

@Test
public void createDistrictDistributionYearEndNonGradReport() throws Exception {
LOG.debug("<{}.createDistrictDistributionYearEndNonGradReport at {}", CLASS_NAME, dateFormat.format(new Date()));
Expand Down Expand Up @@ -147,6 +173,19 @@ public void createDistrictDistributionYearEndNonGradReport() throws Exception {
LOG.debug(">createDistrictDistributionYearEndNonGradReport");
}

@Test(expected = ReportApiServiceException.class)
public void createDistrictDistributionYearEndNonGradReportException() throws Exception {
LOG.debug("<{}.createDistrictDistributionYearEndNonGradReportException at {}", CLASS_NAME, dateFormat.format(new Date()));
ReportRequest reportRequest = createReportRequest("json/districtDistributionYearEndNonGradReportRequest.json");

assertNotNull(reportRequest);
reportRequest.setData(null);

apiReportService.getDistrictDistributionReportYearEndNonGrad(reportRequest);

LOG.debug(">createDistrictDistributionYearEndNonGradReportException");
}

@Test
public void createSchoolDistributionYearEndReport() throws Exception {
LOG.debug("<{}.createSchoolDistributionYearEndReport at {}", CLASS_NAME, dateFormat.format(new Date()));
Expand Down Expand Up @@ -181,6 +220,13 @@ public void createSchoolDistributionYearEndReport() throws Exception {
LOG.debug(">createSchoolDistributionYearEndReport");
}

@Test(expected = ReportApiServiceException.class)
public void createSchoolDistributionYearEndReportException() throws Exception {
LOG.debug("<{}.createSchoolDistributionYearEndReportException at {}", CLASS_NAME, dateFormat.format(new Date()));
apiReportService.getSchoolDistributionReportYearEnd(null);
LOG.debug(">createSchoolDistributionYearEndReportException");
}

@Test
public void createSchoolDistributionReport_NOSTUDENTS() throws Exception {
LOG.debug("<{}.createSchoolDistributionReport_NOSTUDENTS at {}", CLASS_NAME, dateFormat.format(new Date()));
Expand Down Expand Up @@ -250,6 +296,19 @@ public void createSchoolLabelReport() throws Exception {
LOG.debug(">createSchoolLabelReport");
}

@Test(expected = ReportApiServiceException.class)
public void createSchoolLabelReportException() throws Exception {
LOG.debug("<{}.createSchoolLabelReportException at {}", CLASS_NAME, dateFormat.format(new Date()));
ReportRequest reportRequest = createReportRequest("json/schoolLabelReportRequest.json");

assertNotNull(reportRequest);
reportRequest.setData(null);

apiReportService.getSchoolLabelReport(reportRequest);

LOG.debug(">createSchoolLabelReportException");
}

@Test
public void createSchoolGraduationReport() throws Exception {
LOG.debug("<{}.createSchoolGraduationReport at {}", CLASS_NAME, dateFormat.format(new Date()));
Expand Down Expand Up @@ -277,6 +336,19 @@ public void createSchoolGraduationReport() throws Exception {
LOG.debug(">createSchoolGraduationReport");
}

@Test(expected = ReportApiServiceException.class)
public void createSchoolGraduationReportException() throws Exception {
LOG.debug("<{}.createSchoolGraduationReportException at {}", CLASS_NAME, dateFormat.format(new Date()));
ReportRequest reportRequest = createReportRequest("json/schoolGraduationReportRequest.json");

assertNotNull(reportRequest);
reportRequest.setData(null);

apiReportService.getSchoolGraduationReport(reportRequest);

LOG.debug(">createSchoolGraduationReportException");
}

@Test
public void createSchoolGraduationReport_NOSTUDENTS() throws Exception {
LOG.debug("<{}.createSchoolGraduationReport_NOSTUDENTS at {}", CLASS_NAME, dateFormat.format(new Date()));
Expand Down Expand Up @@ -325,6 +397,19 @@ public void createSchoolNonGraduationReport() throws Exception {
LOG.debug(">createSchoolNonGraduationReport");
}

@Test(expected = ReportApiServiceException.class)
public void createSchoolNonGraduationReportException() throws Exception {
LOG.debug("<{}.createSchoolNonGraduationReportException at {}", CLASS_NAME, dateFormat.format(new Date()));
ReportRequest reportRequest = createReportRequest("json/schoolNonGraduationReportRequest.json");

assertNotNull(reportRequest);
reportRequest.setData(null);

apiReportService.getSchoolNonGraduationReport(reportRequest);

LOG.debug(">createSchoolNonGraduationReportException");
}

@Test
public void createSchoolNonGraduationReport_NOSTUDENTS() throws Exception {
LOG.debug("<{}.createSchoolNonGraduationReport_NOSTUDENTS at {}", CLASS_NAME, dateFormat.format(new Date()));
Expand Down Expand Up @@ -367,6 +452,19 @@ public void createStudentNonGradReport() throws Exception {
LOG.debug(">createStudentNonGradReport");
}

@Test(expected = ReportApiServiceException.class)
public void createStudentNonGradReportException() throws Exception {
LOG.debug("<{}.createStudentNonGradReportException at {}", CLASS_NAME, dateFormat.format(new Date()));
ReportRequest reportRequest = createReportRequest("json/studentNonGradReportRequest.json");

assertNotNull(reportRequest);
reportRequest.setData(null);

apiReportService.getStudentNonGradReport(reportRequest);

LOG.debug(">createStudentNonGradReportException");
}

@Test
public void createStudentNonGradReport_NOSTUDENTS() throws Exception {
LOG.debug("<{}.createStudentNonGradReport_NOSTUDENTS at {}", CLASS_NAME, dateFormat.format(new Date()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.util.List;

import static org.junit.Assert.*;
import static org.mockito.Mockito.when;

@WebAppConfiguration
public class GradReportApiTranscriptServiceTests extends GradReportBaseTest {
Expand Down Expand Up @@ -79,6 +80,31 @@ public void createStudentAchievementReport() throws Exception {
LOG.debug(">createStudentAchievementReport");
}

@Test(expected = ReportApiServiceException.class)
public void createStudentAchievementReportException() throws Exception {
LOG.debug("<{}.createStudentAchievementReportException at {}", CLASS_NAME, dateFormat.format(new Date()));
ReportRequest reportRequest = createReportRequest("json/studentAchievementReportRequest.json");

assertNotNull(reportRequest);
assertNotNull(reportRequest.getData());

reportRequest.getData().setAccessToken("accessToken");

mockTraxSchool(adaptTraxSchool(getReportDataSchool(reportRequest.getData())));
ReportRequestDataThreadLocal.setReportData(reportRequest.getData());

String pen = reportRequest.getData().getStudent().getPen().getPen();
reportRequest.getOptions().setReportFile(String.format(reportRequest.getOptions().getReportFile(), pen));

GraduationStudentRecord graduationStudentRecord = mockGraduationStudentRecord(pen, mockGradSearchStudent(pen).getStudentID());
assertNotNull(graduationStudentRecord);
assertNotNull(graduationStudentRecord.getLastUpdateDate());

when(apiReportService.getStudentAchievementReportDocument(reportRequest)).thenThrow(new ReportApiServiceException(String.format("Unable to retrieve %s", "getStudentAchievementReport(ReportRequest reportRequest)"), new Exception()));
apiReportService.getStudentAchievementReport(reportRequest);
LOG.debug(">createStudentAchievementReportException");
}

@Test
public void createStudentAchievementReportError() throws Exception {
LOG.debug("<{}.createStudentAchievementReportError at {}", CLASS_NAME, dateFormat.format(new Date()));
Expand Down Expand Up @@ -420,6 +446,31 @@ public void createXmlTranscriptReport() throws Exception {
LOG.debug(">createXmlTranscriptReport");
}

@Test(expected = ReportApiServiceException.class)
public void createXmlTranscriptReportException() throws Exception {
LOG.debug("<{}.createXmlTranscriptReportException at {}", CLASS_NAME, dateFormat.format(new Date()));
XmlReportRequest reportRequest = createXmlReportRequest("json/xmlTranscriptReportRequest.json");

assertNotNull(reportRequest);
assertNotNull(reportRequest.getData());

reportRequest.getData().setAccessToken("accessToken");

ReportRequestDataThreadLocal.setXmlReportData(reportRequest.getData());

String pen = reportRequest.getData().getPen().getPen();
reportRequest.getOptions().setReportFile(String.format(reportRequest.getOptions().getReportFile(), pen));

GraduationStudentRecord graduationStudentRecord = mockGraduationStudentRecord(pen, mockGradSearchStudent(pen).getStudentID());
assertNotNull(graduationStudentRecord);
assertNotNull(graduationStudentRecord.getLastUpdateDate());

when(apiReportService.getStudentXmlTranscriptReportDocument(reportRequest)).thenThrow(new ReportApiServiceException(String.format("Unable to retrieve %s", "getStudentXmlTranscriptReport(XmlReportRequest reportRequest)"), new Exception()));
apiReportService.getStudentXmlTranscriptReport(reportRequest);

LOG.debug(">createXmlTranscriptReportException");
}

@Test
public void createTranscriptReportDuplicateInterimCourses_BC2018_PUB() throws Exception {
LOG.debug("<{}.createTranscriptReportDuplicateInterimCourses_BC2018_PUB at {}", CLASS_NAME, dateFormat.format(new Date()));
Expand Down

0 comments on commit a6b9e6b

Please sign in to comment.