use of indi.mybatis.flying.pojo.Account_ 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);
}
use of indi.mybatis.flying.pojo.Account_ 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.selectAll(lc2);
Assert.assertEquals(1, loginLogC.size());
for (LoginLog_ l : loginLogC) {
Assert.assertEquals("0.0.0.1", l.getLoginIP());
}
}
use of indi.mybatis.flying.pojo.Account_ in project mybatis.flying by limeng32.
the class AccountTypeHandlerTest method testAccountTypeHandler.
/* 测试AccountTypeHandler的功能 */
@Test
@DatabaseSetups({ @DatabaseSetup(connection = "dataSource1", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/accountTypeHandlerTest/testAccountTypeHandler.datasource.xml"), @DatabaseSetup(connection = "dataSource2", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/accountTypeHandlerTest/testAccountTypeHandler.datasource2.xml") })
@ExpectedDatabases({ @ExpectedDatabase(connection = "dataSource1", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/accountTypeHandlerTest/testAccountTypeHandler.datasource.result.xml"), @ExpectedDatabase(connection = "dataSource2", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/accountTypeHandlerTest/testAccountTypeHandler.datasource2.result.xml") })
@DatabaseTearDowns({ @DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/accountTypeHandlerTest/testAccountTypeHandler.datasource.result.xml"), @DatabaseTearDown(connection = "dataSource2", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/accountTypeHandlerTest/testAccountTypeHandler.datasource2.result.xml") })
public void testAccountTypeHandler() {
LoginLogSource2 longinLogSource0 = loginLogSource2Service.selectWithoutAccount(22);
Assert.assertNull(longinLogSource0.getAccount());
LoginLogSource2 longinLogSource = loginLogSource2Service.select(22);
Assert.assertNotNull(longinLogSource);
Assert.assertNotNull(longinLogSource.getAccount());
Assert.assertEquals("ann@live.cn", longinLogSource.getAccount().getEmail());
Account_ ac = new Account_();
ac.setId(1L);
LoginLogSource2 l2c = new LoginLogSource2();
l2c.setAccount(ac);
Collection<LoginLogSource2> loginLogSource2C = loginLogSource2Service.selectAll(l2c);
Assert.assertEquals(2, loginLogSource2C.size());
for (LoginLogSource2 e : loginLogSource2C) {
Assert.assertEquals("ann@live.cn", e.getAccount().getEmail());
}
LoginLogSource2 loginLogSource2 = loginLogSource2Service.select(24);
Assert.assertNull(loginLogSource2.getAccount());
LoginLogSource2 loginLogSource3 = loginLogSource2Service.select(25);
Assert.assertNull(loginLogSource3.getAccount());
Account_ ac2 = new Account_();
ac2.setId(2L);
LoginLogSource2 l2c2 = new LoginLogSource2();
l2c2.setAccount(ac2);
LoginLogSource2 loginLogSource4 = loginLogSource2Service.selectOne(l2c2);
loginLogSource4 = loginLogSource2Service.selectOne(l2c2);
loginLogSource4 = loginLogSource2Service.selectOne(l2c2);
loginLogSource4 = loginLogSource2Service.selectOne(l2c2);
loginLogSource4 = loginLogSource2Service.selectOne(l2c2);
Assert.assertEquals("bob@live.cn", loginLogSource4.getAccount().getEmail());
Account_ ac3 = new Account_();
ac3.setId(1L);
LoginLogSource2 l2c3 = new LoginLogSource2();
l2c3.setAccount(ac3);
l2c3.setLoginIP("ip1");
int i = loginLogSource2Service.count(l2c3);
Assert.assertEquals(1, i);
Account_ account2 = accountService.select(2);
loginLogSource2.setAccount(account2);
loginLogSource2Service.update(loginLogSource2);
loginLogSource4.setAccount(null);
loginLogSource2Service.updatePersistent(loginLogSource4);
Account_ account = accountService.select(1);
loginLogSource2Service.loadAccount(account, new LoginLogSource2());
Assert.assertEquals(2, account.getLoginLogSource2().size());
}
use of indi.mybatis.flying.pojo.Account_ in project mybatis.flying by limeng32.
the class CacheTest method testPagination.
@Test
@IfProfileValue(name = "CACHE", value = "true")
@DatabaseSetup(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/cacheTest/testPagination.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/cacheTest/testPagination.result.xml")
public void testPagination() {
String name1 = "ann", name2 = "bob", name3 = "carl", name4 = "duke";
Account_ a1 = new Account_();
a1.setId(1L);
a1.setName(name1);
accountService.insert(a1);
Account_ a2 = new Account_();
a2.setId(2L);
a2.setName(name2);
accountService.insert(a2);
Account_ a3 = new Account_();
a3.setId(3L);
a3.setName(name3);
accountService.insert(a3);
Account_ a4 = new Account_();
a4.setId(4L);
a4.setName(name4);
accountService.insert(a4);
Account_Condition ac = new Account_Condition();
ac.setLimiter(new PageParam(1, 2));
Collection<Account_> c1 = accountService.selectAll(ac);
Assert.assertEquals(2, c1.size());
for (Account_ a : c1) {
if (a.getId() == 1) {
Assert.assertEquals(name1, a.getName());
} else {
Assert.assertEquals(name2, a.getName());
}
}
Assert.assertEquals(2, ac.getLimiter().getMaxPageNum());
ac.setLimiter(new PageParam(1, 2));
c1 = accountService.selectAll(ac);
Assert.assertEquals(2, ac.getLimiter().getMaxPageNum());
accountService.delete(a1);
accountService.delete(a2);
accountService.delete(a3);
accountService.delete(a4);
}
use of indi.mybatis.flying.pojo.Account_ in project mybatis.flying by limeng32.
the class CacheTest method testUpdateDirect4.
/* 测试在查询对象查询的情况下,缓存确实生效的用例 */
// @Test
@IfProfileValue(name = "CACHE", value = "true")
@ExpectedDatabase(connection = "dataSource1", assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/cacheTest/testUpdateDirect.result.xml")
@DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/cacheTest/testUpdateDirect.result.xml")
public void testUpdateDirect4() {
Role_ r = new Role_();
r.setId(1);
r.setName("ann");
roleService.insert(r);
Account_ a = new Account_();
a.setId(1L);
a.setRole(r);
a.setEmail("email");
accountService.insert(a);
Account_Condition ac = new Account_Condition();
ac.setLimiter(new PageParam(1, 1));
Collection<Account_> c = accountService.selectAll(ac);
Map<String, Object> m = new HashMap<>(4);
m.put("id", 1);
m.put("name", "bob");
roleService.updateDirect(m);
Account_Condition ac2 = new Account_Condition();
ac2.setLimiter(new PageParam(1, 1));
Collection<Account_> c2 = accountService.selectAll(ac2);
for (Account_ t : c2) {
Assert.assertEquals("ann", t.getRole().getName());
}
}
Aggregations