Search in sources :

Example 16 with LoginLog_

use of indi.mybatis.flying.pojo.LoginLog_ in project mybatis.flying by limeng32.

the class DelegateTest method testDelegateInsert.

@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/delegateTest/testDelegateInsert.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/delegateTest/testDelegateInsert.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/delegateTest/testDelegateInsert.xml")
public void testDelegateInsert() {
    LoginLog_ loginLog = new LoginLog_();
    loginLog.setId(1);
    loginLog.setLoginIP("0.0.0.1");
    loginLog.setDelegateAccountId(1L);
    loginLogService.insert(loginLog);
}
Also used : LoginLog_(indi.mybatis.flying.pojo.LoginLog_) 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)

Example 17 with LoginLog_

use of indi.mybatis.flying.pojo.LoginLog_ in project mybatis.flying by limeng32.

the class LoginLogTest method testInsert.

/**
 * 测试insert功能(无乐观锁)
 */
@Test
@DatabaseSetup(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/loginLogTest/testInsert.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/loginLogTest/testInsert.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/loginLogTest/testInsert.xml")
public void testInsert() {
    LoginLog_ a = new LoginLog_();
    a.setId(1);
    a.setLoginIP("0.0.0.1");
    loginLogService.insert(a);
}
Also used : LoginLog_(indi.mybatis.flying.pojo.LoginLog_) 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)

Example 18 with LoginLog_

use of indi.mybatis.flying.pojo.LoginLog_ in project mybatis.flying by limeng32.

the class CacheTest 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 19 with LoginLog_

use of indi.mybatis.flying.pojo.LoginLog_ in project mybatis.flying by limeng32.

the class CacheTest method test3.

@Test
@IfProfileValue(name = "CACHE", value = "true")
@DatabaseSetup(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/cacheTest/test3.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/cacheTest/test3.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/cacheTest/test3.result.xml")
public void test3() {
    String name = "新权限", newName = "新角色", newName2 = "新新角色", accountName = "ann", ip = "0.0.0.1", detailName = "细节";
    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);
    Detail_ d = new Detail_();
    d.setName(detailName);
    d.setLoginLog(l);
    detailService.insert(d);
    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());
    Detail_ detail = detailService.select(d.getId());
    Assert.assertEquals(accountName, detail.getLoginLog().getAccount().getName());
    Assert.assertEquals(newName, detail.getLoginLog().getAccount().getRole().getName());
    // Account_ account3 = accountService.select(a.getId());
    // account3.setName(newAccountName);
    // accountService.update(account3);
    Role_ role2 = roleService.select(r.getId());
    role2.setName(newName2);
    roleService.update(role2);
    Detail_ detail2 = detailService.select(d.getId());
    Assert.assertEquals(newName2, detail2.getLoginLog().getAccount().getRole().getName());
}
Also used : LoginLog_(indi.mybatis.flying.pojo.LoginLog_) Account_(indi.mybatis.flying.pojo.Account_) Role_(indi.mybatis.flying.pojo.Role_) Detail_(indi.mybatis.flying.pojo.Detail_) 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 20 with LoginLog_

use of indi.mybatis.flying.pojo.LoginLog_ in project mybatis.flying by limeng32.

the class WhiteListTest method testWhiteList.

@Test
@DatabaseSetup(connection = "dataSource1", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/whiteListTest/testWhiteList.xml")
@ExpectedDatabase(connection = "dataSource1", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/whiteListTest/testWhiteList.result.xml")
@DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/whiteListTest/testWhiteList.result.xml")
public void testWhiteList() {
    Account_ account = accountService.selectSimple(1);
    Assert.assertNull(account.getEmail());
    Assert.assertNull(account.getPassword());
    Assert.assertNull(account.getPermission().getName());
    Assert.assertNull(account.getPermission().getFakeId());
    LoginLog_ l = new LoginLog_();
    l.setLoginIP("ip1");
    LoginLog_ loginLog = loginLogService.selectOneSimple(l);
    Assert.assertNull(loginLog.getLoginIP2());
    Assert.assertNull(loginLog.getAccount().getEmail());
    Assert.assertNull(loginLog.getAccount().getPassword());
    Assert.assertNull(loginLog.getAccount().getPermission().getName());
    Assert.assertNull(loginLog.getAccount().getPermission().getFakeId());
}
Also used : LoginLog_(indi.mybatis.flying.pojo.LoginLog_) Account_(indi.mybatis.flying.pojo.Account_) 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