use of org.springframework.security.test.context.support.WithUserDetails in project ArachneCentralAPI by OHDSI.
the class AnalysisSubmissionControllerTests method testDeleteSubmissionResult.
// @Test
// @WithUserDetails(DATA_NODE_ONWER)
// @DatabaseSetups({
// @DatabaseSetup("/data/analysis/submission/submission-published-with-added-files.xml"),
// })
// @ExpectedDatabases({
// @ExpectedDatabase(value = "/data/analysis/submission/submission-published-with-added-files.xml", assertionMode = NON_STRICT),
//
// })
// public void testGetUploadingSubmissionResult() throws Exception {
//
// prepareResultFile(1L);
// }
@Test
@WithUserDetails(DATA_NODE_ONWER)
@DatabaseSetups({ @DatabaseSetup("/data/analysis/submission/submission-in-progress.xml"), @DatabaseSetup("/data/analysis/submission/result-file.xml") })
@ExpectedDatabases({ @ExpectedDatabase(value = "/data/analysis/submission/submission-in-progress.xml", assertionMode = NON_STRICT), @ExpectedDatabase(value = "/data/analysis/submission/result/empty-result-file.xml", assertionMode = NON_STRICT) })
public void testDeleteSubmissionResult() throws Exception {
Long submissionId = 1L;
ArachneFileMeta fileMeta = prepareResultFile(1L);
String fileUuid = fileMeta.getUuid();
mvc.perform(delete("/api/v1/analysis-management/submissions/{submissionId}/result/{fileUuid}", submissionId, fileUuid)).andExpect(NO_ERROR_CODE);
if (checkFileExists(getResultFilePath(submissionId))) {
throw new Exception("JCR file was not deleted");
}
}
use of org.springframework.security.test.context.support.WithUserDetails in project ArachneCentralAPI by OHDSI.
the class AnalysisSubmissionControllerTests method testApproveSubmissionResultByNonOwner.
@Test
@WithUserDetails(STUDY_LEAD)
@DatabaseSetups({ @DatabaseSetup("/data/analysis/submission/submission-executed.xml") })
@ExpectedDatabase(value = "/data/analysis/submission/submission-executed.xml", assertionMode = NON_STRICT)
public void testApproveSubmissionResultByNonOwner() throws Exception {
ApproveDTO approveDTO = new ApproveDTO(SUBMISSION_ID, true, null, null);
prepareAnalysisFile(STUDY_ID, ANALYSIS_ID);
prepareSubmissionGroupFile(STUDY_ID, ANALYSIS_ID, SUBMISSION_GROUP_ID);
mvc.perform(post("/api/v1/analysis-management/submissions/{submissionId}/approveresult", 1).contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(approveDTO))).andExpect(PERMISSION_DENIED_CODE);
}
use of org.springframework.security.test.context.support.WithUserDetails in project ArachneCentralAPI by OHDSI.
the class AnalysisSubmissionControllerTests method testManualUploadingSubmissionResult.
@Test
@WithUserDetails(DATA_NODE_ONWER)
@DatabaseSetups({ @DatabaseSetup("/data/analysis/submission/submission-in-progress.xml") })
@ExpectedDatabases({ @ExpectedDatabase(value = "/data/analysis/submission/result/submission-in-progress-with-added-file.xml", assertionMode = NON_STRICT) })
public void testManualUploadingSubmissionResult() throws Exception {
FileInputStream fileInputStream = new FileInputStream(this.getClass().getResource("/test.jpg").getPath());
MockMultipartFile multipartFile = new MockMultipartFile("file", "test.sql", "image/jpeg", fileInputStream);
mvc.perform(fileUpload("/api/v1/analysis-management/submissions/result/manualupload").file(multipartFile).contentType(MULTIPART_FORM_DATA).param("submissionId", "1").param("label", "test.sql")).andExpect(NO_ERROR_CODE);
}
use of org.springframework.security.test.context.support.WithUserDetails in project ArachneCentralAPI by OHDSI.
the class StudyControllerTests method testAddExistedParticipant.
@Test
@WithUserDetails(value = ADMIN_EMAIL)
@DatabaseSetups({ @DatabaseSetup("/data/study/study-participant.xml") })
@ExpectedDatabases({ @ExpectedDatabase(value = "/data/study/study-participant.xml", assertionMode = NON_STRICT) })
public void testAddExistedParticipant() throws Exception {
AddStudyParticipantDTO participantDTO = new AddStudyParticipantDTO();
participantDTO.setUserId(USER_2_UUID);
participantDTO.setRole(CONTRIBUTOR);
mvc.perform(post("/api/v1/study-management/studies/" + STUDY_ID + "/participants").contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(participantDTO))).andExpect(jsonPath("$.errorCode").value(ALREADY_EXIST.getCode()));
}
use of org.springframework.security.test.context.support.WithUserDetails in project ArachneCentralAPI by OHDSI.
the class StudyControllerTests method testUpdateStudyTitle.
@Test
@WithUserDetails(value = ADMIN_EMAIL)
@DatabaseSetup("/data/study/study-before-updating.xml")
@ExpectedDatabases({ @ExpectedDatabase(value = "/data/study/study-after-updating-title.xml", assertionMode = NON_STRICT) })
public void testUpdateStudyTitle() throws Exception {
StudyDTO updatedStudyDTO = new StudyDTO();
updatedStudyDTO.setId(STUDY_ID);
updatedStudyDTO.setTitle("Study Title New");
updatedStudyDTO.setDescription("description");
StudyTypeDTO type = new StudyTypeDTO(STUDY_TYPE_ID);
type.setName("type");
updatedStudyDTO.setType(type);
StudyStatusDTO status = new StudyStatusDTO(STUDY_STATUS_ID, "Initiate");
updatedStudyDTO.setStatus(status);
testUpdate(updatedStudyDTO, UPDATED_STUDY_TITLE_JSON_OBJECT, UPDATED_STUDY_TITLE);
}
Aggregations