Search in sources :

Example 1 with CreateStudyDTO

use of com.odysseusinc.arachne.portal.api.v1.dto.CreateStudyDTO in project ArachneCentralAPI by OHDSI.

the class StudyControllerTests method testCreateStudy.

@Test
@WithUserDetails(value = ADMIN_EMAIL)
@DatabaseSetup("/data/user/admin-user.xml")
@ExpectedDatabases({ @ExpectedDatabase(value = "/data/study/study.xml", assertionMode = NON_STRICT) })
public void testCreateStudy() throws Exception {
    CreateStudyDTO studyDTO = new CreateStudyDTO();
    studyDTO.setTypeId(STUDY_TYPE_ID);
    studyDTO.setTitle(STUDY_TITLE);
    MvcResult mvcResult = mvc.perform(post("/api/v1/study-management/studies/").contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(studyDTO))).andExpect(jsonPath("$.result.id").isNotEmpty()).andExpect(NO_ERROR_CODE).andExpect(OK_STATUS).andReturn();
    JSONObject result = getResultJSONObject(mvcResult);
    JSONAssert.assertEquals(STUDY_JSON_OBJECT, result, false);
}
Also used : JSONObject(org.json.JSONObject) CreateStudyDTO(com.odysseusinc.arachne.portal.api.v1.dto.CreateStudyDTO) MvcResult(org.springframework.test.web.servlet.MvcResult) Test(org.junit.Test) WithUserDetails(org.springframework.security.test.context.support.WithUserDetails) ExpectedDatabases(com.github.springtestdbunit.annotation.ExpectedDatabases) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup)

Aggregations

DatabaseSetup (com.github.springtestdbunit.annotation.DatabaseSetup)1 ExpectedDatabases (com.github.springtestdbunit.annotation.ExpectedDatabases)1 CreateStudyDTO (com.odysseusinc.arachne.portal.api.v1.dto.CreateStudyDTO)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