Search in sources :

Example 6 with DatabaseSetup

use of com.github.springtestdbunit.annotation.DatabaseSetup 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 7 with DatabaseSetup

use of com.github.springtestdbunit.annotation.DatabaseSetup 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 8 with DatabaseSetup

use of com.github.springtestdbunit.annotation.DatabaseSetup 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 9 with DatabaseSetup

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

Example 10 with DatabaseSetup

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

the class ConditionNotInTest method testConditionNotIn2.

/**
 * 测试有外键情况下condition:notIn功能
 */
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/conditionNotInTest/testConditionIn2.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/conditionNotInTest/testConditionIn2.xml")
public void testConditionNotIn2() {
    LoginLog_Condition lc = new LoginLog_Condition();
    Account_Condition ac = new Account_Condition();
    List<String> nameC = new ArrayList<>();
    nameC.add("ann");
    nameC.add("bob");
    ac.setNameNotIn(nameC);
    lc.setAccount(ac);
    Collection<LoginLog_> c = loginLogService.selectAll(lc);
    Assert.assertEquals(0, c.size());
    int count = loginLogService.count(lc);
    Assert.assertEquals(0, 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

DatabaseSetup (com.github.springtestdbunit.annotation.DatabaseSetup)79 Test (org.junit.Test)78 ExpectedDatabase (com.github.springtestdbunit.annotation.ExpectedDatabase)53 DatabaseTearDown (com.github.springtestdbunit.annotation.DatabaseTearDown)44 MvcResult (org.springframework.test.web.servlet.MvcResult)26 Account_ (indi.mybatis.flying.pojo.Account_)25 Account_Condition (indi.mybatis.flying.pojo.condition.Account_Condition)22 WithUserDetails (org.springframework.security.test.context.support.WithUserDetails)21 LoginLog_ (indi.mybatis.flying.pojo.LoginLog_)12 LoginLog_Condition (indi.mybatis.flying.pojo.condition.LoginLog_Condition)11 ArrayList (java.util.ArrayList)11 ExpectedDatabases (com.github.springtestdbunit.annotation.ExpectedDatabases)8 CreateStudyDTO (com.odysseusinc.arachne.portal.api.v1.dto.CreateStudyDTO)7 StudyDTO (com.odysseusinc.arachne.portal.api.v1.dto.StudyDTO)6 StudyStatusDTO (com.odysseusinc.arachne.portal.api.v1.dto.dictionary.StudyStatusDTO)6 IfProfileValue (org.springframework.test.annotation.IfProfileValue)5 StudyTypeDTO (com.odysseusinc.arachne.portal.api.v1.dto.dictionary.StudyTypeDTO)4 Order (indi.mybatis.flying.pagination.Order)4 SortParam (indi.mybatis.flying.pagination.SortParam)4 Role_ (indi.mybatis.flying.pojo.Role_)4