use of indi.mybatis.flying.pojo.condition.Role_Condition in project mybatis.flying by limeng32.
the class CacheTest method testPaginationUsingCacheIndeed.
/* 一个证明分页确实使用了缓存的测试用例 */
@Test
@IfProfileValue(name = "CACHE", value = "true")
@ExpectedDatabase(connection = "dataSource1", assertionMode = DatabaseAssertionMode.NON_STRICT_UNORDERED, value = "/indi/mybatis/flying/test/cacheTest/testPaginationUsingCacheIndeed.result.xml")
@DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/cacheTest/testPaginationUsingCacheIndeed.result.xml")
public void testPaginationUsingCacheIndeed() {
Role_ role1 = new Role_(), role2 = new Role_(), role3 = new Role_();
role1.setName("normal");
roleService.insert(role1);
role2.setName("silver");
roleService.insert(role2);
role3.setName("gold");
roleService.insert(role3);
Role_Condition rc = new Role_Condition();
rc.setLimiter(new PageParam(1, 2));
rc.setSorter(new SortParam(new Order("name", Conditionable.Sequence.asc)));
Collection<Role_> c1 = roleService.selectAll(rc);
Assert.assertEquals(2, c1.size());
Role_[] roles = c1.toArray(new Role_[c1.size()]);
Assert.assertEquals("gold", roles[0].getName());
Map<String, Object> m = new HashMap<>(4);
m.put("name", "gold1");
m.put("id", roles[0].getId());
roleService.updateDirect(m);
Role_Condition rc2 = new Role_Condition();
rc2.setLimiter(new PageParam(1, 2));
rc2.setSorter(new SortParam(new Order("name", Conditionable.Sequence.asc)));
Collection<Role_> c2 = roleService.selectAll(rc2);
Assert.assertEquals(2, c2.size());
Role_[] roles2 = c2.toArray(new Role_[c2.size()]);
Assert.assertEquals("gold", roles2[0].getName());
}
use of indi.mybatis.flying.pojo.condition.Role_Condition in project mybatis.flying by limeng32.
the class OrTest method testOr5.
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/orTest/testOr5.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/orTest/testOr5.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/orTest/testOr5.result.xml")
public void testOr5() {
LoginLog_Condition lc = new LoginLog_Condition();
lc.setAccount(new Account_Condition());
lc.getAccount().setRole(new Role_Condition());
lc.getAccount().setRoleDeputy(new Role_Condition());
((Role_Condition) lc.getAccount().getRole()).setNameEqualsOrAccountNameEquals("user", "bob");
((Role_Condition) lc.getAccount().getRoleDeputy()).setNameEqualsOrAccountNameEquals("silver", "bob");
Collection<LoginLog_> loginLogC = loginLogService.selectAll(lc);
Assert.assertEquals(2, loginLogC.size());
}
use of indi.mybatis.flying.pojo.condition.Role_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.Role_Condition in project mybatis.flying by limeng32.
the class ConditionTest method testSorterWithMultiAssociation.
/**
* 测试多重外键情况下sorter是否能正确发挥作用
*/
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/conditionTest/testSorterWithMultiAssociation.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/conditionTest/testSorterWithMultiAssociation.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/conditionTest/testSorterWithMultiAssociation.xml")
public void testSorterWithMultiAssociation() {
Role_Condition rc1 = new Role_Condition();
rc1.setName("role1");
Role_Condition rc2 = new Role_Condition();
rc2.setName("role2");
Account_Condition ac = new Account_Condition();
ac.setRole(rc1);
ac.setRoleDeputy(rc2);
ac.setSorter(new SortParam(new Order("name", Sequence.asc)));
Collection<Account_> accountC = accountService.selectAll(ac);
Account_[] accounts = accountC.toArray(new Account_[accountC.size()]);
Assert.assertEquals(3, accounts.length);
Assert.assertEquals("bob", accounts[0].getName());
}
use of indi.mybatis.flying.pojo.condition.Role_Condition in project mybatis.flying by limeng32.
the class OrTest method testOr6.
/* 一个只有单独入参的或逻辑测试用例 */
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/orTest/testOr6.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/orTest/testOr6.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/orTest/testOr6.result.xml")
public void testOr6() {
LoginLog_Condition lc = new LoginLog_Condition();
lc.setAccount(new Account_Condition());
lc.getAccount().setRole(new Role_Condition());
((Role_Condition) lc.getAccount().getRole()).setAccountNameEquals("ann");
int i = loginLogService.count(lc);
Assert.assertEquals(2, i);
LoginLog_Condition lc2 = new LoginLog_Condition();
lc2.setAccount(new Account_Condition());
lc2.getAccount().setRole(new Role_Condition());
((Role_Condition) lc2.getAccount().getRole()).setNameEquals("admin");
int i2 = loginLogService.count(lc2);
Assert.assertEquals(4, i2);
}
Aggregations