Search in sources :

Example 16 with Account_Condition

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

the class CacheTest 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)

Example 17 with Account_Condition

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

the class ConditionNotInTest method testConditionNotIn.

/**
 * 测试无外键情况下condition:notIn功能
 */
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/conditionNotInTest/testConditionIn.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/conditionNotInTest/testConditionIn.xml")
public void testConditionNotIn() {
    Account_Condition ac = new Account_Condition();
    List<String> nameC = new ArrayList<>();
    nameC.add("ann");
    ac.setNameNotIn(nameC);
    Collection<Account_> c = accountService.selectAll(ac);
    Assert.assertEquals(1, c.size());
    nameC.add("bob");
    Collection<Account_> c2 = accountService.selectAll(ac);
    Assert.assertEquals(0, c2.size());
    List<String> nameC2 = new ArrayList<>();
    ac.setNameNotIn(nameC2);
    Collection<Account_> c3 = accountService.selectAll(ac);
    Assert.assertEquals(2, c3.size());
}
Also used : 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 18 with Account_Condition

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

the class ConditionNotInTest method testConditionNotIn3.

/**
 * 测试无外键情况下condition:notIn功能且变量类型为数字的情况
 */
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/conditionNotInTest/testConditionIn3.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/conditionNotInTest/testConditionIn3.xml")
public void testConditionNotIn3() {
    Account_Condition ac = new Account_Condition();
    List<Integer> opLockC = new ArrayList<>();
    opLockC.add(1);
    opLockC.add(2);
    ac.setOpLockNotIn(opLockC);
    int count = accountService.count(ac);
    Assert.assertEquals(0, count);
}
Also used : ArrayList(java.util.ArrayList) Account_Condition(indi.mybatis.flying.pojo.condition.Account_Condition) Test(org.junit.Test) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup) DatabaseTearDown(com.github.springtestdbunit.annotation.DatabaseTearDown)

Example 19 with Account_Condition

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

the class ConditionTest method testSorterWithMultiAssociation.

/**
 * 测试多重外键情况下sorter是否能正确发挥作用
 */
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/conditionTest/testSorterWithMultiAssociation.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/conditionTest/testSorterWithMultiAssociation.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/conditionTest/testSorterWithMultiAssociation.xml")
public void testSorterWithMultiAssociation() {
    Role_Condition rc1 = new Role_Condition();
    rc1.setName("role1");
    Role_Condition rc2 = new Role_Condition();
    rc2.setName("role2");
    Account_Condition ac = new Account_Condition();
    ac.setRole(rc1);
    ac.setRoleDeputy(rc2);
    ac.setSorter(new SortParam(new Order("name", Sequence.asc)));
    Collection<Account_> accountC = accountService.selectAll(ac);
    Account_[] accounts = accountC.toArray(new Account_[accountC.size()]);
    Assert.assertEquals(3, accounts.length);
    Assert.assertEquals("bob", accounts[0].getName());
}
Also used : Order(indi.mybatis.flying.pagination.Order) Role_Condition(indi.mybatis.flying.pojo.condition.Role_Condition) Account_Condition(indi.mybatis.flying.pojo.condition.Account_Condition) Account_(indi.mybatis.flying.pojo.Account_) 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 20 with Account_Condition

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

the class ConditionTest method testConditionLike2.

/**
 * 测试condition:like功能2:在parameter为null和为空字符串时的情况
 */
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/conditionTest/testConditionLike2.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/conditionTest/testConditionLike2.xml")
public void testConditionLike2() {
    Account_Condition ac = new Account_Condition(), ac2 = new Account_Condition();
    ac.setEmailLike(null);
    Collection<Account_> c = accountService.selectAll(ac);
    Account_[] accounts = c.toArray(new Account_[c.size()]);
    Assert.assertEquals(2, accounts.length);
    ac2.setEmailLike("");
    Collection<Account_> c2 = accountService.selectAll(ac);
    Assert.assertEquals(2, c2.size());
}
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)

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