use of org.sagebionetworks.bridge.models.StatusMessage in project BridgeServer2 by Sage-Bionetworks.
the class SponsorControllerTest method addStudySponsorOkForAdminInOrg.
@Test
public void addStudySponsorOkForAdminInOrg() {
RequestContext.set(new RequestContext.Builder().withCallerRoles(ImmutableSet.of(ADMIN)).withCallerOrgMembership(TEST_ORG_ID).build());
doReturn(session).when(controller).getAuthenticatedSession(ADMIN);
StatusMessage retValue = controller.addStudySponsor(TEST_STUDY_ID, TEST_ORG_ID);
verify(mockService).addStudySponsor(TEST_APP_ID, TEST_STUDY_ID, TEST_ORG_ID);
assertEquals(retValue.getMessage(), ADD_MSG);
}
use of org.sagebionetworks.bridge.models.StatusMessage in project BridgeServer2 by Sage-Bionetworks.
the class StudyParticipantControllerTest method deleteActivityEvent.
@Test
public void deleteActivityEvent() throws Exception {
RequestContext.set(new RequestContext.Builder().withOrgSponsoredStudies(ImmutableSet.of(TEST_STUDY_ID)).withCallerRoles(ImmutableSet.of(STUDY_COORDINATOR)).build());
session.setParticipant(new StudyParticipant.Builder().withId(TEST_USER_ID).build());
App app = App.create();
when(mockAppService.getApp(TEST_APP_ID)).thenReturn(app);
doReturn(session).when(controller).getAdministrativeSession();
StudyActivityEventIdsMap map = new StudyActivityEventIdsMap();
map.addCustomEvents(ImmutableList.of(new StudyCustomEvent("eventKey", MUTABLE)));
when(mockStudyService.getStudyActivityEventIdsMap(TEST_APP_ID, TEST_STUDY_ID)).thenReturn(map);
TestUtils.mockRequestBody(mockRequest, createJson("{'eventkey':'eventKey','timestamp':'" + CREATED_ON + "'}"));
mockAccountInStudy();
StatusMessage retValue = controller.deleteActivityEvent(TEST_STUDY_ID, TEST_USER_ID, "eventKey", null);
assertEquals(retValue, EVENT_DELETED_MSG);
verify(mockStudyActivityEventService).deleteEvent(eventCaptor.capture(), eq(false));
StudyActivityEvent event = eventCaptor.getValue();
assertEquals(event.getAppId(), TEST_APP_ID);
assertEquals(event.getStudyId(), TEST_STUDY_ID);
assertEquals(event.getUserId(), TEST_USER_ID);
assertEquals(event.getEventId(), "custom:eventKey");
}
use of org.sagebionetworks.bridge.models.StatusMessage in project BridgeServer2 by Sage-Bionetworks.
the class StudyParticipantControllerTest method requestResetPassword.
@Test
public void requestResetPassword() {
RequestContext.set(new RequestContext.Builder().withCallerRoles(ImmutableSet.of(ADMIN)).build());
mockAccountInStudy();
StatusMessage retValue = controller.requestResetPassword(TEST_STUDY_ID, TEST_USER_ID);
assertEquals(retValue.getMessage(), "Request to reset password sent to user.");
verify(mockParticipantService).requestResetPassword(app, TEST_USER_ID);
}
use of org.sagebionetworks.bridge.models.StatusMessage in project BridgeServer2 by Sage-Bionetworks.
the class StudyParticipantControllerTest method deleteParticipantReportIndex.
@Test
public void deleteParticipantReportIndex() {
doReturn(session).when(controller).getAuthenticatedSession(STUDY_DESIGNER, STUDY_COORDINATOR);
ReportDataKey key = new ReportDataKey.Builder().withIdentifier(IDENTIFIER).withReportType(PARTICIPANT).withAppId(TEST_APP_ID).build();
ReportIndex index = ReportIndex.create();
index.setStudyIds(ImmutableSet.of(TEST_STUDY_ID));
when(mockReportService.getReportIndex(key)).thenReturn(index);
StatusMessage retValue = controller.deleteParticipantReportIndex(TEST_STUDY_ID, IDENTIFIER);
assertSame(retValue, REPORT_INDEX_DELETED_MSG);
verify(mockReportService).deleteParticipantReportIndex(TEST_APP_ID, null, IDENTIFIER);
}
use of org.sagebionetworks.bridge.models.StatusMessage in project BridgeServer2 by Sage-Bionetworks.
the class StudyParticipantControllerTest method signOutDoNotDeleteToken.
@Test
public void signOutDoNotDeleteToken() {
RequestContext.set(new RequestContext.Builder().withCallerRoles(ImmutableSet.of(ADMIN)).build());
mockAccountInStudy();
StatusMessage retValue = controller.signOut(TEST_STUDY_ID, TEST_USER_ID, false);
assertEquals(retValue.getMessage(), "User signed out.");
verify(mockParticipantService).signUserOut(app, TEST_USER_ID, false);
}
Aggregations