Search in sources :

Example 1 with PenRequestBatchReportData

use of ca.bc.gov.educ.penreg.api.struct.v1.reportstructs.PenRequestBatchReportData in project EDUC-PEN-REG-BATCH-API by bcgov.

the class PenRequestBatchReportDataMapperTest method testToReportUserMatchedListItem_GivenNullStudent_ShouldNotThrowError.

@Test
public void testToReportUserMatchedListItem_GivenNullStudent_ShouldNotThrowError() throws IOException {
    final var batchEntities = PenRequestBatchTestUtils.createBatchStudents(this.repository, "mock_pen_req_batch_repeat.json", "mock_pen_req_batch_student_archived_with_pen.json", 1, (batch) -> batch.setProcessDate(LocalDateTime.parse("2021-03-23T13:04:48.840098")));
    final var student = Student.builder().studentID("566ee980-8e5f-11eb-8dcd-0242ac130009").pen("123456780").build();
    final List<Student> students = new ArrayList<>();
    students.add(student);
    final var sagaData = PenRequestBatchArchiveAndReturnSagaData.builder().facsimile("3333333333").telephone("5555555555").fromEmail("test@abc.com").mailingAddress("mailing address").students(students).penCoordinator(PenCoordinator.builder().penCoordinatorEmail("test@email.com").penCoordinatorName("Joe Blow").build()).schoolName("Cataline").penRequestBatch(mapper.toStructure(batchEntities.get(0))).penRequestBatchStudents(batchEntities.get(0).getPenRequestBatchStudentEntities().stream().map(studentMapper::toStructure).collect(Collectors.toList())).penRequestBatchStudentValidationIssues(new HashMap<>()).build();
    final PenRequestBatchReportData reportData = reportMapper.toReportData(sagaData);
    assertThat(reportData.getDiffList().size()).isEqualTo(1);
}
Also used : HashMap(java.util.HashMap) PenRequestBatchReportData(ca.bc.gov.educ.penreg.api.struct.v1.reportstructs.PenRequestBatchReportData) ArrayList(java.util.ArrayList) Student(ca.bc.gov.educ.penreg.api.struct.Student) BasePenRegAPITest(ca.bc.gov.educ.penreg.api.BasePenRegAPITest) Test(org.junit.Test)

Example 2 with PenRequestBatchReportData

use of ca.bc.gov.educ.penreg.api.struct.v1.reportstructs.PenRequestBatchReportData in project EDUC-PEN-REG-BATCH-API by bcgov.

the class PenRequestBatchReportDataMapperTest method testToReportUserMatchedListItem_GivenNullValues_ShouldMapSuccessfully.

