use of org.sagebionetworks.bridge.services.RequestInfoService in project BridgeServer2 by Sage-Bionetworks.
the class BridgeUtilsTest method participantEligibleForDeletion_affiliatedResearcherAllowed.
@Test
public void participantEligibleForDeletion_affiliatedResearcherAllowed() {
RequestContext.set(new RequestContext.Builder().withOrgSponsoredStudies(USER_STUDY_IDS).withCallerRoles(ImmutableSet.of(RESEARCHER)).build());
RequestInfoService mockService = mock(RequestInfoService.class);
Account account = Account.create();
account.setEnrollments(STUDY_A_AND_B_ENROLLMENT);
assertTrue(participantEligibleForDeletion(mockService, account));
}
use of org.sagebionetworks.bridge.services.RequestInfoService in project BridgeServer2 by Sage-Bionetworks.
the class BridgeUtilsTest method participantEligibleForDeletion_multipleEnrollmentsFail.
@Test
public void participantEligibleForDeletion_multipleEnrollmentsFail() {
RequestContext.set(new RequestContext.Builder().withOrgSponsoredStudies(// mismatch
ImmutableSet.of("studyA", "studyC")).withCallerRoles(ImmutableSet.of(STUDY_COORDINATOR)).build());
RequestInfoService mockService = mock(RequestInfoService.class);
Account account = Account.create();
account.setEnrollments(STUDY_A_AND_B_ENROLLMENT);
assertFalse(participantEligibleForDeletion(mockService, account));
}
use of org.sagebionetworks.bridge.services.RequestInfoService in project BridgeServer2 by Sage-Bionetworks.
the class BridgeUtilsTest method participantEligibleForDeletion_testUserAllowedAfterSignIn.
@Test
public void participantEligibleForDeletion_testUserAllowedAfterSignIn() {
RequestInfoService mockService = mock(RequestInfoService.class);
Account account = Account.create();
account.setDataGroups(ImmutableSet.of(TEST_USER_GROUP));
// User has signed in, and is still eligible for deletion
RequestInfoService mockRequestService = mock(RequestInfoService.class);
RequestInfo requestInfo = new RequestInfo.Builder().withSignedInOn(CREATED_ON).build();
when(mockRequestService.getRequestInfo(TEST_USER_ID)).thenReturn(requestInfo);
assertTrue(participantEligibleForDeletion(mockService, account));
}
use of org.sagebionetworks.bridge.services.RequestInfoService in project BridgeServer2 by Sage-Bionetworks.
the class BridgeUtilsTest method participantEligibleForDeletion_affiliatedStudyCoordinatorAllowed.
@Test
public void participantEligibleForDeletion_affiliatedStudyCoordinatorAllowed() {
RequestContext.set(new RequestContext.Builder().withOrgSponsoredStudies(USER_STUDY_IDS).withCallerRoles(ImmutableSet.of(STUDY_COORDINATOR)).build());
RequestInfoService mockService = mock(RequestInfoService.class);
Account account = Account.create();
account.setEnrollments(STUDY_A_AND_B_ENROLLMENT);
assertTrue(participantEligibleForDeletion(mockService, account));
}
use of org.sagebionetworks.bridge.services.RequestInfoService in project BridgeServer2 by Sage-Bionetworks.
the class BridgeUtilsTest method participantEligibleForDeletion_testUserAllowed.
@Test
public void participantEligibleForDeletion_testUserAllowed() {
RequestInfoService mockService = mock(RequestInfoService.class);
Account account = Account.create();
account.setId(TEST_USER_ID);
// User hasn't signed in
RequestInfo requestInfo = new RequestInfo.Builder().build();
when(mockService.getRequestInfo(TEST_USER_ID)).thenReturn(requestInfo);
assertTrue(participantEligibleForDeletion(mockService, account));
}
Aggregations