Search in sources :

Example 31 with Account_Condition

use of indi.mybatis.flying.pojo.condition.Account_Condition in project mybatis.flying by limeng32.

the class SelectOneTest method testSelectOne3.

/**
 * 测试selectOne3,缓存测试
 */
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/selectOneTest/testSelectOne3.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/selectOneTest/testSelectOne3.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/selectOneTest/testSelectOne3.result.xml")
public void testSelectOne3() {
    Account_Condition ac = new Account_Condition();
    Account_ account1 = accountService.selectOne(ac);
    Assert.assertEquals("ann", account1.getName());
    ac.setEmail("ann@live.cn");
    ac.setLimiter(new PageParam(1, 8));
    ac.setSorter(new SortParam(new Order("id", Sequence.ASC), new Order("name", Sequence.DESC), new Order("id", Sequence.DESC)));
    Collection<Account_> accountC = accountService.selectAll(ac);
    Assert.assertEquals(2, accountC.size());
}
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) ExpectedDatabase(com.github.springtestdbunit.annotation.ExpectedDatabase) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup) DatabaseTearDown(com.github.springtestdbunit.annotation.DatabaseTearDown)

Example 32 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) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup) DatabaseTearDown(com.github.springtestdbunit.annotation.DatabaseTearDown)

Example 33 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) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup) DatabaseTearDown(com.github.springtestdbunit.annotation.DatabaseTearDown)

Example 34 with Account_Condition

use of indi.mybatis.flying.pojo.condition.Account_Condition in project mybatis.flying by limeng32.

the class CacheTest1 method testClearCache2.

/* 测试分页缓存能正确清除父对象的用例 */
@Test
@IfProfileValue(name = "CACHE", value = "true")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/cacheTest/testClearCache2.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/cacheTest/testClearCache2.result.xml")
public void testClearCache2() {
    Role_ r = new Role_(), r2 = new Role_();
    r.setId(1);
    r.setName("root");
    roleService.insert(r);
    r2.setId(2);
    r2.setName("deployer");
    roleService.insert(r2);
    Account_ a = new Account_(), a2 = new Account_(), a3 = new Account_(), a4 = new Account_(), a5 = new Account_(), a6 = new Account_(), a7 = new Account_(), a8 = new Account_(), a9 = new Account_(), a10 = new Account_(), a11 = new Account_(), a12 = new Account_();
    a.setName("ann");
    a.setEmail("");
    a.setRole(r);
    accountService.insert(a);
    a2.setName("bob");
    a2.setEmail("");
    a2.setRole(r);
    accountService.insert(a2);
    a3.setName("caq");
    a3.setEmail("");
    a3.setRole(r);
    accountService.insert(a3);
    a4.setName("don");
    a4.setEmail("");
    a4.setRole(r);
    accountService.insert(a4);
    a5.setName("eli");
    a5.setEmail("");
    a5.setRole(r);
    accountService.insert(a5);
    a6.setName("fea");
    a6.setEmail("");
    a6.setRole(r);
    accountService.insert(a6);
    a7.setName("gus");
    a7.setEmail("");
    a7.setRole(r);
    accountService.insert(a7);
    a8.setName("hex");
    a8.setEmail("");
    a8.setRole(r);
    accountService.insert(a8);
    a9.setName("ivy");
    a9.setEmail("");
    a9.setRole(r);
    accountService.insert(a9);
    a10.setName("jak");
    a10.setEmail("");
    a10.setRole(r);
    accountService.insert(a10);
    a11.setName("kir");
    a11.setEmail("");
    a11.setRole(r);
    accountService.insert(a11);
    a12.setName("lee");
    a12.setEmail("");
    a12.setRole(r);
    accountService.insert(a12);
    Role_ role = roleService.select(1);
    Account_Condition ac = new Account_Condition();
    ac.setLimiter(new PageParam(2, 10));
    ac.setEmail("");
    Role_ rc = new Role_();
    rc.setId(1);
    ac.setRole(rc);
    Collection<Account_> c = accountService.selectAll(ac);
    Page<Account_> p = new Page<>(c, ac.getLimiter());
    Assert.assertEquals(2, p.getPageItems().size());
    Assert.assertEquals(10, p.getPageSize());
    for (Account_ temp : p.getPageItems()) {
        Assert.assertEquals("root", temp.getRole().getName());
    }
    Account_Condition ac1 = new Account_Condition();
    ac1.setLimiter(new PageParam(2, 10));
    ac1.setEmail("");
    Role_ rc1 = new Role_();
    rc1.setId(1);
    ac1.setRole(rc1);
    Collection<Account_> c1 = accountService.selectAll(ac1);
    role.setName("rootNew");
    roleService.update(role);
    Account_Condition ac2 = new Account_Condition();
    ac2.setLimiter(new PageParam(2, 10));
    ac2.setEmail("");
    Role_ rc2 = new Role_();
    rc2.setId(1);
    ac2.setRole(rc2);
    Collection<Account_> c2 = accountService.selectAll(ac2);
    Page<Account_> p2 = new Page<>(c2, ac2.getLimiter());
    Assert.assertEquals(2, p2.getPageItems().size());
    for (Account_ temp : p2.getPageItems()) {
        Assert.assertEquals("rootNew", temp.getRole().getName());
    }
}
Also used : Account_(indi.mybatis.flying.pojo.Account_) Account_Condition(indi.mybatis.flying.pojo.condition.Account_Condition) Page(indi.mybatis.flying.pagination.Page) PageParam(indi.mybatis.flying.pagination.PageParam) Role_(indi.mybatis.flying.pojo.Role_) ExpectedDatabase(com.github.springtestdbunit.annotation.ExpectedDatabase) Test(org.junit.Test) DatabaseTearDown(com.github.springtestdbunit.annotation.DatabaseTearDown) IfProfileValue(org.springframework.test.annotation.IfProfileValue)

