Search in sources :

Example 1 with LoginLog_

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

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

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

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

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

the class OrTest method testOr5.

@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/orTest/testOr5.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/orTest/testOr5.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/orTest/testOr5.result.xml")
public void testOr5() {
    LoginLog_Condition lc = new LoginLog_Condition();
    lc.setAccount(new Account_Condition());
    lc.getAccount().setRole(new Role_Condition());
    lc.getAccount().setRoleDeputy(new Role_Condition());
    ((Role_Condition) lc.getAccount().getRole()).setNameEqualsOrAccountNameEquals("user", "bob");
    ((Role_Condition) lc.getAccount().getRoleDeputy()).setNameEqualsOrAccountNameEquals("silver", "bob");
    Collection<LoginLog_> loginLogC = loginLogService.selectAll(lc);
    Assert.assertEquals(2, loginLogC.size());
    Collection<LoginLog_> loginLogC2 = loginLogService.selectAllPrefix(lc);
    Assert.assertEquals(2, loginLogC2.size());
}
Also used : LoginLog_(indi.mybatis.flying.pojo.LoginLog_) Role_Condition(indi.mybatis.flying.pojo.condition.Role_Condition) LoginLog_Condition(indi.mybatis.flying.pojo.condition.LoginLog_Condition) Account_Condition(indi.mybatis.flying.pojo.condition.Account_Condition) 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 4 with LoginLog_

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

the class PrefixTest method testSelect2.

@Test
@DatabaseSetup(connection = "dataSource1", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/prefixTest/testSelect2.xml")
@ExpectedDatabase(connection = "dataSource1", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/prefixTest/testSelect2.result.xml")
@DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/prefixTest/testSelect2.result.xml")
public void testSelect2() {
    LoginLog_ lc = new LoginLog_();
    lc.setLoginIP("ip3");
    lc.setAccount(new Account_());
    lc.getAccount().setRoleDeputy(new Role_Condition());
    ((Role_Condition) (lc.getAccount().getRoleDeputy())).setNameNotEquals("roleDeputy2");
    Collection<LoginLog_> loginLogC = loginLogService.selectAllPrefix(lc);
    System.out.println("1::" + JSONObject.toJSONString(loginLogC));
    LoginLog_[] loginLogs = loginLogC.toArray(new LoginLog_[loginLogC.size()]);
    Assert.assertEquals(103, loginLogs[0].getId().intValue());
    Assert.assertEquals("ip2_3", loginLogs[0].getLoginIP2());
    Assert.assertEquals(3, loginLogs[0].getAccount().getId().intValue());
    Assert.assertNull(loginLogs[0].getAccount().getPassword());
    Assert.assertEquals(13, loginLogs[0].getAccount().getRole().getId().intValue());
    Assert.assertEquals("role3", loginLogs[0].getAccount().getRole().getName());
    Assert.assertEquals(113, loginLogs[0].getAccount().getRoleDeputy().getId().intValue());
    Assert.assertEquals("roleDeputy3", loginLogs[0].getAccount().getRoleDeputy().getName());
    Assert.assertEquals(104, loginLogs[1].getId().intValue());
    Assert.assertEquals("ip2_4", loginLogs[1].getLoginIP2());
    Assert.assertEquals(4, loginLogs[1].getAccount().getId().intValue());
    Assert.assertNull(loginLogs[1].getAccount().getPassword());
    Assert.assertEquals(14, loginLogs[1].getAccount().getRole().getId().intValue());
    Assert.assertEquals("role4", loginLogs[1].getAccount().getRole().getName());
    Assert.assertEquals(114, loginLogs[1].getAccount().getRoleDeputy().getId().intValue());
    Assert.assertEquals("roleDeputy4", loginLogs[1].getAccount().getRoleDeputy().getName());
}
Also used : LoginLog_(indi.mybatis.flying.pojo.LoginLog_) Role_Condition(indi.mybatis.flying.pojo.condition.Role_Condition) 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 5 with LoginLog_

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

the class AccountTest method testInsert.

/**
 * 测试insert功能(有乐观锁)
 */
@Test
@DatabaseSetups({ @DatabaseSetup(connection = "dataSource1", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/accountTest/testInsert.datasource.xml"), @DatabaseSetup(connection = "dataSource2", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/accountTest/testInsert.datasource2.xml") })
@ExpectedDatabases({ @ExpectedDatabase(connection = "dataSource1", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/accountTest/testInsert.datasource.result.xml"), @ExpectedDatabase(connection = "dataSource2", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/accountTest/testInsert.datasource2.result.xml") })
@DatabaseTearDowns({ @DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/accountTest/testInsert.datasource.result.xml"), @DatabaseTearDown(connection = "dataSource2", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/accountTest/testInsert.datasource2.result.xml") })
public void testInsert() {
    Account_ a = new Account_();
    a.setId(1L);
    a.setName("ann");
    a.setEmail("ann@live.cn");
    a.setPassword("5a690d842935c51f26f473e025c1b97a");
    a.setActivated(true);
    a.setActivateValue("");
    accountService.insert(a);
    Role2_ role2_ = new Role2_();
    role2_.setName("new");
    role2Service.insert(role2_);
    LoginLog_ loginLog_ = new LoginLog_();
    loginLog_.setLoginIP("old");
    loginLogService.insert(loginLog_);
    LoginLogSource2 loginLogSource2 = new LoginLogSource2();
    loginLogSource2.setLoginIP("new");
    loginLogSource2Service.insert(loginLogSource2);
    Collection<LoginLogSource2> c = loginLogSource2Service.selectAll(new LoginLogSource2());
    LoginLogSource2[] loginLogSource2s = c.toArray(new LoginLogSource2[1]);
    Assert.assertEquals("new", loginLogSource2s[0].getLoginIP());
    Account2_ account2_ = new Account2_();
    account2_.setEmail("l@x.com");
    account2_.setNickname("nick");
    account2_.setRole(role2_);
    account2Service.insert(account2_);
    Collection<Account2_> c2 = account2Service.selectAll(new Account2_());
    Account2_[] account2_s = c2.toArray(new Account2_[1]);
    Assert.assertEquals("new", account2_s[0].getRole().getName());
}
Also used : LoginLog_(indi.mybatis.flying.pojo.LoginLog_) Account2_(indi.mybatis.flying.pojo.Account2_) LoginLogSource2(indi.mybatis.flying.pojo.LoginLogSource2) Account_(indi.mybatis.flying.pojo.Account_) Role2_(indi.mybatis.flying.pojo.Role2_) DatabaseSetups(com.github.springtestdbunit.annotation.DatabaseSetups) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) ExpectedDatabases(com.github.springtestdbunit.annotation.ExpectedDatabases) DatabaseTearDowns(com.github.springtestdbunit.annotation.DatabaseTearDowns)

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