Search in sources :

Example 16 with DatabaseTearDown

use of com.github.springtestdbunit.annotation.DatabaseTearDown in project mybatis.flying by limeng32.

the class CacheTest method testInsertSnowFlakeCache.

/* 一个在缓存状态下使用自定义主键生成器insert的测试用例 */
/* 使用普通方式增加一个Account,查询数量为1,再使用自定义主键方式增加一个Account,查询数量为2 */
@Test
@IfProfileValue(name = "CACHE", value = "true")
@ExpectedDatabase(connection = "dataSource1", assertionMode = DatabaseAssertionMode.NON_STRICT_UNORDERED, value = "/indi/mybatis/flying/test/cacheTest/testInsertSnowFlakeCache.result.xml")
@DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/cacheTest/testInsertSnowFlakeCache.result.xml")
public void testInsertSnowFlakeCache() {
    Account_ account = new Account_();
    account.setName("ann");
    accountService.insert(account);
    int i = accountService.count(new Account_());
    Assert.assertEquals(1, i);
    Account_ account2 = new Account_();
    account2.setName("bob");
    accountService.insertSnowFlake(account2);
    int i2 = accountService.count(new Account_());
    Assert.assertEquals(2, i2);
}
Also used : Account_(indi.mybatis.flying.pojo.Account_) ExpectedDatabase(com.github.springtestdbunit.annotation.ExpectedDatabase) Test(org.junit.Test) DatabaseTearDown(com.github.springtestdbunit.annotation.DatabaseTearDown) IfProfileValue(org.springframework.test.annotation.IfProfileValue)

Example 17 with DatabaseTearDown

use of com.github.springtestdbunit.annotation.DatabaseTearDown in project mybatis.flying by limeng32.

the class ConditionInTest method testConditionIn.

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

use of com.github.springtestdbunit.annotation.DatabaseTearDown in project mybatis.flying by limeng32.

the class ConditionInTest method testConditionIn4.

/**
 * 测试无外键情况下condition:in功能且变量类型为时间的情况
 */
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/conditionInTest/testConditionIn4.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/conditionInTest/testConditionIn4.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/conditionInTest/testConditionIn4.xml")
public void testConditionIn4() {
    LoginLog_Condition lc = new LoginLog_Condition();
    List<Date> timeC = new ArrayList<>();
    Calendar c = Calendar.getInstance(), c2 = Calendar.getInstance();
    c.clear();
    c2.clear();
    c.set(1970, 0, 1, 8, 0, 0);
    c2.set(1970, 0, 1, 8, 0, 1);
    timeC.add(c.getTime());
    timeC.add(c2.getTime());
    lc.setLoginTimeIn(timeC);
    int count = loginLogService.count(lc);
    Assert.assertEquals(2, count);
}
Also used : Calendar(java.util.Calendar) ArrayList(java.util.ArrayList) LoginLog_Condition(indi.mybatis.flying.pojo.condition.LoginLog_Condition) Date(java.util.Date) ExpectedDatabase(com.github.springtestdbunit.annotation.ExpectedDatabase) Test(org.junit.Test) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup) DatabaseTearDown(com.github.springtestdbunit.annotation.DatabaseTearDown)

Example 19 with DatabaseTearDown

use of com.github.springtestdbunit.annotation.DatabaseTearDown in project mybatis.flying by limeng32.

the class ConditionInTest method testConditionIn3.

/**
 * 测试无外键情况下condition:in功能且变量类型为数字的情况
 */
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/conditionInTest/testConditionIn3.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/conditionInTest/testConditionIn3.xml")
public void testConditionIn3() {
    Account_Condition ac = new Account_Condition();
    List<Integer> opLockC = new ArrayList<>();
    opLockC.add(1);
    opLockC.add(2);
    ac.setOpLockIn(opLockC);
    int count = accountService.count(ac);
    Assert.assertEquals(2, 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 20 with DatabaseTearDown

use of com.github.springtestdbunit.annotation.DatabaseTearDown in project mybatis.flying by limeng32.

the class ConditionInTest method testConditionIn2.

/**
 * 测试有外键情况下condition:in功能
 */
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/conditionInTest/testConditionIn2.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/conditionInTest/testConditionIn2.xml")
public void testConditionIn2() {
    LoginLog_Condition lc = new LoginLog_Condition();
    List<String> loginIpC = new ArrayList<>();
    loginIpC.add("11");
    loginIpC.add("22");
    lc.setLoginIPIn(loginIpC);
    Account_Condition ac = new Account_Condition();
    List<String> nameC = new ArrayList<>();
    nameC.add("ann");
    nameC.add("bob");
    ac.setNameIn(nameC);
    lc.setAccount(ac);
    Collection<LoginLog_> c = loginLogService.selectAll(lc);
    Assert.assertEquals(2, c.size());
    int count = loginLogService.count(lc);
    Assert.assertEquals(2, count);
}
Also used : LoginLog_(indi.mybatis.flying.pojo.LoginLog_) ArrayList(java.util.ArrayList) LoginLog_Condition(indi.mybatis.flying.pojo.condition.LoginLog_Condition) 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)

Aggregations

DatabaseTearDown (com.github.springtestdbunit.annotation.DatabaseTearDown)59 Test (org.junit.Test)55 DatabaseSetup (com.github.springtestdbunit.annotation.DatabaseSetup)44 ExpectedDatabase (com.github.springtestdbunit.annotation.ExpectedDatabase)42 Account_ (indi.mybatis.flying.pojo.Account_)36 Account_Condition (indi.mybatis.flying.pojo.condition.Account_Condition)26 IfProfileValue (org.springframework.test.annotation.IfProfileValue)20 Role_ (indi.mybatis.flying.pojo.Role_)17 LoginLog_ (indi.mybatis.flying.pojo.LoginLog_)12 LoginLog_Condition (indi.mybatis.flying.pojo.condition.LoginLog_Condition)11 ArrayList (java.util.ArrayList)10 HashMap (java.util.HashMap)9 PageParam (indi.mybatis.flying.pagination.PageParam)7 Order (indi.mybatis.flying.pagination.Order)5 SortParam (indi.mybatis.flying.pagination.SortParam)5 Role_Condition (indi.mybatis.flying.pojo.condition.Role_Condition)5 Date (java.util.Date)3 Page (indi.mybatis.flying.pagination.Page)2 Account2_ (indi.mybatis.flying.pojo.Account2_)2 Role2_ (indi.mybatis.flying.pojo.Role2_)2