use of com.github.springtestdbunit.annotation.DatabaseSetup 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());
}
use of com.github.springtestdbunit.annotation.DatabaseSetup 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);
}
use of com.github.springtestdbunit.annotation.DatabaseSetup 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());
}
use of com.github.springtestdbunit.annotation.DatabaseSetup 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);
}
use of com.github.springtestdbunit.annotation.DatabaseSetup 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());
}
}
Aggregations