@Test
public void testToReportUserMatchedListItem_GivenNullValues_ShouldMapSuccessfully() throws IOException {
    final var batchEntities = PenRequestBatchTestUtils.createBatchStudents(this.repository, "mock_pen_req_batch_repeat.json", "mock_pen_req_batch_student_null_data.json", 1, (batch) -> batch.setProcessDate(LocalDateTime.parse("2021-03-23T13:04:48.840098")));
    final var student1 = Student.builder().studentID("566ee980-8e5f-11eb-8dcd-0242ac130002").pen("123456785").demogCode("C").build();
    final var student2 = Student.builder().studentID("566ee980-8e5f-11eb-8dcd-0242ac130003").pen("123456780").legalLastName("BILL").build();
    final List<Student> students = new ArrayList<>();
    students.add(student1);
    students.add(student2);
    final var sagaData = PenRequestBatchArchiveAndReturnSagaData.builder().facsimile("3333333333").telephone("5555555555").fromEmail("test@abc.com").mailingAddress("mailing address").schoolName("Cataline").penRequestBatch(mapper.toStructure(batchEntities.get(0))).penRequestBatchStudents(batchEntities.get(0).getPenRequestBatchStudentEntities().stream().map(studentMapper::toStructure).collect(Collectors.toList())).penRequestBatchStudentValidationIssues(new HashMap<>()).students(students).build();
    final PenRequestBatchReportData reportData = reportMapper.toReportData(sagaData);
    assertThat(reportData.getProcessDate()).isEqualTo("2021/03/23");
    assertThat(reportData.getProcessTime()).isEqualTo("13:04");
    assertThat(reportData.getSubmissionNumber()).isEqualTo(batchEntities.get(0).getSubmissionNumber());
    assertThat(reportData.getReportDate()).isEqualTo("2021-MAR-23");
    assertThat(reportData.getReviewer()).isEqualTo("School PEN Coordinator");
    assertThat(reportData.getMincode()).isEqualTo(formatMincode(batchEntities.get(0).getMincode()));
    assertThat(reportData.getSchoolName()).isEqualTo("Cataline");
    assertThat(reportData.getFascimile()).isEqualTo("3333333333");
    assertThat(reportData.getTelephone()).isEqualTo("5555555555");
    assertThat(reportData.getMailingAddress()).isEqualTo("mailing address");
    assertThat(reportData.getPenCordinatorEmail()).isEqualTo("test@abc.com");
    assertThat(reportData.getDiffList().size()).isEqualTo(1);
    assertThat(reportData.getDiffList().get(0).getMin().getBirthDate()).isEqualTo("");
    assertThat(reportData.getDiffList().get(0).getMin().getGender()).isEqualTo("");
    assertThat(reportData.getDiffList().get(0).getMin().getGivenName()).isEqualTo("");
    assertThat(reportData.getDiffList().get(0).getMin().getLegalMiddleNames()).isEqualTo("");
    assertThat(reportData.getDiffList().get(0).getMin().getPen()).isEqualTo("123456780");
    assertThat(reportData.getDiffList().get(0).getMin().getReason()).isEqualTo(null);
    assertThat(reportData.getDiffList().get(0).getMin().getSchoolID()).isEqualTo("");
    assertThat(reportData.getDiffList().get(0).getMin().getSurname()).isEqualTo("BILL");
    assertThat(reportData.getDiffList().get(0).getMin().getUsualName()).isEqualTo("");
    assertThat(reportData.getDiffList().size()).isEqualTo(1);
    assertThat(reportData.getDiffList().get(0).getSchool().getBirthDate()).isEqualTo("");
    assertThat(reportData.getDiffList().get(0).getSchool().getGender()).isEqualTo("");
    assertThat(reportData.getDiffList().get(0).getSchool().getGivenName()).isEqualTo("");
    assertThat(reportData.getDiffList().get(0).getSchool().getLegalMiddleNames()).isEqualTo("");
    assertThat(reportData.getDiffList().get(0).getSchool().getPen()).isEqualTo("");
    assertThat(reportData.getDiffList().get(0).getSchool().getReason()).isEqualTo(null);
    assertThat(reportData.getDiffList().get(0).getSchool().getSchoolID()).isEqualTo("");
    assertThat(reportData.getDiffList().get(0).getSchool().getSurname()).isEqualTo("");
    assertThat(reportData.getDiffList().get(0).getSchool().getUsualName()).isEqualTo("");
    assertThat(reportData.getSysMatchedList().size()).isEqualTo(2);
    assertThat(reportData.getSysMatchedList().get(1).getBirthDate()).isEqualTo("");
    assertThat(reportData.getSysMatchedList().get(1).getGender()).isEqualTo("");
    assertThat(reportData.getSysMatchedList().get(1).getGivenName()).isEqualTo("");
    assertThat(reportData.getSysMatchedList().get(1).getLegalMiddleNames()).isEqualTo("");
    assertThat(reportData.getSysMatchedList().get(1).getPen()).isEqualTo("");
    assertThat(reportData.getSysMatchedList().get(1).getReason()).isEqualTo(null);
    assertThat(reportData.getSysMatchedList().get(1).getSchoolID()).isEqualTo("");
    assertThat(reportData.getSysMatchedList().get(1).getSurname()).isEqualTo("");
    assertThat(reportData.getSysMatchedList().get(1).getUsualName()).isEqualTo("");
    assertThat(reportData.getNewPenList().size()).isEqualTo(2);
    assertThat(reportData.getPendingList().size()).isEqualTo(4);
    assertThat(reportData.getSysMatchedList().size()).isEqualTo(2);
}
Also used : PenRequestBatchReportData(ca.bc.gov.educ.penreg.api.struct.v1.reportstructs.PenRequestBatchReportData) ArrayList(java.util.ArrayList) Student(ca.bc.gov.educ.penreg.api.struct.Student) BasePenRegAPITest(ca.bc.gov.educ.penreg.api.BasePenRegAPITest) Test(org.junit.Test)

Example 3 with PenRequestBatchReportData

use of ca.bc.gov.educ.penreg.api.struct.v1.reportstructs.PenRequestBatchReportData in project EDUC-PEN-REG-BATCH-API by bcgov.

the class PenRequestBatchReportDataMapperTest method testToReportUserMatchedListItem_GivenBadDOB_ShouldMapSuccessfully.

