Source:
<code>public void before() throws Exception { study = new DynamoStudy(); study.setUserProfileAttributes(Sets.newHashSet("foo","baz")); study.setIdentifier(TestConstants.TEST_STUDY_IDENTIFIER); participant = new StudyParticipant.Builder() .withRoles(CALLER_ROLES) <START> .withSubstudyIds(ImmutableSet.of("substudyA")) <END> .withId(ID).build(); session = new UserSession(participant); session.setAuthenticated(true); session.setStudyIdentifier(TestConstants.TEST_STUDY); session.setParticipant(participant); doReturn(session).when(controller).getSessionIfItExists(); when(mockStudyService.getStudy(TestConstants.TEST_STUDY)).thenReturn(study); when(mockStudyService.getStudy(TestConstants.TEST_STUDY_IDENTIFIER)).thenReturn(study); List<AccountSummary> summaries = Lists.newArrayListWithCapacity(3); summaries.add(SUMMARY); summaries.add(SUMMARY); summaries.add(SUMMARY); PagedResourceList<AccountSummary> page = new PagedResourceList<>(summaries, 30) .withRequestParam("offsetBy", 10) .withRequestParam("pageSize", 20) .withRequestParam("startTime", START_TIME) .withRequestParam("endTime", END_TIME) .withRequestParam("emailFilter", "foo"); when(authService.getSession(eq(study), any())).thenReturn(session); when(mockParticipantService.getPagedAccountSummaries(eq(study), any())).thenReturn(page); controller.setParticipantService(mockParticipantService); controller.setStudyService(mockStudyService); controller.setAuthenticationService(authService); controller.setCacheProvider(mockCacheProvider); controller.setUserAdminService(userAdminService); SessionUpdateService sessionUpdateService = new SessionUpdateService(); sessionUpdateService.setCacheProvider(mockCacheProvider); sessionUpdateService.setConsentService(mockConsentService); sessionUpdateService.setNotificationTopicService(mock(NotificationTopicService.class)); controller.setSessionUpdateService(sessionUpdateService); mockPlayContext(); }</code><technical_language>Minor: This test inconsistently teh CALLER_SUBS constant creates a new ImmutableSet fly</technical_language>

Target:
public void before() throws Exception { study = new DynamoStudy(); study.setUserProfileAttributes(Sets.newHashSet("foo","baz")); study.setIdentifier(TestConstants.TEST_STUDY_IDENTIFIER); participant = new StudyParticipant.Builder() .withRoles(CALLER_ROLES) .withSubstudyIds(CALLER_SUBS) .withId(ID).build(); session = new UserSession(participant); session.setAuthenticated(true); session.setStudyIdentifier(TestConstants.TEST_STUDY); session.setParticipant(participant); doReturn(session).when(controller).getSessionIfItExists(); when(mockStudyService.getStudy(TestConstants.TEST_STUDY)).thenReturn(study); when(mockStudyService.getStudy(TestConstants.TEST_STUDY_IDENTIFIER)).thenReturn(study); List<AccountSummary> summaries = Lists.newArrayListWithCapacity(3); summaries.add(SUMMARY); summaries.add(SUMMARY); summaries.add(SUMMARY); PagedResourceList<AccountSummary> page = new PagedResourceList<>(summaries, 30) .withRequestParam("offsetBy", 10) .withRequestParam("pageSize", 20) .withRequestParam("startTime", START_TIME) .withRequestParam("endTime", END_TIME) .withRequestParam("emailFilter", "foo"); when(authService.getSession(eq(study), any())).thenReturn(session); when(mockParticipantService.getPagedAccountSummaries(eq(study), any())).thenReturn(page); controller.setParticipantService(mockParticipantService); controller.setStudyService(mockStudyService); controller.setAuthenticationService(authService); controller.setCacheProvider(mockCacheProvider); controller.setUserAdminService(userAdminService); SessionUpdateService sessionUpdateService = new SessionUpdateService(); sessionUpdateService.setCacheProvider(mockCacheProvider); sessionUpdateService.setConsentService(mockConsentService); sessionUpdateService.setNotificationTopicService(mock(NotificationTopicService.class)); controller.setSessionUpdateService(sessionUpdateService); mockPlayContext(); }