use of indi.mybatis.flying.pojo.condition.Account_Condition in project mybatis.flying by limeng32.
the class ConditionTest method testLikeAndBackslash.
/**
* 测试condition:对含有\的内容进行匹配
*/
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/conditionTest/testLikeBackslash.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/conditionTest/testLikeBackslash.xml")
public void testLikeAndBackslash() {
Account_Condition ac = new Account_Condition();
ac.setNameLike("\\\\");
int c = accountService.count(ac);
Assert.assertEquals(3, c);
ac.setNameLike("\\\\\\\\");
c = accountService.count(ac);
Assert.assertEquals(1, c);
ac.setNameLike("\\\\\\");
c = accountService.count(ac);
Assert.assertEquals(2, c);
ac.setNameLike("\\");
c = accountService.count(ac);
Assert.assertEquals(4, c);
ac.setNameLike(null);
ac.setName("\\");
c = accountService.count(ac);
Assert.assertEquals(1, c);
}
use of indi.mybatis.flying.pojo.condition.Account_Condition in project mybatis.flying by limeng32.
the class ConditionTest method testConditionHeadLike.
/**
* 测试condition:headLike功能
*/
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/conditionTest/testConditionHeadLike.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/conditionTest/testConditionHeadLike.xml")
public void testConditionHeadLike() {
Account_Condition ac = new Account_Condition();
ac.setEmailHeadLike("ann");
Collection<Account_> c = accountService.selectAll(ac);
Account_[] accounts = c.toArray(new Account_[c.size()]);
Assert.assertEquals(1, accounts.length);
Assert.assertEquals("ann@live.cn2", accounts[0].getEmail());
Account_Condition3 ac2 = new Account_Condition3();
ac2.setEmailHeadLike("1");
Collection<Account_> c2 = accountService.selectAll(ac2);
Account_[] accounts2 = c2.toArray(new Account_[c2.size()]);
Assert.assertEquals(1, accounts2.length);
Assert.assertEquals("_ann@live.cn1", accounts2[0].getEmail());
Account_Condition ac3 = new Account_Condition();
ac3.setEmailNotHeadLike("ann");
List<Account_> l = accountService.selectAll(ac3);
Assert.assertEquals(1, l.size());
Assert.assertEquals("_ann@live.cn1", l.get(0).getEmail());
}
use of indi.mybatis.flying.pojo.condition.Account_Condition in project mybatis.flying by limeng32.
the class ConditionTest method testMultiLikeOR.
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/conditionTest/testMultiLikeOR.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/conditionTest/testMultiLikeOR.xml")
public void testMultiLikeOR() {
Account_Condition ac = new Account_Condition();
ac.setName("ann");
ac.setEmailLike("as");
List<String> multi = new ArrayList<>();
multi.add(null);
multi.add(null);
multi.add(null);
multi.add(null);
ac.setMultiLikeOR(multi);
Collection<Account_> c = accountService.selectAll(ac);
Assert.assertEquals(1, c.size());
int count = accountService.count(ac);
Assert.assertEquals(1, count);
Account_Condition ac2 = new Account_Condition();
ac2.setName("ann");
ac2.setEmailLike("as");
List<String> multi2 = new ArrayList<>();
multi2.add(null);
multi2.add("a");
multi2.add("sd");
multi2.add("z");
ac2.setMultiLikeOR(multi2);
Collection<Account_> c2 = accountService.selectAll(ac2);
Assert.assertEquals(1, c2.size());
LoginLog_ lc = new LoginLog_();
Account_Condition ac3 = new Account_Condition();
List<String> multi3 = new ArrayList<>();
multi3.add(null);
multi3.add("a");
multi3.add("sd");
multi3.add("z");
ac3.setMultiLikeOR(multi3);
lc.setAccount(ac3);
Collection<LoginLog_> c3 = loginLogService.selectAll(lc);
Assert.assertEquals(1, c3.size());
Collection<LoginLog_> c4 = loginLogService.selectAllPrefix(lc);
Assert.assertEquals(1, c4.size());
}
use of indi.mybatis.flying.pojo.condition.Account_Condition in project mybatis.flying by limeng32.
the class ConditionTest method testConditionTailLike.
/**
* 测试condition:tailLike功能
*/
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/conditionTest/testConditionTailLike.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/conditionTest/testConditionTailLike.xml")
public void testConditionTailLike() {
Account_Condition ac = new Account_Condition();
ac.setEmailTailLike("live.cn");
Collection<Account_> c = accountService.selectAll(ac);
Account_[] accounts = c.toArray(new Account_[c.size()]);
Assert.assertEquals(1, accounts.length);
Assert.assertEquals("ann@live.cn", accounts[0].getEmail());
Account_Condition ac2 = new Account_Condition();
ac2.setEmailNotTailLike("live.cn");
List<Account_> l = accountService.selectAll(ac2);
Assert.assertEquals(1, l.size());
Assert.assertEquals("_ann@live.cn_", l.get(0).getEmail());
}
use of indi.mybatis.flying.pojo.condition.Account_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