@Test public void testGetAddressLabelsFiltersByCoachId() throws IOException, ObjectNotFoundException, JRException { final Person dennisRitchie = personService.get(Stubs.PersonFixture.DMR.id()); final Person kevinSmith = personService.get(Stubs.PersonFixture.KEVIN_SMITH.id()); dennisRitchie.setCoach(kevinSmith); personService.save(dennisRitchie); sessionFactory.getCurrentSession().flush(); final MockHttpServletResponse response = new MockHttpServletResponse(); // Alan Turing, i.e. the coach assigned to our test student users // in our standard fixture final UUID coachId = Stubs.PersonFixture.ADVISOR_0.id(); controller.getAddressLabels( response, null, coachId, null, null, null, null, null, null, null, null, null, null, null, null, null, "csv"); // "body" is the actual results and the header that describes its columns. // This is as opposed to rows which precede the header, which describe // the filtering criteria final List<String> expectedReportBodyLines = new ArrayList<String>(4); // same as in testGetAddressLabelsReturnsAllStudentsIfNoFiltersSet(), but // Dennis Ritchie is missing expectedReportBodyLines.add( "FIRST,MIDDLE,LAST, ID,TYPE,ADDRESS,CITY,ST,PHONE(H),EMAIL(SCHOOL),EMAIL(ALTERNATE)"); expectedReportBodyLines.add( "James,A,Gosling,student0,ILP,444 West Third Street ,San Francisco,CA,908-123-4567,[email protected],[email protected]"); expectedReportBodyLines.add( "Kenneth,L,Thompson,ken.1,CAP,444 West Third Street ,Murray Hill,NJ,908-123-4567,[email protected],[email protected]"); expectReportBodyLines(expectedReportBodyLines, response, null); }
@Test public void testGetAllCurrentCoachesFiltersDuplicates() throws ObjectNotFoundException { final Person jamesDoe = person(JAMES_DOE); final Person advisor0 = person(ADVISOR_0); jamesDoe.setCoach(advisor0); personService.save(jamesDoe); sessionFactory.getCurrentSession().flush(); final SortedSet<Person> result = personService.getAllCurrentCoaches(null); assertEquals(2, result.size()); }
@Override public EarlyAlert create(@NotNull final EarlyAlert earlyAlert) throws ObjectNotFoundException, ValidationException { // Validate objects if (earlyAlert == null) { throw new IllegalArgumentException("EarlyAlert must be provided."); } if (earlyAlert.getPerson() == null) { throw new ValidationException("EarlyAlert Student data must be provided."); } final Person student = earlyAlert.getPerson(); // Figure student advisor or early alert coordinator final UUID assignedAdvisor = getEarlyAlertAdvisor(earlyAlert); if (assignedAdvisor == null) { throw new ValidationException( "Could not determine the Early Alert Advisor for student ID " + student.getId()); } if (student.getCoach() == null || assignedAdvisor.equals(student.getCoach().getId())) { student.setCoach(personService.get(assignedAdvisor)); } ensureValidAlertedOnPersonStateNoFail(student); // Create alert final EarlyAlert saved = getDao().save(earlyAlert); // Send e-mail to assigned advisor (coach) try { sendMessageToAdvisor(saved, earlyAlert.getEmailCC()); } catch (final SendFailedException e) { LOGGER.warn("Could not send Early Alert message to advisor.", e); throw new ValidationException( "Early Alert notification e-mail could not be sent to advisor. Early Alert was NOT created.", e); } // Send e-mail CONFIRMATION to faculty try { sendConfirmationMessageToFaculty(saved); } catch (final SendFailedException e) { LOGGER.warn("Could not send Early Alert confirmation to faculty.", e); throw new ValidationException( "Early Alert confirmation e-mail could not be sent. Early Alert was NOT created.", e); } return saved; }
@Test public void testGetAllCurrentCoachesFiltersDuplicatesByIdNotName() throws ObjectNotFoundException { final String duplicatePersonSchoolId = ADVISOR_0.schoolId() + "_foo"; this.createExternalPerson( duplicatePersonSchoolId, ADVISOR_0.username() + "_foo", ADVISOR_0.firstName(), // everything else the same ADVISOR_0.lastName(), ADVISOR_0.middleName(), ADVISOR_0.primaryEmailAddress()); // this should create the person record Person duplicatePerson = personService.getBySchoolId(duplicatePersonSchoolId, true); assertNotNull(duplicatePerson); // sanity check final Person jamesDoe = person(JAMES_DOE); jamesDoe.setCoach(duplicatePerson); personService.save(jamesDoe); sessionFactory.getCurrentSession().flush(); final SortedSet<Person> result = personService.getAllCurrentCoaches(null); assertEquals(3, result.size()); }