Search in sources :

Example 66 with ExpectedDatabase

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

the class BasePaperControllerTest method testCreatePaper.

@Test
@WithUserDetails(value = ADMIN_EMAIL)
@ExpectedDatabase(value = "/data/paper/papers-after-creation.xml", assertionMode = NON_STRICT)
public void testCreatePaper() throws Exception {
    final CreatePaperDTO createPaperDTO = new CreatePaperDTO();
    createPaperDTO.setStudyId(1L);
    MvcResult mvcResult = mvc.perform(post("/api/v1/papers").contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(createPaperDTO))).andExpect(OK_STATUS).andReturn();
}
Also used : CreatePaperDTO(com.odysseusinc.arachne.portal.api.v1.dto.CreatePaperDTO) 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)

Example 67 with ExpectedDatabase

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

Example 68 with ExpectedDatabase

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

Example 69 with ExpectedDatabase

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

Example 70 with ExpectedDatabase

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

the class SkillControllerTests method testUpdateSkill.

@Test
@DatabaseSetup("/data/skill/skill-before-updating.xml")
@ExpectedDatabase(value = "/data/skill/skill-after-updating.xml", assertionMode = NON_STRICT)
public void testUpdateSkill() throws Exception {
    SkillDTO skillDTO = new SkillDTO();
    skillDTO.setId(SKILL_ID);
    skillDTO.setName(UPDATED_SKILL_NAME);
    MvcResult mvcResult = mvc.perform(put("/api/v1/admin/skills/" + SKILL_ID).contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(skillDTO))).andExpect(jsonPath("$.result.id").isNotEmpty()).andExpect(OK_STATUS).andExpect(NO_ERROR_CODE).andReturn();
    JSONAssert.assertEquals(UPDATED_SKILL_JSON_OBJECT, getResultJSONObject(mvcResult), false);
}
Also used : SkillDTO(com.odysseusinc.arachne.portal.api.v1.dto.dictionary.SkillDTO) MvcResult(org.springframework.test.web.servlet.MvcResult) ExpectedDatabase(com.github.springtestdbunit.annotation.ExpectedDatabase) Test(org.junit.Test) 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