Search in sources :

Example 11 with Account_Condition

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

Example 12 with Account_Condition

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

Example 13 with Account_Condition

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

Example 14 with Account_Condition

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

Example 15 with Account_Condition

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

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