Search in sources :

Example 1 with DynamoStudyConsent1

use of org.sagebionetworks.bridge.dynamodb.DynamoStudyConsent1 in project BridgeServer2 by Sage-Bionetworks.

the class StudyConsentControllerTest method getConsentV2.

@Test
public void getConsentV2() throws Exception {
    doReturn(session).when(controller).getAuthenticatedSession(DEVELOPER);
    StudyConsentView view = new StudyConsentView(new DynamoStudyConsent1(), "<document/>");
    when(mockStudyConsentService.getConsent(SUBPOP_GUID, DateTime.parse(DATETIME_STRING).getMillis())).thenReturn(view);
    StudyConsentView result = controller.getConsentV2(GUID, DATETIME_STRING);
    assertEquals(result.getDocumentContent(), "<document/>");
}
Also used : DynamoStudyConsent1(org.sagebionetworks.bridge.dynamodb.DynamoStudyConsent1) StudyConsentView(org.sagebionetworks.bridge.models.subpopulations.StudyConsentView) Test(org.testng.annotations.Test)

Example 2 with DynamoStudyConsent1

use of org.sagebionetworks.bridge.dynamodb.DynamoStudyConsent1 in project BridgeServer2 by Sage-Bionetworks.

the class StudyConsentControllerTest method getAllConsentsV2.

@Test
public void getAllConsentsV2() throws Exception {
    doReturn(session).when(controller).getAuthenticatedSession(DEVELOPER);
    List<StudyConsent> consents = Lists.newArrayList(new DynamoStudyConsent1(), new DynamoStudyConsent1());
    when(mockStudyConsentService.getAllConsents(SUBPOP_GUID)).thenReturn(consents);
    ResourceList<StudyConsent> result = controller.getAllConsentsV2(GUID);
    // Do not need to extensively verify, just verify contents are returned in ResourceList
    assertEquals(result.getItems(), consents);
}
Also used : StudyConsent(org.sagebionetworks.bridge.models.subpopulations.StudyConsent) DynamoStudyConsent1(org.sagebionetworks.bridge.dynamodb.DynamoStudyConsent1) Test(org.testng.annotations.Test)

Example 3 with DynamoStudyConsent1

use of org.sagebionetworks.bridge.dynamodb.DynamoStudyConsent1 in project BridgeServer2 by Sage-Bionetworks.

the class SubpopulationServiceTest method createDefaultSubpopulationWhereNoConsents.

@Test
public void createDefaultSubpopulationWhereNoConsents() {
    App app = new DynamoApp();
    app.setIdentifier(TEST_APP_ID);
    StudyConsentView view = new StudyConsentView(new DynamoStudyConsent1(), "");
    Subpopulation subpop = Subpopulation.create();
    SubpopulationGuid defaultGuid = SubpopulationGuid.create(TEST_APP_ID);
    subpop.setGuid(defaultGuid);
    ArgumentCaptor<StudyConsentForm> captor = ArgumentCaptor.forClass(StudyConsentForm.class);
    when(studyConsentService.getAllConsents(defaultGuid)).thenReturn(ImmutableList.of());
    when(studyConsentService.addConsent(eq(defaultGuid), any())).thenReturn(view);
    when(subpopDao.createDefaultSubpopulation(app.getIdentifier(), TEST_STUDY_ID)).thenReturn(subpop);
    Study study = Study.create();
    study.setIdentifier(TEST_STUDY_ID);
    // No consents, so we add and publish one.
    Subpopulation returnValue = service.createDefaultSubpopulation(app, study);
    verify(studyConsentService).addConsent(any(), captor.capture());
    verify(studyConsentService).publishConsent(eq(app), eq(subpop), any(Long.class));
    assertEquals(returnValue, subpop);
    // This used the default document.
    assertEquals(captor.getValue(), form);
}
Also used : DynamoApp(org.sagebionetworks.bridge.dynamodb.DynamoApp) App(org.sagebionetworks.bridge.models.apps.App) Study(org.sagebionetworks.bridge.models.studies.Study) DynamoApp(org.sagebionetworks.bridge.dynamodb.DynamoApp) DynamoStudyConsent1(org.sagebionetworks.bridge.dynamodb.DynamoStudyConsent1) DynamoSubpopulation(org.sagebionetworks.bridge.dynamodb.DynamoSubpopulation) Subpopulation(org.sagebionetworks.bridge.models.subpopulations.Subpopulation) StudyConsentView(org.sagebionetworks.bridge.models.subpopulations.StudyConsentView) SubpopulationGuid(org.sagebionetworks.bridge.models.subpopulations.SubpopulationGuid) StudyConsentForm(org.sagebionetworks.bridge.models.subpopulations.StudyConsentForm) Test(org.testng.annotations.Test)

