Search in sources :

Example 41 with Account_Condition

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

the class ConditionTest method testLikeAndBackslash.

/**
 * 测试condition:对含有\的内容进行匹配
 */
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/conditionTest/testLikeBackslash.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/conditionTest/testLikeBackslash.xml")
public void testLikeAndBackslash() {
    Account_Condition ac = new Account_Condition();
    ac.setNameLike("\\\\");
    int c = accountService.count(ac);
    Assert.assertEquals(3, c);
    ac.setNameLike("\\\\\\\\");
    c = accountService.count(ac);
    Assert.assertEquals(1, c);
    ac.setNameLike("\\\\\\");
    c = accountService.count(ac);
    Assert.assertEquals(2, c);
    ac.setNameLike("\\");
    c = accountService.count(ac);
    Assert.assertEquals(4, c);
    ac.setNameLike(null);
    ac.setName("\\");
    c = accountService.count(ac);
    Assert.assertEquals(1, c);
}
Also used : Account_Condition(indi.mybatis.flying.pojo.condition.Account_Condition) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup) DatabaseTearDown(com.github.springtestdbunit.annotation.DatabaseTearDown)

Example 42 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());
    Account_Condition ac3 = new Account_Condition();
    ac3.setEmailNotHeadLike("ann");
    List<Account_> l = accountService.selectAll(ac3);
    Assert.assertEquals(1, l.size());
    Assert.assertEquals("_ann@live.cn1", l.get(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) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup) DatabaseTearDown(com.github.springtestdbunit.annotation.DatabaseTearDown)

Example 43 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());
    Collection<LoginLog_> c4 = loginLogService.selectAllPrefix(lc);
    Assert.assertEquals(1, c4.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) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup) DatabaseTearDown(com.github.springtestdbunit.annotation.DatabaseTearDown)

Example 44 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());
    Account_Condition ac2 = new Account_Condition();
    ac2.setEmailNotTailLike("live.cn");
    List<Account_> l = accountService.selectAll(ac2);
    Assert.assertEquals(1, l.size());
    Assert.assertEquals("_ann@live.cn_", l.get(0).getEmail());
}
Also used : Account_Condition(indi.mybatis.flying.pojo.condition.Account_Condition) Account_(indi.mybatis.flying.pojo.Account_) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup) DatabaseTearDown(com.github.springtestdbunit.annotation.DatabaseTearDown)

Example 45 with Account_Condition

use of indi.mybatis.flying.pojo.condition.Account_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) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup) DatabaseTearDown(com.github.springtestdbunit.annotation.DatabaseTearDown)

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