use of indi.mybatis.flying.pagination.PageParam in project mybatis.flying by limeng32.
the class CacheTest method testPagination.
@Test
@IfProfileValue(name = "CACHE", value = "true")
@DatabaseSetup(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/cacheTest/testPagination.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/cacheTest/testPagination.result.xml")
public void testPagination() {
String name1 = "ann", name2 = "bob", name3 = "carl", name4 = "duke";
Account_ a1 = new Account_();
a1.setId(1L);
a1.setName(name1);
accountService.insert(a1);
Account_ a2 = new Account_();
a2.setId(2L);
a2.setName(name2);
accountService.insert(a2);
Account_ a3 = new Account_();
a3.setId(3L);
a3.setName(name3);
accountService.insert(a3);
Account_ a4 = new Account_();
a4.setId(4L);
a4.setName(name4);
accountService.insert(a4);
Account_Condition ac = new Account_Condition();
ac.setLimiter(new PageParam(1, 2));
Collection<Account_> c1 = accountService.selectAll(ac);
Assert.assertEquals(2, c1.size());
for (Account_ a : c1) {
if (a.getId() == 1) {
Assert.assertEquals(name1, a.getName());
} else {
Assert.assertEquals(name2, a.getName());
}
}
Assert.assertEquals(2, ac.getLimiter().getMaxPageNum());
ac.setLimiter(new PageParam(1, 2));
c1 = accountService.selectAll(ac);
Assert.assertEquals(2, ac.getLimiter().getMaxPageNum());
accountService.delete(a1);
accountService.delete(a2);
accountService.delete(a3);
accountService.delete(a4);
}
use of indi.mybatis.flying.pagination.PageParam in project mybatis.flying by limeng32.
the class CacheTest method testUpdateDirect4.
/* 测试在查询对象查询的情况下,缓存确实生效的用例 */
// @Test
@IfProfileValue(name = "CACHE", value = "true")
@ExpectedDatabase(connection = "dataSource1", assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/cacheTest/testUpdateDirect.result.xml")
@DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/cacheTest/testUpdateDirect.result.xml")
public void testUpdateDirect4() {
Role_ r = new Role_();
r.setId(1);
r.setName("ann");
roleService.insert(r);
Account_ a = new Account_();
a.setId(1L);
a.setRole(r);
a.setEmail("email");
accountService.insert(a);
Account_Condition ac = new Account_Condition();
ac.setLimiter(new PageParam(1, 1));
Collection<Account_> c = accountService.selectAll(ac);
Map<String, Object> m = new HashMap<>(4);
m.put("id", 1);
m.put("name", "bob");
roleService.updateDirect(m);
Account_Condition ac2 = new Account_Condition();
ac2.setLimiter(new PageParam(1, 1));
Collection<Account_> c2 = accountService.selectAll(ac2);
for (Account_ t : c2) {
Assert.assertEquals("ann", t.getRole().getName());
}
}
Aggregations