Search in sources :

Example 76 with DatabaseSetup

use of com.github.springtestdbunit.annotation.DatabaseSetup 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 77 with DatabaseSetup

use of com.github.springtestdbunit.annotation.DatabaseSetup 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 78 with DatabaseSetup

use of com.github.springtestdbunit.annotation.DatabaseSetup 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)

Example 79 with DatabaseSetup

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

the class UserControllerTests method testUpdate.

@Test
@WithUserDetails(value = ADMIN_EMAIL)
@DatabaseSetup("/data/user/admin-user.xml")
@ExpectedDatabase(value = "/data/user/updated-admin-user.xml", assertionMode = NON_STRICT)
public void testUpdate() throws Exception {
    UserProfileGeneralDTO dto = getUserProfileGeneralDTO();
    MvcResult mvcResult = mvc.perform(post("/api/v1/user-management/users/profile").contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(dto))).andExpect(NO_ERROR_CODE).andExpect(OK_STATUS).andReturn();
    JSONObject general = getGeneral(mvcResult);
    JSONAssert.assertEquals(UPDATED_USER_JSON_OBJECT, general, false);
    Assert.assertEquals(PROFESSIONAL_TYPE_ID.intValue(), general.getJSONObject("professionalType").get("id"));
}
Also used : UserProfileGeneralDTO(com.odysseusinc.arachne.portal.api.v1.dto.UserProfileGeneralDTO) JSONObject(org.json.JSONObject) 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

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