@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());
  }
  /** Persist the form contents */
  @Override
  public boolean save(final AccommodationForm form) throws ObjectNotFoundException {
    if (form.getPerson() == null) {
      throw new ObjectNotFoundException("Missing (null) Person.", "Person");
    }

    final Person person = form.getPerson();

    // Save changes to persistent storage.
    personService.save(person);

    return true;
  }
  @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());
  }