Search in sources :

Example 96 with StatusMessage

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);
}
Also used : StatusMessage(org.sagebionetworks.bridge.models.StatusMessage) Test(org.testng.annotations.Test)

Example 97 with StatusMessage

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");
}
Also used : App(org.sagebionetworks.bridge.models.apps.App) StudyCustomEvent(org.sagebionetworks.bridge.models.studies.StudyCustomEvent) StudyActivityEventIdsMap(org.sagebionetworks.bridge.models.activities.StudyActivityEventIdsMap) StudyActivityEvent(org.sagebionetworks.bridge.models.activities.StudyActivityEvent) StudyParticipant(org.sagebionetworks.bridge.models.accounts.StudyParticipant) StatusMessage(org.sagebionetworks.bridge.models.StatusMessage) Test(org.testng.annotations.Test)

Example 98 with StatusMessage

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);
}
Also used : RequestContext(org.sagebionetworks.bridge.RequestContext) StatusMessage(org.sagebionetworks.bridge.models.StatusMessage) Test(org.testng.annotations.Test)

Example 99 with StatusMessage

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);
}
Also used : ReportIndex(org.sagebionetworks.bridge.models.reports.ReportIndex) ReportDataKey(org.sagebionetworks.bridge.models.reports.ReportDataKey) StatusMessage(org.sagebionetworks.bridge.models.StatusMessage) Test(org.testng.annotations.Test)

Example 100 with StatusMessage

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);
}
Also used : RequestContext(org.sagebionetworks.bridge.RequestContext) StatusMessage(org.sagebionetworks.bridge.models.StatusMessage) Test(org.testng.annotations.Test)

Aggregations

StatusMessage (org.sagebionetworks.bridge.models.StatusMessage)239 Test (org.testng.annotations.Test)168 UserSession (org.sagebionetworks.bridge.models.accounts.UserSession)58 PostMapping (org.springframework.web.bind.annotation.PostMapping)43 StudyParticipant (org.sagebionetworks.bridge.models.accounts.StudyParticipant)36 App (org.sagebionetworks.bridge.models.apps.App)28 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)23 DeleteMapping (org.springframework.web.bind.annotation.DeleteMapping)22 Account (org.sagebionetworks.bridge.models.accounts.Account)21 ReportData (org.sagebionetworks.bridge.models.reports.ReportData)13 SignIn (org.sagebionetworks.bridge.models.accounts.SignIn)12 AccountId (org.sagebionetworks.bridge.models.accounts.AccountId)11 RequestContext (org.sagebionetworks.bridge.RequestContext)10 EntityNotFoundException (org.sagebionetworks.bridge.exceptions.EntityNotFoundException)10 DateRangeResourceList (org.sagebionetworks.bridge.models.DateRangeResourceList)10 JsonNode (com.fasterxml.jackson.databind.JsonNode)9 HealthDataSubmission (org.sagebionetworks.bridge.models.healthdata.HealthDataSubmission)9 Cookie (javax.servlet.http.Cookie)6 Appointment (org.hl7.fhir.dstu3.model.Appointment)6 NotificationMessage (org.sagebionetworks.bridge.models.notifications.NotificationMessage)6