Search in sources :

Example 11 with StatusMessage

use of org.sagebionetworks.bridge.models.StatusMessage in project BridgeServer2 by Sage-Bionetworks.

the class SchedulePlanControllerTest method deleteSchedulePlanPermanentlyOnlyLogicalForDeveloper.

@Test
public void deleteSchedulePlanPermanentlyOnlyLogicalForDeveloper() throws Exception {
    StatusMessage result = controller.deleteSchedulePlan("GGG", true);
    assertEquals(result, SchedulePlanController.DELETE_MSG);
    verify(mockSchedulePlanService).deleteSchedulePlan(TEST_APP_ID, "GGG");
}
Also used : StatusMessage(org.sagebionetworks.bridge.models.StatusMessage) Test(org.testng.annotations.Test)

Example 12 with StatusMessage

use of org.sagebionetworks.bridge.models.StatusMessage in project BridgeServer2 by Sage-Bionetworks.

the class NotificationTopicControllerTest method sendNotification.

@Test
public void sendNotification() throws Exception {
    doReturn(mockUserSession).when(controller).getAuthenticatedSession(ADMIN);
    mockRequestBody(mockRequest, NOTIFICATION_MESSAGE);
    StatusMessage result = controller.sendNotification(GUID);
    assertEquals(result, NotificationTopicController.SEND_STATUS_MSG);
    verify(mockTopicService).sendNotification(eq(TEST_APP_ID), eq(GUID), messageCaptor.capture());
    NotificationMessage captured = messageCaptor.getValue();
    assertEquals(captured.getSubject(), "a subject");
    assertEquals(captured.getMessage(), "a message");
}
Also used : NotificationMessage(org.sagebionetworks.bridge.models.notifications.NotificationMessage) StatusMessage(org.sagebionetworks.bridge.models.StatusMessage) Test(org.testng.annotations.Test)

Example 13 with StatusMessage

use of org.sagebionetworks.bridge.models.StatusMessage in project BridgeServer2 by Sage-Bionetworks.

the class NotificationTopicControllerTest method deleteTopicPermanentlyForDeveloper.

@Test
public void deleteTopicPermanentlyForDeveloper() throws Exception {
    doReturn(mockUserSession).when(controller).getAuthenticatedSession(DEVELOPER);
    StatusMessage result = controller.deleteTopic(GUID, true);
    assertEquals(result, NotificationTopicController.DELETE_STATUS_MSG);
    // Does not delete permanently because permissions are wrong; just logically deletes
    verify(mockTopicService).deleteTopic(TEST_APP_ID, GUID);
}
Also used : StatusMessage(org.sagebionetworks.bridge.models.StatusMessage) Test(org.testng.annotations.Test)

Example 14 with StatusMessage

use of org.sagebionetworks.bridge.models.StatusMessage in project BridgeServer2 by Sage-Bionetworks.

the class ParticipantControllerTest method updateParticipant.

@Test
public void updateParticipant() throws Exception {
    app.getUserProfileAttributes().add("can_be_recontacted");
    String json = createJson("{'firstName':'firstName'," + "'lastName':'lastName'," + "'email':'email@email.com'," + "'externalId':'externalId'," + "'password':'newUserPassword'," + "'sharingScope':'sponsors_and_partners'," + "'notifyByEmail':true," + "'dataGroups':['group2','group1']," + "'attributes':{'can_be_recontacted':'true'}," + "'languages':['en','fr']}");
    mockRequestBody(mockRequest, json);
    StatusMessage result = controller.updateParticipant(TEST_USER_ID);
    assertEquals(result.getMessage(), "Participant updated.");
    // Both the caller roles and the caller's studies are passed to participantService
    verify(mockParticipantService).updateParticipant(eq(app), participantCaptor.capture());
    StudyParticipant participant = participantCaptor.getValue();
    assertEquals(participant.getId(), TEST_USER_ID);
    assertEquals(participant.getFirstName(), "firstName");
    assertEquals(participant.getLastName(), "lastName");
    assertEquals(participant.getEmail(), EMAIL);
    assertEquals(participant.getPassword(), "newUserPassword");
    assertEquals(participant.getExternalId(), "externalId");
    assertEquals(participant.getSharingScope(), SPONSORS_AND_PARTNERS);
    assertTrue(participant.isNotifyByEmail());
    assertEquals(participant.getDataGroups(), ImmutableSet.of("group2", "group1"));
    assertEquals(participant.getAttributes().get("can_be_recontacted"), "true");
    assertEquals(participant.getLanguages(), ImmutableList.of("en", "fr"));
}
Also used : StudyParticipant(org.sagebionetworks.bridge.models.accounts.StudyParticipant) StatusMessage(org.sagebionetworks.bridge.models.StatusMessage) Test(org.testng.annotations.Test)

Example 15 with StatusMessage

use of org.sagebionetworks.bridge.models.StatusMessage in project BridgeServer2 by Sage-Bionetworks.

the class ParticipantDataControllerTest method testSaveDataForSelf.

@Test
public void testSaveDataForSelf() throws Exception {
    String json = createJson("{'userId':'aUserId', 'data':{'field1':'a','field2':'b'}}");
    mockRequestBody(mockRequest, json);
    StatusMessage result = controller.saveDataForSelf(IDENTIFIER);
    assertEquals(result.getMessage(), "Participant data saved.");
    verify(mockParticipantDataService).saveParticipantData(anyString(), anyString(), participantDataCaptor.capture());
    ParticipantData capture = participantDataCaptor.getValue();
    assertNull(capture.getUserId());
    assertNull(capture.getIdentifier());
    assertEquals(capture.getData(), participantData.getData());
}
Also used : ParticipantData(org.sagebionetworks.bridge.models.ParticipantData) DynamoParticipantData(org.sagebionetworks.bridge.dynamodb.DynamoParticipantData) 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