Search in sources :

Example 21 with Account_

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

the class AccountTest method testDelete.

/**
 * 测试delete功能
 */
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/accountTest/testDelete.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/accountTest/testDelete.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/accountTest/testDelete.xml")
public void testDelete() {
    Account_ a = accountService.select(1);
    accountService.delete(a);
}
Also used : 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)

Example 22 with Account_

use of indi.mybatis.flying.pojo.Account_ 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.selectAll(lc2);
    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) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup) DatabaseTearDown(com.github.springtestdbunit.annotation.DatabaseTearDown)

Example 23 with Account_

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

the class AccountTypeHandlerTest method testAccountTypeHandler.

/* 测试AccountTypeHandler的功能 */
@Test
@DatabaseSetups({ @DatabaseSetup(connection = "dataSource1", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/accountTypeHandlerTest/testAccountTypeHandler.datasource.xml"), @DatabaseSetup(connection = "dataSource2", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/accountTypeHandlerTest/testAccountTypeHandler.datasource2.xml") })
@ExpectedDatabases({ @ExpectedDatabase(connection = "dataSource1", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/accountTypeHandlerTest/testAccountTypeHandler.datasource.result.xml"), @ExpectedDatabase(connection = "dataSource2", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/accountTypeHandlerTest/testAccountTypeHandler.datasource2.result.xml") })
@DatabaseTearDowns({ @DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/accountTypeHandlerTest/testAccountTypeHandler.datasource.result.xml"), @DatabaseTearDown(connection = "dataSource2", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/accountTypeHandlerTest/testAccountTypeHandler.datasource2.result.xml") })
public void testAccountTypeHandler() {
    LoginLogSource2 longinLogSource0 = loginLogSource2Service.selectWithoutAccount(22);
    Assert.assertNull(longinLogSource0.getAccount());
    LoginLogSource2 longinLogSource = loginLogSource2Service.select(22);
    Assert.assertNotNull(longinLogSource);
    Assert.assertNotNull(longinLogSource.getAccount());
    Assert.assertEquals("ann@live.cn", longinLogSource.getAccount().getEmail());
    Account_ ac = new Account_();
    ac.setId(1L);
    LoginLogSource2 l2c = new LoginLogSource2();
    l2c.setAccount(ac);
    Collection<LoginLogSource2> loginLogSource2C = loginLogSource2Service.selectAll(l2c);
    Assert.assertEquals(2, loginLogSource2C.size());
    for (LoginLogSource2 e : loginLogSource2C) {
        Assert.assertEquals("ann@live.cn", e.getAccount().getEmail());
    }
    LoginLogSource2 loginLogSource2 = loginLogSource2Service.select(24);
    Assert.assertNull(loginLogSource2.getAccount());
    LoginLogSource2 loginLogSource3 = loginLogSource2Service.select(25);
    Assert.assertNull(loginLogSource3.getAccount());
    Account_ ac2 = new Account_();
    ac2.setId(2L);
    LoginLogSource2 l2c2 = new LoginLogSource2();
    l2c2.setAccount(ac2);
    LoginLogSource2 loginLogSource4 = loginLogSource2Service.selectOne(l2c2);
    loginLogSource4 = loginLogSource2Service.selectOne(l2c2);
    loginLogSource4 = loginLogSource2Service.selectOne(l2c2);
    loginLogSource4 = loginLogSource2Service.selectOne(l2c2);
    loginLogSource4 = loginLogSource2Service.selectOne(l2c2);
    Assert.assertEquals("bob@live.cn", loginLogSource4.getAccount().getEmail());
    Account_ ac3 = new Account_();
    ac3.setId(1L);
    LoginLogSource2 l2c3 = new LoginLogSource2();
    l2c3.setAccount(ac3);
    l2c3.setLoginIP("ip1");
    int i = loginLogSource2Service.count(l2c3);
    Assert.assertEquals(1, i);
    Account_ account2 = accountService.select(2);
    loginLogSource2.setAccount(account2);
    loginLogSource2Service.update(loginLogSource2);
    loginLogSource4.setAccount(null);
    loginLogSource2Service.updatePersistent(loginLogSource4);
    Account_ account = accountService.select(1);
    loginLogSource2Service.loadAccount(account, new LoginLogSource2());
    Assert.assertEquals(2, account.getLoginLogSource2().size());
}
Also used : LoginLogSource2(indi.mybatis.flying.pojo.LoginLogSource2) Account_(indi.mybatis.flying.pojo.Account_) DatabaseSetups(com.github.springtestdbunit.annotation.DatabaseSetups) Test(org.junit.Test) ExpectedDatabases(com.github.springtestdbunit.annotation.ExpectedDatabases) DatabaseTearDowns(com.github.springtestdbunit.annotation.DatabaseTearDowns)

Example 24 with Account_

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

the class CacheTest method testPagination.

