Search in sources :

Example 86 with DatabaseSetup

use of com.github.springtestdbunit.annotation.DatabaseSetup in project thingsboard by thingsboard.

the class JpaBaseRuleDaoTest method testFindAllTenantRulesByTenantId.

@Test
@DatabaseSetup("classpath:dbunit/empty_dataset.xml")
public void testFindAllTenantRulesByTenantId() {
    UUID tenantId1 = UUIDs.timeBased();
    UUID tenantId2 = UUIDs.timeBased();
    createTenantsAndSystemRules(tenantId1, tenantId2, "name_", "token");
    List<RuleMetaData> rules1 = ruleDao.findAllTenantRulesByTenantId(tenantId1, new TextPageLink(40, "name_"));
    assertEquals(40, rules1.size());
    List<RuleMetaData> rules2 = ruleDao.findAllTenantRulesByTenantId(tenantId1, new TextPageLink(40, "name_", rules1.get(19).getId().getId(), null));
    assertEquals(20, rules2.size());
    List<RuleMetaData> rules3 = ruleDao.findAllTenantRulesByTenantId(tenantId1, new TextPageLink(40, "name_", rules2.get(19).getId().getId(), null));
    assertEquals(0, rules3.size());
}
Also used : TextPageLink(org.thingsboard.server.common.data.page.TextPageLink) RuleMetaData(org.thingsboard.server.common.data.rule.RuleMetaData) UUID(java.util.UUID) AbstractJpaDaoTest(org.thingsboard.server.dao.AbstractJpaDaoTest) Test(org.junit.Test) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup)

Example 87 with DatabaseSetup

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

the class WhiteListTest method testWhiteListInsert.

@Test
@DatabaseSetup(connection = "dataSource1", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/whiteListTest/testWhiteListInsert.xml")
@ExpectedDatabase(connection = "dataSource1", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/whiteListTest/testWhiteListInsert.result.xml")
@DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/whiteListTest/testWhiteListInsert.result.xml")
public void testWhiteListInsert() {
    Account_ account = new Account_();
    account.setName("name");
    account.setEmail("email");
    account.setPassword("aaa");
    Role_ role = new Role_();
    role.setId(11);
    account.setRole(role);
    Permission permission = new Permission();
    permission.setId(22);
    account.setPermission(permission);
    accountService.insertSimpleNoName(account);
}
Also used : Permission(indi.mybatis.flying.pojo.Permission) 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 88 with DatabaseSetup

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

the class WhiteListTest method testWhiteListUpdatePersistent.

@Test
@DatabaseSetup(connection = "dataSource1", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/whiteListTest/testWhiteListUpdatePersistent.xml")
@ExpectedDatabase(connection = "dataSource1", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/whiteListTest/testWhiteListUpdatePersistent.result.xml")
@DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/whiteListTest/testWhiteListUpdatePersistent.result.xml")
public void testWhiteListUpdatePersistent() {
    Account_ account = accountService.select(1);
    account.setName("bob");
    account.setEmail("bob@live.cn");
    account.setPassword("bbb");
    account.setStatus(StoryStatus_.PUBLISH);
    account.setActivateValue(null);
    Role_ role = new Role_();
    role.setId(33);
    account.setRole(role);
    accountService.updatePersistentSimpleNoName(account);
}
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 89 with DatabaseSetup

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

the class WhiteListTest method testWhiteListInsertBatch.

@Test
@DatabaseSetup(connection = "dataSource1", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/whiteListTest/testWhiteListInsertBatch.xml")
@ExpectedDatabase(connection = "dataSource1", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/whiteListTest/testWhiteListInsertBatch.result.xml")
@DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/whiteListTest/testWhiteListInsertBatch.result.xml")
public void testWhiteListInsertBatch() {
    Account_ account = new Account_();
    account.setName("name");
    account.setEmail("email");
    account.setPassword("aaa");
    Role_ role = new Role_();
    role.setId(11);
    account.setRole(role);
    Permission permission = new Permission();
    permission.setId(22);
    account.setPermission(permission);
    Collection<Account_> ac = new ArrayList<>();
    ac.add(account);
    accountService.insertBatchSimpleNoName(ac);
}
Also used : Permission(indi.mybatis.flying.pojo.Permission) ArrayList(java.util.ArrayList) 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 90 with DatabaseSetup

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

the class WhiteListTest method testWhiteList.

@Test
@DatabaseSetup(connection = "dataSource1", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/whiteListTest/testWhiteList.xml")
@ExpectedDatabase(connection = "dataSource1", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/whiteListTest/testWhiteList.result.xml")
@DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/whiteListTest/testWhiteList.result.xml")
public void testWhiteList() {
    Account_ account = accountService.selectSimple(1);
    Assert.assertNull(account.getEmail());
    Assert.assertNull(account.getPassword());
    Assert.assertNull(account.getPermission().getName());
    Assert.assertNull(account.getPermission().getFakeId());
    LoginLog_ l = new LoginLog_();
    l.setLoginIP("ip1");
    LoginLog_ loginLog = loginLogService.selectOneSimple(l);
    Assert.assertNull(loginLog.getLoginIP2());
    Assert.assertNull(loginLog.getAccount().getEmail());
    Assert.assertNull(loginLog.getAccount().getPassword());
    Assert.assertNull(loginLog.getAccount().getPermission().getName());
    Assert.assertNull(loginLog.getAccount().getPermission().getFakeId());
}
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)

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