use of com.github.springtestdbunit.annotation.ExpectedDatabase in project ArachneCentralAPI by OHDSI.
the class StudyTypeControllerTests method testUpdateStudyType.
@Test
@DatabaseSetup("/data/study/type/study-type-before-updating.xml")
@ExpectedDatabase(value = "/data/study/type/study-type-after-updating.xml", assertionMode = NON_STRICT)
public void testUpdateStudyType() throws Exception {
StudyTypeDTO dto = new StudyTypeDTO(ID);
dto.setName(UPDATED_NAME);
MvcResult mvcResult = mvc.perform(put("/api/v1/admin/study-types/" + ID).contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(dto))).andExpect(jsonPath("$.result.id").isNotEmpty()).andExpect(OK_STATUS).andReturn();
JSONAssert.assertEquals(UPDATED_STUDY_TYPE_JSON_OBJECT, getResultJSONObject(mvcResult), false);
}
use of com.github.springtestdbunit.annotation.ExpectedDatabase in project ArachneCentralAPI by OHDSI.
the class StudyDataSourceControllerTests method testAddVirtualDataSource.
@Test
@WithUserDetails(STUDY_LEAD)
@ExpectedDatabase(value = "/data/study/datasource/study-data-source1-virtual.xml", assertionMode = NON_STRICT)
public void testAddVirtualDataSource() throws Exception {
final CreateVirtualDataSourceDTO createVirtualDataSourceDTO = new CreateVirtualDataSourceDTO();
createVirtualDataSourceDTO.setName("virtual");
createVirtualDataSourceDTO.setDataOwnersIds(Arrays.asList(UserIdUtils.idToUuid(1l)));
mvc.perform(post("/api/v1/study-management/studies/{studyId}/data-sources", STUDY_ID).contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(createVirtualDataSourceDTO))).andExpect(NO_ERROR_CODE);
}
use of com.github.springtestdbunit.annotation.ExpectedDatabase in project ArachneCentralAPI by OHDSI.
the class UserControllerTests method testCreateUserWithBadPassword.
@Test
@DatabaseSetup("/data/user/admin-user.xml")
@ExpectedDatabase(value = "/data/user/admin-user.xml", assertionMode = DatabaseAssertionMode.NON_STRICT)
public void testCreateUserWithBadPassword() throws Exception {
CommonUserRegistrationDTO inputDTO = getCommonUserRegistrationDTO(BAD_PASSWORD);
MvcResult mvcResult = mvc.perform(post("/api/v1/auth/registration").contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(inputDTO)).with(anonymous())).andExpect(VALIDATION_ERROR_CODE).andExpect(OK_STATUS).andReturn();
}
use of com.github.springtestdbunit.annotation.ExpectedDatabase in project ArachneCentralAPI by OHDSI.
the class UserControllerTests method testAddSkillToUser.
@Test
@WithUserDetails(value = ADMIN_EMAIL)
@DatabaseSetup("/data/user/admin-user-and-skill.xml")
@ExpectedDatabase(value = "/data/user/admin-user-with-skill.xml", assertionMode = NON_STRICT)
public void testAddSkillToUser() throws Exception {
final Integer skillId = 1;
MvcResult mvcResult = mvc.perform(post("/api/v1/user-management/users/skills/" + skillId)).andExpect(NO_ERROR_CODE).andExpect(OK_STATUS).andExpect(jsonPath("$.result.skills").isNotEmpty()).andExpect(jsonPath("$.result.skills[0].id").value(1)).andReturn();
JSONAssert.assertEquals(ADMIN_JSON_OBJECT, getGeneral(mvcResult), false);
}
use of com.github.springtestdbunit.annotation.ExpectedDatabase in project ArachneCentralAPI by OHDSI.
the class UserControllerTests method testRemoveSkillFromUser.
@Test
@WithUserDetails(value = ADMIN_EMAIL)
@DatabaseSetup("/data/user/admin-user-with-skill.xml")
@ExpectedDatabase(value = "/data/user/admin-user-and-skill.xml", assertionMode = NON_STRICT)
public void testRemoveSkillFromUser() throws Exception {
final Integer skillId = 1;
MvcResult mvcResult = mvc.perform(delete("/api/v1/user-management/users/skills/" + skillId)).andExpect(NO_ERROR_CODE).andExpect(OK_STATUS).andExpect(jsonPath("$.result.skills").isEmpty()).andReturn();
JSONAssert.assertEquals(ADMIN_JSON_OBJECT, getGeneral(mvcResult), false);
}
Aggregations