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);
}
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);
}
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);
}
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());
}
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);
}
Aggregations