Example 35 with Account_Condition

use of indi.mybatis.flying.pojo.condition.Account_Condition in project mybatis.flying by limeng32.

the class CacheTest1 method testUpdateDirect4.

/* 测试在查询对象查询的情况下,缓存确实生效的用例 */
// @Test
@IfProfileValue(name = "CACHE", value = "true")
@ExpectedDatabase(connection = "dataSource1", assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/cacheTest/testUpdateDirect.result.xml")
@DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/cacheTest/testUpdateDirect.result.xml")
public void testUpdateDirect4() {
    Role_ r = new Role_();
    r.setId(1);
    r.setName("ann");
    roleService.insert(r);
    Account_ a = new Account_();
    a.setId(1L);
    a.setRole(r);
    a.setEmail("email");
    accountService.insert(a);
    Account_Condition ac = new Account_Condition();
    ac.setLimiter(new PageParam(1, 1));
    Collection<Account_> c = accountService.selectAll(ac);
    Map<String, Object> m = new HashMap<>(4);
    m.put("id", 1);
    m.put("name", "bob");
    roleService.updateDirect(m);
    Account_Condition ac2 = new Account_Condition();
    ac2.setLimiter(new PageParam(1, 1));
    Collection<Account_> c2 = accountService.selectAll(ac2);
    for (Account_ t : c2) {
        Assert.assertEquals("ann", t.getRole().getName());
    }
}
Also used : HashMap(java.util.HashMap) Account_(indi.mybatis.flying.pojo.Account_) Account_Condition(indi.mybatis.flying.pojo.condition.Account_Condition) PageParam(indi.mybatis.flying.pagination.PageParam) Role_(indi.mybatis.flying.pojo.Role_) ExpectedDatabase(com.github.springtestdbunit.annotation.ExpectedDatabase) DatabaseTearDown(com.github.springtestdbunit.annotation.DatabaseTearDown) IfProfileValue(org.springframework.test.annotation.IfProfileValue)

Aggregations

DatabaseTearDown (com.github.springtestdbunit.annotation.DatabaseTearDown)54 Account_Condition (indi.mybatis.flying.pojo.condition.Account_Condition)54 Test (org.junit.Test)50 DatabaseSetup (com.github.springtestdbunit.annotation.DatabaseSetup)46 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)44 ExpectedDatabase (com.github.springtestdbunit.annotation.ExpectedDatabase)37 Account_ (indi.mybatis.flying.pojo.Account_)28 ArrayList (java.util.ArrayList)12 PageParam (indi.mybatis.flying.pagination.PageParam)11 IfProfileValue (org.springframework.test.annotation.IfProfileValue)10 Role_ (indi.mybatis.flying.pojo.Role_)9 LoginLog_ (indi.mybatis.flying.pojo.LoginLog_)6 LoginLog_Condition (indi.mybatis.flying.pojo.condition.LoginLog_Condition)6 Order (indi.mybatis.flying.pagination.Order)5 SortParam (indi.mybatis.flying.pagination.SortParam)5 Page (indi.mybatis.flying.pagination.Page)4 Role_Condition (indi.mybatis.flying.pojo.condition.Role_Condition)4 HashMap (java.util.HashMap)4 Permission (indi.mybatis.flying.pojo.Permission)1 Account_Condition3 (indi.mybatis.flying.pojo.condition.Account_Condition3)1