use of org.springframework.security.test.context.support.WithUserDetails in project ArachneCentralAPI by OHDSI.
the class AnalysisControllerTests method testGetAnalysis.
@Test
@WithUserDetails(value = ADMIN_EMAIL)
@DatabaseSetups({ @DatabaseSetup("/data/study-with-contributor.xml"), @DatabaseSetup("/data/analysis/analysis-after-title-updating.xml") })
@ExpectedDatabases({ @ExpectedDatabase(value = "/data/study-with-contributor.xml", assertionMode = NON_STRICT), @ExpectedDatabase(value = "/data/analysis/analysis-after-title-updating.xml", assertionMode = NON_STRICT) })
public void testGetAnalysis() throws Exception {
MvcResult mvcResult = mvc.perform(get("/api/v1/analysis-management/analyses/" + ANALYSIS_ID)).andExpect(OK_STATUS).andExpect(NO_ERROR_CODE).andReturn();
JSONAssert.assertEquals(UPDATED_ANALYSIS_JSON_OBJECT, getResultJSONObject(mvcResult), false);
}
use of org.springframework.security.test.context.support.WithUserDetails in project ArachneCentralAPI by OHDSI.
the class AnalysisControllerTests method testUpdateAnalysisType.
@Test
@WithUserDetails(value = ADMIN_EMAIL)
@DatabaseSetups({ @DatabaseSetup("/data/study-with-contributor.xml"), @DatabaseSetup("/data/analysis/analysis-before-updating.xml") })
@ExpectedDatabases({ @ExpectedDatabase(value = "/data/study-with-contributor.xml", assertionMode = NON_STRICT), @ExpectedDatabase(value = "/data/analysis/analysis-after-type-updating.xml", assertionMode = NON_STRICT) })
public void testUpdateAnalysisType() throws Exception {
AnalysisUpdateDTO analysisDTO = new AnalysisUpdateDTO();
analysisDTO.setTypeId(CommonAnalysisType.COHORT_CHARACTERIZATION.name());
testUpdate(analysisDTO, UPDATED_ANALYSIS_TYPE_JSON_OBJECT, "Cohort Characterization");
}
use of org.springframework.security.test.context.support.WithUserDetails in project ArachneCentralAPI by OHDSI.
the class AnalysisLockingControllerTests method testLockAnalysis.
@Test
@WithUserDetails(value = ADMIN_EMAIL)
@DatabaseSetups({ @DatabaseSetup("/data/users.xml"), @DatabaseSetup("/data/study-with-contributor.xml"), @DatabaseSetup("/data/analysis/analysis-list.xml") })
@ExpectedDatabases({ @ExpectedDatabase(value = "/data/users.xml", assertionMode = NON_STRICT), @ExpectedDatabase(value = "/data/study-with-contributor.xml", assertionMode = NON_STRICT), @ExpectedDatabase(value = "/data/analysis/analysis-after-locking.xml", assertionMode = NON_STRICT) })
public void testLockAnalysis() throws Exception {
AnalysisLockDTO lockFileDTO = new AnalysisLockDTO();
lockFileDTO.setLocked(TRUE);
mvc.perform(post("/api/v1/analysis-management/analyses/{analysisId}/lock", ANALYSIS_ID).contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(lockFileDTO))).andExpect(NO_ERROR_CODE);
}
use of org.springframework.security.test.context.support.WithUserDetails in project ArachneCentralAPI by OHDSI.
the class AnalysisLockingControllerTests method testProcessUnlockRequest.
@Test
@WithUserDetails(value = "user@mail.com")
@DatabaseSetups({ @DatabaseSetup("/data/study/study-participant-with-contributor-and-leader-before.xml"), @DatabaseSetup("/data/analysis/analysis-after-locking.xml"), @DatabaseSetup("/data/analysis/analysis-unlock-requests-before-processing.xml") })
@ExpectedDatabases({ @ExpectedDatabase(value = "/data/study/study-participant-with-contributor-and-leader-before.xml", assertionMode = NON_STRICT), @ExpectedDatabase(value = "/data/analysis/analysis-list.xml", assertionMode = NON_STRICT), @ExpectedDatabase(value = "/data/analysis/analysis-unlock-requests-after-processing.xml", assertionMode = NON_STRICT) })
public void testProcessUnlockRequest() throws Exception {
InvitationActionDTO actionDTO = new InvitationActionDTO();
actionDTO.setAccepted(true);
actionDTO.setId(30L);
actionDTO.setType(InvitationType.UNLOCK_ANALYSIS);
mvc.perform(post("/api/v1/user-management/users/invitations").contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(actionDTO))).andExpect(NO_ERROR_CODE);
}
use of org.springframework.security.test.context.support.WithUserDetails in project ArachneCentralAPI by OHDSI.
the class AnalysisSubmissionControllerTests method testApproveSubmissionByNonOwner.
@Test
@WithUserDetails(DATA_NODE_USER)
@DatabaseSetups({ @DatabaseSetup("/data/analysis/submission/submission-pending.xml") })
@ExpectedDatabase(value = "/data/analysis/submission/submission-pending.xml", assertionMode = NON_STRICT)
public void testApproveSubmissionByNonOwner() 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}/approve", 1).contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(approveDTO))).andExpect(PERMISSION_DENIED_CODE);
}
Aggregations