Search in sources :

Example 1 with AnalysisCreateDTO

use of com.odysseusinc.arachne.portal.api.v1.dto.AnalysisCreateDTO 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

DatabaseSetups (com.github.springtestdbunit.annotation.DatabaseSetups)1 ExpectedDatabases (com.github.springtestdbunit.annotation.ExpectedDatabases)1 AnalysisCreateDTO (com.odysseusinc.arachne.portal.api.v1.dto.AnalysisCreateDTO)1 JSONObject (org.json.JSONObject)1 Test (org.junit.Test)1 WithUserDetails (org.springframework.security.test.context.support.WithUserDetails)1 MvcResult (org.springframework.test.web.servlet.MvcResult)1