@Test public void testGenerateTasks_CtepSponsor() throws Exception { Set<String> groupNames = Sets.newHashSet(); sponsor.getSponsorRoles().clear(); Organization ctepSponsor = new Organization(); sponsor.addSponsorRepresentativeRole(ctepSponsor); when(mockSponsorService.getSponsorOrganizationWithAnnualRegistrations()) .thenReturn(ctepSponsor); List<Task> tasks = generator.generateTasks(sponsor, groupNames); assertTrue(tasks.isEmpty()); }
@Override public void setUp() throws Exception { super.setUp(); FirebirdUser investigator = builder.createInvestigatorWithCompleteProfile().get(); Protocol protocol = builder.createProtocol().withProtocolRevision("comment", "some modification").get(); builder .createRegistration(protocol, investigator.getInvestigatorRole().getProfile()) .complete() .withStatus(RegistrationStatus.IN_PROGRESS) .get(); builder.createCoordinator().withApprovedMangedInvestigator(investigator); dataSet = builder.build(); }
@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()); }
private boolean hasVerifiedSponsorRole( FirebirdUser currentUser, UserSessionInformation sessionInformation) { for (SponsorRole role : currentUser.getSponsorRoles()) { if (sessionInformation.getGroupNames().contains(role.getVerifiedSponsorGroupName())) { return true; } } return false; }
@Override @Before public void setUp() throws Exception { super.setUp(); action.setServletRequest(getMockRequest()); setAccountConfigurationDataInSession(getAccountConfigurationData()); action.prepare(); user.setId(1L); setUpGridSessionInformation(); }
@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 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)); }
public void setUpGridSessionInformation(String... groupNames) { UserSessionInformation sessionInformation = UserSessionInformationFactory.getInstance().create(user.getUsername(), groupNames); FirebirdWebTestUtility.setUpGridSessionInformation(action, sessionInformation); }