Search in sources :

Example 71 with ExpectedDatabase

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);
}
Also used : MvcResult(org.springframework.test.web.servlet.MvcResult) CreateStudyTypeDTO(com.odysseusinc.arachne.portal.api.v1.dto.dictionary.CreateStudyTypeDTO) StudyTypeDTO(com.odysseusinc.arachne.portal.api.v1.dto.dictionary.StudyTypeDTO) ExpectedDatabase(com.github.springtestdbunit.annotation.ExpectedDatabase) Test(org.junit.Test) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup)

Example 72 with ExpectedDatabase

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);
}
Also used : CreateVirtualDataSourceDTO(com.odysseusinc.arachne.portal.api.v1.dto.CreateVirtualDataSourceDTO) ExpectedDatabase(com.github.springtestdbunit.annotation.ExpectedDatabase) Test(org.junit.Test) WithUserDetails(org.springframework.security.test.context.support.WithUserDetails)

Example 73 with ExpectedDatabase

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();
}
Also used : CommonUserRegistrationDTO(com.odysseusinc.arachne.commons.api.v1.dto.CommonUserRegistrationDTO) MvcResult(org.springframework.test.web.servlet.MvcResult) ExpectedDatabase(com.github.springtestdbunit.annotation.ExpectedDatabase) Test(org.junit.Test) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup)

Example 74 with ExpectedDatabase

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);
}
Also used : MvcResult(org.springframework.test.web.servlet.MvcResult) ExpectedDatabase(com.github.springtestdbunit.annotation.ExpectedDatabase) Test(org.junit.Test) WithUserDetails(org.springframework.security.test.context.support.WithUserDetails) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup)

Example 75 with ExpectedDatabase

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);
}
Also used : MvcResult(org.springframework.test.web.servlet.MvcResult) ExpectedDatabase(com.github.springtestdbunit.annotation.ExpectedDatabase) Test(org.junit.Test) WithUserDetails(org.springframework.security.test.context.support.WithUserDetails) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup)

Aggregations

ExpectedDatabase (com.github.springtestdbunit.annotation.ExpectedDatabase)76 Test (org.junit.Test)72 DatabaseSetup (com.github.springtestdbunit.annotation.DatabaseSetup)53 DatabaseTearDown (com.github.springtestdbunit.annotation.DatabaseTearDown)42 MvcResult (org.springframework.test.web.servlet.MvcResult)26 Account_ (indi.mybatis.flying.pojo.Account_)25 WithUserDetails (org.springframework.security.test.context.support.WithUserDetails)20 IfProfileValue (org.springframework.test.annotation.IfProfileValue)19 Role_ (indi.mybatis.flying.pojo.Role_)17 Account_Condition (indi.mybatis.flying.pojo.condition.Account_Condition)11 HashMap (java.util.HashMap)9 LoginLog_ (indi.mybatis.flying.pojo.LoginLog_)7 LoginLog_Condition (indi.mybatis.flying.pojo.condition.LoginLog_Condition)7 DatabaseSetups (com.github.springtestdbunit.annotation.DatabaseSetups)6 ApproveDTO (com.odysseusinc.arachne.portal.api.v1.dto.ApproveDTO)6 PageParam (indi.mybatis.flying.pagination.PageParam)5 Role_Condition (indi.mybatis.flying.pojo.condition.Role_Condition)5 Order (indi.mybatis.flying.pagination.Order)3 SortParam (indi.mybatis.flying.pagination.SortParam)3 JSONArray (org.json.JSONArray)3