use of indi.mybatis.flying.pojo.Account_ in project mybatis.flying by limeng32.
the class AccountTest method testUpdate.
/**
* 测试update功能(有乐观锁)
*/
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/accountTest/testUpdate.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/accountTest/testUpdate.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/accountTest/testUpdate.xml")
public void testUpdate() {
Account_ a = accountService.select(1);
a.setEmail("ann@tom.com");
a.setActivated(false);
accountService.update(a);
}
use of indi.mybatis.flying.pojo.Account_ in project mybatis.flying by limeng32.
the class AccountTest method testSorter.
/**
* 测试sorter功能
*/
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/accountTest/testSorter.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/accountTest/testSorter.xml")
public void testSorter() {
Account_Condition ac = new Account_Condition();
ac.setSorter(new SortParam(new Order(Account_Condition.field_name, Conditionable.Sequence.desc)));
Collection<Account_> c = accountService.selectAll(ac);
Account_[] accounts = c.toArray(new Account_[c.size()]);
Assert.assertEquals("ann", accounts[3].getName());
ac.setSorter(new SortParam(new Order(Account_Condition.field_name, Conditionable.Sequence.desc), new Order(Account_Condition.field_password, Conditionable.Sequence.desc)));
c = accountService.selectAll(ac);
accounts = c.toArray(new Account_[c.size()]);
Assert.assertEquals(new Long(4), accounts[0].getId());
ac.setSorter(new SortParam(new Order(Account_Condition.field_name, Conditionable.Sequence.desc), new Order(Account_Condition.field_name, Conditionable.Sequence.asc)));
c = accountService.selectAll(ac);
accounts = c.toArray(new Account_[c.size()]);
Assert.assertEquals("ann", accounts[3].getName());
}
use of indi.mybatis.flying.pojo.Account_ in project mybatis.flying by limeng32.
the class AccountTest method testDeputy2.
/**
* 更多的测试deputyRole
*/
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/accountTest/testDeputy2.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/accountTest/testDeputy2.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/accountTest/testDeputy2.xml")
public void testDeputy2() {
Role_ rc = new Role_();
rc.setName("role1");
Role_ rdc = new Role_();
rdc.setName("role2");
Account_ ac = new Account_();
ac.setRole(rc);
ac.setRoleDeputy(rdc);
Collection<Account_> accountC = accountService.selectAll(ac);
Assert.assertEquals(1, accountC.size());
int count = accountService.count(ac);
Assert.assertEquals(1, count);
Account_ ac2 = new Account_();
ac2.setRole(rc);
Collection<Account_> accountC2 = accountService.selectAll(ac2);
Assert.assertEquals(2, accountC2.size());
int count2 = accountService.count(ac2);
Assert.assertEquals(2, count2);
Account_ ac3 = new Account_();
ac3.setRoleDeputy(rdc);
Collection<Account_> accountC3 = accountService.selectAll(ac3);
Assert.assertEquals(2, accountC3.size());
int count3 = accountService.count(ac3);
Assert.assertEquals(2, count3);
Account_ ac4 = new Account_();
Collection<Account_> accountC4 = accountService.selectAll(ac4);
Assert.assertEquals(4, accountC4.size());
int count4 = accountService.count(ac4);
Assert.assertEquals(4, count4);
}
use of indi.mybatis.flying.pojo.Account_ 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());
}
use of indi.mybatis.flying.pojo.Account_ in project mybatis.flying by limeng32.
the class CacheTest method testUpdateDirect.
/* 测试在select查询的情况下,缓存确实生效的用例 */
// @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 testUpdateDirect() {
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_ account = accountService.select(1);
Assert.assertEquals("ann", account.getRole().getName());
Map<String, Object> m = new HashMap<>(4);
m.put("id", 1);
m.put("name", "bob");
roleService.updateDirect(m);
Account_ account2 = accountService.select(1);
Assert.assertEquals("ann", account2.getRole().getName());
}
Aggregations