private boolean hasVerifiedSponsorRole( FirebirdUser currentUser, UserSessionInformation sessionInformation) { for (SponsorRole role : currentUser.getSponsorRoles()) { if (sessionInformation.getGroupNames().contains(role.getVerifiedSponsorGroupName())) { return true; } } return false; }
public void remove(SponsorRole role) { ConfirmDialog confirmDialog = getListing(role).clickRemove(); confirmDialog .getHelper() .checkTitleAndMessage( role.getSponsor().getName(), role.getUser().getPerson().getDisplayName()); confirmDialog.clickConfirmButton(); WaitUtils.pause(100); // Sometimes too quick to check page after dialog closes. }
@Override public boolean isEquivalent(SponsorDelegateListing listing, SponsorRole sponsorRole) { return new EqualsBuilder() .append( listing.getDisplayName(), sponsorRole.getUser().getPerson().getDisplayNameForList()) .append(listing.getSponsor(), sponsorRole.getSponsor().getName()) .append(listing.getId(), sponsorRole.getId()) .isEquals(); }
@Override public void setUp() { super.setUp(); generator = new DcpSponsorTasksGenerator(templateService, mockRegistrationService, mockSponsorService); SponsorRole sponsorRole = sponsor.addSponsorRepresentativeRole(sponsorOrganization); groupNames.add(sponsorRole.getVerifiedSponsorGroupName()); List<AbstractProtocolRegistration> emptyList = Collections.emptyList(); when(mockRegistrationService.getByStatusForUser( any(RegistrationStatus.class), eq(sponsor), anySetOf(String.class))) .thenReturn(emptyList); }
@Test public void testGenerateTasks_RegistrationReadyForApproval_NotSponsorRepresentativeForProtocolSponsor() throws Exception { sponsor.getSponsorRoles().clear(); groupNames.clear(); SponsorRole sponsorDelegateRole = sponsor.addSponsorDelegateRole(sponsorOrganization); groupNames.add(sponsorDelegateRole.getVerifiedSponsorGroupName()); InvestigatorRegistration registration = RegistrationFactory.getInstance().createInvestigatorRegistration(ACCEPTED); setUpMockRegistrationServiceToReturnRegistration(registration); registration.getProtocol().setSponsor(sponsorOrganization); List<Task> tasks = generator.generateTasks(sponsor, groupNames); assertTrue(tasks.isEmpty()); }
@Test public void testPrepare() { FirebirdUser user = FirebirdUserFactory.getInstance().create(); Organization annualRegistrationSponsor = OrganizationFactory.getInstance().create(); Organization verifiedSponsor = OrganizationFactory.getInstance().create(); Organization unverifiedSponsor = OrganizationFactory.getInstance().create(); SponsorRole verifiedRole = user.addSponsorRepresentativeRole(verifiedSponsor); SponsorRole unverifiedRole = user.addSponsorRepresentativeRole(unverifiedSponsor); user.addSponsorRepresentativeRole(annualRegistrationSponsor); FirebirdWebTestUtility.setCurrentUser(action, user); UserSessionInformation userSessionInformation = UserSessionInformationFactory.getInstance() .create(user.getUsername(), verifiedRole.getVerifiedSponsorGroupName()); FirebirdWebTestUtility.setUpGridSessionInformation(action, userSessionInformation); when(mockSponsorService.getSponsorOrganizationWithAnnualRegistrations()) .thenReturn(annualRegistrationSponsor); action.prepare(); assertEquals(1, action.getUnverifiedSponsorRoles().size()); assertEquals(unverifiedRole, action.getUnverifiedSponsorRoles().get(0)); }