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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations