Search in sources :

Example 1 with Role_Condition

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

the class CacheTest method testPaginationUsingCacheIndeed.

/* 一个证明分页确实使用了缓存的测试用例 */
@Test
@IfProfileValue(name = "CACHE", value = "true")
@ExpectedDatabase(connection = "dataSource1", assertionMode = DatabaseAssertionMode.NON_STRICT_UNORDERED, value = "/indi/mybatis/flying/test/cacheTest/testPaginationUsingCacheIndeed.result.xml")
@DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/cacheTest/testPaginationUsingCacheIndeed.result.xml")
public void testPaginationUsingCacheIndeed() {
    Role_ role1 = new Role_(), role2 = new Role_(), role3 = new Role_();
    role1.setName("normal");
    roleService.insert(role1);
    role2.setName("silver");
    roleService.insert(role2);
    role3.setName("gold");
    roleService.insert(role3);
    Role_Condition rc = new Role_Condition();
    rc.setLimiter(new PageParam(1, 2));
    rc.setSorter(new SortParam(new Order("name", Conditionable.Sequence.asc)));
    Collection<Role_> c1 = roleService.selectAll(rc);
    Assert.assertEquals(2, c1.size());
    Role_[] roles = c1.toArray(new Role_[c1.size()]);
    Assert.assertEquals("gold", roles[0].getName());
    Map<String, Object> m = new HashMap<>(4);
    m.put("name", "gold1");
    m.put("id", roles[0].getId());
    roleService.updateDirect(m);
    Role_Condition rc2 = new Role_Condition();
    rc2.setLimiter(new PageParam(1, 2));
    rc2.setSorter(new SortParam(new Order("name", Conditionable.Sequence.asc)));
    Collection<Role_> c2 = roleService.selectAll(rc2);
    Assert.assertEquals(2, c2.size());
    Role_[] roles2 = c2.toArray(new Role_[c2.size()]);
    Assert.assertEquals("gold", roles2[0].getName());
}
Also used : Order(indi.mybatis.flying.pagination.Order) Role_Condition(indi.mybatis.flying.pojo.condition.Role_Condition) HashMap(java.util.HashMap) PageParam(indi.mybatis.flying.pagination.PageParam) Role_(indi.mybatis.flying.pojo.Role_) SortParam(indi.mybatis.flying.pagination.SortParam) ExpectedDatabase(com.github.springtestdbunit.annotation.ExpectedDatabase) Test(org.junit.Test) DatabaseTearDown(com.github.springtestdbunit.annotation.DatabaseTearDown) IfProfileValue(org.springframework.test.annotation.IfProfileValue)

Example 2 with Role_Condition

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

the class OrTest method testOr5.

@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/orTest/testOr5.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/orTest/testOr5.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/orTest/testOr5.result.xml")
public void testOr5() {
    LoginLog_Condition lc = new LoginLog_Condition();
    lc.setAccount(new Account_Condition());
    lc.getAccount().setRole(new Role_Condition());
    lc.getAccount().setRoleDeputy(new Role_Condition());
    ((Role_Condition) lc.getAccount().getRole()).setNameEqualsOrAccountNameEquals("user", "bob");
    ((Role_Condition) lc.getAccount().getRoleDeputy()).setNameEqualsOrAccountNameEquals("silver", "bob");
    Collection<LoginLog_> loginLogC = loginLogService.selectAll(lc);
    Assert.assertEquals(2, loginLogC.size());
}
Also used : LoginLog_(indi.mybatis.flying.pojo.LoginLog_) 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 3 with Role_Condition

use of indi.mybatis.flying.pojo.condition.Role_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 4 with Role_Condition

use of indi.mybatis.flying.pojo.condition.Role_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 5 with Role_Condition

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

the class OrTest method testOr6.

/* 一个只有单独入参的或逻辑测试用例 */
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/orTest/testOr6.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/orTest/testOr6.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/orTest/testOr6.result.xml")
public void testOr6() {
    LoginLog_Condition lc = new LoginLog_Condition();
    lc.setAccount(new Account_Condition());
    lc.getAccount().setRole(new Role_Condition());
    ((Role_Condition) lc.getAccount().getRole()).setAccountNameEquals("ann");
    int i = loginLogService.count(lc);
    Assert.assertEquals(2, i);
    LoginLog_Condition lc2 = new LoginLog_Condition();
    lc2.setAccount(new Account_Condition());
    lc2.getAccount().setRole(new Role_Condition());
    ((Role_Condition) lc2.getAccount().getRole()).setNameEquals("admin");
    int i2 = loginLogService.count(lc2);
    Assert.assertEquals(4, 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)

Aggregations

DatabaseTearDown (com.github.springtestdbunit.annotation.DatabaseTearDown)5 ExpectedDatabase (com.github.springtestdbunit.annotation.ExpectedDatabase)5 Role_Condition (indi.mybatis.flying.pojo.condition.Role_Condition)5 Test (org.junit.Test)5 DatabaseSetup (com.github.springtestdbunit.annotation.DatabaseSetup)4 Account_Condition (indi.mybatis.flying.pojo.condition.Account_Condition)4 LoginLog_Condition (indi.mybatis.flying.pojo.condition.LoginLog_Condition)3 Order (indi.mybatis.flying.pagination.Order)2 SortParam (indi.mybatis.flying.pagination.SortParam)2 PageParam (indi.mybatis.flying.pagination.PageParam)1 Account_ (indi.mybatis.flying.pojo.Account_)1 LoginLog_ (indi.mybatis.flying.pojo.LoginLog_)1 Role_ (indi.mybatis.flying.pojo.Role_)1 HashMap (java.util.HashMap)1 IfProfileValue (org.springframework.test.annotation.IfProfileValue)1