use of indi.mybatis.flying.pojo.condition.Account_Condition in project mybatis.flying by limeng32.
the class OrTest method testOr2.
/* 一个dbAssociationUniqueKey型外键的或逻辑测试用例 */
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/orTest/testOr2.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/orTest/testOr2.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/orTest/testOr2.result.xml")
public void testOr2() {
LoginLog_Condition lc = new LoginLog_Condition();
lc.setAccount(new Account_Condition());
((Account_Condition) lc.getAccount()).setIdEqualsOr(1L, 2L);
int i = loginLogService.count(lc);
Assert.assertEquals(4, i);
}
use of indi.mybatis.flying.pojo.condition.Account_Condition in project mybatis.flying by limeng32.
the class OrTest method testOr4.
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/orTest/testOr4.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/orTest/testOr4.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/orTest/testOr4.result.xml")
public void testOr4() {
LoginLog_Condition lc = new LoginLog_Condition();
Account_Condition ac = new Account_Condition();
ac.setNameEqualsOrLoginlogIpEquals("ann", "bob", "c1");
lc.setAccount(ac);
int i1 = loginLogService.count(lc);
Assert.assertEquals(5, i1);
LoginLog_Condition lc2 = new LoginLog_Condition();
lc2.setAccount(new Account_Condition());
lc2.getAccount().setRole(new Role_Condition());
((Role_Condition) (lc2.getAccount().getRole())).setNameEqualsOrAccountNameEquals("admin", "cal");
int i2 = loginLogService.count(lc2);
Assert.assertEquals(6, i2);
}
use of indi.mybatis.flying.pojo.condition.Account_Condition in project mybatis.flying by limeng32.
the class SelectOneTest method testSelectOne2.
/**
* 测试selectOne2
*/
@Test
@DatabaseSetup(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/selectOneTest/testSelectOne2.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/selectOneTest/testSelectOne2.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/selectOneTest/testSelectOne2.result.xml")
public void testSelectOne2() {
Account_ a1 = new Account_();
a1.setName("ann");
a1.setEmail("ann@live.cn");
accountService.insert(a1);
Account_ a2 = new Account_();
a2.setName("ann");
a2.setEmail("bob@live.cn");
accountService.insert(a2);
Account_Condition ac = new Account_Condition();
ac.setLimiter(new PageParam(1, 2));
ac.setSorter(new SortParam(new Order("id", Sequence.asc)));
ac.setName("ann");
Account_ account = accountService.selectOne(ac);
Assert.assertEquals("ann@live.cn", account.getEmail());
Assert.assertNull(ac.getLimiter());
}
use of indi.mybatis.flying.pojo.condition.Account_Condition in project mybatis.flying by limeng32.
the class AccountTest method testLimiter.
/**
* 测试limiter功能
*/
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/accountTest/testLimiter.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/accountTest/testLimiter.xml")
public void testLimiter() {
Account_Condition ac = new Account_Condition();
ac.setLimiter(new PageParam(1, 2));
Collection<Account_> c = accountService.selectAll(ac);
Account_[] accounts = c.toArray(new Account_[c.size()]);
Assert.assertEquals(2, accounts.length);
Assert.assertEquals(1, accounts[0].getId().intValue());
Assert.assertEquals(2, accounts[1].getId().intValue());
Assert.assertEquals(2, ac.getLimiter().getMaxPageNum());
ac.setSorter(new SortParam(new Order(Account_Condition.field_id, Conditionable.Sequence.desc)));
c = accountService.selectAll(ac);
accounts = c.toArray(new Account_[c.size()]);
Assert.assertEquals(2, accounts.length);
Assert.assertEquals(4, accounts[0].getId().intValue());
Assert.assertEquals(3, accounts[1].getId().intValue());
}
use of indi.mybatis.flying.pojo.condition.Account_Condition 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);
}
Aggregations