package com.blueland.ebpm.engine.config.service;

import static junit.framework.Assert.assertNotNull;

/**
 * @author lw
 * @version 1.0
 * @since  
 */

import com.blueland.bpm.engine.config.service.ActivityRuleManager;
import com.blueland.ebpm.engine.BaseManagerTestCase;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;

import com.blueland.bpm.engine.config.model.ActivityRule;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

@SpringBootTest
@RunWith(SpringRunner.class)
public class ActivityRuleManagerTest extends BaseManagerTestCase {

	private ActivityRuleManager manager;
	
	@Autowired
	public void setActivityRuleManager(ActivityRuleManager manager) {
		this.manager = manager;
	}

	//数据库单元测试前会开始事务，结束时会回滚事务，所以测试方法可以不用关心测试数据的删除
	@Test
	public void crud() {

		ActivityRule obj = newActivityRule();
		manager.save(obj);
		//manager.getEntityDao().flush();
		
		manager.update(obj);
		//manager.getEntityDao().flush();
		
		assertNotNull(obj.getRuleId());
		
		manager.removeById(obj.getRuleId());
		//manager.getEntityDao().flush();
	
	}
	
	public static ActivityRule newActivityRule() {
		ActivityRule obj = new ActivityRule();
		obj.setRuleId(java.util.UUID.randomUUID().toString());
	  	obj.setRuleName(new String("1"));
	  	obj.setProcDefId(new String("1"));
	  	obj.setSourceActId(new String("1"));
	  	obj.setTargetActId(new String("1"));
	  	obj.setRuleScript(new String("1"));
	  	obj.setRulePriority(new Integer("1"));
	  	obj.setRuleRemark(new String("1"));
		return obj;
	}
}
