@Test public void testGetAllAssignedCoaches() throws ObjectNotFoundException { // basically the same as testGetAllAssignedCoachesLite() except // we expect Persons instead final Collection<UUID> expected = Lists.newArrayList(ADVISOR_0.id(), COACH_1.id()); final PagingWrapper<Person> result1 = personService.getAllAssignedCoaches(null); assertPersonCollectionsHaveSameIds(expected, result1.getRows()); // zero b/c the request specified no pagination, so impl skips total // result size calculation assertEquals(0, result1.getResults()); // now prove that getAllAssignedCoaches() doesn't lazily // create/return new coaches by creating a fixture where it could do so, // run the same method again, then checking that we get the exact // same results as before final Set<String> newExternalCoachUsernames = addCoachesToExternalDataAndAttributeService(5); final PagingWrapper<Person> result2 = personService.getAllAssignedCoaches(null); assertPersonCollectionsHaveSameIds(expected, result2.getRows()); // zero b/c the request specified no pagination, so impl skips total // result size calculation assertEquals(0, result2.getResults()); }
@Test public void testGetAllCurrentCoaches() throws ObjectNotFoundException { // unlike the getAllAssignedCoaches()/getAllAssignedCoachesLite() // pair, getAllCurrentCoaches()/getAllCurrentCoachesLite() have // significantly different behavior. Specifically the non-lite version, // tested here, *does* lazily create and return new Persons. The lite // version does not. final SortedSet<Person> result1 = personService.getAllCurrentCoaches(null); assertPersonCollectionsHaveSameIds(Lists.newArrayList(ADVISOR_0.id(), COACH_1.id()), result1); final Set<String> newExternalCoachUsernames = addCoachesToExternalDataAndAttributeService(2); final SortedSet<Person> result2 = personService.getAllCurrentCoaches(null); assertPersonCollectionsHaveSameIds( Lists.newArrayList( personService.personFromUsername("bulk_coach_001").getId(), personService.personFromUsername("bulk_coach_002").getId(), ADVISOR_0.id(), COACH_1.id()), result2); }