Search in sources :

Example 91 with DatabaseSetup

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());
}
Also used : Order(indi.mybatis.flying.pagination.Order) Account_Condition(indi.mybatis.flying.pojo.condition.Account_Condition) Account_(indi.mybatis.flying.pojo.Account_) PageParam(indi.mybatis.flying.pagination.PageParam) SortParam(indi.mybatis.flying.pagination.SortParam) ExpectedDatabase(com.github.springtestdbunit.annotation.ExpectedDatabase) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup) DatabaseTearDown(com.github.springtestdbunit.annotation.DatabaseTearDown)

Example 92 with DatabaseSetup

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());
}
Also used : Detail_(indi.mybatis.flying.pojo.Detail_) ExpectedDatabase(com.github.springtestdbunit.annotation.ExpectedDatabase) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup) DatabaseTearDown(com.github.springtestdbunit.annotation.DatabaseTearDown)

Example 93 with DatabaseSetup

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());
}
Also used : LoginLog_(indi.mybatis.flying.pojo.LoginLog_) Account_(indi.mybatis.flying.pojo.Account_) Detail_(indi.mybatis.flying.pojo.Detail_) ExpectedDatabase(com.github.springtestdbunit.annotation.ExpectedDatabase) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup) DatabaseTearDown(com.github.springtestdbunit.annotation.DatabaseTearDown)

Example 94 with DatabaseSetup

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());
}
Also used : Detail_(indi.mybatis.flying.pojo.Detail_) ExpectedDatabase(com.github.springtestdbunit.annotation.ExpectedDatabase) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup) DatabaseTearDown(com.github.springtestdbunit.annotation.DatabaseTearDown)

Example 95 with DatabaseSetup

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);
}
Also used : Account_Condition(indi.mybatis.flying.pojo.condition.Account_Condition) Account_(indi.mybatis.flying.pojo.Account_) ExpectedDatabase(com.github.springtestdbunit.annotation.ExpectedDatabase) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup) DatabaseTearDown(com.github.springtestdbunit.annotation.DatabaseTearDown)

Aggregations

DatabaseSetup (com.github.springtestdbunit.annotation.DatabaseSetup)151 Test (org.junit.Test)150 ExpectedDatabase (com.github.springtestdbunit.annotation.ExpectedDatabase)98 DatabaseTearDown (com.github.springtestdbunit.annotation.DatabaseTearDown)92 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)78 Account_Condition (indi.mybatis.flying.pojo.condition.Account_Condition)46 Account_ (indi.mybatis.flying.pojo.Account_)43 MvcResult (org.springframework.test.web.servlet.MvcResult)26 LoginLog_ (indi.mybatis.flying.pojo.LoginLog_)25 AbstractJpaDaoTest (org.thingsboard.server.dao.AbstractJpaDaoTest)24 WithUserDetails (org.springframework.security.test.context.support.WithUserDetails)21 ArrayList (java.util.ArrayList)17 LoginLog_Condition (indi.mybatis.flying.pojo.condition.LoginLog_Condition)15 UUID (java.util.UUID)15 AbstractServiceTest (org.thingsboard.server.dao.service.AbstractServiceTest)12 Role_ (indi.mybatis.flying.pojo.Role_)11 IfProfileValue (org.springframework.test.annotation.IfProfileValue)10 ExpectedDatabases (com.github.springtestdbunit.annotation.ExpectedDatabases)8 CreateStudyDTO (com.odysseusinc.arachne.portal.api.v1.dto.CreateStudyDTO)7 Detail_ (indi.mybatis.flying.pojo.Detail_)7