Search in sources :

Example 21 with Account_Condition

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());
}
Also used : Account_Condition(indi.mybatis.flying.pojo.condition.Account_Condition) Account_(indi.mybatis.flying.pojo.Account_) Test(org.junit.Test) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup) DatabaseTearDown(com.github.springtestdbunit.annotation.DatabaseTearDown)

Example 22 with Account_Condition

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());
}
Also used : LoginLog_(indi.mybatis.flying.pojo.LoginLog_) ArrayList(java.util.ArrayList) Account_Condition(indi.mybatis.flying.pojo.condition.Account_Condition) Account_(indi.mybatis.flying.pojo.Account_) Test(org.junit.Test) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup) DatabaseTearDown(com.github.springtestdbunit.annotation.DatabaseTearDown)

Example 23 with Account_Condition

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());
}
Also used : Account_Condition(indi.mybatis.flying.pojo.condition.Account_Condition) Account_(indi.mybatis.flying.pojo.Account_) Account_Condition3(indi.mybatis.flying.pojo.condition.Account_Condition3) Test(org.junit.Test) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup) DatabaseTearDown(com.github.springtestdbunit.annotation.DatabaseTearDown)

Example 24 with Account_Condition

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());
}
Also used : Account_Condition(indi.mybatis.flying.pojo.condition.Account_Condition) Account_(indi.mybatis.flying.pojo.Account_) Test(org.junit.Test) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup) DatabaseTearDown(com.github.springtestdbunit.annotation.DatabaseTearDown)

Example 25 with Account_Condition

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);
}
Also used : Account_Condition(indi.mybatis.flying.pojo.condition.Account_Condition) Account_(indi.mybatis.flying.pojo.Account_) ExpectedDatabase(com.github.springtestdbunit.annotation.ExpectedDatabase) Test(org.junit.Test) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup) DatabaseTearDown(com.github.springtestdbunit.annotation.DatabaseTearDown)

Aggregations

DatabaseTearDown (com.github.springtestdbunit.annotation.DatabaseTearDown)26 Account_Condition (indi.mybatis.flying.pojo.condition.Account_Condition)26 Test (org.junit.Test)24 DatabaseSetup (com.github.springtestdbunit.annotation.DatabaseSetup)22 Account_ (indi.mybatis.flying.pojo.Account_)18 ExpectedDatabase (com.github.springtestdbunit.annotation.ExpectedDatabase)11 ArrayList (java.util.ArrayList)8 PageParam (indi.mybatis.flying.pagination.PageParam)6 LoginLog_Condition (indi.mybatis.flying.pojo.condition.LoginLog_Condition)6 LoginLog_ (indi.mybatis.flying.pojo.LoginLog_)5 IfProfileValue (org.springframework.test.annotation.IfProfileValue)5 Order (indi.mybatis.flying.pagination.Order)4 SortParam (indi.mybatis.flying.pagination.SortParam)4 Role_ (indi.mybatis.flying.pojo.Role_)4 Role_Condition (indi.mybatis.flying.pojo.condition.Role_Condition)4 Page (indi.mybatis.flying.pagination.Page)2 HashMap (java.util.HashMap)2 Account_Condition3 (indi.mybatis.flying.pojo.condition.Account_Condition3)1 LinkedList (java.util.LinkedList)1