@Test
@IfProfileValue(name = "CACHE", value = "true")
@DatabaseSetup(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/cacheTest/testPagination.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/cacheTest/testPagination.result.xml")
public void testPagination() {
    String name1 = "ann", name2 = "bob", name3 = "carl", name4 = "duke";
    Account_ a1 = new Account_();
    a1.setId(1L);
    a1.setName(name1);
    accountService.insert(a1);
    Account_ a2 = new Account_();
    a2.setId(2L);
    a2.setName(name2);
    accountService.insert(a2);
    Account_ a3 = new Account_();
    a3.setId(3L);
    a3.setName(name3);
    accountService.insert(a3);
    Account_ a4 = new Account_();
    a4.setId(4L);
    a4.setName(name4);
    accountService.insert(a4);
    Account_Condition ac = new Account_Condition();
    ac.setLimiter(new PageParam(1, 2));
    Collection<Account_> c1 = accountService.selectAll(ac);
    Assert.assertEquals(2, c1.size());
    for (Account_ a : c1) {
        if (a.getId() == 1) {
            Assert.assertEquals(name1, a.getName());
        } else {
            Assert.assertEquals(name2, a.getName());
        }
    }
    Assert.assertEquals(2, ac.getLimiter().getMaxPageNum());
    ac.setLimiter(new PageParam(1, 2));
    c1 = accountService.selectAll(ac);
    Assert.assertEquals(2, ac.getLimiter().getMaxPageNum());
    accountService.delete(a1);
    accountService.delete(a2);
    accountService.delete(a3);
    accountService.delete(a4);
}
Also used : Account_(indi.mybatis.flying.pojo.Account_) Account_Condition(indi.mybatis.flying.pojo.condition.Account_Condition) PageParam(indi.mybatis.flying.pagination.PageParam) 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 Account_

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

the class CacheTest method testUpdateDirect4.

/* 测试在查询对象查询的情况下,缓存确实生效的用例 */
// @Test
@IfProfileValue(name = "CACHE", value = "true")
@ExpectedDatabase(connection = "dataSource1", assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/cacheTest/testUpdateDirect.result.xml")
@DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/cacheTest/testUpdateDirect.result.xml")
public void testUpdateDirect4() {
    Role_ r = new Role_();
    r.setId(1);
    r.setName("ann");
    roleService.insert(r);
    Account_ a = new Account_();
    a.setId(1L);
    a.setRole(r);
    a.setEmail("email");
    accountService.insert(a);
    Account_Condition ac = new Account_Condition();
    ac.setLimiter(new PageParam(1, 1));
    Collection<Account_> c = accountService.selectAll(ac);
    Map<String, Object> m = new HashMap<>(4);
    m.put("id", 1);
    m.put("name", "bob");
    roleService.updateDirect(m);
    Account_Condition ac2 = new Account_Condition();
    ac2.setLimiter(new PageParam(1, 1));
    Collection<Account_> c2 = accountService.selectAll(ac2);
    for (Account_ t : c2) {
        Assert.assertEquals("ann", t.getRole().getName());
    }
}
Also used : HashMap(java.util.HashMap) Account_(indi.mybatis.flying.pojo.Account_) Account_Condition(indi.mybatis.flying.pojo.condition.Account_Condition) PageParam(indi.mybatis.flying.pagination.PageParam) Role_(indi.mybatis.flying.pojo.Role_) ExpectedDatabase(com.github.springtestdbunit.annotation.ExpectedDatabase) DatabaseTearDown(com.github.springtestdbunit.annotation.DatabaseTearDown) IfProfileValue(org.springframework.test.annotation.IfProfileValue)

Aggregations

Account_ (indi.mybatis.flying.pojo.Account_)42 Test (org.junit.Test)38 DatabaseTearDown (com.github.springtestdbunit.annotation.DatabaseTearDown)36 DatabaseSetup (com.github.springtestdbunit.annotation.DatabaseSetup)25 ExpectedDatabase (com.github.springtestdbunit.annotation.ExpectedDatabase)25 Account_Condition (indi.mybatis.flying.pojo.condition.Account_Condition)18 IfProfileValue (org.springframework.test.annotation.IfProfileValue)18 Role_ (indi.mybatis.flying.pojo.Role_)17 LoginLog_ (indi.mybatis.flying.pojo.LoginLog_)8 HashMap (java.util.HashMap)8 DatabaseSetups (com.github.springtestdbunit.annotation.DatabaseSetups)6 DatabaseTearDowns (com.github.springtestdbunit.annotation.DatabaseTearDowns)6 ExpectedDatabases (com.github.springtestdbunit.annotation.ExpectedDatabases)6 PageParam (indi.mybatis.flying.pagination.PageParam)6 Order (indi.mybatis.flying.pagination.Order)4 SortParam (indi.mybatis.flying.pagination.SortParam)4 ArrayList (java.util.ArrayList)4 LoginLogSource2 (indi.mybatis.flying.pojo.LoginLogSource2)3 Page (indi.mybatis.flying.pagination.Page)2 Account2_ (indi.mybatis.flying.pojo.Account2_)2