Search in sources :

Example 1 with RequestInfoService

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));
}
Also used : Account(org.sagebionetworks.bridge.models.accounts.Account) RequestInfoService(org.sagebionetworks.bridge.services.RequestInfoService) Test(org.testng.annotations.Test) AssessmentConfigValidatorTest(org.sagebionetworks.bridge.validators.AssessmentConfigValidatorTest)

Example 2 with RequestInfoService

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));
}
Also used : Account(org.sagebionetworks.bridge.models.accounts.Account) RequestInfoService(org.sagebionetworks.bridge.services.RequestInfoService) Test(org.testng.annotations.Test) AssessmentConfigValidatorTest(org.sagebionetworks.bridge.validators.AssessmentConfigValidatorTest)

Example 3 with RequestInfoService

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));
}
Also used : Account(org.sagebionetworks.bridge.models.accounts.Account) RequestInfoService(org.sagebionetworks.bridge.services.RequestInfoService) RequestInfo(org.sagebionetworks.bridge.models.RequestInfo) Test(org.testng.annotations.Test) AssessmentConfigValidatorTest(org.sagebionetworks.bridge.validators.AssessmentConfigValidatorTest)

Example 4 with RequestInfoService

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));
}
Also used : Account(org.sagebionetworks.bridge.models.accounts.Account) RequestInfoService(org.sagebionetworks.bridge.services.RequestInfoService) Test(org.testng.annotations.Test) AssessmentConfigValidatorTest(org.sagebionetworks.bridge.validators.AssessmentConfigValidatorTest)

Example 5 with RequestInfoService

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));
}
Also used : Account(org.sagebionetworks.bridge.models.accounts.Account) RequestInfoService(org.sagebionetworks.bridge.services.RequestInfoService) RequestInfo(org.sagebionetworks.bridge.models.RequestInfo) Test(org.testng.annotations.Test) AssessmentConfigValidatorTest(org.sagebionetworks.bridge.validators.AssessmentConfigValidatorTest)

Aggregations

Account (org.sagebionetworks.bridge.models.accounts.Account)12 RequestInfoService (org.sagebionetworks.bridge.services.RequestInfoService)12 AssessmentConfigValidatorTest (org.sagebionetworks.bridge.validators.AssessmentConfigValidatorTest)12 Test (org.testng.annotations.Test)12 RequestInfo (org.sagebionetworks.bridge.models.RequestInfo)3