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());
}
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());
}
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());
}
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());
}
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());
}
Aggregations