Search in sources :

Example 41 with ExpectedDatabase

use of com.github.springtestdbunit.annotation.ExpectedDatabase 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);
}
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 42 with ExpectedDatabase

use of com.github.springtestdbunit.annotation.ExpectedDatabase 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);
}
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 43 with ExpectedDatabase

use of com.github.springtestdbunit.annotation.ExpectedDatabase 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);
}
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 44 with ExpectedDatabase

use of com.github.springtestdbunit.annotation.ExpectedDatabase in project mybatis.flying by limeng32.

the class AccountTest method testCostumizeStatus.

/**
 * 测试CostumizeStatus功能
 */
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/accountTest/testCostumizeStatus.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/accountTest/testCostumizeStatus.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/accountTest/testCostumizeStatus.xml")
public void testCostumizeStatus() {
    Account_ a = accountService.select(1);
    Assert.assertEquals("发布", a.getStatus().text());
    Account_ ac = new Account_();
    ac.setStatus(StoryStatus_.p);
    Collection<Account_> c = accountService.selectAll(ac);
    Assert.assertEquals(1, c.size());
    Account_ a2 = accountService.select(2);
    Assert.assertEquals(StoryStatus_.s, a2.getStatus());
    a2.setStatus(StoryStatus_.c);
    accountService.update(a2);
    Account_ a3 = accountService.select(3);
    Assert.assertNull(a3.getStatus());
    a3.setPassword("5a690d842935c51f26f473e025c1b97a");
    accountService.updatePersistent(a3);
    Account_ a4 = accountService.select(3);
    Assert.assertNull(a4.getStatus());
}
Also used : Account_(indi.mybatis.flying.pojo.Account_) ExpectedDatabase(com.github.springtestdbunit.annotation.ExpectedDatabase) Test(org.junit.Test) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup) DatabaseTearDown(com.github.springtestdbunit.annotation.DatabaseTearDown)

Example 45 with ExpectedDatabase

use of com.github.springtestdbunit.annotation.ExpectedDatabase in project mybatis.flying by limeng32.

the class AccountTest method testDeputy.

/**
 * 测试deputyRole
 */
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/accountTest/testDeputy.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/accountTest/testDeputy.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/accountTest/testDeputy.xml")
public void testDeputy() {
    Account_ account = accountService.select(1);
    Assert.assertEquals("role1", account.getRole().getName());
    Assert.assertEquals("role2", account.getRoleDeputy().getName());
    Role_ rc = new Role_();
    rc.setName("role1");
    Role_ rdc = new Role_();
    rdc.setName("role2");
    Account_ ac = new Account_();
    ac.setRole(rc);
    ac.setRoleDeputy(rdc);
    Collection<Account_> accountC = accountService.selectAll(ac);
    Assert.assertEquals(1, accountC.size());
    int count = accountService.count(ac);
    Assert.assertEquals(1, count);
}
Also used : Account_(indi.mybatis.flying.pojo.Account_) Role_(indi.mybatis.flying.pojo.Role_) ExpectedDatabase(com.github.springtestdbunit.annotation.ExpectedDatabase) Test(org.junit.Test) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup) DatabaseTearDown(com.github.springtestdbunit.annotation.DatabaseTearDown)

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