Search in sources :

Example 16 with StatusMessage

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

the class ParticipantDataControllerTest method testDeleteAllParticipantDataForAdmin.

@Test
public void testDeleteAllParticipantDataForAdmin() {
    doReturn(session).when(controller).getAuthenticatedSession(ADMIN);
    StatusMessage result = controller.deleteAllParticipantDataForAdmin(session.getAppId(), session.getId());
    assertEquals(result.getMessage(), "Participant data deleted.");
    verify(mockParticipantDataService).deleteAllParticipantData(TEST_USER_ID);
}
Also used : StatusMessage(org.sagebionetworks.bridge.models.StatusMessage) Test(org.testng.annotations.Test)

Example 17 with StatusMessage

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

the class IntentControllerTest method canSubmitAnIntent.

@Test
public void canSubmitAnIntent() throws Exception {
    // See comment in controller. Client APIs send scope as part of signature for legacy
    // reasons, but it is not part of the consent signature. Controller transfers it to the ITP.
    IntentToParticipate intent = createIntentToParticipate();
    JsonNode node = BridgeObjectMapper.get().valueToTree(intent);
    ((ObjectNode) node).remove("scope");
    ((ObjectNode) node.get("consentSignature")).put("scope", "all_qualified_researchers");
    mockRequestBody(mockRequest, node.toString());
    StatusMessage result = controller.submitIntentToParticipate();
    assertEquals(result, IntentController.SUBMITTED_MSG);
    verify(mockIntentService).submitIntentToParticipate(intentCaptor.capture());
    IntentToParticipate captured = intentCaptor.getValue();
    // It's pretty simple, we just want to make sure we got it, check a couple of fields
    assertEquals(captured.getPhone().getNumber(), PHONE.getNumber());
    assertEquals(captured.getConsentSignature().getName(), "Gladlight Stonewell");
    assertEquals(captured.getScope(), ALL_QUALIFIED_RESEARCHERS);
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) IntentToParticipate(org.sagebionetworks.bridge.models.itp.IntentToParticipate) JsonNode(com.fasterxml.jackson.databind.JsonNode) StatusMessage(org.sagebionetworks.bridge.models.StatusMessage) Test(org.testng.annotations.Test)

Example 18 with StatusMessage

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

the class MasterSchedulerControllerTest method deleteSchedulerConfig.

@Test
public void deleteSchedulerConfig() throws Exception {
    StatusMessage message = controller.deleteSchedulerConfig(SCHEDULE_ID);
    assertEquals(message.getMessage(), "Scheduler config deleted.");
    verify(mockSchedulerService).deleteSchedulerConfig(SCHEDULE_ID);
}
Also used : StatusMessage(org.sagebionetworks.bridge.models.StatusMessage) Test(org.testng.annotations.Test)

Example 19 with StatusMessage

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

the class ParticipantControllerTest method sendInstallLink.

@Test
public void sendInstallLink() {
    session.setParticipant(new StudyParticipant.Builder().withRoles(ImmutableSet.of(RESEARCHER)).build());
    Account account = Account.create();
    account.setId(TEST_USER_ID);
    account.setHealthCode(HEALTH_CODE);
    account.setEmail(EMAIL);
    account.setEmailVerified(true);
    account.setPhone(PHONE);
    account.setPhoneVerified(true);
    when(mockAccountService.getAccount(any())).thenReturn(Optional.of(account));
    StatusMessage retValue = controller.sendInstallLink(TEST_USER_ID, "Android");
    assertSame(retValue, INSTALL_LINK_SEND_MSG);
    verify(mockParticipantService).sendInstallLinkMessage(app, PROMOTIONAL, HEALTH_CODE, EMAIL, PHONE, "Android");
}
Also used : Account(org.sagebionetworks.bridge.models.accounts.Account) StudyParticipant(org.sagebionetworks.bridge.models.accounts.StudyParticipant) StatusMessage(org.sagebionetworks.bridge.models.StatusMessage) Test(org.testng.annotations.Test)

Example 20 with StatusMessage

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

the class ParticipantControllerTest method resendEmailVerification.

@Test
public void resendEmailVerification() throws Exception {
    StatusMessage result = controller.resendEmailVerification(TEST_USER_ID);
    assertEquals(result.getMessage(), "Email verification request has been resent to user.");
    verify(mockParticipantService).resendVerification(app, ChannelType.EMAIL, TEST_USER_ID);
}
Also used : 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