use of com.github.springtestdbunit.annotation.DatabaseSetup in project mybatis.flying by limeng32.
the class ConditionNotInTest method testConditionNotIn4.
/**
* 测试无外键情况下condition:notIn功能且变量类型为时间的情况
*/
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/conditionNotInTest/testConditionIn4.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/conditionNotInTest/testConditionIn4.xml")
public void testConditionNotIn4() {
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.setLoginTimeNotIn(timeC);
int count = loginLogService.count(lc);
Assert.assertEquals(0, count);
}
use of com.github.springtestdbunit.annotation.DatabaseSetup in project mybatis.flying by limeng32.
the class ConditionTest method testSorterWithMultiAssociation.
/**
* 测试多重外键情况下sorter是否能正确发挥作用
*/
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/conditionTest/testSorterWithMultiAssociation.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/conditionTest/testSorterWithMultiAssociation.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/conditionTest/testSorterWithMultiAssociation.xml")
public void testSorterWithMultiAssociation() {
Role_Condition rc1 = new Role_Condition();
rc1.setName("role1");
Role_Condition rc2 = new Role_Condition();
rc2.setName("role2");
Account_Condition ac = new Account_Condition();
ac.setRole(rc1);
ac.setRoleDeputy(rc2);
ac.setSorter(new SortParam(new Order("name", Sequence.asc)));
Collection<Account_> accountC = accountService.selectAll(ac);
Account_[] accounts = accountC.toArray(new Account_[accountC.size()]);
Assert.assertEquals(3, accounts.length);
Assert.assertEquals("bob", accounts[0].getName());
}
use of com.github.springtestdbunit.annotation.DatabaseSetup in project mybatis.flying by limeng32.
the class ConditionTest method testConditionLike2.
/**
* 测试condition:like功能2:在parameter为null和为空字符串时的情况
*/
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/conditionTest/testConditionLike2.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/conditionTest/testConditionLike2.xml")
public void testConditionLike2() {
Account_Condition ac = new Account_Condition(), ac2 = new Account_Condition();
ac.setEmailLike(null);
Collection<Account_> c = accountService.selectAll(ac);
Account_[] accounts = c.toArray(new Account_[c.size()]);
Assert.assertEquals(2, accounts.length);
ac2.setEmailLike("");
Collection<Account_> c2 = accountService.selectAll(ac);
Assert.assertEquals(2, c2.size());
}
use of com.github.springtestdbunit.annotation.DatabaseSetup in project mybatis.flying by limeng32.
the class ConditionTest method testConditionLike.
/**
* 测试condition:like功能
*/
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/conditionTest/testConditionLike.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/conditionTest/testConditionLike.xml")
public void testConditionLike() {
Account_Condition ac = new Account_Condition();
ac.setEmailLike("%%");
Collection<Account_> c = accountService.selectAll(ac);
Account_[] accounts = c.toArray(new Account_[c.size()]);
Assert.assertEquals(1, accounts.length);
Assert.assertEquals("an%%n@live.cn", accounts[0].getEmail());
}
use of com.github.springtestdbunit.annotation.DatabaseSetup 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());
}
Aggregations