Search in sources :

Example 6 with LoginLog_

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

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());
}
Also used : LoginLog_(indi.mybatis.flying.pojo.LoginLog_) LoginLogSource2(indi.mybatis.flying.pojo.LoginLogSource2) Account_(indi.mybatis.flying.pojo.Account_) Role_(indi.mybatis.flying.pojo.Role_) DatabaseSetups(com.github.springtestdbunit.annotation.DatabaseSetups) Test(org.junit.Test) ExpectedDatabases(com.github.springtestdbunit.annotation.ExpectedDatabases) DatabaseTearDowns(com.github.springtestdbunit.annotation.DatabaseTearDowns) IfProfileValue(org.springframework.test.annotation.IfProfileValue)

Example 8 with LoginLog_

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);
}
Also used : LoginLog_(indi.mybatis.flying.pojo.LoginLog_) ArrayList(java.util.ArrayList) LoginLog_Condition(indi.mybatis.flying.pojo.condition.LoginLog_Condition) Account_Condition(indi.mybatis.flying.pojo.condition.Account_Condition) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup) DatabaseTearDown(com.github.springtestdbunit.annotation.DatabaseTearDown)

Example 9 with LoginLog_

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);
}
Also used : LoginLog_(indi.mybatis.flying.pojo.LoginLog_) ArrayList(java.util.ArrayList) LoginLog_Condition(indi.mybatis.flying.pojo.condition.LoginLog_Condition) Account_Condition(indi.mybatis.flying.pojo.condition.Account_Condition) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup) DatabaseTearDown(com.github.springtestdbunit.annotation.DatabaseTearDown)

Example 10 with LoginLog_

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);
}
Also used : LoginLog_(indi.mybatis.flying.pojo.LoginLog_) ArrayList(java.util.ArrayList) Account_Condition(indi.mybatis.flying.pojo.condition.Account_Condition) 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)

Aggregations

LoginLog_ (indi.mybatis.flying.pojo.LoginLog_)28 Test (org.junit.Test)28 DatabaseSetup (com.github.springtestdbunit.annotation.DatabaseSetup)25 DatabaseTearDown (com.github.springtestdbunit.annotation.DatabaseTearDown)25 ExpectedDatabase (com.github.springtestdbunit.annotation.ExpectedDatabase)20 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)20 Account_ (indi.mybatis.flying.pojo.Account_)17 IfProfileValue (org.springframework.test.annotation.IfProfileValue)8 Role_ (indi.mybatis.flying.pojo.Role_)7 LoginLog_Condition (indi.mybatis.flying.pojo.condition.LoginLog_Condition)7 Account_Condition (indi.mybatis.flying.pojo.condition.Account_Condition)6 ArrayList (java.util.ArrayList)5 DatabaseSetups (com.github.springtestdbunit.annotation.DatabaseSetups)3 DatabaseTearDowns (com.github.springtestdbunit.annotation.DatabaseTearDowns)3 ExpectedDatabases (com.github.springtestdbunit.annotation.ExpectedDatabases)3 Detail_ (indi.mybatis.flying.pojo.Detail_)3 LoginLogSource2 (indi.mybatis.flying.pojo.LoginLogSource2)3 Role_Condition (indi.mybatis.flying.pojo.condition.Role_Condition)2 LinkedList (java.util.LinkedList)2 Page (indi.mybatis.flying.pagination.Page)1