Search in sources :

Example 6 with DatabaseSetups

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

the class BatchProcessTest method testUpdateBatch3.

@Test
@DatabaseSetups({ @DatabaseSetup(connection = "dataSource1", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/batchProcessTest/testUpdateBatch.datasource.xml") })
@ExpectedDatabases({ @ExpectedDatabase(connection = "dataSource1", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/batchProcessTest/testUpdateBatch3.datasource.result.xml") })
@DatabaseTearDowns({ @DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/batchProcessTest/testUpdateBatch.datasource.result.xml") })
public void testUpdateBatch3() {
    List<Account_> l = new LinkedList<>();
    Account_ a1 = new Account_();
    Account_ a2 = new Account_();
    Account_ a3 = new Account_();
    a1.setId(1L);
    a1.setName("ann1");
    l.add(a1);
    a2.setId(2L);
    a2.setName("bob2");
    a2.setPassword("b");
    a2.setStatus(StoryStatus_.CANCEL);
    Role_ r1 = new Role_();
    r1.setId(11);
    a2.setRole(r1);
    l.add(a2);
    a3.setId(3L);
    a3.setName("carl3");
    Role_ r2 = new Role_();
    r2.setId(24);
    a3.setRole(r2);
    l.add(a3);
    int i = accountService.updateBatch(l);
    System.out.println("::" + i);
}
Also used : Account_(indi.mybatis.flying.pojo.Account_) LinkedList(java.util.LinkedList) Role_(indi.mybatis.flying.pojo.Role_) DatabaseSetups(com.github.springtestdbunit.annotation.DatabaseSetups) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) ExpectedDatabases(com.github.springtestdbunit.annotation.ExpectedDatabases) DatabaseTearDowns(com.github.springtestdbunit.annotation.DatabaseTearDowns)

Example 7 with DatabaseSetups

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

the class BatchProcessTest method testUpdateBatch.

@Test
@DatabaseSetups({ @DatabaseSetup(connection = "dataSource1", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/batchProcessTest/testUpdateBatch.datasource.xml") })
@ExpectedDatabases({ @ExpectedDatabase(connection = "dataSource1", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/batchProcessTest/testUpdateBatch.datasource.result.xml") })
@DatabaseTearDowns({ @DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/batchProcessTest/testUpdateBatch.datasource.result.xml") })
public void testUpdateBatch() {
    List<Account_> l = new LinkedList<>();
    Account_ a1 = new Account_();
    Account_ a2 = new Account_();
    Account_ a3 = new Account_();
    a1.setId(1L);
    a1.setName("ann1");
    l.add(a1);
    a2.setId(2L);
    a2.setName("bob2");
    a2.setPassword("b");
    a2.setStatus(StoryStatus_.CANCEL);
    Role_ r1 = new Role_();
    r1.setId(11);
    a2.setRole(r1);
    l.add(a2);
    a3.setId(3L);
    a3.setName("carl3");
    a3.setDelegateRoleId(24L);
    l.add(a3);
    int i = accountService.updateBatch(l);
    System.out.println("::" + i);
}
Also used : Account_(indi.mybatis.flying.pojo.Account_) LinkedList(java.util.LinkedList) Role_(indi.mybatis.flying.pojo.Role_) DatabaseSetups(com.github.springtestdbunit.annotation.DatabaseSetups) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) ExpectedDatabases(com.github.springtestdbunit.annotation.ExpectedDatabases) DatabaseTearDowns(com.github.springtestdbunit.annotation.DatabaseTearDowns)

Example 8 with DatabaseSetups

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

the class GroupByTest method test1.

@Test
@DatabaseSetups({ @DatabaseSetup(connection = "dataSource1", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/groupByTest/test1.datasource.xml") })
@ExpectedDatabases({ @ExpectedDatabase(connection = "dataSource1", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/groupByTest/test1.datasource.result.xml") })
@DatabaseTearDowns({ @DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/groupByTest/test1.datasource.xml") })
public void test1() {
    List<Map<String, Object>> m = accountMapper.selectGroupBy2();
    System.out.println("::" + m);
    Account_ a = new Account_();
    a.setName("ann");
    List<Map<String, Object>> m2 = accountMapper.selectGroupBy(a);
    System.out.println("::" + m2);
}
Also used : Account_(indi.mybatis.flying.pojo.Account_) Map(java.util.Map) DatabaseSetups(com.github.springtestdbunit.annotation.DatabaseSetups) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) ExpectedDatabases(com.github.springtestdbunit.annotation.ExpectedDatabases) DatabaseTearDowns(com.github.springtestdbunit.annotation.DatabaseTearDowns)

Example 9 with DatabaseSetups

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

the class IgnoreInsertAndUpdateTest method testInsert.

@Test
@DatabaseSetups({ @DatabaseSetup(connection = "dataSource2", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/ignoreInsertAndUpdateTest/testInsert.datasource2.xml") })
@ExpectedDatabases({ @ExpectedDatabase(connection = "dataSource2", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/ignoreInsertAndUpdateTest/testInsert.datasource2.result.xml") })
@DatabaseTearDowns({ @DatabaseTearDown(connection = "dataSource2", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/ignoreInsertAndUpdateTest/testInsert.datasource2.result.xml") })
public void testInsert() {
    Detail2_ d = new Detail2_(), d2 = new Detail2_();
    d.setName("n");
    d.setNumber(123);
    d.setDetail("d");
    d.setCreatetime(Calendar.getInstance().getTime());
    detail2Service.insertWithoutName(d);
    d2.setName("n2");
    d2.setNumber(234);
    d2.setDetail("d2");
    d2.setCreatetime(Calendar.getInstance().getTime());
    LoginLogSource2 loginLog2 = new LoginLogSource2();
    loginLog2.setId(22);
    d2.setLoginLogSource2(loginLog2);
    detail2Service.insertWithoutFoo(d2);
}
Also used : Detail2_(indi.mybatis.flying.pojo.Detail2_) LoginLogSource2(indi.mybatis.flying.pojo.LoginLogSource2) DatabaseSetups(com.github.springtestdbunit.annotation.DatabaseSetups) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) ExpectedDatabases(com.github.springtestdbunit.annotation.ExpectedDatabases) DatabaseTearDowns(com.github.springtestdbunit.annotation.DatabaseTearDowns)

Example 10 with DatabaseSetups

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

the class IgnoreInsertAndUpdateTest method testInsertBatch.

@Test
@DatabaseSetups({ @DatabaseSetup(connection = "dataSource2", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/ignoreInsertAndUpdateTest/testInsertBatch.datasource2.xml") })
@ExpectedDatabases({ @ExpectedDatabase(connection = "dataSource2", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/ignoreInsertAndUpdateTest/testInsertBatch.datasource2.result.xml") })
@DatabaseTearDowns({ @DatabaseTearDown(connection = "dataSource2", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/ignoreInsertAndUpdateTest/testInsertBatch.datasource2.result.xml") })
public void testInsertBatch() {
    Collection<Detail2_> dc = new ArrayList<>();
    Detail2_ d1 = new Detail2_();
    d1.setCreatetime(Calendar.getInstance().getTime());
    d1.setName("n1");
    d1.setNumber(123);
    d1.setDetail("d");
    LoginLogSource2 loginLog21 = new LoginLogSource2();
    loginLog21.setId(11);
    d1.setLoginLogSource2(loginLog21);
    dc.add(d1);
    Detail2_ d2 = new Detail2_();
    d2.setCreatetime(Calendar.getInstance().getTime());
    d2.setName("n2");
    d2.setNumber(456);
    d2.setDetail("e");
    LoginLogSource2 loginLog22 = new LoginLogSource2();
    loginLog22.setId(22);
    d2.setLoginLogSource2(loginLog22);
    dc.add(d2);
    detail2Service.insertBatchWithoutName(dc);
}
Also used : Detail2_(indi.mybatis.flying.pojo.Detail2_) LoginLogSource2(indi.mybatis.flying.pojo.LoginLogSource2) ArrayList(java.util.ArrayList) DatabaseSetups(com.github.springtestdbunit.annotation.DatabaseSetups) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) ExpectedDatabases(com.github.springtestdbunit.annotation.ExpectedDatabases) DatabaseTearDowns(com.github.springtestdbunit.annotation.DatabaseTearDowns)

Aggregations

DatabaseSetups (com.github.springtestdbunit.annotation.DatabaseSetups)50 Test (org.junit.Test)49 ExpectedDatabases (com.github.springtestdbunit.annotation.ExpectedDatabases)44 WithUserDetails (org.springframework.security.test.context.support.WithUserDetails)26 DatabaseTearDowns (com.github.springtestdbunit.annotation.DatabaseTearDowns)24 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)17 Account_ (indi.mybatis.flying.pojo.Account_)15 Role_ (indi.mybatis.flying.pojo.Role_)10 ApproveDTO (com.odysseusinc.arachne.portal.api.v1.dto.ApproveDTO)8 LoginLogSource2 (indi.mybatis.flying.pojo.LoginLogSource2)7 ExpectedDatabase (com.github.springtestdbunit.annotation.ExpectedDatabase)6 Detail2_ (indi.mybatis.flying.pojo.Detail2_)5 IfProfileValue (org.springframework.test.annotation.IfProfileValue)5 UpdateParticipantDTO (com.odysseusinc.arachne.portal.api.v1.dto.UpdateParticipantDTO)4 ArrayList (java.util.ArrayList)4 LinkedList (java.util.LinkedList)4 AnalysisUpdateDTO (com.odysseusinc.arachne.portal.api.v1.dto.AnalysisUpdateDTO)3 Account2_ (indi.mybatis.flying.pojo.Account2_)3 LoginLog_ (indi.mybatis.flying.pojo.LoginLog_)3 Role2_ (indi.mybatis.flying.pojo.Role2_)3