use of org.sagebionetworks.bridge.models.StatusMessage in project BridgeServer2 by Sage-Bionetworks.
the class ParticipantReportControllerTest method adminCanDeleteParticipantIndex.
@Test
public void adminCanDeleteParticipantIndex() throws Exception {
// Mock getAuthenticatedSession().
doReturn(session).when(controller).getAuthenticatedSession(ADMIN);
// Execute and validate.
StatusMessage result = controller.deleteParticipantReportIndex(REPORT_ID);
assertEquals(result.getMessage(), "Report index deleted.");
verify(mockReportService).deleteParticipantReportIndex(TEST_APP_ID, TEST_USER_ID, REPORT_ID);
}
use of org.sagebionetworks.bridge.models.StatusMessage in project BridgeServer2 by Sage-Bionetworks.
the class ParticipantReportControllerTest method saveParticipantReportData.
@Test
public void saveParticipantReportData() throws Exception {
String json = TestUtils.createJson("{'date':'2015-02-12','data':{'field1':'Last','field2':'Name'}}");
mockRequestBody(mockRequest, json);
when(mockAccountService.getAccount(any())).thenReturn(Optional.of(mockOtherAccount));
StatusMessage result = controller.saveParticipantReport(OTHER_PARTICIPANT_ID, REPORT_ID);
assertEquals(result.getMessage(), "Report data saved.");
verify(mockReportService).saveParticipantReport(eq(TEST_APP_ID), eq(TEST_USER_ID), eq(REPORT_ID), eq(OTHER_PARTICIPANT_HEALTH_CODE), reportDataCaptor.capture());
ReportData reportData = reportDataCaptor.getValue();
assertEquals(reportData.getDate().toString(), LocalDate.parse("2015-02-12").toString());
assertNull(reportData.getKey());
assertEquals(reportData.getData().get("field1").asText(), "Last");
assertEquals(reportData.getData().get("field2").asText(), "Name");
}
use of org.sagebionetworks.bridge.models.StatusMessage in project BridgeServer2 by Sage-Bionetworks.
the class ParticipantVersionControllerTest method deleteForHealthCode.
@Test
public void deleteForHealthCode() {
// Mock dependencies.
Account account = Account.create();
account.setHealthCode(TestConstants.HEALTH_CODE);
account.setDataGroups(ImmutableSet.of(BridgeConstants.TEST_USER_GROUP));
when(mockAccountService.getAccount(any())).thenReturn(Optional.of(account));
// Execute and validate.
StatusMessage response = controller.deleteParticipantVersionsForUser(TestConstants.TEST_USER_ID);
assertNotNull(response);
verify(mockParticipantVersionService).deleteParticipantVersionsForHealthCode(TestConstants.TEST_APP_ID, TestConstants.HEALTH_CODE);
ArgumentCaptor<AccountId> accountIdCaptor = ArgumentCaptor.forClass(AccountId.class);
verify(mockAccountService).getAccount(accountIdCaptor.capture());
AccountId accountId = accountIdCaptor.getValue();
assertEquals(accountId.getAppId(), TestConstants.TEST_APP_ID);
assertEquals(accountId.getId(), TestConstants.TEST_USER_ID);
}
use of org.sagebionetworks.bridge.models.StatusMessage in project BridgeServer2 by Sage-Bionetworks.
the class FileControllerTest method adminCanPermanentlyDelete.
@Test
public void adminCanPermanentlyDelete() throws Exception {
doReturn(session).when(controller).getAuthenticatedSession(DEVELOPER);
session.setParticipant(new StudyParticipant.Builder().withRoles(ImmutableSet.of(ADMIN)).build());
StatusMessage message = controller.deleteFile(GUID, "true");
assertEquals(message.getMessage(), DELETE_MSG.getMessage());
verify(mockFileService).deleteFilePermanently(TEST_APP_ID, GUID);
}
use of org.sagebionetworks.bridge.models.StatusMessage in project BridgeServer2 by Sage-Bionetworks.
the class FileControllerTest method deleteTemplate.
@Test
public void deleteTemplate() throws Exception {
doReturn(session).when(controller).getAuthenticatedSession(DEVELOPER);
StatusMessage message = controller.deleteFile(GUID, "false");
assertEquals(message.getMessage(), DELETE_MSG.getMessage());
verify(mockFileService).deleteFile(TEST_APP_ID, GUID);
}
Aggregations