use of indi.mybatis.flying.pojo.LoginLog_ in project mybatis.flying by limeng32.
the class CacheTest1 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 indi.mybatis.flying.pojo.LoginLog_ in project mybatis.flying by limeng32.
the class CacheTest1 method testAccountTypeHandlerUsingCache.
/* 一个证明缓存对跨库关联也有效的测试用例 */
@Test
@IfProfileValue(name = "CACHE", value = "true")
@DatabaseSetups({ @DatabaseSetup(connection = "dataSource1", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/cacheTest/testAccountTypeHandlerUsingCache.datasource.xml"), @DatabaseSetup(connection = "dataSource2", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/cacheTest/testAccountTypeHandlerUsingCache.datasource2.xml") })
@ExpectedDatabases({ @ExpectedDatabase(connection = "dataSource1", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT_UNORDERED, value = "/indi/mybatis/flying/test/cacheTest/testAccountTypeHandlerUsingCache.datasource.result.xml"), @ExpectedDatabase(connection = "dataSource2", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT_UNORDERED, value = "/indi/mybatis/flying/test/cacheTest/testAccountTypeHandlerUsingCache.datasource2.result.xml") })
@DatabaseTearDowns({ @DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/cacheTest/testAccountTypeHandlerUsingCache.datasource.result.xml"), @DatabaseTearDown(connection = "dataSource2", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/cacheTest/testAccountTypeHandlerUsingCache.datasource2.result.xml") })
public void testAccountTypeHandlerUsingCache() {
Role_ r = new Role_();
r.setId(101);
r.setName("user");
roleService.insert(r);
Account_ a = new Account_();
a.setId(1L);
a.setEmail("ann@live.cn");
a.setRole(r);
accountService.insert(a);
Account_ a2 = new Account_();
a2.setId(2L);
a2.setEmail("bob@live.cn");
accountService.insert(a2);
LoginLog_ l = new LoginLog_();
l.setId(2);
l.setLoginIP("2");
loginLogService.insert(l);
LoginLogSource2 l2 = new LoginLogSource2();
l2.setId(21);
l2.setLoginIP("ip0");
l2.setAccount(a);
loginLogSource2Service.insert(l2);
LoginLogSource2 loginLogSource2 = loginLogSource2Service.select(21);
Assert.assertEquals("user", loginLogSource2.getAccount().getRole().getName());
Account_ account = accountService.select(1L);
LoginLogSource2 loginLogSource4 = loginLogSource2Service.select(21);
loginLogSource4.setLoginIP("ip00");
loginLogSource2Service.updateNoFlush(loginLogSource4);
account = accountService.select(1L);
accountService.update(account);
LoginLogSource2 loginLogSource5 = loginLogSource2Service.select(21);
Assert.assertEquals("ip00", loginLogSource5.getLoginIP());
Assert.assertEquals(1, loginLogSource5.getAccount().getOpLock().intValue());
}
use of indi.mybatis.flying.pojo.LoginLog_ in project mybatis.flying by limeng32.
the class ConditionNotInTest method testConditionNotIn2.
/**
* 测试有外键情况下condition:notIn功能
*/
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/conditionNotInTest/testConditionIn2.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/conditionNotInTest/testConditionIn2.xml")
public void testConditionNotIn2() {
LoginLog_Condition lc = new LoginLog_Condition();
Account_Condition ac = new Account_Condition();
List<String> nameC = new ArrayList<>();
nameC.add("ann");
nameC.add("bob");
ac.setNameNotIn(nameC);
lc.setAccount(ac);
Collection<LoginLog_> c = loginLogService.selectAll(lc);
Assert.assertEquals(0, c.size());
int count = loginLogService.count(lc);
Assert.assertEquals(0, count);
Collection<LoginLog_> c2 = loginLogService.selectAllPrefix(lc);
Assert.assertEquals(0, c2.size());
int count2 = loginLogService.count(lc);
Assert.assertEquals(0, count2);
}
use of indi.mybatis.flying.pojo.LoginLog_ in project mybatis.flying by limeng32.
the class ConditionInTest method testConditionIn2.
/**
* 测试有外键情况下condition:in功能
*/
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/conditionInTest/testConditionIn2.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/conditionInTest/testConditionIn2.xml")
public void testConditionIn2() {
LoginLog_Condition lc = new LoginLog_Condition();
List<String> loginIpC = new ArrayList<>();
loginIpC.add("11");
loginIpC.add("22");
lc.setLoginIPIn(loginIpC);
Account_Condition ac = new Account_Condition();
List<String> nameC = new ArrayList<>();
nameC.add("ann");
nameC.add("bob");
ac.setNameIn(nameC);
lc.setAccount(ac);
Collection<LoginLog_> c = loginLogService.selectAll(lc);
Assert.assertEquals(2, c.size());
int count = loginLogService.count(lc);
Assert.assertEquals(2, count);
Collection<LoginLog_> c2 = loginLogService.selectAllPrefix(lc);
Assert.assertEquals(2, c2.size());
int count2 = loginLogService.count(lc);
Assert.assertEquals(2, count2);
}
use of indi.mybatis.flying.pojo.LoginLog_ in project mybatis.flying by limeng32.
the class ConditionInTest method testConditionIn5.
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/conditionInTest/testConditionIn5.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/conditionInTest/testConditionIn5.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/conditionInTest/testConditionIn5.xml")
public void testConditionIn5() {
Account_Condition ac = new Account_Condition();
Account_Condition ac2 = new Account_Condition();
Account_Condition ac3 = new Account_Condition();
List<Integer> roleIds = new ArrayList<>();
roleIds.add(1);
roleIds.add(2);
ac.setRoleIdIn(roleIds);
Role_ r1 = new Role_();
r1.setId(1);
Role_ r2 = new Role_();
r2.setId(2);
int c = accountService.count(ac);
Assert.assertEquals(2, c);
ac3.setRoleIdNotIn(roleIds);
int c3 = accountService.count(ac3);
Assert.assertEquals(1, c3);
ac2.setRoleIdNotIn(roleIds);
Account_ account = accountService.selectOne(ac2);
Assert.assertEquals("role3", account.getRole().getName());
LoginLog_ l = new LoginLog_();
l.setAccount(ac2);
LoginLog_ loginLog = loginLogService.selectOne(l);
Assert.assertEquals("role3", loginLog.getAccount().getRole().getName());
List<String> nameIn = new ArrayList<>();
nameIn.add("ann");
nameIn.add("bob");
Account_Condition ac4 = new Account_Condition();
ac4.setNameIn(nameIn);
LoginLog_ l2 = new LoginLog_();
l2.setAccount(ac4);
int c4 = loginLogService.count(l2);
Assert.assertEquals(2, c4);
}
Aggregations