@Test
public void testToReportUserMatchedListItem_GivenBadDOB_ShouldMapSuccessfully() throws IOException {
    final var batchEntities = PenRequestBatchTestUtils.createBatchStudents(this.repository, "mock_pen_req_batch_repeat.json", "mock_pen_req_batch_student_bad_dob.json", 1, (batch) -> batch.setProcessDate(LocalDateTime.parse("2021-03-23T13:04:48.840098")));
    final var student = Student.builder().studentID("566ee980-8e5f-11eb-8dcd-0242ac130003").dob("19900734").genderCode("F").legalFirstName("Ted").pen("123456780").legalLastName("Jones").legalMiddleNames("Jim").usualFirstName("Steal").usualLastName("Mr").usualMiddleNames("Yo Girl").mincode(batchEntities.get(0).getMincode()).demogCode("A").build();
    final List<Student> students = new ArrayList<>();
    students.add(student);
    final var sagaData = PenRequestBatchArchiveAndReturnSagaData.builder().facsimile("3333333333").telephone("5555555555").fromEmail("test@abc.com").mailingAddress("mailing address").penCoordinator(PenCoordinator.builder().penCoordinatorEmail("test@email.com").penCoordinatorName("Joe Blow").build()).schoolName("Cataline").penRequestBatch(mapper.toStructure(batchEntities.get(0))).penRequestBatchStudents(batchEntities.get(0).getPenRequestBatchStudentEntities().stream().map(studentMapper::toStructure).collect(Collectors.toList())).students(students).build();
    final PenRequestBatchReportData reportData = reportMapper.toReportData(sagaData);
    assertThat(reportData.getDiffList().size()).isEqualTo(1);
    assertThat(reportData.getDiffList().get(0).getSchool().getBirthDate()).isEqualTo("20111234");
    assertThat(reportData.getDiffList().get(0).getMin().getBirthDate()).isEqualTo("19900734");
}
Also used : PenRequestBatchReportData(ca.bc.gov.educ.penreg.api.struct.v1.reportstructs.PenRequestBatchReportData) ArrayList(java.util.ArrayList) Student(ca.bc.gov.educ.penreg.api.struct.Student) BasePenRegAPITest(ca.bc.gov.educ.penreg.api.BasePenRegAPITest) Test(org.junit.Test)

Example 4 with PenRequestBatchReportData

use of ca.bc.gov.educ.penreg.api.struct.v1.reportstructs.PenRequestBatchReportData in project EDUC-PEN-REG-BATCH-API by bcgov.

the class PenRequestBatchReportDataMapperTest method testToReportUserMatchedListItem_GivenAllValues_ShouldMapSuccessfully.

