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/>");
}
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);
}
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);
}
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());
}
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/>");
}
Aggregations