Example 4 with DynamoStudyConsent1

use of org.sagebionetworks.bridge.dynamodb.DynamoStudyConsent1 in project BridgeServer2 by Sage-Bionetworks.

the class SubpopulationServiceTest method createDefaultSubpopulationWhereConsentsExist.

@Test
public void createDefaultSubpopulationWhereConsentsExist() {
    App app = new DynamoApp();
    app.setIdentifier(TEST_APP_ID);
    SubpopulationGuid defaultGuid = SubpopulationGuid.create(TEST_APP_ID);
    Subpopulation subpop = Subpopulation.create();
    when(studyConsentService.getAllConsents(defaultGuid)).thenReturn(ImmutableList.of(new DynamoStudyConsent1()));
    when(subpopDao.createDefaultSubpopulation(app.getIdentifier(), TEST_STUDY_ID)).thenReturn(subpop);
    Study study = Study.create();
    study.setIdentifier(TEST_STUDY_ID);
    Subpopulation returnValue = service.createDefaultSubpopulation(app, study);
    assertEquals(returnValue, subpop);
    // Consents exist... don't add any
    verify(studyConsentService, never()).addConsent(any(), any());
}
Also used : DynamoApp(org.sagebionetworks.bridge.dynamodb.DynamoApp) App(org.sagebionetworks.bridge.models.apps.App) Study(org.sagebionetworks.bridge.models.studies.Study) DynamoApp(org.sagebionetworks.bridge.dynamodb.DynamoApp) DynamoStudyConsent1(org.sagebionetworks.bridge.dynamodb.DynamoStudyConsent1) DynamoSubpopulation(org.sagebionetworks.bridge.dynamodb.DynamoSubpopulation) Subpopulation(org.sagebionetworks.bridge.models.subpopulations.Subpopulation) SubpopulationGuid(org.sagebionetworks.bridge.models.subpopulations.SubpopulationGuid) Test(org.testng.annotations.Test)

Example 5 with DynamoStudyConsent1

use of org.sagebionetworks.bridge.dynamodb.DynamoStudyConsent1 in project BridgeServer2 by Sage-Bionetworks.

the class StudyConsentControllerTest method getActiveConsentV2.

@Test
public void getActiveConsentV2() throws Exception {
    doReturn(session).when(controller).getAuthenticatedSession(DEVELOPER);
    StudyConsentView view = new StudyConsentView(new DynamoStudyConsent1(), "<document/>");
    when(mockStudyConsentService.getActiveConsent(any())).thenReturn(view);
    StudyConsentView result = controller.getActiveConsentV2(GUID);
    assertEquals(result.getDocumentContent(), "<document/>");
}
Also used : DynamoStudyConsent1(org.sagebionetworks.bridge.dynamodb.DynamoStudyConsent1) StudyConsentView(org.sagebionetworks.bridge.models.subpopulations.StudyConsentView) Test(org.testng.annotations.Test)

Aggregations

DynamoStudyConsent1 (org.sagebionetworks.bridge.dynamodb.DynamoStudyConsent1)8 Test (org.testng.annotations.Test)8 StudyConsentView (org.sagebionetworks.bridge.models.subpopulations.StudyConsentView)5 DynamoApp (org.sagebionetworks.bridge.dynamodb.DynamoApp)2 DynamoSubpopulation (org.sagebionetworks.bridge.dynamodb.DynamoSubpopulation)2 App (org.sagebionetworks.bridge.models.apps.App)2 Study (org.sagebionetworks.bridge.models.studies.Study)2 StudyConsentForm (org.sagebionetworks.bridge.models.subpopulations.StudyConsentForm)2 Subpopulation (org.sagebionetworks.bridge.models.subpopulations.Subpopulation)2 SubpopulationGuid (org.sagebionetworks.bridge.models.subpopulations.SubpopulationGuid)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 StudyConsent (org.sagebionetworks.bridge.models.subpopulations.StudyConsent)1