use of indi.mybatis.flying.pojo.condition.Account_Condition in project mybatis.flying by limeng32.
the class ConditionTest method testConditionLike.
/**
* 测试condition:like功能
*/
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/conditionTest/testConditionLike.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/conditionTest/testConditionLike.xml")
public void testConditionLike() {
Account_Condition ac = new Account_Condition();
ac.setEmailLike("%%");
Collection<Account_> c = accountService.selectAll(ac);
Account_[] accounts = c.toArray(new Account_[c.size()]);
Assert.assertEquals(1, accounts.length);
Assert.assertEquals("an%%n@live.cn", accounts[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());
}
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());
}
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());
}
use of indi.mybatis.flying.pojo.condition.Account_Condition in project mybatis.flying by limeng32.
the class NullOrNotTest method testNullOrNot.
/**
* 测试NullOrNot关键字
*/
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/nullOrNotTest/testNullOrNot.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/nullOrNotTest/testNullOrNot.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/nullOrNotTest/testNullOrNot.xml")
public void testNullOrNot() {
Account_Condition ac = new Account_Condition();
ac.setEmailIsNull(true);
Collection<Account_> accountC = accountService.selectAll(ac);
Assert.assertEquals(1, accountC.size());
int count = accountService.count(ac);
Assert.assertEquals(1, count);
Account_Condition ac2 = new Account_Condition();
ac2.setEmailIsNull(false);
Collection<Account_> accountC2 = accountService.selectAll(ac2);
Assert.assertEquals(1, accountC2.size());
int count2 = accountService.count(ac2);
Assert.assertEquals(1, count2);
Account_Condition ac3 = new Account_Condition();
Collection<Account_> accountC3 = accountService.selectAll(ac3);
Assert.assertEquals(2, accountC3.size());
int count3 = accountService.count(ac3);
Assert.assertEquals(2, count3);
Account_Condition ac4 = new Account_Condition();
ac4.setRoleIsNull(true);
Collection<Account_> accountC4 = accountService.selectAll(ac4);
for (Account_ a : accountC4) {
Assert.assertEquals("bob", a.getName());
}
int count4 = accountService.count(ac4);
Assert.assertEquals(1, count4);
Account_Condition ac5 = new Account_Condition();
ac5.setRoleIsNull(false);
Collection<Account_> accountC5 = accountService.selectAll(ac5);
for (Account_ a : accountC5) {
Assert.assertEquals("ann", a.getName());
}
int count5 = accountService.count(ac5);
Assert.assertEquals(1, count5);
}
Aggregations