Java Code Examples for com.github.springtestdbunit.annotation.DatabaseOperation#CLEAN_INSERT

The following examples show how to use com.github.springtestdbunit.annotation.DatabaseOperation#CLEAN_INSERT . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AccountTest.java    From mybatis.flying with Apache License 2.0 6 votes vote down vote up
/** 测试CostumizeStatus功能 */
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/accountTest/testCostumizeStatus.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/accountTest/testCostumizeStatus.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/accountTest/testCostumizeStatus.xml")
public void testCostumizeStatus() {
	Account_ a = accountService.select(1);
	Assert.assertEquals("发布", a.getStatus().text());
	Account_ ac = new Account_();
	ac.setStatus(StoryStatus_.p);
	Collection<Account_> c = accountService.selectAll(ac);
	Assert.assertEquals(1, c.size());
	Account_ a2 = accountService.select(2);
	Assert.assertEquals(StoryStatus_.s, a2.getStatus());
	a2.setStatus(StoryStatus_.c);
	accountService.update(a2);
	Account_ a3 = accountService.select(3);
	Assert.assertNull(a3.getStatus());
	a3.setPassword("5a690d842935c51f26f473e025c1b97a");
	accountService.updatePersistent(a3);
	Account_ a4 = accountService.select(3);
	Assert.assertNull(a4.getStatus());
}
 
Example 2
Source File: BatchProcessTest.java    From mybatis.flying with Apache License 2.0 6 votes vote down vote up
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/batchProcessTest/testBatchUpdate12.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT_UNORDERED, value = "/indi/mybatis/flying/test/batchProcessTest/testBatchUpdate12.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/batchProcessTest/testBatchUpdate12.xml")
public void testBatchUpdate12() {
	List<String> nameC = new ArrayList<>();
	nameC.add("a2");
	nameC.add("b");
	Account_Condition ac = new Account_Condition();
	ac.setEmail("[email protected]");
	ac.setNameNotIn(nameC);
	accountService.update(ac);

	Account_ a2 = new Account_();
	a2.setId(2L);
	a2.setPassword("aaa");
	// wrong opLock
	a2.setOpLock(10);
	accountService.update(a2);
}
 
Example 3
Source File: WhiteListTest.java    From mybatis.flying with Apache License 2.0 6 votes vote down vote up
@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());
}
 
