Search in sources :

Example 66 with DatabaseSetup

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

the class RoleControllerTests method testGetRole.

@Test
@DatabaseSetup(value = "/data/role/roles.xml")
@ExpectedDatabase(table = "roles", value = "/data/role/roles.xml", assertionMode = NON_STRICT)
public void testGetRole() throws Exception {
    MvcResult mvcResult = mvc.perform(get("/api/v1/admin/roles/" + ROLE_ID)).andExpect(OK_STATUS).andExpect(NO_ERROR_CODE).andReturn();
    JSONAssert.assertEquals(UPDATED_ROLE_JSON_OBJECT, getResultJSONObject(mvcResult), false);
}
Also used : MvcResult(org.springframework.test.web.servlet.MvcResult) ExpectedDatabase(com.github.springtestdbunit.annotation.ExpectedDatabase) Test(org.junit.Test) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup)

Example 67 with DatabaseSetup

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

the class RoleControllerTests method testRole.

@Test
@DatabaseSetup(value = "/data/role/empty-role.xml")
@ExpectedDatabase(table = "roles", value = "/data/role/added-role.xml", assertionMode = NON_STRICT)
public void testRole() throws Exception {
    RoleDTO roleDTO = new RoleDTO();
    roleDTO.setName(ROLE_NAME);
    roleDTO.setDescription(ROLE_DESCRIPTION);
    MvcResult mvcResult = mvc.perform(post("/api/v1/admin/roles/").contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(roleDTO))).andExpect(jsonPath("$.result.id").isNotEmpty()).andExpect(OK_STATUS).andExpect(NO_ERROR_CODE).andReturn();
    JSONAssert.assertEquals(ROLE_JSON_OBJECT, getResultJSONObject(mvcResult), false);
}
Also used : RoleDTO(com.odysseusinc.arachne.portal.api.v1.dto.dictionary.RoleDTO) MvcResult(org.springframework.test.web.servlet.MvcResult) ExpectedDatabase(com.github.springtestdbunit.annotation.ExpectedDatabase) Test(org.junit.Test) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup)

Example 68 with DatabaseSetup

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

the class ProfessionalTypeControllerTests method testUpdateProfessionalType.

@Test
@DatabaseSetup(value = "/data/professionaltype/professional-type-before-updating.xml")
@ExpectedDatabase(table = "professional_types", value = "/data/professionaltype/professional-type-after-updating.xml", assertionMode = NON_STRICT)
public void testUpdateProfessionalType() throws Exception {
    CommonProfessionalTypeDTO professionalTypeDTO = new CommonProfessionalTypeDTO();
    professionalTypeDTO.setName(UPDATED_PROFESSIONAL_TYPE_NAME);
    professionalTypeDTO.setId(PROFESSIONAL_TYPE_ID);
    MvcResult mvcResult = mvc.perform(put("/api/v1/admin/professional-types/" + PROFESSIONAL_TYPE_ID).contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(professionalTypeDTO))).andExpect(jsonPath("$.result.id").isNotEmpty()).andExpect(OK_STATUS).andExpect(NO_ERROR_CODE).andReturn();
    JSONAssert.assertEquals(UPDATED_PROFESSIONAL_TYPE_JSON_OBJECT, getResultJSONObject(mvcResult), false);
}
Also used : CommonProfessionalTypeDTO(com.odysseusinc.arachne.commons.api.v1.dto.CommonProfessionalTypeDTO) MvcResult(org.springframework.test.web.servlet.MvcResult) ExpectedDatabase(com.github.springtestdbunit.annotation.ExpectedDatabase) Test(org.junit.Test) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup)

Example 69 with DatabaseSetup

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

the class StudyControllerTests method testUploadFile.

@Test
@WithUserDetails(value = ADMIN_EMAIL)
@DatabaseSetup("/data/study/study-after-updating-description.xml")
@ExpectedDatabases({ @ExpectedDatabase(value = "/data/study/study-after-updating-description.xml", assertionMode = NON_STRICT), @ExpectedDatabase(value = "/data/study/studies-files.xml", assertionMode = NON_STRICT) })
public void testUploadFile() throws Exception {
    String path = this.getClass().getResource("/test.jpg").getPath();
    FileInputStream fileInputStream = new FileInputStream(path);
    MockMultipartFile multipartFile = new MockMultipartFile("file", "test.jpg", "image/jpeg", fileInputStream);
    mvc.perform(fileUpload("/api/v1/study-management/studies/" + STUDY_ID + "/upload").file(multipartFile).param("label", "labelUploadedFile").param("file", path).contentType(MULTIPART_FORM_DATA)).andExpect(NO_ERROR_CODE);
}
Also used : MockMultipartFile(org.springframework.mock.web.MockMultipartFile) FileInputStream(java.io.FileInputStream) Test(org.junit.Test) WithUserDetails(org.springframework.security.test.context.support.WithUserDetails) ExpectedDatabases(com.github.springtestdbunit.annotation.ExpectedDatabases) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup)

Example 70 with DatabaseSetup

use of com.github.springtestdbunit.annotation.DatabaseSetup 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)79 Test (org.junit.Test)78 ExpectedDatabase (com.github.springtestdbunit.annotation.ExpectedDatabase)53 DatabaseTearDown (com.github.springtestdbunit.annotation.DatabaseTearDown)44 MvcResult (org.springframework.test.web.servlet.MvcResult)26 Account_ (indi.mybatis.flying.pojo.Account_)25 Account_Condition (indi.mybatis.flying.pojo.condition.Account_Condition)22 WithUserDetails (org.springframework.security.test.context.support.WithUserDetails)21 LoginLog_ (indi.mybatis.flying.pojo.LoginLog_)12 LoginLog_Condition (indi.mybatis.flying.pojo.condition.LoginLog_Condition)11 ArrayList (java.util.ArrayList)11 ExpectedDatabases (com.github.springtestdbunit.annotation.ExpectedDatabases)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 IfProfileValue (org.springframework.test.annotation.IfProfileValue)5 StudyTypeDTO (com.odysseusinc.arachne.portal.api.v1.dto.dictionary.StudyTypeDTO)4 Order (indi.mybatis.flying.pagination.Order)4 SortParam (indi.mybatis.flying.pagination.SortParam)4 Role_ (indi.mybatis.flying.pojo.Role_)4