use of com.github.springtestdbunit.annotation.DatabaseSetup in project mybatis.flying by limeng32.
the class SelectOneTest method testSelectOne3.
/**
* 测试selectOne3,缓存测试
*/
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/selectOneTest/testSelectOne3.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/selectOneTest/testSelectOne3.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/selectOneTest/testSelectOne3.result.xml")
public void testSelectOne3() {
Account_Condition ac = new Account_Condition();
Account_ account1 = accountService.selectOne(ac);
Assert.assertEquals("ann", account1.getName());
ac.setEmail("ann@live.cn");
ac.setLimiter(new PageParam(1, 8));
ac.setSorter(new SortParam(new Order("id", Sequence.ASC), new Order("name", Sequence.DESC), new Order("id", Sequence.DESC)));
Collection<Account_> accountC = accountService.selectAll(ac);
Assert.assertEquals(2, accountC.size());
}
use of com.github.springtestdbunit.annotation.DatabaseSetup in project mybatis.flying by limeng32.
the class IgnoreTest method testSelectPrefixIgnore.
@Test
@DatabaseSetup(connection = "dataSource1", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/ignoreTest/testSelectPrefixIgnore.xml")
@ExpectedDatabase(connection = "dataSource1", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/ignoreTest/testSelectPrefixIgnore.result.xml")
@DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/ignoreTest/testSelectPrefixIgnore.result.xml")
public void testSelectPrefixIgnore() {
Detail_ detail = detailService.selectPrefixIgnore(202);
Assert.assertNull(detail.getId());
Assert.assertNotNull(detail.getLoginLog().getId());
Assert.assertNull(detail.getLoginLog().getAccount().getName());
Assert.assertEquals("bbb", detail.getLoginLog().getAccount().getPassword());
}
use of com.github.springtestdbunit.annotation.DatabaseSetup in project mybatis.flying by limeng32.
the class IgnoreTest method testIgnore.
@Test
@DatabaseSetup(connection = "dataSource1", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/ignoreTest/testIgnore.xml")
@ExpectedDatabase(connection = "dataSource1", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/ignoreTest/testIgnore.result.xml")
@DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/ignoreTest/testIgnore.result.xml")
public void testIgnore() {
Account_ ac = new Account_();
Collection<Account_> accountC = accountService.selectAllPrefixIgnore(ac);
Account_[] accounts = accountC.toArray(new Account_[accountC.size()]);
Assert.assertNotNull(accounts[0].getPassword());
Assert.assertNull(accounts[0].getName());
LoginLog_ lc = new LoginLog_();
Collection<LoginLog_> loginLogC = loginLogService.selectAllPrefixIgnore(lc);
LoginLog_[] loginLogs = loginLogC.toArray(new LoginLog_[loginLogC.size()]);
Assert.assertNull(loginLogs[0].getAccount().getName());
Detail_ dc = new Detail_();
Collection<Detail_> detailC = detailService.selectAllPrefixIgnore(dc);
Detail_[] details = detailC.toArray(new Detail_[detailC.size()]);
Assert.assertNull(details[0].getId());
Assert.assertNotNull(details[0].getLoginLog().getId());
Assert.assertNull(details[0].getLoginLog().getAccount().getName());
Collection<Detail_> detailC2 = detailService.selectAllPrefixIgnore2(dc);
Detail_[] details2 = detailC2.toArray(new Detail_[detailC2.size()]);
Assert.assertNull(details2[0].getLoginLog());
Collection<Detail_> detailC3 = detailService.selectAllPrefixIgnore3(dc);
Detail_[] details3 = detailC3.toArray(new Detail_[detailC3.size()]);
Assert.assertNull(details3[0].getLoginLog().getId());
}
use of com.github.springtestdbunit.annotation.DatabaseSetup in project mybatis.flying by limeng32.
the class IgnoreTest method testSelectOne.
@Test
@DatabaseSetup(connection = "dataSource1", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/ignoreTest/testSelectOne.xml")
@ExpectedDatabase(connection = "dataSource1", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/ignoreTest/testSelectOne.result.xml")
@DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/ignoreTest/testSelectOne.result.xml")
public void testSelectOne() {
Detail_ dc = new Detail_();
dc.setId(202);
Detail_ detail = detailService.selectOnePrefixIgnore(dc);
Assert.assertNull(detail.getId());
Assert.assertNotNull(detail.getLoginLog().getId());
Assert.assertNull(detail.getLoginLog().getAccount().getName());
Assert.assertEquals("bbb", detail.getLoginLog().getAccount().getPassword());
}
use of com.github.springtestdbunit.annotation.DatabaseSetup in project mybatis.flying by limeng32.
the class NullOrNotTest method testNullOrNot.
/**
* 测试NullOrNot关键字
*/
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/nullOrNotTest/testNullOrNot.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/nullOrNotTest/testNullOrNot.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/nullOrNotTest/testNullOrNot.xml")
public void testNullOrNot() {
Account_Condition ac = new Account_Condition();
ac.setEmailIsNull(true);
Collection<Account_> accountC = accountService.selectAll(ac);
Assert.assertEquals(1, accountC.size());
int count = accountService.count(ac);
Assert.assertEquals(1, count);
Account_Condition ac2 = new Account_Condition();
ac2.setEmailIsNull(false);
Collection<Account_> accountC2 = accountService.selectAll(ac2);
Assert.assertEquals(1, accountC2.size());
int count2 = accountService.count(ac2);
Assert.assertEquals(1, count2);
Account_Condition ac3 = new Account_Condition();
Collection<Account_> accountC3 = accountService.selectAll(ac3);
Assert.assertEquals(2, accountC3.size());
int count3 = accountService.count(ac3);
Assert.assertEquals(2, count3);
Account_Condition ac4 = new Account_Condition();
ac4.setRoleIsNull(true);
Collection<Account_> accountC4 = accountService.selectAll(ac4);
for (Account_ a : accountC4) {
Assert.assertEquals("bob", a.getName());
}
int count4 = accountService.count(ac4);
Assert.assertEquals(1, count4);
Account_Condition ac5 = new Account_Condition();
ac5.setRoleIsNull(false);
Collection<Account_> accountC5 = accountService.selectAll(ac5);
for (Account_ a : accountC5) {
Assert.assertEquals("ann", a.getName());
}
int count5 = accountService.count(ac5);
Assert.assertEquals(1, count5);
}
Aggregations