use of com.github.springtestdbunit.annotation.DatabaseSetup in project ArachneCentralAPI by OHDSI.
the class AchillesControllerTest method getFile.
@WithUserDetails(value = "admin@odysseusinc.com")
@DatabaseSetup(value = { "/data/achilles/datanode.xml", "/data/achilles/users.xml", "/data/achilles/studies.xml", "/data/achilles/datasources.xml", "/data/achilles/reports.xml", "/data/achilles/characterizations.xml", "/data/achilles/permissions.xml", "/data/achilles/study-participants.xml" })
public void getFile() throws Exception {
Bootstrap bootstrap = new Bootstrap();
AchillesFile observationFile = achillesFileRepository.findOne(11L);
assertThat(observationFile, is(notNullValue()));
observationFile.setData(bootstrap.observationJson());
AchillesFile dashboardFile = achillesFileRepository.findOne(4L);
assertThat(dashboardFile, is(notNullValue()));
dashboardFile.setData(bootstrap.dashboardJson());
achillesFileRepository.save(Arrays.asList(observationFile, dashboardFile));
mvc.perform(get(String.format(API_FILES, PUBLIC_DS, "dashboard.json")).accept(MediaType.APPLICATION_JSON_UTF8)).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)).andExpect(jsonPath("$.result.SUMMARY.ATTRIBUTE_NAME[0]", is("Source name")));
mvc.perform(get(String.format(API_FILES, PUBLIC_DS, "observations/observation_3051227.json")).accept(MediaType.APPLICATION_JSON_UTF8)).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)).andExpect(jsonPath("$.result.OBSERVATIONS_BY_TYPE.CONCEPT_NAME", is("Lab observation numeric result")));
}
use of com.github.springtestdbunit.annotation.DatabaseSetup in project ArachneCentralAPI by OHDSI.
the class RoleControllerTests method testUpdateRole.
@Test
@DatabaseSetup(value = "/data/role/role-before-updating.xml")
@ExpectedDatabase(table = "roles", value = "/data/role/roles.xml", assertionMode = NON_STRICT_UNORDERED)
public void testUpdateRole() throws Exception {
RoleDTO roleDTO = new RoleDTO();
roleDTO.setId(ROLE_ID);
roleDTO.setName(UPDATED_ROLE_NAME);
roleDTO.setDescription(ROLE_DESCRIPTION);
MvcResult mvcResult = mvc.perform(put("/api/v1/admin/roles/" + ROLE_ID).contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(roleDTO))).andExpect(jsonPath("$.result.id").isNotEmpty()).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 ProfessionalTypeControllerTests method testGetProfessionalType.
@Test
@DatabaseSetup("/data/professionaltype/professional-type-after-updating.xml")
@ExpectedDatabase(table = "professional_types", value = "/data/professionaltype/professional-type-after-updating.xml", assertionMode = NON_STRICT)
public void testGetProfessionalType() throws Exception {
MvcResult mvcResult = mvc.perform(get("/api/v1/user-management/professional-types/" + PROFESSIONAL_TYPE_ID)).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 ProfessionalTypeControllerTests method testCreateProfessionalType.
@Test
@DatabaseSetup(value = "/data/professionaltype/empty-professional-type.xml")
@ExpectedDatabase(table = "users_data", value = "/data/users-without-external-dependency.xml", assertionMode = NON_STRICT)
public void testCreateProfessionalType() throws Exception {
CommonProfessionalTypeDTO professionalTypeDTO = new CommonProfessionalTypeDTO();
professionalTypeDTO.setName(PROFESSIONAL_TYPE_NAME);
MvcResult mvcResult = mvc.perform(post("/api/v1/admin/professional-types/").contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(professionalTypeDTO))).andExpect(jsonPath("$.result.id").isNotEmpty()).andExpect(OK_STATUS).andExpect(NO_ERROR_CODE).andReturn();
JSONAssert.assertEquals(PROFESSIONAL_TYPE_JSON_OBJECT, getResultJSONObject(mvcResult), false);
}
use of com.github.springtestdbunit.annotation.DatabaseSetup in project ArachneCentralAPI by OHDSI.
the class StudyControllerTests method testUpdateStudyTitle.
@Test
@WithUserDetails(value = ADMIN_EMAIL)
@DatabaseSetup("/data/study/study-before-updating.xml")
@ExpectedDatabases({ @ExpectedDatabase(value = "/data/study/study-after-updating-title.xml", assertionMode = NON_STRICT) })
public void testUpdateStudyTitle() throws Exception {
StudyDTO updatedStudyDTO = new StudyDTO();
updatedStudyDTO.setId(STUDY_ID);
updatedStudyDTO.setTitle("Study Title New");
updatedStudyDTO.setDescription("description");
StudyTypeDTO type = new StudyTypeDTO(STUDY_TYPE_ID);
type.setName("type");
updatedStudyDTO.setType(type);
StudyStatusDTO status = new StudyStatusDTO(STUDY_STATUS_ID, "Initiate");
updatedStudyDTO.setStatus(status);
testUpdate(updatedStudyDTO, UPDATED_STUDY_TITLE_JSON_OBJECT, UPDATED_STUDY_TITLE);
}
Aggregations