Search in sources :

Example 96 with DatabaseSetup

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

the class AccountTest method testDeputy.

/**
 * 测试deputyRole
 */
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/accountTest/testDeputy.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/accountTest/testDeputy.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/accountTest/testDeputy.xml")
public void testDeputy() {
    Account_ account = accountService.select(1);
    Assert.assertEquals("role1", account.getRole().getName());
    Assert.assertEquals("role2", account.getRoleDeputy().getName());
    Role_ rc = new Role_();
    rc.setName("role1");
    Role_ rdc = new Role_();
    rdc.setName("role2");
    Account_ ac = new Account_();
    ac.setRole(rc);
    ac.setRoleDeputy(rdc);
    Collection<Account_> accountC = accountService.selectAll(ac);
    Assert.assertEquals(1, accountC.size());
    int count = accountService.count(ac);
    Assert.assertEquals(1, count);
}
Also used : Account_(indi.mybatis.flying.pojo.Account_) Role_(indi.mybatis.flying.pojo.Role_) 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 97 with DatabaseSetup

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

the class AccountTest method testLimiter.

/**
 * 测试limiter功能
 */
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/accountTest/testLimiter.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/accountTest/testLimiter.xml")
public void testLimiter() {
    Account_Condition ac = new Account_Condition();
    ac.setLimiter(new PageParam(1, 2));
    Collection<Account_> c = accountService.selectAll(ac);
    Account_[] accounts = c.toArray(new Account_[c.size()]);
    Assert.assertEquals(2, accounts.length);
    Assert.assertEquals(1, accounts[0].getId().intValue());
    Assert.assertEquals(2, accounts[1].getId().intValue());
    Assert.assertEquals(2, ac.getLimiter().getMaxPageNum());
    ac.setSorter(new SortParam(new Order(Account_Condition.field_id, Conditionable.Sequence.DESC)));
    c = accountService.selectAll(ac);
    accounts = c.toArray(new Account_[c.size()]);
    Assert.assertEquals(2, accounts.length);
    Assert.assertEquals(4, accounts[0].getId().intValue());
    Assert.assertEquals(3, accounts[1].getId().intValue());
}
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) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup) DatabaseTearDown(com.github.springtestdbunit.annotation.DatabaseTearDown)

Example 98 with DatabaseSetup

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

the class AccountTest method testIgnoreTag.

/**
 * 测试ignoreTag功能
 */
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/accountTest/testIgnoredSelect.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/accountTest/testIgnoredSelect.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/accountTest/testIgnoredSelect.xml")
public void testIgnoreTag() {
    Account_ account = accountService.select(1);
    Assert.assertNull(account.getPassword());
    Account_ ac = new Account_();
    Collection<Account_> accountC = accountService.selectAll(ac);
    for (Account_ a : accountC) {
        Assert.assertNull(a.getPassword());
    }
    Account_ ac2 = new Account_();
    ac2.setPassword("5a690d842935c51f26f473e025c1b97a");
    Collection<Account_> accountC2 = accountService.selectAll(ac2);
    Assert.assertEquals(1, accountC2.size());
    LoginLog_ loginLog = loginLogService.select(1);
    Assert.assertNull(loginLog.getAccount().getPassword());
    LoginLog_ lc2 = new LoginLog_();
    lc2.setAccount(ac2);
    Collection<LoginLog_> loginLogC = loginLogService.selectAllPrefix(lc2);
    System.out.println("::::" + JSONObject.toJSONString(loginLogC));
    Assert.assertEquals(1, loginLogC.size());
    for (LoginLog_ l : loginLogC) {
        Assert.assertEquals("0.0.0.1", l.getLoginIP());
    }
}
Also used : LoginLog_(indi.mybatis.flying.pojo.LoginLog_) 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)

Example 99 with DatabaseSetup

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

the class AccountTest method testDelete.

/**
 * 测试delete功能
 */
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/accountTest/testDelete.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/accountTest/testDelete.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/accountTest/testDelete.xml")
public void testDelete() {
    Account_ a = accountService.select(1);
    accountService.delete(a);
}
Also used : 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)

Example 100 with DatabaseSetup

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

the class AccountTest method testCostumizeStatus.

/**
 * 测试CostumizeStatus功能
 */
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/accountTest/testCostumizeStatus.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/accountTest/testCostumizeStatus.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/accountTest/testCostumizeStatus.xml")
public void testCostumizeStatus() {
    Account_ a = accountService.select(1);
    Assert.assertEquals("发布", a.getStatus().text());
    Account_ ac = new Account_();
    ac.setStatus(StoryStatus_.PUBLISH);
    Collection<Account_> c = accountService.selectAll(ac);
    Assert.assertEquals(1, c.size());
    Account_ a2 = accountService.select(2);
    Assert.assertEquals(StoryStatus_.SKETCH, a2.getStatus());
    a2.setStatus(StoryStatus_.CANCEL);
    accountService.update(a2);
    Account_ a3 = accountService.select(3);
    Assert.assertNull(a3.getStatus());
    a3.setPassword("5a690d842935c51f26f473e025c1b97a");
    accountService.updatePersistent(a3);
    Account_ a4 = accountService.select(3);
    Assert.assertNull(a4.getStatus());
}
Also used : 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