Search in sources :

Example 26 with ExpectedDatabases

use of com.github.springtestdbunit.annotation.ExpectedDatabases in project ArachneCentralAPI by OHDSI.

the class AnalysisControllerTests method testUpdateAnalysisDescription.

@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-description-updating.xml", assertionMode = NON_STRICT) })
public void testUpdateAnalysisDescription() throws Exception {
    AnalysisUpdateDTO analysisDTO = new AnalysisUpdateDTO();
    analysisDTO.setDescription(UPDATED_ANALYSIS_DESCRIPTION_VALUE);
    analysisDTO.setTypeId(ANALYSIS_TYPE_ID);
    testUpdate(analysisDTO, UPDATED_ANALYSIS_DESCR_JSON_OBJECT, null);
}
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 27 with ExpectedDatabases

use of com.github.springtestdbunit.annotation.ExpectedDatabases in project ArachneCentralAPI by OHDSI.

the class AnalysisControllerTests method testUpdateCodeFile.

@Test
@WithUserDetails(value = ADMIN_EMAIL)
@DatabaseSetups({ @DatabaseSetup("/data/study-with-contributor.xml"), @DatabaseSetup("/data/analysis/analysis-list.xml"), @DatabaseSetup("/data/analysis/code-file-before-deleting.xml") })
@ExpectedDatabases({ @ExpectedDatabase(value = "/data/study-with-contributor.xml", assertionMode = NON_STRICT), @ExpectedDatabase(value = "/data/analysis/code-file-after-updating.xml", assertionMode = NON_STRICT) })
public void testUpdateCodeFile() throws Exception {
    String uuid = "68b75ac9-ab29-49a6-8edb-95142456f5fc";
    String path = this.getClass().getResource("/test.jpg").getPath();
    FileInputStream fileInputStream = new FileInputStream(path);
    MockMultipartFile multipartFile = new MockMultipartFile("file", "test_updated.jpg", "image/jpeg", fileInputStream);
    MockMultipartHttpServletRequestBuilder builder = fileUpload("/api/v1/analysis-management/analyses/{analysisId}/files/{fileUuid}", ANALYSIS_ID, uuid);
    builder.with(request -> {
        request.setMethod("PUT");
        return request;
    });
    mvc.perform(builder.file(multipartFile).param("label", "labelUploadedFile").param("file", path).contentType(MULTIPART_FORM_DATA)).andExpect(NO_ERROR_CODE).andExpect(TRUE_RESULT);
}
Also used : MockMultipartFile(org.springframework.mock.web.MockMultipartFile) MockMultipartHttpServletRequestBuilder(org.springframework.test.web.servlet.request.MockMultipartHttpServletRequestBuilder) FileInputStream(java.io.FileInputStream) 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 28 with ExpectedDatabases

use of com.github.springtestdbunit.annotation.ExpectedDatabases in project ArachneCentralAPI by OHDSI.

the class AnalysisControllerTests method testUploadCodeFile.

@Test
@WithUserDetails(value = ADMIN_EMAIL)
@DatabaseSetups({ @DatabaseSetup("/data/study-with-contributor.xml"), @DatabaseSetup("/data/analysis/analysis-list.xml") })
@ExpectedDatabases({ @ExpectedDatabase(value = "/data/study-with-contributor.xml", assertionMode = NON_STRICT), @ExpectedDatabase(value = "/data/analysis/code-file.xml", assertionMode = NON_STRICT) })
public void testUploadCodeFile() throws Exception {
    FileInputStream fileInputStream = new FileInputStream(this.getClass().getResource("/test.jpg").getPath());
    MockMultipartFile multipartFile = new MockMultipartFile("file", "test.jpg", "image/jpeg", fileInputStream);
    this.mvc.perform(fileUpload("/api/v1/analysis-management/analyses/{analysisId}/upload", ANALYSIS_ID).file(multipartFile).contentType(MULTIPART_FORM_DATA).param("label", "newCodeFile")).andExpect(NO_ERROR_CODE).andExpect(OK_STATUS);
}
Also used : MockMultipartFile(org.springframework.mock.web.MockMultipartFile) FileInputStream(java.io.FileInputStream) 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 29 with ExpectedDatabases

use of com.github.springtestdbunit.annotation.ExpectedDatabases in project ArachneCentralAPI by OHDSI.

the class AnalysisControllerTests method testUpdateAnalysisTitle.

@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-title-updating.xml", assertionMode = NON_STRICT) })
public void testUpdateAnalysisTitle() throws Exception {
    AnalysisUpdateDTO analysisDTO = new AnalysisUpdateDTO();
    analysisDTO.setTitle(UPDATED_ANALYSIS_TITLE);
    analysisDTO.setTypeId(ANALYSIS_TYPE_ID);
    testUpdate(analysisDTO, UPDATED_ANALYSIS_JSON_OBJECT, UPDATED_ANALYSIS_TITLE);
}
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 30 with ExpectedDatabases

use of com.github.springtestdbunit.annotation.ExpectedDatabases in project ArachneCentralAPI by OHDSI.

the class AnalysisControllerTests method testCreateAnalysis.

@Test
@WithUserDetails(value = ADMIN_EMAIL)
@DatabaseSetups({ @DatabaseSetup("/data/study-with-contributor.xml"), @DatabaseSetup("/data/analysis/empty-analysis.xml") })
@ExpectedDatabases({ @ExpectedDatabase(value = "/data/study-with-contributor.xml", assertionMode = NON_STRICT), @ExpectedDatabase(value = "/data/analysis/analysis.xml", assertionMode = NON_STRICT) })
public void testCreateAnalysis() throws Exception {
    AnalysisCreateDTO analysisDTO = new AnalysisCreateDTO();
    analysisDTO.setTitle(ANALYSIS_TITLE);
    analysisDTO.setTypeId(ANALYSIS_TYPE_ID);
    analysisDTO.setStudyId(STUDY_ID);
    MvcResult mvcResult = mvc.perform(post("/api/v1/analysis-management/analyses").contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(analysisDTO))).andExpect(OK_STATUS).andExpect(NO_ERROR_CODE).andExpect(jsonPath("$.result.id").isNotEmpty()).andReturn();
    JSONObject result = getResultJSONObject(mvcResult);
    JSONAssert.assertEquals(ANALYSIS_JSON_OBJECT, result, false);
}
Also used : AnalysisCreateDTO(com.odysseusinc.arachne.portal.api.v1.dto.AnalysisCreateDTO) JSONObject(org.json.JSONObject) 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)

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