@Test
public void testToReportUserMatchedListItem_GivenAllValues_ShouldMapSuccessfully() throws IOException {
    final var batchEntities = PenRequestBatchTestUtils.createBatchStudents(this.repository, "mock_pen_req_batch_repeat.json", "mock_pen_req_batch_student_archived_with_pen.json", 1, (batch) -> batch.setProcessDate(LocalDateTime.parse("2021-03-23T13:04:48.840098")));
    final var student1 = Student.builder().studentID("566ee980-8e5f-11eb-8dcd-0242ac130002").dob("1990-07-04").genderCode("M").legalFirstName("Mike").pen("123456785").legalLastName("Joe").legalMiddleNames("Tim").usualFirstName("Bob").usualLastName("Smithy").usualMiddleNames("Smalls").mincode(batchEntities.get(0).getMincode()).demogCode("C").build();
    final var student3 = Student.builder().studentID("566ee980-8e5f-11eb-8dcd-0242ac130009").dob("2011-12-07").genderCode("M").sexCode("M").legalFirstName("BRAYDON").pen("123456784").legalLastName("JOSEPH").legalMiddleNames("JAMIESON").usualFirstName("BRAYDON").usualLastName("JOSEPH").usualMiddleNames(null).mincode(batchEntities.get(0).getMincode()).demogCode("A").build();
    final List<Student> students = new ArrayList<>();
    students.add(student1);
    students.add(student3);
    final var sagaData = PenRequestBatchArchiveAndReturnSagaData.builder().facsimile("3333333333").telephone("5555555555").fromEmail("test@abc.com").mailingAddress("mailing address").penCoordinator(PenCoordinator.builder().penCoordinatorEmail("test@email.com").penCoordinatorName("Joe Blow").build()).schoolName("Cataline").penRequestBatch(mapper.toStructure(batchEntities.get(0))).penRequestBatchStudents(batchEntities.get(0).getPenRequestBatchStudentEntities().stream().map(studentMapper::toStructure).collect(Collectors.toList())).penRequestBatchStudentValidationIssues(new HashMap<>()).students(students).build();
    final PenRequestBatchReportData reportData = reportMapper.toReportData(sagaData);
    assertThat(reportData.getProcessDate()).isEqualTo("2021/03/23");
    assertThat(reportData.getProcessTime()).isEqualTo("13:04");
    assertThat(reportData.getSubmissionNumber()).isEqualTo(batchEntities.get(0).getSubmissionNumber());
    assertThat(reportData.getReportDate()).isEqualTo("2021-MAR-23");
    assertThat(reportData.getReviewer()).isEqualTo("Joe Blow");
    assertThat(reportData.getMincode()).isEqualTo(formatMincode(batchEntities.get(0).getMincode()));
    assertThat(reportData.getSchoolName()).isEqualTo("Cataline");
    assertThat(reportData.getFascimile()).isEqualTo("3333333333");
    assertThat(reportData.getTelephone()).isEqualTo("5555555555");
    assertThat(reportData.getMailingAddress()).isEqualTo("mailing address");
    assertThat(reportData.getPenCordinatorEmail()).isEqualTo("test@abc.com");
    assertThat(reportData.getDiffList().size()).isEqualTo(1);
    assertThat(reportData.getDiffList().get(0).getMin().getBirthDate()).isEqualTo("1990/07/04");
    assertThat(reportData.getDiffList().get(0).getMin().getGender()).isEqualTo("M");
    assertThat(reportData.getDiffList().get(0).getMin().getGivenName()).isEqualTo("Mike");
    assertThat(reportData.getDiffList().get(0).getMin().getLegalMiddleNames()).isEqualTo("Tim");
    assertThat(reportData.getDiffList().get(0).getMin().getPen()).isEqualTo("123456785");
    assertThat(reportData.getDiffList().get(0).getMin().getReason()).isNull();
    assertThat(reportData.getDiffList().get(0).getMin().getSchoolID()).isBlank();
    assertThat(reportData.getDiffList().get(0).getMin().getSurname()).isEqualTo("Joe");
    assertThat(reportData.getDiffList().get(0).getMin().getUsualName()).isEqualTo("JOSEPH, BRAYDON, KIM");
    assertThat(reportData.getDiffList().get(0).getSchool().getBirthDate()).isEqualTo("2011/12/08");
    assertThat(reportData.getDiffList().get(0).getSchool().getGender()).isEqualTo("M");
    assertThat(reportData.getDiffList().get(0).getSchool().getGivenName()).isEqualTo("BRAYDON");
    assertThat(reportData.getDiffList().get(0).getSchool().getLegalMiddleNames()).isEqualTo("JAMIESON");
    assertThat(reportData.getDiffList().get(0).getSchool().getPen()).isEqualTo("123456785");
    assertThat(reportData.getDiffList().get(0).getSchool().getReason()).isEqualTo("Here's some info");
    assertThat(reportData.getDiffList().get(0).getSchool().getSchoolID()).isEqualTo("2046302");
    assertThat(reportData.getDiffList().get(0).getSchool().getSurname()).isEqualTo("JOSEPH");
    assertThat(reportData.getDiffList().get(0).getSchool().getUsualName()).isEqualTo("JOSEPH, BRAYDON, KIM");
    assertThat(reportData.getNewPenList().size()).isEqualTo(1);
    assertThat(reportData.getPendingList().size()).isEqualTo(5);
    // exact match
    assertThat(reportData.getSysMatchedList().size()).isEqualTo(1);
}
Also used : PenRequestBatchReportData(ca.bc.gov.educ.penreg.api.struct.v1.reportstructs.PenRequestBatchReportData) ArrayList(java.util.ArrayList) Student(ca.bc.gov.educ.penreg.api.struct.Student) BasePenRegAPITest(ca.bc.gov.educ.penreg.api.BasePenRegAPITest) Test(org.junit.Test)

Example 5 with PenRequestBatchReportData

use of ca.bc.gov.educ.penreg.api.struct.v1.reportstructs.PenRequestBatchReportData in project EDUC-PEN-REG-BATCH-API by bcgov.

the class PenRequestBatchReportDataDecorator method toReportData.

/**
 * To pen request batch student entity pen request batch student entity.
 *
 * @param data the saga data
 * @return the pen request batch report data entity
 */
