Search in sources :

Example 36 with Account_

use of indi.mybatis.flying.pojo.Account_ 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());
}
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) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup) DatabaseTearDown(com.github.springtestdbunit.annotation.DatabaseTearDown)

Example 37 with Account_

use of indi.mybatis.flying.pojo.Account_ 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());
}
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) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup) DatabaseTearDown(com.github.springtestdbunit.annotation.DatabaseTearDown)

Example 38 with Account_

use of indi.mybatis.flying.pojo.Account_ 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());
}
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)

Example 39 with Account_

use of indi.mybatis.flying.pojo.Account_ in project mybatis.flying by limeng32.

the class DirectSqlTest method testDirectSelect.

/**
 * flying托管与非托管共存的情况
 */
@Test
@DatabaseSetups({ @DatabaseSetup(connection = "dataSource1", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/directSqlTest/testDirectSelect.xml") })
@ExpectedDatabases({ @ExpectedDatabase(connection = "dataSource1", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/directSqlTest/testDirectSelect.result.xml") })
@DatabaseTearDowns({ @DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/directSqlTest/testDirectSelect.result.xml") })
public void testDirectSelect() {
    Account_ account1 = accountService.selectDirect(1);
    Assert.assertEquals("ann", account1.getName());
    Assert.assertEquals("5a690d842935c51f26f473e025c1b97a", account1.getPassword());
    Account_ account2 = accountService.select(1);
    Assert.assertNull(account2.getPassword());
    Account_ account3 = accountService.selectEverything(1);
    Assert.assertEquals("5a690d842935c51f26f473e025c1b97a", account3.getPassword());
    Map<String, Object> map = new HashMap<>(4);
    map.put("name", "bob");
    map.put("email", "bob@live.cn");
    Collection<Account_> c1 = accountService.selectAllDirect(map);
    for (Account_ t : c1) {
        Assert.assertEquals("5a690d842935c51f26f473e025c1b97b", t.getPassword());
    }
    Account_ a1 = new Account_();
    a1.setName("bob");
    a1.setEmail("bob@live.cn");
    Collection<Account_> c2 = accountService.selectAll(a1);
    for (Account_ t : c2) {
        Assert.assertNull(t.getPassword());
    }
    Collection<Account_> c3 = accountService.selectAllEverything(a1);
    for (Account_ t : c3) {
        Assert.assertEquals("5a690d842935c51f26f473e025c1b97b", t.getPassword());
    }
}
Also used : HashMap(java.util.HashMap) Account_(indi.mybatis.flying.pojo.Account_) DatabaseSetups(com.github.springtestdbunit.annotation.DatabaseSetups) Test(org.junit.Test) ExpectedDatabases(com.github.springtestdbunit.annotation.ExpectedDatabases) DatabaseTearDowns(com.github.springtestdbunit.annotation.DatabaseTearDowns)

Example 40 with Account_

use of indi.mybatis.flying.pojo.Account_ in project mybatis.flying by limeng32.

the class NoApplicationContextProviderTest method testNormal.

@Test
@IfProfileValue(name = "NO_PROVIDER", value = "true")
@DatabaseSetups({ @DatabaseSetup(connection = "dataSource1", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/noApplicationContextProviderTest/testNormal.datasource.xml"), @DatabaseSetup(connection = "dataSource2", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/noApplicationContextProviderTest/testNormal.datasource2.xml") })
@ExpectedDatabases({ @ExpectedDatabase(connection = "dataSource1", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/noApplicationContextProviderTest/testNormal.datasource.result.xml"), @ExpectedDatabase(connection = "dataSource2", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/noApplicationContextProviderTest/testNormal.datasource2.result.xml") })
@DatabaseTearDowns({ @DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/noApplicationContextProviderTest/testNormal.datasource.result.xml"), @DatabaseTearDown(connection = "dataSource2", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/noApplicationContextProviderTest/testNormal.datasource2.result.xml") })
public void testNormal() {
    Account_ a = accountService.selectWithoutCache(1);
    assertEquals("r", a.getRole().getName());
    Role_ r = roleService.selectWithoutCache(51);
    assertEquals("r", r.getName());
    try {
        Account22 account22 = account22Service.select(11);
        fail("Expected an Exception to be thrown");
    } catch (Exception e) {
        assertEquals("Can not find the ApplicationContextProvider bean in the context", e.getCause().getCause().getMessage());
    }
}
Also used : Account22(indi.mybatis.flying.pojo.Account22) Account_(indi.mybatis.flying.pojo.Account_) Role_(indi.mybatis.flying.pojo.Role_) DatabaseSetups(com.github.springtestdbunit.annotation.DatabaseSetups) Test(org.junit.Test) ExpectedDatabases(com.github.springtestdbunit.annotation.ExpectedDatabases) DatabaseTearDowns(com.github.springtestdbunit.annotation.DatabaseTearDowns) IfProfileValue(org.springframework.test.annotation.IfProfileValue)

Aggregations

Account_ (indi.mybatis.flying.pojo.Account_)42 Test (org.junit.Test)38 DatabaseTearDown (com.github.springtestdbunit.annotation.DatabaseTearDown)36 DatabaseSetup (com.github.springtestdbunit.annotation.DatabaseSetup)25 ExpectedDatabase (com.github.springtestdbunit.annotation.ExpectedDatabase)25 Account_Condition (indi.mybatis.flying.pojo.condition.Account_Condition)18 IfProfileValue (org.springframework.test.annotation.IfProfileValue)18 Role_ (indi.mybatis.flying.pojo.Role_)17 LoginLog_ (indi.mybatis.flying.pojo.LoginLog_)8 HashMap (java.util.HashMap)8 DatabaseSetups (com.github.springtestdbunit.annotation.DatabaseSetups)6 DatabaseTearDowns (com.github.springtestdbunit.annotation.DatabaseTearDowns)6 ExpectedDatabases (com.github.springtestdbunit.annotation.ExpectedDatabases)6 PageParam (indi.mybatis.flying.pagination.PageParam)6 Order (indi.mybatis.flying.pagination.Order)4 SortParam (indi.mybatis.flying.pagination.SortParam)4 ArrayList (java.util.ArrayList)4 LoginLogSource2 (indi.mybatis.flying.pojo.LoginLogSource2)3 Page (indi.mybatis.flying.pagination.Page)2 Account2_ (indi.mybatis.flying.pojo.Account2_)2