Example 4
Source File: OrTest.java    From mybatis.flying with Apache License 2.0 6 votes vote down vote up
@Test
@DatabaseSetups({
		@DatabaseSetup(connection = "dataSource1", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/orTest/testOrMashup.dataSource1.xml"),
		@DatabaseSetup(connection = "dataSource2", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/orTest/testOrMashup.dataSource2.xml"), })
@ExpectedDatabases({
		@ExpectedDatabase(connection = "dataSource1", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT_UNORDERED, value = "/indi/mybatis/flying/test/orTest/testOrMashup.dataSource1.result.xml"),
		@ExpectedDatabase(connection = "dataSource2", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT_UNORDERED, value = "/indi/mybatis/flying/test/orTest/testOrMashup.dataSource2.result.xml"), })
@DatabaseTearDowns({
		@DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/orTest/testOrMashup.dataSource1.result.xml"),
		@DatabaseTearDown(connection = "dataSource2", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/orTest/testOrMashup.dataSource2.result.xml"), })
public void testOrMashup() {
	LoginLogSource2Condition l2c = new LoginLogSource2Condition();
	l2c.setAccountEqualsOr2(1L, 2L, "23453");
	int i1 = loginLogSource2Service.count(l2c);
	Assert.assertEquals(3, i1);

	LoginLogSource2Condition l2c2 = new LoginLogSource2Condition();
	l2c2.setAccountEqualsOr3(1L, 2L, "23453", "d4");
	Detail2_ d2c = new Detail2_();
	d2c.setLoginLogSource2(l2c2);
	int i2 = detail2Service.count(d2c);
	Assert.assertEquals(4, i2);
}
 
Example 5
Source File: IgnoreInsertAndUpdateTest.java    From mybatis.flying with Apache License 2.0 6 votes vote down vote up
@Test
@DatabaseSetups({
		@DatabaseSetup(connection = "dataSource2", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/ignoreInsertAndUpdateTest/testUpdate.datasource2.xml") })
@ExpectedDatabases({
		@ExpectedDatabase(connection = "dataSource2", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT_UNORDERED, value = "/indi/mybatis/flying/test/ignoreInsertAndUpdateTest/testUpdate.datasource2.result.xml") })
@DatabaseTearDowns({
		@DatabaseTearDown(connection = "dataSource2", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/ignoreInsertAndUpdateTest/testUpdate.datasource2.result.xml") })
public void testUpdate() {
	Detail2_ detail = detail2Service.select(1);
	detail.setName("n1New");
	detail.setDetail("dNew");
	LoginLogSource2 log = loginLogSource2Service.select(12);
	detail.setLoginLogSource2(log);
	detail2Service.updateWithoutName(detail);

	Detail2_ detail2 = detail2Service.select(2);
	detail2.setName(null);
	detail2.setNumber(null);
	detail2.setLoginLogSource2(null);
	detail2Service.updatePersistentWithoutName(detail2);
}
 
Example 6
Source File: WhiteListTest.java    From mybatis.flying with Apache License 2.0 6 votes vote down vote up
@Test
@DatabaseSetup(connection = "dataSource1", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/whiteListTest/testWhiteListInsert.xml")
@ExpectedDatabase(connection = "dataSource1", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/whiteListTest/testWhiteListInsert.result.xml")
@DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/whiteListTest/testWhiteListInsert.result.xml")
public void testWhiteListInsert() {
	Account_ account = new Account_();
	account.setName("name");
	account.setEmail("email");
	account.setPassword("aaa");
	Role_ role = new Role_();
	role.setId(11);
	account.setRole(role);
	Permission permission = new Permission();
	permission.setId(22);
	account.setPermission(permission);
	accountService.insertSimpleNoName(account);
}
 
Example 7
Source File: ConditionTest.java    From mybatis.flying with Apache License 2.0 6 votes vote down vote up
/** 测试condition:headLike功能 */
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/conditionTest/testConditionHeadLike.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/conditionTest/testConditionHeadLike.xml")
public void testConditionHeadLike() {
	Account_Condition ac = new Account_Condition();
	ac.setEmailHeadLike("ann");
	Collection<Account_> c = accountService.selectAll(ac);
	Account_[] accounts = c.toArray(new Account_[c.size()]);
	Assert.assertEquals(1, accounts.length);
	Assert.assertEquals("[email protected]", accounts[0].getEmail());

	Account_Condition3 ac2 = new Account_Condition3();
	ac2.setEmailHeadLike("1");
	Collection<Account_> c2 = accountService.selectAll(ac2);
	Account_[] accounts2 = c2.toArray(new Account_[c2.size()]);
	Assert.assertEquals(1, accounts2.length);
	Assert.assertEquals("[email protected]", accounts2[0].getEmail());
}
 
Example 8
Source File: ConditionNotInTest.java    From mybatis.flying with Apache License 2.0 6 votes vote down vote up
/** 测试无外键情况下condition:notIn功能且变量类型为时间的情况 */
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/conditionNotInTest/testConditionIn4.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/conditionNotInTest/testConditionIn4.xml")
public void testConditionNotIn4() {
	LoginLog_Condition lc = new LoginLog_Condition();
	List<Date> timeC = new ArrayList<>();
	Calendar c = Calendar.getInstance(), c2 = Calendar.getInstance();
	c.clear();
	c2.clear();
	c.set(1970, 0, 1, 8, 0, 0);
	c2.set(1970, 0, 1, 8, 0, 1);
	timeC.add(c.getTime());
	timeC.add(c2.getTime());
	lc.setLoginTimeNotIn(timeC);
	int count = loginLogService.count(lc);
	Assert.assertEquals(0, count);
}
 
Example 9
Source File: DelegateTest.java    From mybatis.flying with Apache License 2.0 6 votes vote down vote up
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/delegateTest/testDelegateUpdate.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/delegateTest/testDelegateUpdate.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/delegateTest/testDelegateUpdate.xml")
public void testDelegateUpdate() {
	LoginLog_ loginLog = loginLogService.select(1);
	loginLog.setAccount(null);
	loginLog.setDelegateAccountId(2L);
	loginLogService.update(loginLog);

	// 当login.getAccount()不为null时,修改accountId不起作用
	LoginLog_ loginLog2 = loginLogService.select(1);
	loginLog2.setDelegateAccountId(11L);
	loginLogService.update(loginLog2);

}
 
Example 10
Source File: BatchProcessTest.java    From mybatis.flying with Apache License 2.0 5 votes vote down vote up
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/batchProcessTest/testBatchDelete4.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/batchProcessTest/testBatchDelete4.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/batchProcessTest/testBatchDelete4.xml")
public void testBatchDelete4() {
	Account_Condition ac = new Account_Condition();
	ac.setNameIsNull(true);
	accountService.delete(ac);
}
 
Example 11
Source File: OrTest.java    From mybatis.flying with Apache License 2.0 5 votes vote down vote up
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/orTest/testOr2.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/orTest/testOr2.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/orTest/testOr2.result.xml")
public void testOr2() {
	LoginLog_Condition lc = new LoginLog_Condition();
	lc.setAccount(new Account_Condition());
	((Account_Condition) lc.getAccount()).setIdEqualsOr(1L, 2L);
	int i = loginLogService.count(lc);
	Assert.assertEquals(4, i);
}
 
Example 12
Source File: BatchProcessTest.java    From mybatis.flying with Apache License 2.0 5 votes vote down vote up
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/batchProcessTest/testBatchUpdatePersistent.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT_UNORDERED, value = "/indi/mybatis/flying/test/batchProcessTest/testBatchUpdatePersistent.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/batchProcessTest/testBatchUpdatePersistent.xml")
public void testBatchUpdatePersistent() {
	Account_Condition ac = new Account_Condition();
	ac.setId(1L);
	ac.setName("a2");
	ac.setOpLock(1);
	ac.setActivated(false);
	accountService.updatePersistent(ac);
}
 
Example 13
Source File: AccountTest.java    From mybatis.flying with Apache License 2.0 5 votes vote down vote up
/** 测试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("[email protected]");
	a.setActivated(false);
	accountService.update(a);
}
 
Example 14
Source File: IgnoreInsertAndUpdateTest.java    From mybatis.flying with Apache License 2.0 5 votes vote down vote up
@Test
@DatabaseSetups({
		@DatabaseSetup(connection = "dataSource2", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/ignoreInsertAndUpdateTest/testInsertBatch.datasource2.xml") })
@ExpectedDatabases({
		@ExpectedDatabase(connection = "dataSource2", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/ignoreInsertAndUpdateTest/testInsertBatch.datasource2.result.xml") })
@DatabaseTearDowns({
		@DatabaseTearDown(connection = "dataSource2", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/ignoreInsertAndUpdateTest/testInsertBatch.datasource2.result.xml") })
public void testInsertBatch() {
	Collection<Detail2_> dc = new ArrayList<>();

	Detail2_ d1 = new Detail2_();
	d1.setCreatetime(Calendar.getInstance().getTime());
	d1.setName("n1");
	d1.setNumber(123);
	d1.setDetail("d");
	LoginLogSource2 loginLog21 = new LoginLogSource2();
	loginLog21.setId(11);
	d1.setLoginLogSource2(loginLog21);
	dc.add(d1);

	Detail2_ d2 = new Detail2_();
	d2.setCreatetime(Calendar.getInstance().getTime());
	d2.setName("n2");
	d2.setNumber(456);
	d2.setDetail("e");
	LoginLogSource2 loginLog22 = new LoginLogSource2();
	loginLog22.setId(22);
	d2.setLoginLogSource2(loginLog22);
	dc.add(d2);

	detail2Service.insertBatchWithoutName(dc);
}
 
Example 15
Source File: IgnoreTest.java    From mybatis.flying with Apache License 2.0 5 votes vote down vote up
@Test
@DatabaseSetup(connection = "dataSource1", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/ignoreTest/testSelectPrefixIgnore.xml")
@ExpectedDatabase(connection = "dataSource1", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/ignoreTest/testSelectPrefixIgnore.result.xml")
@DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/ignoreTest/testSelectPrefixIgnore.result.xml")
public void testSelectPrefixIgnore() {
	Detail_ detail = detailService.selectPrefixIgnore(202);
	Assert.assertNull(detail.getId());
	Assert.assertNotNull(detail.getLoginLog().getId());
	Assert.assertNull(detail.getLoginLog().getAccount().getName());
	Assert.assertEquals("bbb", detail.getLoginLog().getAccount().getPassword());
}
 
Example 16
Source File: NotEqualConditionTest.java    From mybatis.flying with Apache License 2.0 4 votes vote down vote up
/** 测试condition:greaterThan功能 */
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/notEqualConditionTest/testConditionGreaterThan.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/notEqualConditionTest/testConditionGreaterThan.xml")
public void testConditionGreaterThan() {
	LoginLog_Condition lc = new LoginLog_Condition(), lc2 = new LoginLog_Condition(),
			lc3 = new LoginLog_Condition(), lc4 = new LoginLog_Condition();
	lc.setLoginTimeGreaterThan(new Date(1));
	lc.setIdGreaterThan(0);
	Collection<LoginLog_> c = loginLogService.selectAll(lc);
	Assert.assertEquals(1, c.size());
	LoginLog_[] loginlogs = c.toArray(new LoginLog_[c.size()]);
	Assert.assertEquals("0.0.0.1", loginlogs[0].getLoginIP());

	Collection<LoginLog_> c11 = loginLogService.selectAllPrefix(lc);
	Assert.assertEquals(1, c11.size());
	LoginLog_[] loginlogs11 = c11.toArray(new LoginLog_[c11.size()]);
	Assert.assertEquals("0.0.0.1", loginlogs11[0].getLoginIP());

	lc2.setLoginTimeGreaterThan(new Date());
	Collection<LoginLog_> c2 = loginLogService.selectAll(lc2);
	Assert.assertEquals(0, c2.size());

	Collection<LoginLog_> c12 = loginLogService.selectAllPrefix(lc2);
	Assert.assertEquals(0, c12.size());

	lc3.setIdGreaterThan(10);
	int count3 = loginLogService.count(lc3);
	Assert.assertEquals(0, count3);
	lc3.setIdGreaterThan(null);
	lc3.setIdGreaterOrEqual(10);
	count3 = loginLogService.count(lc3);
	Assert.assertEquals(1, count3);
	lc3.setIdGreaterOrEqual(null);
	lc3.setLoginTime(loginlogs[0].getLoginTime());
	count3 = loginLogService.count(lc3);
	Assert.assertEquals(1, count3);
	lc3.setLoginTime(null);
	lc3.setLoginTimeNotEqual(loginlogs[0].getLoginTime());
	count3 = loginLogService.count(lc3);
	Assert.assertEquals(0, count3);

	lc4.setIdGreaterThan(9);
	int count4 = loginLogService.count(lc4);
	Assert.assertEquals(1, count4);
	lc4.setIdGreaterThan(null);
	lc4.setIdLessThan(11);
	count4 = loginLogService.count(lc4);
	Assert.assertEquals(1, count4);
	lc4.setIdLessThan(10);
	count4 = loginLogService.count(lc4);
	Assert.assertEquals(0, count4);
	lc4.setIdLessThan(null);
	lc4.setIdLessOrEqual(10);
	count4 = loginLogService.count(lc4);
	Assert.assertEquals(1, count4);
	lc4.setIdLessOrEqual(null);
	lc4.setIdNotEqual(10);
	count4 = loginLogService.count(lc4);
	Assert.assertEquals(0, count4);
}
 
Example 17
Source File: PrefixTest.java    From mybatis.flying with Apache License 2.0 4 votes vote down vote up
@Test
@DatabaseSetup(connection = "dataSource1", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/prefixTest/testSelect.xml")
@ExpectedDatabase(connection = "dataSource1", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/prefixTest/testSelect.result.xml")
@DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/prefixTest/testSelect.result.xml")
public void testSelect() {
	Map<String, String> map = new HashMap<>();
	map.put("id", "1");
	Account_ account = accountService.selectAsd(1);
	Assert.assertTrue(account.getActivated());
	Assert.assertEquals("bob", account.getName());
	Assert.assertEquals("[email protected]_", account.getEmail());
	Assert.assertNull(account.getPassword());
	Assert.assertEquals("a111", account.getActivateValue());
	Assert.assertEquals(11, account.getOpLock().intValue());

	Account_ ac = new Account_();
	ac.setName("carl");
	Permission pc = new Permission();
	pc.setName("carl");
	ac.setPermission(pc);
	Collection<Account_> accountC = accountService.selectAllPrefix(ac);
	System.out.println(JSONObject.toJSONString(accountC));
	Account_[] accounts = accountC.toArray(new Account_[accountC.size()]);
	Assert.assertEquals(3, accounts[0].getId().intValue());
	Assert.assertEquals(23, accounts[0].getPermission().getFakeId().intValue());
	Assert.assertEquals(3, accounts[0].getPermission().getId().intValue());
	Assert.assertEquals("carl", accounts[0].getPermission().getName());
	Assert.assertEquals(13, accounts[0].getRole().getId().intValue());
	Assert.assertEquals("role3", accounts[0].getRole().getName());
	Assert.assertEquals(113, accounts[0].getRoleDeputy().getId().intValue());
	Assert.assertEquals("roleDeputy3", accounts[0].getRoleDeputy().getName());

	Assert.assertEquals(4, accounts[1].getId().intValue());
	Assert.assertEquals(24, accounts[1].getPermission().getFakeId().intValue());
	Assert.assertEquals(4, accounts[1].getPermission().getId().intValue());
	Assert.assertEquals("carl", accounts[1].getPermission().getName());
	Assert.assertEquals(14, accounts[1].getRole().getId().intValue());
	Assert.assertEquals("role4", accounts[1].getRole().getName());
	Assert.assertEquals(114, accounts[1].getRoleDeputy().getId().intValue());
	Assert.assertEquals("roleDeputy4", accounts[1].getRoleDeputy().getName());

	int c = accountService.countAsd(ac);
	Assert.assertEquals(2, c);

	FlyingModel fm = FlyingManager
			.getFlyingModelFromCache("indi.mybatis.flying.mapper.AccountMapper.selectAllPrefix");
	System.out.println("fm::" + JSONObject.toJSONString(fm));

	Assert.assertEquals("noPassword", fm.getIgnoreTag());
	Assert.assertEquals("use index(index1)", fm.getIndex());
	Assert.assertNull(fm.getPrefix());

	FlyingModel fm1 = fm.getProperties().get("permission");
	Assert.assertNull(fm1.getIgnoreTag());
	Assert.assertNull(fm1.getIndex());
	Assert.assertEquals("permission__", fm1.getPrefix());
	Assert.assertEquals("indi.mybatis.flying.mapper.PermissionMapper.select", fm1.getId());

	FlyingModel fm2 = fm.getProperties().get("role");
	Assert.assertNull(fm2.getIndex());
	Assert.assertEquals("indi.mybatis.flying.mapper.RoleMapper.select", fm2.getId());
	Assert.assertEquals("role__", fm2.getPrefix());

	FlyingModel fm3 = fm.getProperties().get("roleDeputy");
	Assert.assertNull(fm3.getIndex());
	Assert.assertEquals("roleDeputy__", fm3.getPrefix());
}
 
Example 18
Source File: BatchProcessTest.java    From mybatis.flying with Apache License 2.0 4 votes vote down vote up
@Test
@DatabaseSetups({
		@DatabaseSetup(connection = "dataSource1", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/batchProcessTest/testBatchInsert2.datasource.xml") })
@ExpectedDatabases({
		@ExpectedDatabase(connection = "dataSource1", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/batchProcessTest/testBatchInsert2.datasource.result.xml") })
@DatabaseTearDowns({
		@DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/batchProcessTest/testBatchInsert2.datasource.result.xml") })
public void testBatchInsert2() {
	Collection<Account_> ac = new ArrayList<>();
	Role_ r1 = new Role_(), r2 = new Role_(), r3 = new Role_();
	r1.setId(1);
	r2.setId(2);
	r3.setId(3);
	Account_ a = new Account_();
	a.setName("ann");
	a.setEmail("[email protected]");
	a.setPassword("5a690d842935c51f26f473e025c1b97a");
	a.setActivated(true);
	a.setActivateValue("");
	a.setRole(r1);
	ac.add(a);

	Account_ a2 = new Account_();
	a2.setName("bob");
	a2.setEmail("[email protected]");
	a2.setPassword("6a690d842935c51f26f473e025c1b97a");
	a2.setActivated(true);
	a2.setActivateValue("");
	a2.setRole(r2);
	ac.add(a2);

	Account_ a3 = new Account_();
	a3.setName("carl");
	a3.setEmail("[email protected]");
	a3.setPassword("7a690d842935c51f26f473e025c1b97a");
	a3.setActivated(true);
	a3.setActivateValue("");
	a3.setRole(r3);
	ac.add(a3);
	accountService.insertSnowFlakeBatch(ac);
	for (Account_ e : ac) {
		Assert.assertNotNull(e.getId());
	}
}
 
Example 19
Source File: BatchProcessTest.java    From mybatis.flying with Apache License 2.0 4 votes vote down vote up
@Test
@DatabaseSetups({
		@DatabaseSetup(connection = "dataSource1", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/batchProcessTest/testBatchInsert.datasource.xml") })
@ExpectedDatabases({
		@ExpectedDatabase(connection = "dataSource1", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/batchProcessTest/testBatchInsert.datasource.result.xml") })
@DatabaseTearDowns({
		@DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/batchProcessTest/testBatchInsert.datasource.result.xml") })
public void testBatchInsert() {
	Collection<Account_> ac = new ArrayList<>();
	Role_ r1 = new Role_(), r2 = new Role_(), r3 = new Role_();
	r1.setId(1);
	r2.setId(2);
	r3.setId(3);
	Account_ a = new Account_();
	a.setId(1L);
	a.setName("ann");
	a.setEmail("[email protected]");
	a.setPassword("5a690d842935c51f26f473e025c1b97a");
	a.setActivated(true);
	a.setActivateValue("");
	a.setRole(r1);
	ac.add(a);

	Account_ a2 = new Account_();
	a2.setId(2L);
	a2.setName("bob");
	a2.setEmail("[email protected]");
	a2.setPassword("6a690d842935c51f26f473e025c1b97a");
	a2.setActivated(true);
	a2.setActivateValue("");
	a2.setRole(r2);
	ac.add(a2);

	Account_ a3 = new Account_();
	a3.setId(3L);
	a3.setName("carl");
	a3.setEmail("[email protected]");
	a3.setPassword("7a690d842935c51f26f473e025c1b97a");
	a3.setActivated(true);
	a3.setActivateValue("");
	a3.setRole(r3);
	ac.add(a3);
	accountService.insertBatch(ac);
	System.out.println(JSONObject.toJSONString(ac));

	Collection<Account_> ac2 = new ArrayList<>();
	try {
		accountService.insertBatch(ac2);
		// below code should never reach
		Assert.assertTrue(false);
	} catch (Exception e) {

	}
	System.out.println(JSONObject.toJSONString(ac2));
}
 
Example 20
Source File: AccountTypeHandlerTest.java    From mybatis.flying with Apache License 2.0 4 votes vote down vote up
@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("[email protected]", 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("[email protected]", 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("[email protected]", 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());
}