Search in sources :

Example 31 with DatabaseTearDown

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

the class AccountTest method testCostumizeStatus.

/**
 * 测试CostumizeStatus功能
 */
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/accountTest/testCostumizeStatus.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/accountTest/testCostumizeStatus.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/accountTest/testCostumizeStatus.xml")
public void testCostumizeStatus() {
    Account_ a = accountService.select(1);
    Assert.assertEquals("发布", a.getStatus().text());
    Account_ ac = new Account_();
    ac.setStatus(StoryStatus_.p);
    Collection<Account_> c = accountService.selectAll(ac);
    Assert.assertEquals(1, c.size());
    Account_ a2 = accountService.select(2);
    Assert.assertEquals(StoryStatus_.s, a2.getStatus());
    a2.setStatus(StoryStatus_.c);
    accountService.update(a2);
    Account_ a3 = accountService.select(3);
    Assert.assertNull(a3.getStatus());
    a3.setPassword("5a690d842935c51f26f473e025c1b97a");
    accountService.updatePersistent(a3);
    Account_ a4 = accountService.select(3);
    Assert.assertNull(a4.getStatus());
}
Also used : Account_(indi.mybatis.flying.pojo.Account_) ExpectedDatabase(com.github.springtestdbunit.annotation.ExpectedDatabase) Test(org.junit.Test) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup) DatabaseTearDown(com.github.springtestdbunit.annotation.DatabaseTearDown)

Example 32 with DatabaseTearDown

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

the class AccountTest method testDeputy.

/**
 * 测试deputyRole
 */
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/accountTest/testDeputy.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/accountTest/testDeputy.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/accountTest/testDeputy.xml")
public void testDeputy() {
    Account_ account = accountService.select(1);
    Assert.assertEquals("role1", account.getRole().getName());
    Assert.assertEquals("role2", account.getRoleDeputy().getName());
    Role_ rc = new Role_();
    rc.setName("role1");
    Role_ rdc = new Role_();
    rdc.setName("role2");
    Account_ ac = new Account_();
    ac.setRole(rc);
    ac.setRoleDeputy(rdc);
    Collection<Account_> accountC = accountService.selectAll(ac);
    Assert.assertEquals(1, accountC.size());
    int count = accountService.count(ac);
    Assert.assertEquals(1, count);
}
Also used : Account_(indi.mybatis.flying.pojo.Account_) Role_(indi.mybatis.flying.pojo.Role_) ExpectedDatabase(com.github.springtestdbunit.annotation.ExpectedDatabase) Test(org.junit.Test) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup) DatabaseTearDown(com.github.springtestdbunit.annotation.DatabaseTearDown)

Example 33 with DatabaseTearDown

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

the class AccountTest method testLimiter.

/**
 * 测试limiter功能
 */
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/accountTest/testLimiter.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/accountTest/testLimiter.xml")
public void testLimiter() {
    Account_Condition ac = new Account_Condition();
    ac.setLimiter(new PageParam(1, 2));
    Collection<Account_> c = accountService.selectAll(ac);
    Account_[] accounts = c.toArray(new Account_[c.size()]);
    Assert.assertEquals(2, accounts.length);
    Assert.assertEquals(1, accounts[0].getId().intValue());
    Assert.assertEquals(2, accounts[1].getId().intValue());
    Assert.assertEquals(2, ac.getLimiter().getMaxPageNum());
    ac.setSorter(new SortParam(new Order(Account_Condition.field_id, Conditionable.Sequence.desc)));
    c = accountService.selectAll(ac);
    accounts = c.toArray(new Account_[c.size()]);
    Assert.assertEquals(2, accounts.length);
    Assert.assertEquals(4, accounts[0].getId().intValue());
    Assert.assertEquals(3, accounts[1].getId().intValue());
}
Also used : Order(indi.mybatis.flying.pagination.Order) Account_Condition(indi.mybatis.flying.pojo.condition.Account_Condition) Account_(indi.mybatis.flying.pojo.Account_) PageParam(indi.mybatis.flying.pagination.PageParam) SortParam(indi.mybatis.flying.pagination.SortParam) Test(org.junit.Test) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup) DatabaseTearDown(com.github.springtestdbunit.annotation.DatabaseTearDown)

Example 34 with DatabaseTearDown

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

the class AccountTest method testDelete.

/**
 * 测试delete功能
 */
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/accountTest/testDelete.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/accountTest/testDelete.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/accountTest/testDelete.xml")
public void testDelete() {
    Account_ a = accountService.select(1);
    accountService.delete(a);
}
Also used : Account_(indi.mybatis.flying.pojo.Account_) ExpectedDatabase(com.github.springtestdbunit.annotation.ExpectedDatabase) Test(org.junit.Test) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup) DatabaseTearDown(com.github.springtestdbunit.annotation.DatabaseTearDown)

Example 35 with DatabaseTearDown

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

the class AccountTest method testIgnoreTag.

/**
 * 测试ignoreTag功能
 */
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/accountTest/testIgnoredSelect.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/accountTest/testIgnoredSelect.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/accountTest/testIgnoredSelect.xml")
public void testIgnoreTag() {
    Account_ account = accountService.select(1);
    Assert.assertNull(account.getPassword());
    Account_ ac = new Account_();
    Collection<Account_> accountC = accountService.selectAll(ac);
    for (Account_ a : accountC) {
        Assert.assertNull(a.getPassword());
    }
    Account_ ac2 = new Account_();
    ac2.setPassword("5a690d842935c51f26f473e025c1b97a");
    Collection<Account_> accountC2 = accountService.selectAll(ac2);
    Assert.assertEquals(1, accountC2.size());
    LoginLog_ loginLog = loginLogService.select(1);
    Assert.assertNull(loginLog.getAccount().getPassword());
    LoginLog_ lc2 = new LoginLog_();
    lc2.setAccount(ac2);
    Collection<LoginLog_> loginLogC = loginLogService.selectAll(lc2);
    Assert.assertEquals(1, loginLogC.size());
    for (LoginLog_ l : loginLogC) {
        Assert.assertEquals("0.0.0.1", l.getLoginIP());
    }
}
Also used : LoginLog_(indi.mybatis.flying.pojo.LoginLog_) Account_(indi.mybatis.flying.pojo.Account_) 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)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