Search in sources :

Example 11 with ExpectedDatabases

use of com.github.springtestdbunit.annotation.ExpectedDatabases 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);
}
Also used : MvcResult(org.springframework.test.web.servlet.MvcResult) DatabaseSetups(com.github.springtestdbunit.annotation.DatabaseSetups) Test(org.junit.Test) WithUserDetails(org.springframework.security.test.context.support.WithUserDetails) ExpectedDatabases(com.github.springtestdbunit.annotation.ExpectedDatabases)

Example 12 with ExpectedDatabases

use of com.github.springtestdbunit.annotation.ExpectedDatabases 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");
}
Also used : AnalysisUpdateDTO(com.odysseusinc.arachne.portal.api.v1.dto.AnalysisUpdateDTO) DatabaseSetups(com.github.springtestdbunit.annotation.DatabaseSetups) Test(org.junit.Test) WithUserDetails(org.springframework.security.test.context.support.WithUserDetails) ExpectedDatabases(com.github.springtestdbunit.annotation.ExpectedDatabases)

Example 13 with ExpectedDatabases

use of com.github.springtestdbunit.annotation.ExpectedDatabases 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);
}
Also used : AnalysisLockDTO(com.odysseusinc.arachne.portal.api.v1.dto.AnalysisLockDTO) DatabaseSetups(com.github.springtestdbunit.annotation.DatabaseSetups) Test(org.junit.Test) WithUserDetails(org.springframework.security.test.context.support.WithUserDetails) ExpectedDatabases(com.github.springtestdbunit.annotation.ExpectedDatabases)

Example 14 with ExpectedDatabases

use of com.github.springtestdbunit.annotation.ExpectedDatabases 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);
}
Also used : InvitationActionDTO(com.odysseusinc.arachne.portal.api.v1.dto.InvitationActionDTO) DatabaseSetups(com.github.springtestdbunit.annotation.DatabaseSetups) Test(org.junit.Test) WithUserDetails(org.springframework.security.test.context.support.WithUserDetails) ExpectedDatabases(com.github.springtestdbunit.annotation.ExpectedDatabases)

Example 15 with ExpectedDatabases

use of com.github.springtestdbunit.annotation.ExpectedDatabases 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");
    }
}
Also used : ArachneFileMeta(com.odysseusinc.arachne.storage.model.ArachneFileMeta) IOException(java.io.IOException) DatabaseSetups(com.github.springtestdbunit.annotation.DatabaseSetups) Test(org.junit.Test) WithUserDetails(org.springframework.security.test.context.support.WithUserDetails) ExpectedDatabases(com.github.springtestdbunit.annotation.ExpectedDatabases)

Aggregations

ExpectedDatabases (com.github.springtestdbunit.annotation.ExpectedDatabases)40 Test (org.junit.Test)40 DatabaseSetups (com.github.springtestdbunit.annotation.DatabaseSetups)31 WithUserDetails (org.springframework.security.test.context.support.WithUserDetails)28 DatabaseTearDowns (com.github.springtestdbunit.annotation.DatabaseTearDowns)12 DatabaseSetup (com.github.springtestdbunit.annotation.DatabaseSetup)8 CreateStudyDTO (com.odysseusinc.arachne.portal.api.v1.dto.CreateStudyDTO)7 StudyDTO (com.odysseusinc.arachne.portal.api.v1.dto.StudyDTO)6 StudyStatusDTO (com.odysseusinc.arachne.portal.api.v1.dto.dictionary.StudyStatusDTO)6 Account_ (indi.mybatis.flying.pojo.Account_)6 UpdateParticipantDTO (com.odysseusinc.arachne.portal.api.v1.dto.UpdateParticipantDTO)4 Detail2_ (indi.mybatis.flying.pojo.Detail2_)4 LoginLogSource2 (indi.mybatis.flying.pojo.LoginLogSource2)4 FileInputStream (java.io.FileInputStream)4 MockMultipartFile (org.springframework.mock.web.MockMultipartFile)4 IfProfileValue (org.springframework.test.annotation.IfProfileValue)4 AnalysisUpdateDTO (com.odysseusinc.arachne.portal.api.v1.dto.AnalysisUpdateDTO)3 StudyTypeDTO (com.odysseusinc.arachne.portal.api.v1.dto.dictionary.StudyTypeDTO)3 Role2_ (indi.mybatis.flying.pojo.Role2_)3 Role_ (indi.mybatis.flying.pojo.Role_)3