@Test public void testGetAllCurrentCoachesLite() throws ObjectNotFoundException { final Collection<CoachPersonLiteTO> expected = Lists.newArrayList(coachPersonLiteTOFor(ADVISOR_0), coachPersonLiteTOFor(COACH_1)); final SortedSet<CoachPersonLiteTO> result1 = personService.getAllCurrentCoachesLite(null); assertCoachPersonLiteTOCollectionsEqual(expected, result1); final Set<String> newExternalCoachUsernames = addCoachesToExternalDataAndAttributeService(2); final SortedSet<CoachPersonLiteTO> result2 = personService.getAllCurrentCoachesLite(null); assertCoachPersonLiteTOCollectionsEqual(expected, result2); }
@Test public void testGetAllCurrentCoachesLiteFiltersDuplicates() 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<CoachPersonLiteTO> result = personService.getAllCurrentCoachesLite(null); assertEquals(2, result.size()); }
@Test public void testGetAllCurrentCoachesLiteFiltersDuplicatesByIdNotName() 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<CoachPersonLiteTO> result = personService.getAllCurrentCoachesLite(null); assertEquals(3, result.size()); }