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