Search in sources :

Example 21 with LoginLog_

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

the class IgnoreTest method testIgnore.

@Test
@DatabaseSetup(connection = "dataSource1", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/ignoreTest/testIgnore.xml")
@ExpectedDatabase(connection = "dataSource1", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/ignoreTest/testIgnore.result.xml")
@DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/ignoreTest/testIgnore.result.xml")
public void testIgnore() {
    Account_ ac = new Account_();
    Collection<Account_> accountC = accountService.selectAllPrefixIgnore(ac);
    Account_[] accounts = accountC.toArray(new Account_[accountC.size()]);
    Assert.assertNotNull(accounts[0].getPassword());
    Assert.assertNull(accounts[0].getName());
    LoginLog_ lc = new LoginLog_();
    Collection<LoginLog_> loginLogC = loginLogService.selectAllPrefixIgnore(lc);
    LoginLog_[] loginLogs = loginLogC.toArray(new LoginLog_[loginLogC.size()]);
    Assert.assertNull(loginLogs[0].getAccount().getName());
    Detail_ dc = new Detail_();
    Collection<Detail_> detailC = detailService.selectAllPrefixIgnore(dc);
    Detail_[] details = detailC.toArray(new Detail_[detailC.size()]);
    Assert.assertNull(details[0].getId());
    Assert.assertNotNull(details[0].getLoginLog().getId());
    Assert.assertNull(details[0].getLoginLog().getAccount().getName());
    Collection<Detail_> detailC2 = detailService.selectAllPrefixIgnore2(dc);
    Detail_[] details2 = detailC2.toArray(new Detail_[detailC2.size()]);
    Assert.assertNull(details2[0].getLoginLog());
    Collection<Detail_> detailC3 = detailService.selectAllPrefixIgnore3(dc);
    Detail_[] details3 = detailC3.toArray(new Detail_[detailC3.size()]);
    Assert.assertNull(details3[0].getLoginLog().getId());
}
Also used : LoginLog_(indi.mybatis.flying.pojo.LoginLog_) Account_(indi.mybatis.flying.pojo.Account_) Detail_(indi.mybatis.flying.pojo.Detail_) 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 22 with LoginLog_

use of indi.mybatis.flying.pojo.LoginLog_ 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.selectAllPrefix(lc2);
    System.out.println("::::" + JSONObject.toJSONString(loginLogC));
    Assert.assertEquals(1, loginLogC.size());
    for (LoginLog_ l : loginLogC) {
        Assert.assertEquals("0.0.0.1", l.getLoginIP());
    }
}
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)

Example 23 with LoginLog_

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

the class CacheTest1 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 24 with LoginLog_

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

the class CacheTest1 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());
}
Also used : LoginLog_(indi.mybatis.flying.pojo.LoginLog_) Account_(indi.mybatis.flying.pojo.Account_) Role_(indi.mybatis.flying.pojo.Role_) 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 25 with LoginLog_

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

the class ConditionTest method testMultiLikeOR.

@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/conditionTest/testMultiLikeOR.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/conditionTest/testMultiLikeOR.xml")
public void testMultiLikeOR() {
    Account_Condition ac = new Account_Condition();
    ac.setName("ann");
    ac.setEmailLike("as");
    List<String> multi = new ArrayList<>();
    multi.add(null);
    multi.add(null);
    multi.add(null);
    multi.add(null);
    ac.setMultiLikeOR(multi);
    Collection<Account_> c = accountService.selectAll(ac);
    Assert.assertEquals(1, c.size());
    int count = accountService.count(ac);
    Assert.assertEquals(1, count);
    Account_Condition ac2 = new Account_Condition();
    ac2.setName("ann");
    ac2.setEmailLike("as");
    List<String> multi2 = new ArrayList<>();
    multi2.add(null);
    multi2.add("a");
    multi2.add("sd");
    multi2.add("z");
    ac2.setMultiLikeOR(multi2);
    Collection<Account_> c2 = accountService.selectAll(ac2);
    Assert.assertEquals(1, c2.size());
    LoginLog_ lc = new LoginLog_();
    Account_Condition ac3 = new Account_Condition();
    List<String> multi3 = new ArrayList<>();
    multi3.add(null);
    multi3.add("a");
    multi3.add("sd");
    multi3.add("z");
    ac3.setMultiLikeOR(multi3);
    lc.setAccount(ac3);
    Collection<LoginLog_> c3 = loginLogService.selectAll(lc);
    Assert.assertEquals(1, c3.size());
    Collection<LoginLog_> c4 = loginLogService.selectAllPrefix(lc);
    Assert.assertEquals(1, c4.size());
}
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_) 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