@Override
public PenRequestBatchReportData toReportData(final BasePenRequestBatchReturnFilesSagaData data) {
    final var reportData = this.delegate.toReportData(data);
    final List<ReportListItem> pendingList = new ArrayList<>();
    final List<ReportListItem> newPenList = new ArrayList<>();
    final List<ReportListItem> sysMatchedList = new ArrayList<>();
    final List<ReportUserMatchedListItem> diffList = new ArrayList<>();
    final List<ReportUserMatchedListItem> confirmedList = new ArrayList<>();
    if (data != null && !CollectionUtils.isEmpty(data.getPenRequestBatchStudents())) {
        final Map<String, Student> students = this.setStudents(data.getStudents());
        for (final PenRequestBatchStudent penRequestBatchStudent : data.getPenRequestBatchStudents()) {
            switch(Objects.requireNonNull(PenRequestBatchStudentStatusCodes.valueOfCode(penRequestBatchStudent.getPenRequestBatchStudentStatusCode()))) {
                case DUPLICATE:
                case ERROR:
                case REPEAT:
                case INFOREQ:
                case FIXABLE:
                    val issues = data.getPenRequestBatchStudentValidationIssues().get(penRequestBatchStudent.getPenRequestBatchStudentID());
                    val pendingItem = listItemMapper.toReportListItem(penRequestBatchStudent, issues);
                    if (!"Duplicate".equals(pendingItem.getPen())) {
                        pendingItem.setPen("Pending");
                    }
                    pendingList.add(pendingItem);
                    break;
                case SYS_NEW_PEN:
                case USR_NEW_PEN:
                    this.populateForNewPenStatus(newPenList, students, penRequestBatchStudent);
                    break;
                case SYS_MATCHED:
                    this.populateForSystemMatchedStatus(sysMatchedList, diffList, students, penRequestBatchStudent);
                    break;
                case USR_MATCHED:
                    this.populateForUserMatchedStatus(sysMatchedList, diffList, students, penRequestBatchStudent);
                    break;
                default:
                    log.error("Unexpected pen request batch student status code encountered while attempting generate report data :: " + penRequestBatchStudent.getPenRequestBatchStudentStatusCode());
                    break;
            }
        }
        val processDateTime = data.getPenRequestBatch() == null || data.getPenRequestBatch().getProcessDate() == null ? LocalDateTime.now() : LocalDateTime.parse(data.getPenRequestBatch().getProcessDate());
        reportData.setProcessDate(processDateTime.format(DateTimeFormatter.ofPattern("yyyy/MM/dd")));
        reportData.setProcessTime(processDateTime.format(DateTimeFormatter.ofPattern("HH:mm")));
        reportData.setReportDate(processDateTime.format(DateTimeFormatter.ofPattern("yyyy-MMM-dd")).toUpperCase().replace(".", ""));
        reportData.setReviewer(this.setReviewer(data.getPenCoordinator()));
    }
    reportData.setSysMatchedList(sysMatchedList);
    reportData.setPendingList(pendingList);
    reportData.setNewPenList(newPenList);
    reportData.setDiffList(diffList);
    reportData.setConfirmedList(confirmedList);
    return reportData;
}
Also used : lombok.val(lombok.val) ReportUserMatchedListItem(ca.bc.gov.educ.penreg.api.struct.v1.reportstructs.ReportUserMatchedListItem) ReportListItem(ca.bc.gov.educ.penreg.api.struct.v1.reportstructs.ReportListItem) PenRequestBatchStudent(ca.bc.gov.educ.penreg.api.struct.v1.PenRequestBatchStudent) Student(ca.bc.gov.educ.penreg.api.struct.Student) PenRequestBatchStudent(ca.bc.gov.educ.penreg.api.struct.v1.PenRequestBatchStudent)

Aggregations

Student (ca.bc.gov.educ.penreg.api.struct.Student)5 BasePenRegAPITest (ca.bc.gov.educ.penreg.api.BasePenRegAPITest)4 PenRequestBatchReportData (ca.bc.gov.educ.penreg.api.struct.v1.reportstructs.PenRequestBatchReportData)4 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 PenRequestBatchStudent (ca.bc.gov.educ.penreg.api.struct.v1.PenRequestBatchStudent)1 ReportListItem (ca.bc.gov.educ.penreg.api.struct.v1.reportstructs.ReportListItem)1 ReportUserMatchedListItem (ca.bc.gov.educ.penreg.api.struct.v1.reportstructs.ReportUserMatchedListItem)1 HashMap (java.util.HashMap)1 lombok.val (lombok.val)1