Search in sources :

Example 1 with DatabaseSetup

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

the class CacheTest method test.

@Test
@IfProfileValue(name = "CACHE", value = "true")
@DatabaseSetup(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/cacheTest/test.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/cacheTest/test.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/cacheTest/test.result.xml")
public void test() {
    String name = "ann";
    String newName = "bob";
    String loginIP = "0.0.0.1";
    Account_ a = new Account_();
    LoginLog_ l = new LoginLog_();
    a.setName(name);
    accountService.insert(a);
    l.setLoginIP(loginIP);
    l.setAccount(a);
    loginLogService.insert(l);
    LoginLog_ loginLog = loginLogService.select(l.getId());
    Assert.assertEquals(name, loginLog.getAccount().getName());
    Account_ account = accountService.select(a.getId());
    account.setName(newName);
    accountService.update(account);
    LoginLog_ loginLog2 = loginLogService.select(l.getId());
    Assert.assertEquals(newName, loginLog2.getAccount().getName());
}
Also used : LoginLog_(indi.mybatis.flying.pojo.LoginLog_) Account_(indi.mybatis.flying.pojo.Account_) ExpectedDatabase(com.github.springtestdbunit.annotation.ExpectedDatabase) Test(org.junit.Test) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup) DatabaseTearDown(com.github.springtestdbunit.annotation.DatabaseTearDown) IfProfileValue(org.springframework.test.annotation.IfProfileValue)

Example 2 with DatabaseSetup

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

the class CacheTest method test2.

@Test
@IfProfileValue(name = "CACHE", value = "true")
@DatabaseSetup(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/cacheTest/test2.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/cacheTest/test2.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/cacheTest/test2.result.xml")
public void test2() {
    String name = "新权限", newName = "新角色", accountName = "ann", ip = "0.0.0.1";
    Role_ r = new Role_();
    r.setName(name);
    roleService.insert(r);
    Account_ a = new Account_();
    a.setName(accountName);
    a.setRole(r);
    accountService.insert(a);
    LoginLog_ l = new LoginLog_();
    l.setLoginIP(ip);
    l.setAccount(a);
    loginLogService.insert(l);
    Account_ account = accountService.select(a.getId());
    Assert.assertEquals(name, account.getRole().getName());
    LoginLog_ loginLog = loginLogService.select(l.getId());
    Assert.assertEquals(name, loginLog.getAccount().getRole().getName());
    Role_ role = roleService.select(r.getId());
    role.setName(newName);
    roleService.update(role);
    Account_ account2 = accountService.select(a.getId());
    Assert.assertEquals(newName, account2.getRole().getName());
    LoginLog_ loginLog2 = loginLogService.select(l.getId());
    Assert.assertEquals(newName, loginLog2.getAccount().getRole().getName());
}
Also used : LoginLog_(indi.mybatis.flying.pojo.LoginLog_) Account_(indi.mybatis.flying.pojo.Account_) Role_(indi.mybatis.flying.pojo.Role_) ExpectedDatabase(com.github.springtestdbunit.annotation.ExpectedDatabase) Test(org.junit.Test) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup) DatabaseTearDown(com.github.springtestdbunit.annotation.DatabaseTearDown) IfProfileValue(org.springframework.test.annotation.IfProfileValue)

Example 3 with DatabaseSetup

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

the class SelectOneTest method testSelectOne1.

/**
 * 测试selectOne1
 */
@Test
@DatabaseSetup(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/selectOneTest/testSelectOne1.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/selectOneTest/testSelectOne1.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/selectOneTest/testSelectOne1.result.xml")
public void testSelectOne1() {
    Account_ a1 = new Account_();
    a1.setName("ann");
    a1.setEmail("ann@live.cn");
    accountService.insert(a1);
    Account_ a2 = new Account_();
    a2.setName("bob");
    a2.setEmail("bob@live.cn");
    accountService.insert(a2);
    accountService.update(a2);
    accountService.updatePersistent(a2);
    Account_ account_ = accountService.select(a2.getId());
    Account_ ac = new Account_();
    ac.setName("bob");
    ac.setEmail("bob@live.cn");
    Account_ account = accountService.selectOne(ac);
    Assert.assertEquals("bob@live.cn", account.getEmail());
}
Also used : Account_(indi.mybatis.flying.pojo.Account_) ExpectedDatabase(com.github.springtestdbunit.annotation.ExpectedDatabase) Test(org.junit.Test) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup) DatabaseTearDown(com.github.springtestdbunit.annotation.DatabaseTearDown)

Example 4 with DatabaseSetup

use of com.github.springtestdbunit.annotation.DatabaseSetup in project irida by phac-nml.

the class SampleServiceImplIT method testGetSampleByExternalIdDuplicates.

@Test
@WithMockUser(username = "fbristow", roles = "ADMIN")
@DatabaseSetup("/ca/corefacility/bioinformatics/irida/service/impl/SampleServiceImplIT_duplicateSampleIds.xml")
public void testGetSampleByExternalIdDuplicates() {
    Project p = projectService.read(7L);
    Sample s = sampleService.getSampleBySampleName(p, "sample");
    assertEquals("Should have retrieved sample with ID 1L.", Long.valueOf(7L), s.getId());
}
Also used : Project(ca.corefacility.bioinformatics.irida.model.project.Project) Sample(ca.corefacility.bioinformatics.irida.model.sample.Sample) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup)

Example 5 with DatabaseSetup

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

the class JpaDeviceCredentialsDaoTest method findByCredentialsId.

@Test
@DatabaseSetup("classpath:dbunit/device_credentials.xml")
public void findByCredentialsId() {
    String credentialsId = "ID_2";
    DeviceCredentials deviceCredentials = deviceCredentialsDao.findByCredentialsId(credentialsId);
    assertNotNull(deviceCredentials);
    assertEquals("958e3c74-3215-11e7-93ae-92361f002671", deviceCredentials.getId().getId().toString());
}
Also used : DeviceCredentials(org.thingsboard.server.common.data.security.DeviceCredentials) AbstractJpaDaoTest(org.thingsboard.server.dao.AbstractJpaDaoTest) Test(org.junit.Test) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup)

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 Role_ (indi.mybatis.flying.pojo.Role_)11 TextPageLink (org.thingsboard.server.common.data.page.TextPageLink)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