Here are the examples of the java api org.activiti.engine.ProcessEngine taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
225 Examples
19
Source : WorkflowEngineGetterImpl.java
with Apache License 2.0
from Yiuman
with Apache License 2.0
from Yiuman
/**
* 默认的流程引擎获取方式
*
* @author yiuman
* @date 2020/12/17
*/
public clreplaced WorkflowEngineGetterImpl implements WorkflowEngineGetter {
private ProcessEngine processEngine;
public WorkflowEngineGetterImpl() {
}
@Override
public ProcessEngine getProcessEngine() {
ProcessEngine processEngine = Optional.ofNullable(this.processEngine).orElse(SpringUtils.getBean(ProcessEngine.clreplaced, true));
this.processEngine = processEngine;
// 这里置空
// ((SpringProcessEngineConfiguration) processEngine.getProcessEngineConfiguration()).setUserGroupManager(null);
return processEngine;
}
}
19
Source : WorkflowEngineGetterImpl.java
with Apache License 2.0
from Yiuman
with Apache License 2.0
from Yiuman
@Override
public ProcessEngine getProcessEngine() {
ProcessEngine processEngine = Optional.ofNullable(this.processEngine).orElse(SpringUtils.getBean(ProcessEngine.clreplaced, true));
this.processEngine = processEngine;
// 这里置空
// ((SpringProcessEngineConfiguration) processEngine.getProcessEngineConfiguration()).setUserGroupManager(null);
return processEngine;
}
19
Source : BaseWorkflowQueryController.java
with Apache License 2.0
from Yiuman
with Apache License 2.0
from Yiuman
private void initQueryMapping() {
ProcessEngine processEngine = getProcessEngine();
// 流程定义
QUERY_MAPPING.put(ProcessDefinition.clreplaced, () -> processEngine.getRepositoryService().createProcessDefinitionQuery());
// 任务
QUERY_MAPPING.put(Task.clreplaced, () -> processEngine.getTaskService().createTaskQuery());
// 活动历史
QUERY_MAPPING.put(HistoricActivityInstance.clreplaced, () -> processEngine.getHistoryService().createHistoricActivityInstanceQuery());
// 历史任务
QUERY_MAPPING.put(HistoricTaskInstance.clreplaced, () -> processEngine.getHistoryService().createHistoricTaskInstanceQuery());
}
19
Source : ActivitiModelServiceImpl.java
with Apache License 2.0
from weizhiqiang1995
with Apache License 2.0
from weizhiqiang1995
@Service
public clreplaced ActivitiModelServiceImpl implements ActivitiModelService {
@Autowired
private ProcessEngine processEngine;
@Autowired
private ObjectMapper objectMapper;
@Autowired
private RepositoryService repositoryService;
/**
* @replacedle: insertNewActivitiModel
* @Description: 新建一个空模型
* @param @param inputObject
* @param @param outputObject
* @param @throws Exception 参数
* @return void 返回类型
* @throws
*/
@SuppressWarnings("deprecation")
@Override
public void insertNewActivitiModel(InputObject inputObject, OutputObject outputObject) throws Exception {
Map<String, Object> map = inputObject.getParams();
RepositoryService repositoryService = processEngine.getRepositoryService();
// 初始化一个空模型
Model model = repositoryService.newModel();
// 设置一些默认信息
String name = "new-process";
String description = "";
int revision = 1;
String key = "process";
ObjectNode modelNode = objectMapper.createObjectNode();
modelNode.put(ModelDataJsonConstants.MODEL_NAME, name);
modelNode.put(ModelDataJsonConstants.MODEL_DESCRIPTION, description);
modelNode.put(ModelDataJsonConstants.MODEL_REVISION, revision);
model.setName(name);
model.setKey(key);
model.setMetaInfo(modelNode.toString());
repositoryService.saveModel(model);
String id = model.getId();
ObjectNode editorNode = objectMapper.createObjectNode();
editorNode.put("id", "canvas");
editorNode.put("resourceId", "canvas");
ObjectNode stencilSetNode = objectMapper.createObjectNode();
stencilSetNode.put("namespace", "http://b3mn.org/stencilset/bpmn2.0#");
editorNode.put("stencilset", stencilSetNode);
repositoryService.addModelEditorSource(id, editorNode.toString().getBytes("utf-8"));
map.put("id", model.getId());
outputObject.setBean(map);
}
/**
* @replacedle: queryActivitiModelList
* @Description: 获取所有模型
* @param @param inputObject
* @param @param outputObject
* @param @throws Exception 参数
* @return void 返回类型
* @throws
*/
@Override
public void queryActivitiModelList(InputObject inputObject, OutputObject outputObject) throws Exception {
Map<String, Object> map = inputObject.getParams();
RepositoryService repositoryService = processEngine.getRepositoryService();
List<Model> beans = repositoryService.createModelQuery().listPage(Integer.parseInt(map.get("limit").toString()) * (Integer.parseInt(map.get("page").toString()) - 1), Integer.parseInt(map.get("limit").toString()));
long count = repositoryService.createModelQuery().count() - repositoryService.createDeploymentQuery().count();
List<Map<String, Object>> rows = new ArrayList<>();
for (Model model : beans) {
if (ToolUtil.isBlank(model.getDeploymentId())) {
rows.add(ToolUtil.javaBean2Map(model));
}
}
outputObject.setBeans(rows);
outputObject.settotal(count);
}
/**
* @replacedle: editActivitiModelToDeploy
* @Description: 发布模型为流程定义
* @param @param inputObject
* @param @param outputObject
* @param @throws Exception 参数
* @return void 返回类型
* @throws
*/
@Override
public void editActivitiModelToDeploy(InputObject inputObject, OutputObject outputObject) throws Exception {
Map<String, Object> map = inputObject.getParams();
String modelId = map.get("modelId").toString();
// 获取模型
RepositoryService repositoryService = processEngine.getRepositoryService();
Model modelData = repositoryService.getModel(modelId);
byte[] bytes = repositoryService.getModelEditorSource(modelData.getId());
if (bytes == null) {
outputObject.setreturnMessage("模型数据为空,请先设计流程并成功保存,再进行发布。");
} else {
JsonNode modelNode = new ObjectMapper().readTree(bytes);
BpmnModel model = new BpmnJsonConverter().convertToBpmnModel(modelNode);
if (model.getProcesses().size() == 0) {
outputObject.setreturnMessage("数据模型不符要求,请至少设计一条主线流程。");
} else {
byte[] bpmnBytes = new BpmnXMLConverter().convertToXML(model);
// 发布流程
String processName = modelData.getName() + ".bpmn20.xml";
Deployment deployment = repositoryService.createDeployment().name(modelData.getName()).addString(processName, new String(bpmnBytes, "UTF-8")).deploy();
modelData.setDeploymentId(deployment.getId());
repositoryService.saveModel(modelData);
}
}
}
/**
* @replacedle: editActivitiModelToStartProcess
* @Description: 启动流程
* @param @param inputObject
* @param @param outputObject
* @param @throws Exception 参数
* @return void 返回类型
* @throws
*/
@Override
public void editActivitiModelToStartProcess(InputObject inputObject, OutputObject outputObject) throws Exception {
Map<String, Object> map = inputObject.getParams();
String keyName = map.get("keyName").toString();
ProcessInstance process = processEngine.getRuntimeService().startProcessInstanceByKey(keyName);
map.clear();
map.put("id", process.getId());
map.put("processDefinitionId", process.getProcessDefinitionId());
outputObject.setBean(map);
}
/**
* @replacedle: editActivitiModelToRun
* @Description: 提交任务
* @param @param inputObject
* @param @param outputObject
* @param @throws Exception 参数
* @return void 返回类型
* @throws
*/
@Override
public void editActivitiModelToRun(InputObject inputObject, OutputObject outputObject) throws Exception {
Map<String, Object> map = inputObject.getParams();
String processInstanceId = map.get("processInstanceId").toString();
Task task = processEngine.getTaskService().createTaskQuery().processInstanceId(processInstanceId).singleResult();
processEngine.getTaskService().complete(task.getId());
}
/**
* @replacedle: deleteActivitiModelById
* @Description: 删除模型
* @param @param inputObject
* @param @param outputObject
* @param @throws Exception 参数
* @return void 返回类型
* @throws
*/
@Override
public void deleteActivitiModelById(InputObject inputObject, OutputObject outputObject) throws Exception {
Map<String, Object> map = inputObject.getParams();
String id = map.get("id").toString();
repositoryService.deleteModel(id);
}
/**
* @replacedle: queryReleasedActivitiModelList
* @Description: 获取已经发布的模型
* @param @param inputObject
* @param @param outputObject
* @param @throws Exception 参数
* @return void 返回类型
* @throws
*/
@Override
public void queryReleasedActivitiModelList(InputObject inputObject, OutputObject outputObject) throws Exception {
Map<String, Object> map = inputObject.getParams();
List<Deployment> deployments = repositoryService.createDeploymentQuery().listPage(Integer.parseInt(map.get("limit").toString()) * (Integer.parseInt(map.get("page").toString()) - 1), Integer.parseInt(map.get("limit").toString()));
long count = repositoryService.createDeploymentQuery().count();
List<DeploymentResponse> list = new ArrayList<>();
for (Deployment deployment : deployments) {
list.add(new DeploymentResponse(deployment));
}
List<Map<String, Object>> rows = new ArrayList<>();
for (DeploymentResponse deploymentResponse : list) {
rows.add(ToolUtil.javaBean2Map(deploymentResponse));
}
outputObject.setBeans(rows);
outputObject.settotal(count);
}
/**
* @replacedle: deleteReleasedActivitiModelById
* @Description: 取消发布
* @param @param inputObject
* @param @param outputObject
* @param @throws Exception 参数
* @return void 返回类型
* @throws
*/
@Override
public void deleteReleasedActivitiModelById(InputObject inputObject, OutputObject outputObject) throws Exception {
Map<String, Object> map = inputObject.getParams();
String deploymentId = map.get("deploymentId").toString();
repositoryService.deleteDeployment(deploymentId);
}
}
19
Source : BPMNProcessSequenceFlowTokenRecorder.java
with Apache License 2.0
from vc-thesf
with Apache License 2.0
from vc-thesf
/**
* One kind of BPMN process activity recorder. - {@literal SequenceFlow Taken}
*
* @author VirtualCry
*/
public clreplaced BPMNProcessSequenceFlowTokenRecorder {
private final ProcessEngine processEngine;
private final BPMNProcessChainCacheManager bpmnProcessChainCacheManager;
public BPMNProcessSequenceFlowTokenRecorder(ProcessEngine processEngine, BPMNProcessChainCacheManager bpmnProcessChainCacheManager) {
this.processEngine = processEngine;
this.bpmnProcessChainCacheManager = bpmnProcessChainCacheManager;
}
/**
* Record when {@literal sequence flow token}.
*
* @param sequenceFlow sequenceFlow
*/
public void record(BPMNSequenceFlow sequenceFlow) {
BPMNActivity sourceActivity = BPMNActivityreplacedembler.fromSource(sequenceFlow);
BPMNActivity targetActivity = BPMNActivityreplacedembler.fromTarget(sequenceFlow);
// Get process chain with process instance id
BPMNProcessChain processChain = this.bpmnProcessChainCacheManager.computeIfAbsent(sequenceFlow.getProcessInstanceId(), key -> {
BPMNProcessChain candidateChain = new BPMNProcessChainImpl();
BPMNActivityChain activityChain = new BPMNActivityChainImpl(Arrays.asList(sourceActivity, targetActivity));
candidateChain.run(activityChain);
return candidateChain;
});
// Calculate the number of activities from the same source.
int outgoingCount = processEngine.getManagementService().executeCommand(new CalculateOutgoingFlowsCmd(sequenceFlow.getProcessInstanceId(), sourceActivity.getElementId())).size();
// Suspend the source activity when the number of activities is greater than one
if (outgoingCount > 1)
processChain.suspend(sourceActivity);
// Clear suspended activity when the outgoingCount equals the number of suspended activities
if (outgoingCount == processChain.getSuspendedCount(sourceActivity))
processChain.clearSuspended(sourceActivity);
// Get running candidate chains which its last activity is the same as the source activity from running chains
List<BPMNActivityChain> candidateActivityChains = processChain.getRunningActivityChains().stream().filter(activityChain -> activityChain.getLastActivity().getElementId().equals(sourceActivity.getElementId())).collect(Collectors.toList());
if (candidateActivityChains.isEmpty())
return;
// Exit the specified running candidate chains if the source activity is not suspended
if (processChain.isSuspended(sourceActivity))
processChain.exitAll(candidateActivityChains);
// Create new chains and add the each target activity to the end
List<BPMNActivityChain> newActivityChains = candidateActivityChains.stream().map(activityChain -> {
BPMNActivityChain newActivityChain = new BPMNActivityChainImpl(activityChain);
newActivityChain.add(targetActivity);
return newActivityChain;
}).collect(Collectors.toList());
// Run the new chains
processChain.runAll(newActivityChains);
}
}
19
Source : ConfigDBTests.java
with Apache License 2.0
from ukihsoroy
with Apache License 2.0
from ukihsoroy
@Test
public void testConfig2() {
// 基于默认的配置文件,初始化流程引擎,resource目录下需要有对应的activiti.cfg.xml配置文件,要不报错
ProcessEngineConfiguration configuration = ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("activiti_druid.cfg.xml");
logger.info("configuration {}", configuration);
ProcessEngine processEngine = configuration.buildProcessEngine();
logger.info("获取流程引擎 {}", processEngine);
processEngine.close();
logger.info("over");
}
19
Source : ConfigDBTests.java
with Apache License 2.0
from ukihsoroy
with Apache License 2.0
from ukihsoroy
@Test
public void testConfig1() {
// 基于默认的配置文件,初始化流程引擎,resource目录下需要有对应的activiti.cfg.xml配置文件,要不报错
ProcessEngineConfiguration configuration = ProcessEngineConfiguration.createProcessEngineConfigurationFromResourceDefault();
logger.info("configuration {}", configuration);
ProcessEngine processEngine = configuration.buildProcessEngine();
logger.info("获取流程引擎 {}", processEngine);
processEngine.close();
logger.info("over");
}
19
Source : TaskHandler.java
with MIT License
from smallyunet
with MIT License
from smallyunet
/**
* @description 任务相关操作
* @author wangyu
* @date 2019/11/1 13:20
*/
public clreplaced TaskHandler {
private Logger logger = LoggerFactory.getLogger(TaskHandler.clreplaced);
private ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
private TaskService taskService = processEngine.getTaskService();
/**
* @description 获取全部任务
* @return list
*/
public List<Task> getAllTask() {
List<Task> list = taskService.createTaskQuery().list();
logger.info("[查询任务列表] [全部] 共 " + list.size() + " 条记录");
return list;
}
/**
* @description 根据userID获取全部任务
* @param userID
* @return
*/
public List<Task> getTaskByUserID(String userID) {
List<Task> list = taskService.createTaskQuery().taskreplacedignee(userID).list();
logger.info("[查询任务列表] [userID=" + userID + "] 共 " + list.size() + " 条记录");
return list;
}
/**
* @description 委派任务
* @param taskID
* @param userID
* @return
*/
public boolean taskreplacedignee(String taskID, String userID) {
try {
taskService.setreplacedignee(taskID, userID);
} catch (ActivitiObjectNotFoundException e) {
logger.error("[任务委派失败] " + e.getMessage());
return false;
}
logger.info("[任务委派成功] 任务ID: " + taskID + ", 用户ID: " + userID);
return true;
}
/**
* @description 根据taskID完成任务
* @param taskID
*/
public boolean completeTaskByTaskID(String taskID) {
try {
processEngine.getTaskService().complete(taskID);
} catch (ActivitiObjectNotFoundException e) {
logger.info("[任务完成操作失败] " + e.getMessage());
return false;
}
logger.info("[任务完成操作成功] [taskID=" + taskID + "]");
return true;
}
/**
* @description 根据taskID删除任务
* @param taskID
*/
public boolean deleteTaskByTaskID(String taskID) {
try {
processEngine.getTaskService().deleteTask(taskID, true);
} catch (ActivitiObjectNotFoundException e) {
logger.info("[任务删除操作失败] " + e.getMessage());
return false;
}
logger.info("[任务删除操作成功] [taskID=" + taskID + "]");
return true;
}
}
19
Source : HistoryHandler.java
with MIT License
from smallyunet
with MIT License
from smallyunet
/**
* @author wangyu
* @date 2019/11/1 14:58
*/
public clreplaced HistoryHandler {
private Logger logger = LoggerFactory.getLogger(HistoryHandler.clreplaced);
private ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
private HistoryService historyService = processEngine.getHistoryService();
/**
* @description 查询所有流程实例
* @return
*/
public List<HistoricProcessInstance> getAllHistoryProcessInstance() {
List<HistoricProcessInstance> list = // 与历史数据(历史表)相关的Service
historyService.createHistoricProcessInstanceQuery().list();
logger.info("[查询历史全部流程实例] 共 " + list.size() + " 条记录");
return list;
}
/**
* @description 根据processInstanceID查询流程实例
* @param processInstanceID
* @return
*/
public HistoricProcessInstance getHistoryProcessInstanceByProcessInstanceID(String processInstanceID) {
HistoricProcessInstance hpi = // 与历史数据(历史表)相关的Service
historyService.createHistoricProcessInstanceQuery().processInstanceId(// 使用流程实例ID查询
processInstanceID).singleResult();
logger.info("[查询历史流程实例] [processInstanceID=" + processInstanceID + "]");
return hpi;
}
/**
* @description 查询所有历史任务
* @return
*/
public List<HistoricTaskInstance> getAllHistoryTask() {
List<HistoricTaskInstance> list = // 与历史数据(历史表)相关的Service
processEngine.getHistoryService().createHistoricTaskInstanceQuery().list();
logger.info("[查询历史全部任务] 共 " + list.size() + " 条记录");
return list;
}
/**
* @description 根据userID查询所有历史任务
* @param userID
* @return
*/
public List<HistoricTaskInstance> getHistoryTaskByUserID(String userID) {
List<HistoricTaskInstance> list = // 与历史数据(历史表)相关的Service
processEngine.getHistoryService().createHistoricTaskInstanceQuery().taskreplacedignee(// 指定历史任务的办理人
userID).list();
logger.info("[查询历史任务] [userID=" + userID + "] 共 " + list.size() + " 条记录");
return list;
}
}
19
Source : ActivitiPlugin.java
with Apache License 2.0
from qinyou
with Apache License 2.0
from qinyou
/**
* Jfinal activiti 插件
* @author chuang
*/
@Slf4j
public clreplaced ActivitiPlugin implements IPlugin {
static ProcessEngine processEngine = null;
@Override
public boolean start() {
try {
createProcessEngine();
} catch (Exception e) {
log.error(e.getMessage(), e);
}
return true;
}
@Override
public boolean stop() {
ProcessEngines.destroy();
ActivitiPlugin.processEngine = null;
return true;
}
/**
* 创建工作流引擎
*
* @return
*/
private void createProcessEngine() {
if (processEngine != null) {
return;
}
StandaloneProcessEngineConfiguration conf = (StandaloneProcessEngineConfiguration) ProcessEngineConfiguration.createStandaloneProcessEngineConfiguration();
conf.setDataSource(DbKit.getConfig().getDataSource()).setDatabaseSchemaUpdate(// 自动更新数据库表
ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE).setDbHistoryUsed(// 历史表生效功能
true);
// 使用托管事务工厂(不配置,事务也可生效)
conf.setTransactionsExternallyManaged(true);
conf.setTransactionFactory(new ActivireplacedransactionFactory());
// 流程图字体
conf.setActivityFontName(ActConst.DEFAULT_FONT);
conf.setLabelFontName(ActConst.DEFAULT_FONT);
conf.setAnnotationFontName(ActConst.DEFAULT_FONT);
// 注入流程中使用的 bean方法
Map<Object, Object> beans = new HashMap<>();
DirectorMethod directorMethod = new DirectorMethod();
beans.put("directorMethod", directorMethod);
CommonMethod commonMethod = new CommonMethod();
beans.put("commonMethod", commonMethod);
conf.setBeans(beans);
// 整合 用户 用户组 到 系统用户 角色 ( 主要用于候选任务查询)
List<SessionFactory> sessionFactories = new ArrayList<>();
UserManagerFactory userManagerFactory = new UserManagerFactory();
userManagerFactory.setUserManager(new UserManager());
sessionFactories.add(userManagerFactory);
GroupManagerFactory groupManagerFactory = new GroupManagerFactory();
groupManagerFactory.setGroupManager(new GroupManager());
sessionFactories.add(groupManagerFactory);
conf.setCustomSessionFactories(sessionFactories);
// 全局监听器
Map<String, List<ActivitiEventListener>> typedListeners = new HashMap<>();
// 1. 流程运行结束 通知申请人
List<ActivitiEventListener> processEndListeners = new ArrayList<>();
processEndListeners.add(new ProcessEndEventListener());
typedListeners.put("PROCESS_COMPLETED", processEndListeners);
// 2. 任务关联接收人后,通知处理人
List<ActivitiEventListener> taskreplacedignedListeners = new ArrayList<>();
taskreplacedignedListeners.add(new TaskreplacedignedEventListener());
typedListeners.put("TASK_replacedIGNED", taskreplacedignedListeners);
conf.setTypedEventListeners(typedListeners);
ActivitiPlugin.processEngine = conf.buildProcessEngine();
}
}
19
Source : ActivitiManagerImpl.java
with Apache License 2.0
from oneops
with Apache License 2.0
from oneops
public clreplaced ActivitiManagerImpl implements ActivitiManager {
private ProcessEngine processEngine;
public ActivitiManagerImpl() {
this.processEngine = ProcessEngines.getDefaultProcessEngine();
}
@Override
public List getProcesses() {
// this.processEngine;
return null;
}
}
19
Source : ComplaintUserInnerServiceSMOImpl.java
with Apache License 2.0
from java110
with Apache License 2.0
from java110
public void setProcessEngine(ProcessEngine processEngine) {
this.processEngine = processEngine;
}
19
Source : DeploymentActivity.java
with Apache License 2.0
from java110
with Apache License 2.0
from java110
public static void deploymentProcess() {
ProcessEngine processEngine = ApplicationContextFactory.getBean("processEngine", ProcessEngine.clreplaced);
RepositoryService repositoryService = processEngine.getRepositoryService();
repositoryService.createDeployment().name("采购申请流程").addClreplacedpathResource("processes/resourceEntryStore.bpmn").deploy();
}
19
Source : CloseXADataSourceLifecycleListener.java
with Apache License 2.0
from flowable
with Apache License 2.0
from flowable
@Override
public void onProcessEngineClosed(ProcessEngine processEngine) {
LOGGER.info("--------------------- Callback for engine end");
if (dataSource != null) {
LOGGER.info("--------------------- Closing datasource");
dataSource.close();
}
if (transactionManager != null) {
transactionManager.shutdown();
}
}
19
Source : CloseXADataSourceLifecycleListener.java
with Apache License 2.0
from flowable
with Apache License 2.0
from flowable
@Override
public void onProcessEngineBuilt(ProcessEngine processEngine) {
LOGGER.info("--------------------- Callback for engine start");
}
19
Source : SpringProcessEngineConfiguration.java
with Apache License 2.0
from flowable
with Apache License 2.0
from flowable
@Override
public ProcessEngine buildProcessEngine() {
ProcessEngine processEngine = super.buildProcessEngine();
ProcessEngines.setInitialized(true);
autoDeployResources(processEngine);
return processEngine;
}
19
Source : SpringProcessEngineConfiguration.java
with Apache License 2.0
from flowable
with Apache License 2.0
from flowable
protected void autoDeployResources(ProcessEngine processEngine) {
if (deploymentResources != null && deploymentResources.length > 0) {
final AutoDeploymentStrategy strategy = getAutoDeploymentStrategy(deploymentMode);
strategy.deployResources(deploymentName, deploymentResources, processEngine.getRepositoryService());
}
}
19
Source : SpringConfigurationHelper.java
with Apache License 2.0
from flowable
with Apache License 2.0
from flowable
private static ProcessEngine buildProcessEngine(URL resource) {
LOGGER.debug("==== BUILDING SPRING APPLICATION CONTEXT AND PROCESS ENGINE =========================================");
ApplicationContext applicationContext = new GenericXmlApplicationContext(new UrlResource(resource));
Map<String, ProcessEngine> beansOfType = applicationContext.getBeansOfType(ProcessEngine.clreplaced);
if ((beansOfType == null) || (beansOfType.isEmpty())) {
throw new ActivitiException("no " + ProcessEngine.clreplaced.getName() + " defined in the application context " + resource.toString());
}
ProcessEngine processEngine = beansOfType.values().iterator().next();
LOGGER.debug("==== SPRING PROCESS ENGINE CREATED ==================================================================");
return processEngine;
}
19
Source : ProcessEngineFactoryBean.java
with Apache License 2.0
from flowable
with Apache License 2.0
from flowable
/**
* @author Dave Syer
* @author Christian Stettler
* @author Tom Baeyens
* @author Joram Barrez
* @author Josh Long
*/
public clreplaced ProcessEngineFactoryBean implements FactoryBean<ProcessEngine>, DisposableBean, ApplicationContextAware {
protected ProcessEngineConfigurationImpl processEngineConfiguration;
protected ApplicationContext applicationContext;
protected ProcessEngine processEngine;
@Override
public void destroy() throws Exception {
if (processEngine != null) {
processEngine.close();
}
}
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.applicationContext = applicationContext;
}
@Override
public ProcessEngine getObject() throws Exception {
configureExpressionManager();
configureExternallyManagedTransactions();
if (processEngineConfiguration.getBeans() == null) {
processEngineConfiguration.setBeans(new SpringBeanFactoryProxyMap(applicationContext));
}
this.processEngine = processEngineConfiguration.buildProcessEngine();
return this.processEngine;
}
protected void configureExpressionManager() {
if (processEngineConfiguration.getExpressionManager() == null && applicationContext != null) {
processEngineConfiguration.setExpressionManager(new SpringExpressionManager(applicationContext, processEngineConfiguration.getBeans()));
}
}
protected void configureExternallyManagedTransactions() {
if (processEngineConfiguration instanceof SpringProcessEngineConfiguration) {
// remark:
// any
// config
// can
// be
// injected,
// so
// we
// cannot
// have
// SpringConfiguration
// as
// member
SpringProcessEngineConfiguration engineConfiguration = (SpringProcessEngineConfiguration) processEngineConfiguration;
if (engineConfiguration.getTransactionManager() != null) {
processEngineConfiguration.setTransactionsExternallyManaged(true);
}
}
}
@Override
public Clreplaced<ProcessEngine> getObjectType() {
return ProcessEngine.clreplaced;
}
@Override
public boolean isSingleton() {
return true;
}
public ProcessEngineConfigurationImpl getProcessEngineConfiguration() {
return processEngineConfiguration;
}
public void setProcessEngineConfiguration(ProcessEngineConfigurationImpl processEngineConfiguration) {
this.processEngineConfiguration = processEngineConfiguration;
}
}
19
Source : Main.java
with Apache License 2.0
from flowable
with Apache License 2.0
from flowable
public static void main(String[] args) throws Exception {
LOGGER.info("Booting up v5 Process Engine");
ProcessEngine processEngine = ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("v5.cfg.xml").buildProcessEngine();
LOGGER.info("Starting test data generation.");
List<String> executedGenerators = new ArrayList<String>();
Reflections reflections = new Reflections("org.flowable.compatibility.testdata.generator");
Set<Clreplaced<? extends Flowable5TestDataGenerator>> generatorClreplacedes = reflections.getSubTypesOf(Flowable5TestDataGenerator.clreplaced);
for (Clreplaced<? extends Flowable5TestDataGenerator> generatorClreplaced : generatorClreplacedes) {
Flowable5TestDataGenerator testDataGenerator = generatorClreplaced.newInstance();
testDataGenerator.generateTestData(processEngine);
executedGenerators.add(testDataGenerator.getClreplaced().getCanonicalName());
}
LOGGER.info("Test data generation completed.");
for (String generatorClreplaced : executedGenerators) {
LOGGER.info("Executed test data generator {}", generatorClreplaced);
}
}
19
Source : DisabledSchemaValidationTest.java
with Apache License 2.0
from dingziyang
with Apache License 2.0
from dingziyang
/**
* @author Joram Barrez
*/
public clreplaced DisabledSchemaValidationTest {
protected ProcessEngine processEngine;
protected RepositoryService repositoryService;
@Before
public void setup() {
StandaloneInMemProcessEngineConfiguration processEngineConfiguration = new StandaloneInMemProcessEngineConfiguration();
processEngineConfiguration.setJdbcUrl("jdbc:h2:mem:activiti-process-validation;DB_CLOSE_DELAY=1000");
processEngineConfiguration.setActiviti5CompatibilityEnabled(true);
this.processEngine = processEngineConfiguration.buildProcessEngine();
this.repositoryService = processEngine.getRepositoryService();
}
@After
public void tearDown() {
for (Deployment deployment : repositoryService.createDeploymentQuery().list()) {
repositoryService.deleteDeployment(deployment.getId());
}
ProcessEngines.unregister(processEngine);
processEngine = null;
repositoryService = null;
}
@Test
public void testDisableValidation() {
// Should fail
try {
repositoryService.createDeployment().addClreplacedpathResource("org/activiti5/standalone/validation/invalid_process_xsd_error.bpmn20.xml").deploymentProperty(DeploymentProperties.DEPLOY_AS_ACTIVITI5_PROCESS_DEFINITION, Boolean.TRUE).deploy();
replacedert.fail();
} catch (XMLException e) {
// expected exception
}
// Should fail with validation errors
try {
repositoryService.createDeployment().addClreplacedpathResource("org/activiti5/standalone/validation/invalid_process_xsd_error.bpmn20.xml").deploymentProperty(DeploymentProperties.DEPLOY_AS_ACTIVITI5_PROCESS_DEFINITION, Boolean.TRUE).disableSchemaValidation().deploy();
replacedert.fail();
} catch (ActivitiException e) {
// expected exception
}
}
}
19
Source : JPAVariableTest.java
with Apache License 2.0
from dingziyang
with Apache License 2.0
from dingziyang
/**
* @author Frederik Heremans
*/
public clreplaced JPAVariableTest extends AbstractActivireplacedestCase {
protected static ProcessEngine cachedProcessEngine;
private static FieldAccessJPAEnreplacedy simpleEnreplacedyFieldAccess;
private static PropertyAccessJPAEnreplacedy simpleEnreplacedyPropertyAccess;
private static SubclreplacedFieldAccessJPAEnreplacedy subclreplacedFieldAccess;
private static SubclreplacedPropertyAccessJPAEnreplacedy subclreplacedPropertyAccess;
private static ByteIdJPAEnreplacedy byteIdJPAEnreplacedy;
private static ShortIdJPAEnreplacedy shortIdJPAEnreplacedy;
private static IntegerIdJPAEnreplacedy integerIdJPAEnreplacedy;
private static LongIdJPAEnreplacedy longIdJPAEnreplacedy;
private static FloatIdJPAEnreplacedy floatIdJPAEnreplacedy;
private static DoubleIdJPAEnreplacedy doubleIdJPAEnreplacedy;
private static CharIdJPAEnreplacedy charIdJPAEnreplacedy;
private static StringIdJPAEnreplacedy stringIdJPAEnreplacedy;
private static DateIdJPAEnreplacedy dateIdJPAEnreplacedy;
private static SQLDateIdJPAEnreplacedy sqlDateIdJPAEnreplacedy;
private static BigDecimalIdJPAEnreplacedy bigDecimalIdJPAEnreplacedy;
private static BigIntegerIdJPAEnreplacedy bigIntegerIdJPAEnreplacedy;
private static CompoundIdJPAEnreplacedy compoundIdJPAEnreplacedy;
private static FieldAccessJPAEnreplacedy enreplacedyToQuery;
private static FieldAccessJPAEnreplacedy enreplacedyToUpdate;
private static boolean enreplacediesInitialized = false;
private static EnreplacedyManagerFactory enreplacedyManagerFactory;
protected void initializeProcessEngine() {
if (cachedProcessEngine == null) {
ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("org/activiti5/standalone/jpa/activiti.cfg.xml");
cachedProcessEngine = processEngineConfiguration.buildProcessEngine();
org.activiti5.engine.impl.cfg.ProcessEngineConfigurationImpl activiti5ProcessEngineConfig = (org.activiti5.engine.impl.cfg.ProcessEngineConfigurationImpl) ((ProcessEngineConfigurationImpl) cachedProcessEngine.getProcessEngineConfiguration()).getActiviti5CompatibilityHandler().getRawProcessConfiguration();
EnreplacedyManagerSessionFactory enreplacedyManagerSessionFactory = (EnreplacedyManagerSessionFactory) activiti5ProcessEngineConfig.getSessionFactories().get(EnreplacedyManagerSession.clreplaced);
enreplacedyManagerFactory = enreplacedyManagerSessionFactory.getEnreplacedyManagerFactory();
}
processEngine = cachedProcessEngine;
}
public void setupJPAEnreplacedies() {
if (!enreplacediesInitialized) {
EnreplacedyManager manager = enreplacedyManagerFactory.createEnreplacedyManager();
manager.getTransaction().begin();
// Simple test data
simpleEnreplacedyFieldAccess = new FieldAccessJPAEnreplacedy();
simpleEnreplacedyFieldAccess.setId(1L);
simpleEnreplacedyFieldAccess.setValue("value1");
manager.persist(simpleEnreplacedyFieldAccess);
simpleEnreplacedyPropertyAccess = new PropertyAccessJPAEnreplacedy();
simpleEnreplacedyPropertyAccess.setId(1L);
simpleEnreplacedyPropertyAccess.setValue("value2");
manager.persist(simpleEnreplacedyPropertyAccess);
subclreplacedFieldAccess = new SubclreplacedFieldAccessJPAEnreplacedy();
subclreplacedFieldAccess.setId(1L);
subclreplacedFieldAccess.setValue("value3");
manager.persist(subclreplacedFieldAccess);
subclreplacedPropertyAccess = new SubclreplacedPropertyAccessJPAEnreplacedy();
subclreplacedPropertyAccess.setId(1L);
subclreplacedPropertyAccess.setValue("value4");
manager.persist(subclreplacedPropertyAccess);
// Test enreplacedies with all possible ID types
byteIdJPAEnreplacedy = new ByteIdJPAEnreplacedy();
byteIdJPAEnreplacedy.setByteId((byte) 1);
manager.persist(byteIdJPAEnreplacedy);
shortIdJPAEnreplacedy = new ShortIdJPAEnreplacedy();
shortIdJPAEnreplacedy.setShortId((short) 123);
manager.persist(shortIdJPAEnreplacedy);
integerIdJPAEnreplacedy = new IntegerIdJPAEnreplacedy();
integerIdJPAEnreplacedy.setIntId(123);
manager.persist(integerIdJPAEnreplacedy);
longIdJPAEnreplacedy = new LongIdJPAEnreplacedy();
longIdJPAEnreplacedy.setLongId(123456789L);
manager.persist(longIdJPAEnreplacedy);
floatIdJPAEnreplacedy = new FloatIdJPAEnreplacedy();
floatIdJPAEnreplacedy.setFloatId((float) 123.45678);
manager.persist(floatIdJPAEnreplacedy);
doubleIdJPAEnreplacedy = new DoubleIdJPAEnreplacedy();
doubleIdJPAEnreplacedy.setDoubleId(12345678.987654);
manager.persist(doubleIdJPAEnreplacedy);
charIdJPAEnreplacedy = new CharIdJPAEnreplacedy();
charIdJPAEnreplacedy.setCharId('g');
manager.persist(charIdJPAEnreplacedy);
dateIdJPAEnreplacedy = new DateIdJPAEnreplacedy();
dateIdJPAEnreplacedy.setDateId(new java.util.Date());
manager.persist(dateIdJPAEnreplacedy);
sqlDateIdJPAEnreplacedy = new SQLDateIdJPAEnreplacedy();
sqlDateIdJPAEnreplacedy.setDateId(new java.sql.Date(Calendar.getInstance().getTimeInMillis()));
manager.persist(sqlDateIdJPAEnreplacedy);
stringIdJPAEnreplacedy = new StringIdJPAEnreplacedy();
stringIdJPAEnreplacedy.setStringId("azertyuiop");
manager.persist(stringIdJPAEnreplacedy);
bigDecimalIdJPAEnreplacedy = new BigDecimalIdJPAEnreplacedy();
bigDecimalIdJPAEnreplacedy.setBigDecimalId(new BigDecimal("12345678912345678900000.123456789123456789"));
manager.persist(bigDecimalIdJPAEnreplacedy);
bigIntegerIdJPAEnreplacedy = new BigIntegerIdJPAEnreplacedy();
bigIntegerIdJPAEnreplacedy.setBigIntegerId(new BigInteger("12345678912345678912345678900000"));
manager.persist(bigIntegerIdJPAEnreplacedy);
manager.flush();
manager.getTransaction().commit();
manager.close();
enreplacediesInitialized = true;
}
}
public void setupIllegalJPAEnreplacedies() {
EnreplacedyManager manager = enreplacedyManagerFactory.createEnreplacedyManager();
manager.getTransaction().begin();
compoundIdJPAEnreplacedy = new CompoundIdJPAEnreplacedy();
EmbeddableCompoundId id = new EmbeddableCompoundId();
id.setIdPart1(123L);
id.setIdPart2("part2");
compoundIdJPAEnreplacedy.setId(id);
manager.persist(compoundIdJPAEnreplacedy);
manager.flush();
manager.getTransaction().commit();
manager.close();
}
public void setupQueryJPAEnreplacedy() {
EnreplacedyManager manager = enreplacedyManagerFactory.createEnreplacedyManager();
manager.getTransaction().begin();
enreplacedyToQuery = new FieldAccessJPAEnreplacedy();
enreplacedyToQuery.setId(2L);
manager.persist(enreplacedyToQuery);
manager.flush();
manager.getTransaction().commit();
manager.close();
}
public void setupJPAEnreplacedyToUpdate() {
EnreplacedyManager manager = enreplacedyManagerFactory.createEnreplacedyManager();
manager.getTransaction().begin();
enreplacedyToUpdate = new FieldAccessJPAEnreplacedy();
enreplacedyToUpdate.setId(3L);
manager.persist(enreplacedyToUpdate);
manager.flush();
manager.getTransaction().commit();
manager.close();
}
@Deployment
public void testStoreJPAEnreplacedyAsVariable() {
setupJPAEnreplacedies();
// -----------------------------------------------------------------------------
// Simple test, Start process with JPA enreplacedies as variables
// -----------------------------------------------------------------------------
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("simpleEnreplacedyFieldAccess", simpleEnreplacedyFieldAccess);
variables.put("simpleEnreplacedyPropertyAccess", simpleEnreplacedyPropertyAccess);
variables.put("subclreplacedFieldAccess", subclreplacedFieldAccess);
variables.put("subclreplacedPropertyAccess", subclreplacedPropertyAccess);
// Start the process with the JPA-enreplacedies as variables. They will be stored in the DB.
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("JPAVariableProcess", variables);
if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.AUDIT)) {
HistoricVariableInstance historicVariableInstance = historyService.createHistoricVariableInstanceQuery().variableName("simpleEnreplacedyFieldAccess").singleResult();
FieldAccessJPAEnreplacedy enreplacedy = (FieldAccessJPAEnreplacedy) historicVariableInstance.getValue();
replacedertNotNull(enreplacedy);
replacedertEquals("value1", enreplacedy.getValue());
}
// Read enreplacedy with @Id on field
Object fieldAccessResult = runtimeService.getVariable(processInstance.getId(), "simpleEnreplacedyFieldAccess");
replacedertTrue(fieldAccessResult instanceof FieldAccessJPAEnreplacedy);
replacedertEquals(1L, ((FieldAccessJPAEnreplacedy) fieldAccessResult).getId().longValue());
replacedertEquals("value1", ((FieldAccessJPAEnreplacedy) fieldAccessResult).getValue());
// Read enreplacedy with @Id on property
Object propertyAccessResult = runtimeService.getVariable(processInstance.getId(), "simpleEnreplacedyPropertyAccess");
replacedertTrue(propertyAccessResult instanceof PropertyAccessJPAEnreplacedy);
replacedertEquals(1L, ((PropertyAccessJPAEnreplacedy) propertyAccessResult).getId().longValue());
replacedertEquals("value2", ((PropertyAccessJPAEnreplacedy) propertyAccessResult).getValue());
// Read enreplacedy with @Id on field of mapped superclreplaced
Object subclreplacedFieldResult = runtimeService.getVariable(processInstance.getId(), "subclreplacedFieldAccess");
replacedertTrue(subclreplacedFieldResult instanceof SubclreplacedFieldAccessJPAEnreplacedy);
replacedertEquals(1L, ((SubclreplacedFieldAccessJPAEnreplacedy) subclreplacedFieldResult).getId().longValue());
replacedertEquals("value3", ((SubclreplacedFieldAccessJPAEnreplacedy) subclreplacedFieldResult).getValue());
// Read enreplacedy with @Id on property of mapped superclreplaced
Object subclreplacedPropertyResult = runtimeService.getVariable(processInstance.getId(), "subclreplacedPropertyAccess");
replacedertTrue(subclreplacedPropertyResult instanceof SubclreplacedPropertyAccessJPAEnreplacedy);
replacedertEquals(1L, ((SubclreplacedPropertyAccessJPAEnreplacedy) subclreplacedPropertyResult).getId().longValue());
replacedertEquals("value4", ((SubclreplacedPropertyAccessJPAEnreplacedy) subclreplacedPropertyResult).getValue());
// -----------------------------------------------------------------------------
// Test updating JPA-enreplacedy to null-value and back again
// -----------------------------------------------------------------------------
Object currentValue = runtimeService.getVariable(processInstance.getId(), "simpleEnreplacedyFieldAccess");
replacedertNotNull(currentValue);
// Set to null
runtimeService.setVariable(processInstance.getId(), "simpleEnreplacedyFieldAccess", null);
currentValue = runtimeService.getVariable(processInstance.getId(), "simpleEnreplacedyFieldAccess");
replacedertNull(currentValue);
// Set to JPA-enreplacedy again
runtimeService.setVariable(processInstance.getId(), "simpleEnreplacedyFieldAccess", simpleEnreplacedyFieldAccess);
currentValue = runtimeService.getVariable(processInstance.getId(), "simpleEnreplacedyFieldAccess");
replacedertNotNull(currentValue);
replacedertTrue(currentValue instanceof FieldAccessJPAEnreplacedy);
replacedertEquals(1L, ((FieldAccessJPAEnreplacedy) currentValue).getId().longValue());
// -----------------------------------------------------------------------------
// Test all allowed types of ID values
// -----------------------------------------------------------------------------
variables = new HashMap<String, Object>();
variables.put("byteIdJPAEnreplacedy", byteIdJPAEnreplacedy);
variables.put("shortIdJPAEnreplacedy", shortIdJPAEnreplacedy);
variables.put("integerIdJPAEnreplacedy", integerIdJPAEnreplacedy);
variables.put("longIdJPAEnreplacedy", longIdJPAEnreplacedy);
variables.put("floatIdJPAEnreplacedy", floatIdJPAEnreplacedy);
variables.put("doubleIdJPAEnreplacedy", doubleIdJPAEnreplacedy);
variables.put("charIdJPAEnreplacedy", charIdJPAEnreplacedy);
variables.put("stringIdJPAEnreplacedy", stringIdJPAEnreplacedy);
variables.put("dateIdJPAEnreplacedy", dateIdJPAEnreplacedy);
variables.put("sqlDateIdJPAEnreplacedy", sqlDateIdJPAEnreplacedy);
variables.put("bigDecimalIdJPAEnreplacedy", bigDecimalIdJPAEnreplacedy);
variables.put("bigIntegerIdJPAEnreplacedy", bigIntegerIdJPAEnreplacedy);
// Start the process with the JPA-enreplacedies as variables. They will be stored in the DB.
ProcessInstance processInstanceAllTypes = runtimeService.startProcessInstanceByKey("JPAVariableProcess", variables);
Object byteIdResult = runtimeService.getVariable(processInstanceAllTypes.getId(), "byteIdJPAEnreplacedy");
replacedertTrue(byteIdResult instanceof ByteIdJPAEnreplacedy);
replacedertEquals(byteIdJPAEnreplacedy.getByteId(), ((ByteIdJPAEnreplacedy) byteIdResult).getByteId());
Object shortIdResult = runtimeService.getVariable(processInstanceAllTypes.getId(), "shortIdJPAEnreplacedy");
replacedertTrue(shortIdResult instanceof ShortIdJPAEnreplacedy);
replacedertEquals(shortIdJPAEnreplacedy.getShortId(), ((ShortIdJPAEnreplacedy) shortIdResult).getShortId());
Object integerIdResult = runtimeService.getVariable(processInstanceAllTypes.getId(), "integerIdJPAEnreplacedy");
replacedertTrue(integerIdResult instanceof IntegerIdJPAEnreplacedy);
replacedertEquals(integerIdJPAEnreplacedy.getIntId(), ((IntegerIdJPAEnreplacedy) integerIdResult).getIntId());
Object longIdResult = runtimeService.getVariable(processInstanceAllTypes.getId(), "longIdJPAEnreplacedy");
replacedertTrue(longIdResult instanceof LongIdJPAEnreplacedy);
replacedertEquals(longIdJPAEnreplacedy.getLongId(), ((LongIdJPAEnreplacedy) longIdResult).getLongId());
Object floatIdResult = runtimeService.getVariable(processInstanceAllTypes.getId(), "floatIdJPAEnreplacedy");
replacedertTrue(floatIdResult instanceof FloatIdJPAEnreplacedy);
replacedertEquals(floatIdJPAEnreplacedy.getFloatId(), ((FloatIdJPAEnreplacedy) floatIdResult).getFloatId());
Object doubleIdResult = runtimeService.getVariable(processInstanceAllTypes.getId(), "doubleIdJPAEnreplacedy");
replacedertTrue(doubleIdResult instanceof DoubleIdJPAEnreplacedy);
replacedertEquals(doubleIdJPAEnreplacedy.getDoubleId(), ((DoubleIdJPAEnreplacedy) doubleIdResult).getDoubleId());
Object charIdResult = runtimeService.getVariable(processInstanceAllTypes.getId(), "charIdJPAEnreplacedy");
replacedertTrue(charIdResult instanceof CharIdJPAEnreplacedy);
replacedertEquals(charIdJPAEnreplacedy.getCharId(), ((CharIdJPAEnreplacedy) charIdResult).getCharId());
Object stringIdResult = runtimeService.getVariable(processInstanceAllTypes.getId(), "stringIdJPAEnreplacedy");
replacedertTrue(stringIdResult instanceof StringIdJPAEnreplacedy);
replacedertEquals(stringIdJPAEnreplacedy.getStringId(), ((StringIdJPAEnreplacedy) stringIdResult).getStringId());
Object dateIdResult = runtimeService.getVariable(processInstanceAllTypes.getId(), "dateIdJPAEnreplacedy");
replacedertTrue(dateIdResult instanceof DateIdJPAEnreplacedy);
replacedertEquals(dateIdJPAEnreplacedy.getDateId(), ((DateIdJPAEnreplacedy) dateIdResult).getDateId());
Object sqlDateIdResult = runtimeService.getVariable(processInstanceAllTypes.getId(), "sqlDateIdJPAEnreplacedy");
replacedertTrue(sqlDateIdResult instanceof SQLDateIdJPAEnreplacedy);
replacedertEquals(sqlDateIdJPAEnreplacedy.getDateId(), ((SQLDateIdJPAEnreplacedy) sqlDateIdResult).getDateId());
Object bigDecimalIdResult = runtimeService.getVariable(processInstanceAllTypes.getId(), "bigDecimalIdJPAEnreplacedy");
replacedertTrue(bigDecimalIdResult instanceof BigDecimalIdJPAEnreplacedy);
replacedertEquals(bigDecimalIdJPAEnreplacedy.getBigDecimalId(), ((BigDecimalIdJPAEnreplacedy) bigDecimalIdResult).getBigDecimalId());
Object bigIntegerIdResult = runtimeService.getVariable(processInstanceAllTypes.getId(), "bigIntegerIdJPAEnreplacedy");
replacedertTrue(bigIntegerIdResult instanceof BigIntegerIdJPAEnreplacedy);
replacedertEquals(bigIntegerIdJPAEnreplacedy.getBigIntegerId(), ((BigIntegerIdJPAEnreplacedy) bigIntegerIdResult).getBigIntegerId());
}
@Deployment(resources = { "org/activiti5/standalone/jpa/JPAVariableTest.testStoreJPAEnreplacedyAsVariable.bpmn20.xml" })
public void testStoreJPAEnreplacedyListAsVariable() {
setupJPAEnreplacedies();
// -----------------------------------------------------------------------------
// Simple test, Start process with lists of JPA enreplacedies as variables
// -----------------------------------------------------------------------------
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("simpleEnreplacedyFieldAccess", Arrays.asList(simpleEnreplacedyFieldAccess, simpleEnreplacedyFieldAccess, simpleEnreplacedyFieldAccess));
variables.put("simpleEnreplacedyPropertyAccess", Arrays.asList(simpleEnreplacedyPropertyAccess, simpleEnreplacedyPropertyAccess, simpleEnreplacedyPropertyAccess));
variables.put("subclreplacedFieldAccess", Arrays.asList(subclreplacedFieldAccess, subclreplacedFieldAccess, subclreplacedFieldAccess));
variables.put("subclreplacedPropertyAccess", Arrays.asList(subclreplacedPropertyAccess, subclreplacedPropertyAccess, subclreplacedPropertyAccess));
// Start the process with the JPA-enreplacedies as variables. They will be stored in the DB.
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("JPAVariableProcess", variables);
// Read enreplacedy with @Id on field
Object fieldAccessResult = runtimeService.getVariable(processInstance.getId(), "simpleEnreplacedyFieldAccess");
replacedertTrue(fieldAccessResult instanceof List<?>);
List<?> list = (List<?>) fieldAccessResult;
replacedertEquals(3L, list.size());
replacedertTrue(list.get(0) instanceof FieldAccessJPAEnreplacedy);
replacedertEquals(((FieldAccessJPAEnreplacedy) list.get(0)).getId(), simpleEnreplacedyFieldAccess.getId());
// Read enreplacedy with @Id on property
Object propertyAccessResult = runtimeService.getVariable(processInstance.getId(), "simpleEnreplacedyPropertyAccess");
replacedertTrue(propertyAccessResult instanceof List<?>);
list = (List<?>) propertyAccessResult;
replacedertEquals(3L, list.size());
replacedertTrue(list.get(0) instanceof PropertyAccessJPAEnreplacedy);
replacedertEquals(((PropertyAccessJPAEnreplacedy) list.get(0)).getId(), simpleEnreplacedyPropertyAccess.getId());
// Read enreplacedy with @Id on field of mapped superclreplaced
Object subclreplacedFieldResult = runtimeService.getVariable(processInstance.getId(), "subclreplacedFieldAccess");
replacedertTrue(subclreplacedFieldResult instanceof List<?>);
list = (List<?>) subclreplacedFieldResult;
replacedertEquals(3L, list.size());
replacedertTrue(list.get(0) instanceof SubclreplacedFieldAccessJPAEnreplacedy);
replacedertEquals(((SubclreplacedFieldAccessJPAEnreplacedy) list.get(0)).getId(), simpleEnreplacedyPropertyAccess.getId());
// Read enreplacedy with @Id on property of mapped superclreplaced
Object subclreplacedPropertyResult = runtimeService.getVariable(processInstance.getId(), "subclreplacedPropertyAccess");
replacedertTrue(subclreplacedPropertyResult instanceof List<?>);
list = (List<?>) subclreplacedPropertyResult;
replacedertEquals(3L, list.size());
replacedertTrue(list.get(0) instanceof SubclreplacedPropertyAccessJPAEnreplacedy);
replacedertEquals(((SubclreplacedPropertyAccessJPAEnreplacedy) list.get(0)).getId(), simpleEnreplacedyPropertyAccess.getId());
}
@Deployment(resources = { "org/activiti5/standalone/jpa/JPAVariableTest.testStoreJPAEnreplacedyAsVariable.bpmn20.xml" })
public void testStoreJPAEnreplacedyListAsVariableEdgeCases() {
setupJPAEnreplacedies();
// Test using mixed JPA-enreplacedies which are not serializable, should not be picked up by JPA list type en therefor fail
// due to serialization error
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("simpleEnreplacedyFieldAccess", Arrays.asList(simpleEnreplacedyFieldAccess, simpleEnreplacedyPropertyAccess));
try {
runtimeService.startProcessInstanceByKey("JPAVariableProcess", variables);
fail("Exception expected");
} catch (ActivitiException ae) {
// Expected
}
// Test updating value to an empty list and back
variables = new HashMap<String, Object>();
variables.put("list", Arrays.asList(simpleEnreplacedyFieldAccess, simpleEnreplacedyFieldAccess));
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("JPAVariableProcess", variables);
runtimeService.setVariable(processInstance.getId(), "list", new ArrayList<String>());
replacedertEquals(0L, ((List<?>) runtimeService.getVariable(processInstance.getId(), "list")).size());
runtimeService.setVariable(processInstance.getId(), "list", Arrays.asList(simpleEnreplacedyFieldAccess, simpleEnreplacedyFieldAccess));
replacedertEquals(2L, ((List<?>) runtimeService.getVariable(processInstance.getId(), "list")).size());
replacedertTrue(((List<?>) runtimeService.getVariable(processInstance.getId(), "list")).get(0) instanceof FieldAccessJPAEnreplacedy);
// Test updating to list of Strings
runtimeService.setVariable(processInstance.getId(), "list", Arrays.asList("TEST", "TESTING"));
replacedertEquals(2L, ((List<?>) runtimeService.getVariable(processInstance.getId(), "list")).size());
replacedertTrue(((List<?>) runtimeService.getVariable(processInstance.getId(), "list")).get(0) instanceof String);
runtimeService.setVariable(processInstance.getId(), "list", Arrays.asList(simpleEnreplacedyFieldAccess, simpleEnreplacedyFieldAccess));
replacedertEquals(2L, ((List<?>) runtimeService.getVariable(processInstance.getId(), "list")).size());
replacedertTrue(((List<?>) runtimeService.getVariable(processInstance.getId(), "list")).get(0) instanceof FieldAccessJPAEnreplacedy);
// Test updating to null
runtimeService.setVariable(processInstance.getId(), "list", null);
replacedertNull(runtimeService.getVariable(processInstance.getId(), "list"));
runtimeService.setVariable(processInstance.getId(), "list", Arrays.asList(simpleEnreplacedyFieldAccess, simpleEnreplacedyFieldAccess));
replacedertEquals(2L, ((List<?>) runtimeService.getVariable(processInstance.getId(), "list")).size());
replacedertTrue(((List<?>) runtimeService.getVariable(processInstance.getId(), "list")).get(0) instanceof FieldAccessJPAEnreplacedy);
}
// https://activiti.atlreplacedian.net/browse/ACT-995
@Deployment(resources = "org/activiti5/standalone/jpa/JPAVariableTest.testQueryJPAVariable.bpmn20.xml")
public void testReplaceExistingJPAEnreplacedyWithAnotherOfSameType() {
EnreplacedyManager manager = enreplacedyManagerFactory.createEnreplacedyManager();
manager.getTransaction().begin();
// Old variable that gets replaced
FieldAccessJPAEnreplacedy oldVariable = new FieldAccessJPAEnreplacedy();
oldVariable.setId(11L);
oldVariable.setValue("value1");
manager.persist(oldVariable);
// New variable
FieldAccessJPAEnreplacedy newVariable = new FieldAccessJPAEnreplacedy();
newVariable.setId(12L);
newVariable.setValue("value2");
manager.persist(newVariable);
manager.flush();
manager.getTransaction().commit();
manager.close();
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("JPAVariableProcess");
String executionId = processInstance.getId();
String variableName = "testVariable";
runtimeService.setVariable(executionId, variableName, oldVariable);
runtimeService.setVariable(executionId, variableName, newVariable);
Object variable = runtimeService.getVariable(executionId, variableName);
replacedertEquals(newVariable.getId(), ((FieldAccessJPAEnreplacedy) variable).getId());
}
@Deployment
public void testIllegalEnreplacedies() {
setupIllegalJPAEnreplacedies();
// Starting process instance with a variable that has a compound primary key, which is not supported.
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("compoundIdJPAEnreplacedy", compoundIdJPAEnreplacedy);
try {
runtimeService.startProcessInstanceByKey("JPAVariableProcessExceptions", variables);
fail("Exception expected");
} catch (ActivitiException ae) {
replacedertTextPresent("Cannot find field or method with annotation @Id on clreplaced", ae.getMessage());
replacedertTextPresent("only single-valued primary keys are supported on JPA-enities", ae.getMessage());
}
// Starting process instance with a variable that has null as ID-value
variables = new HashMap<String, Object>();
variables.put("nullValueEnreplacedy", new FieldAccessJPAEnreplacedy());
try {
runtimeService.startProcessInstanceByKey("JPAVariableProcessExceptions", variables);
fail("Exception expected");
} catch (ActivitiIllegalArgumentException ae) {
replacedertTextPresent("Value of primary key for JPA-Enreplacedy cannot be null", ae.getMessage());
}
// Starting process instance with an invalid type of ID
// Under normal cirreplacedstances, JPA will throw an exception for this of the clreplaced is
// present in the PU when creating EnreplacedyanagerFactory, but we test it *just in case*
variables = new HashMap<String, Object>();
IllegalIdClreplacedJPAEnreplacedy illegalIdTypeEnreplacedy = new IllegalIdClreplacedJPAEnreplacedy();
illegalIdTypeEnreplacedy.setId(Calendar.getInstance());
variables.put("illegalTypeId", illegalIdTypeEnreplacedy);
try {
runtimeService.startProcessInstanceByKey("JPAVariableProcessExceptions", variables);
fail("Exception expected");
} catch (ActivitiException ae) {
replacedertTextPresent("Unsupported Primary key type for JPA-Enreplacedy", ae.getMessage());
}
// Start process instance with JPA-enreplacedy which has an ID but isn't persisted. When reading
// the variable we should get an exception.
variables = new HashMap<String, Object>();
FieldAccessJPAEnreplacedy nonPersistentEnreplacedy = new FieldAccessJPAEnreplacedy();
nonPersistentEnreplacedy.setId(9999L);
variables.put("nonPersistentEnreplacedy", nonPersistentEnreplacedy);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("JPAVariableProcessExceptions", variables);
try {
runtimeService.getVariable(processInstance.getId(), "nonPersistentEnreplacedy");
fail("Exception expected");
} catch (ActivitiException ae) {
replacedertTextPresent("Enreplacedy does not exist: " + FieldAccessJPAEnreplacedy.clreplaced.getName() + " - 9999", ae.getMessage());
}
}
@Deployment
public void testQueryJPAVariable() {
setupQueryJPAEnreplacedy();
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("enreplacedyToQuery", enreplacedyToQuery);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("JPAVariableProcess", variables);
// Query the processInstance
ProcessInstance result = runtimeService.createProcessInstanceQuery().variableValueEquals("enreplacedyToQuery", enreplacedyToQuery).singleResult();
replacedertNotNull(result);
replacedertEquals(result.getId(), processInstance.getId());
// Query with the same enreplacedy-type but with different ID should have no result
FieldAccessJPAEnreplacedy unexistingEnreplacedy = new FieldAccessJPAEnreplacedy();
unexistingEnreplacedy.setId(8888L);
result = runtimeService.createProcessInstanceQuery().variableValueEquals("enreplacedyToQuery", unexistingEnreplacedy).singleResult();
replacedertNull(result);
// All other operators are unsupported
try {
runtimeService.createProcessInstanceQuery().variableValueNotEquals("enreplacedyToQuery", enreplacedyToQuery).singleResult();
fail("Exception expected");
} catch (ActivitiIllegalArgumentException ae) {
replacedertTextPresent("JPA enreplacedy variables can only be used in 'variableValueEquals'", ae.getMessage());
}
try {
runtimeService.createProcessInstanceQuery().variableValueGreaterThan("enreplacedyToQuery", enreplacedyToQuery).singleResult();
fail("Exception expected");
} catch (ActivitiIllegalArgumentException ae) {
replacedertTextPresent("JPA enreplacedy variables can only be used in 'variableValueEquals'", ae.getMessage());
}
try {
runtimeService.createProcessInstanceQuery().variableValueGreaterThanOrEqual("enreplacedyToQuery", enreplacedyToQuery).singleResult();
fail("Exception expected");
} catch (ActivitiIllegalArgumentException ae) {
replacedertTextPresent("JPA enreplacedy variables can only be used in 'variableValueEquals'", ae.getMessage());
}
try {
runtimeService.createProcessInstanceQuery().variableValueLessThan("enreplacedyToQuery", enreplacedyToQuery).singleResult();
fail("Exception expected");
} catch (ActivitiIllegalArgumentException ae) {
replacedertTextPresent("JPA enreplacedy variables can only be used in 'variableValueEquals'", ae.getMessage());
}
try {
runtimeService.createProcessInstanceQuery().variableValueLessThanOrEqual("enreplacedyToQuery", enreplacedyToQuery).singleResult();
fail("Exception expected");
} catch (ActivitiIllegalArgumentException ae) {
replacedertTextPresent("JPA enreplacedy variables can only be used in 'variableValueEquals'", ae.getMessage());
}
}
@Deployment
public void testUpdateJPAEnreplacedyValues() {
setupJPAEnreplacedyToUpdate();
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("enreplacedyToUpdate", enreplacedyToUpdate);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("UpdateJPAValuesProcess", variables);
// Servicetask in process 'UpdateJPAValuesProcess' should have set value on enreplacedyToUpdate.
Object updatedEnreplacedy = runtimeService.getVariable(processInstance.getId(), "enreplacedyToUpdate");
replacedertTrue(updatedEnreplacedy instanceof FieldAccessJPAEnreplacedy);
replacedertEquals("updatedValue", ((FieldAccessJPAEnreplacedy) updatedEnreplacedy).getValue());
}
}
19
Source : JPAEnhancedVariableTest.java
with Apache License 2.0
from dingziyang
with Apache License 2.0
from dingziyang
/**
* Test for JPA enhancement support
*
* @author <a href="mailto:[email protected]">Eugene Khrustalev</a>
*/
public clreplaced JPAEnhancedVariableTest extends AbstractActivireplacedestCase {
protected static final Logger logger = LoggerFactory.getLogger(JPAEnhancedVariableTest.clreplaced);
protected static EnreplacedyManagerFactory enreplacedyManagerFactory;
protected static ProcessEngine cachedProcessEngine;
protected static org.activiti5.engine.impl.cfg.ProcessEngineConfigurationImpl activiti5ProcessEngineConfig;
protected static FieldAccessJPAEnreplacedy fieldEnreplacedy;
protected static FieldAccessJPAEnreplacedy fieldEnreplacedy2;
protected static PropertyAccessJPAEnreplacedy propertyEnreplacedy;
@Override
protected void initializeProcessEngine() {
if (cachedProcessEngine == null) {
ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("org/activiti5/standalone/jpa/activiti.cfg.xml");
cachedProcessEngine = processEngineConfiguration.buildProcessEngine();
activiti5ProcessEngineConfig = (org.activiti5.engine.impl.cfg.ProcessEngineConfigurationImpl) ((ProcessEngineConfigurationImpl) cachedProcessEngine.getProcessEngineConfiguration()).getActiviti5CompatibilityHandler().getRawProcessConfiguration();
EnreplacedyManagerSessionFactory enreplacedyManagerSessionFactory = (EnreplacedyManagerSessionFactory) activiti5ProcessEngineConfig.getSessionFactories().get(EnreplacedyManagerSession.clreplaced);
enreplacedyManagerFactory = enreplacedyManagerSessionFactory.getEnreplacedyManagerFactory();
setupJPAVariables();
}
processEngine = cachedProcessEngine;
}
private static void setupJPAVariables() {
EnreplacedyManager em = enreplacedyManagerFactory.createEnreplacedyManager();
em.getTransaction().begin();
fieldEnreplacedy = new FieldAccessJPAEnreplacedy();
fieldEnreplacedy.setId(1L);
fieldEnreplacedy.setValue("fieldEnreplacedy");
em.persist(fieldEnreplacedy);
propertyEnreplacedy = new PropertyAccessJPAEnreplacedy();
propertyEnreplacedy.setId(1L);
propertyEnreplacedy.setValue("propertyEnreplacedy");
em.persist(propertyEnreplacedy);
em.flush();
em.getTransaction().commit();
em.close();
// load enhanced versions of enreplacedies
em = enreplacedyManagerFactory.createEnreplacedyManager();
fieldEnreplacedy = em.find(FieldAccessJPAEnreplacedy.clreplaced, fieldEnreplacedy.getId());
propertyEnreplacedy = em.find(PropertyAccessJPAEnreplacedy.clreplaced, propertyEnreplacedy.getId());
em.getTransaction().begin();
fieldEnreplacedy2 = new FieldAccessJPAEnreplacedy();
fieldEnreplacedy2.setId(2L);
fieldEnreplacedy2.setValue("fieldEnreplacedy2");
em.persist(fieldEnreplacedy2);
em.flush();
em.getTransaction().commit();
em.close();
}
private Task getTask(ProcessInstance instance) {
return activiti5ProcessEngineConfig.getTaskService().createTaskQuery().processInstanceId(instance.getProcessInstanceId()).includeProcessVariables().singleResult();
}
@Deployment(resources = { "org/activiti5/standalone/jpa/JPAVariableTest.testStoreJPAEnreplacedyAsVariable.bpmn20.xml" })
public void testEnhancedEnreplacedyVariables() throws Exception {
// test if enhancement is used
if (FieldAccessJPAEnreplacedy.clreplaced == fieldEnreplacedy.getClreplaced() || PropertyAccessJPAEnreplacedy.clreplaced == propertyEnreplacedy.getClreplaced()) {
logger.warn("Enreplacedy enhancement is not used");
return;
}
// start process with enhanced jpa variables
Map<String, Object> params = new HashMap<String, Object>();
params.put("fieldEnreplacedy", fieldEnreplacedy);
params.put("propertyEnreplacedy", propertyEnreplacedy);
ProcessInstance instance = processEngine.getRuntimeService().startProcessInstanceByKey("JPAVariableProcess", params);
Task task = getTask(instance);
for (Map.Entry<String, Object> entry : task.getProcessVariables().entrySet()) {
String name = entry.getKey();
Object value = entry.getValue();
if (name.equals("fieldEnreplacedy")) {
replacedertTrue(value instanceof FieldAccessJPAEnreplacedy);
} else if (name.equals("propertyEnreplacedy")) {
replacedertTrue(value instanceof PropertyAccessJPAEnreplacedy);
} else {
fail();
}
}
}
@Deployment(resources = { "org/activiti5/standalone/jpa/JPAVariableTest.testStoreJPAEnreplacedyAsVariable.bpmn20.xml" })
public void testEnhancedEnreplacedyListVariables() throws Exception {
// test if enhancement is used
if (FieldAccessJPAEnreplacedy.clreplaced == fieldEnreplacedy.getClreplaced() || PropertyAccessJPAEnreplacedy.clreplaced == propertyEnreplacedy.getClreplaced()) {
logger.warn("Enreplacedy enhancement is not used");
return;
}
// start process with lists of enhanced jpa variables
Map<String, Object> params = new HashMap<String, Object>();
params.put("list1", Arrays.asList(fieldEnreplacedy, fieldEnreplacedy));
params.put("list2", Arrays.asList(propertyEnreplacedy, propertyEnreplacedy));
ProcessInstance instance = processEngine.getRuntimeService().startProcessInstanceByKey("JPAVariableProcess", params);
Task task = getTask(instance);
List list = (List) task.getProcessVariables().get("list1");
replacedertTrue(list.size() == 2);
replacedertTrue(list.get(0) instanceof FieldAccessJPAEnreplacedy);
replacedertTrue(list.get(1) instanceof FieldAccessJPAEnreplacedy);
list = (List) task.getProcessVariables().get("list2");
replacedertTrue(list.size() == 2);
replacedertTrue(list.get(0) instanceof PropertyAccessJPAEnreplacedy);
replacedertTrue(list.get(1) instanceof PropertyAccessJPAEnreplacedy);
// start process with enhanced and persisted only jpa variables in the same list
params.putAll(Collections.singletonMap("list", Arrays.asList(fieldEnreplacedy, fieldEnreplacedy2)));
instance = processEngine.getRuntimeService().startProcessInstanceByKey("JPAVariableProcess", params);
task = getTask(instance);
list = (List) task.getProcessVariables().get("list");
replacedertTrue(list.size() == 2);
replacedertTrue(list.get(0) instanceof FieldAccessJPAEnreplacedy);
replacedertTrue(((FieldAccessJPAEnreplacedy) list.get(0)).getId().equals(1L));
replacedertTrue(list.get(1) instanceof FieldAccessJPAEnreplacedy);
replacedertTrue(((FieldAccessJPAEnreplacedy) list.get(1)).getId().equals(2L));
// shuffle list and start a new process
params.putAll(Collections.singletonMap("list", Arrays.asList(fieldEnreplacedy2, fieldEnreplacedy)));
instance = processEngine.getRuntimeService().startProcessInstanceByKey("JPAVariableProcess", params);
task = getTask(instance);
list = (List) task.getProcessVariables().get("list");
replacedertTrue(list.size() == 2);
replacedertTrue(list.get(0) instanceof FieldAccessJPAEnreplacedy);
replacedertTrue(((FieldAccessJPAEnreplacedy) list.get(0)).getId().equals(2L));
replacedertTrue(list.get(1) instanceof FieldAccessJPAEnreplacedy);
replacedertTrue(((FieldAccessJPAEnreplacedy) list.get(1)).getId().equals(1L));
// start process with mixed jpa enreplacedies in list
try {
params = new HashMap<String, Object>();
params.put("list", Arrays.asList(fieldEnreplacedy, propertyEnreplacedy));
instance = processEngine.getRuntimeService().startProcessInstanceByKey("JPAVariableProcess", params);
fail();
} catch (Exception e) {
/* do nothing */
}
}
}
19
Source : HistoricJPAVariableTest.java
with Apache License 2.0
from dingziyang
with Apache License 2.0
from dingziyang
/**
* @author Daisuke Yoshimoto
*/
public clreplaced HistoricJPAVariableTest extends AbstractActivireplacedestCase {
protected static ProcessEngine cachedProcessEngine;
private static EnreplacedyManagerFactory enreplacedyManagerFactory;
private static FieldAccessJPAEnreplacedy simpleEnreplacedyFieldAccess;
private static boolean enreplacediesInitialized = false;
protected String processInstanceId;
@Override
protected void initializeProcessEngine() {
if (cachedProcessEngine == null) {
ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("org/activiti5/standalone/jpa/activiti.cfg.xml");
cachedProcessEngine = processEngineConfiguration.buildProcessEngine();
org.activiti5.engine.impl.cfg.ProcessEngineConfigurationImpl activiti5ProcessEngineConfig = (org.activiti5.engine.impl.cfg.ProcessEngineConfigurationImpl) ((ProcessEngineConfigurationImpl) cachedProcessEngine.getProcessEngineConfiguration()).getActiviti5CompatibilityHandler().getRawProcessConfiguration();
EnreplacedyManagerSessionFactory enreplacedyManagerSessionFactory = (EnreplacedyManagerSessionFactory) activiti5ProcessEngineConfig.getSessionFactories().get(EnreplacedyManagerSession.clreplaced);
enreplacedyManagerFactory = enreplacedyManagerSessionFactory.getEnreplacedyManagerFactory();
}
processEngine = cachedProcessEngine;
}
public void setupJPAEnreplacedies() {
if (!enreplacediesInitialized) {
EnreplacedyManager manager = enreplacedyManagerFactory.createEnreplacedyManager();
manager.getTransaction().begin();
// Simple test data
simpleEnreplacedyFieldAccess = new FieldAccessJPAEnreplacedy();
simpleEnreplacedyFieldAccess.setId(1L);
simpleEnreplacedyFieldAccess.setValue("value1");
manager.persist(simpleEnreplacedyFieldAccess);
manager.flush();
manager.getTransaction().commit();
manager.close();
enreplacediesInitialized = true;
}
}
@Deployment
public void testGetJPAEnreplacedyAsHistoricVariable() {
setupJPAEnreplacedies();
// -----------------------------------------------------------------------------
// Simple test, Start process with JPA enreplacedies as variables
// -----------------------------------------------------------------------------
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("simpleEnreplacedyFieldAccess", simpleEnreplacedyFieldAccess);
// Start the process with the JPA-enreplacedies as variables. They will be stored
// in the DB.
this.processInstanceId = runtimeService.startProcessInstanceByKey("JPAVariableProcess", variables).getId();
for (Task task : taskService.createTaskQuery().includeTaskLocalVariables().list()) {
taskService.complete(task.getId());
}
// Get JPAEnreplacedy Variable by HistoricVariableInstanceQuery
HistoricVariableInstance historicVariableInstance = historyService.createHistoricVariableInstanceQuery().processInstanceId(processInstanceId).variableName("simpleEnreplacedyFieldAccess").singleResult();
Object value = historicVariableInstance.getValue();
replacedertTrue(value instanceof FieldAccessJPAEnreplacedy);
replacedertEquals(((FieldAccessJPAEnreplacedy) value).getValue(), simpleEnreplacedyFieldAccess.getValue());
}
@Deployment
public void testGetJPAEnreplacedyAsHistoricLog() {
setupJPAEnreplacedies();
// -----------------------------------------------------------------------------
// Simple test, Start process with JPA enreplacedies as variables
// -----------------------------------------------------------------------------
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("simpleEnreplacedyFieldAccess", simpleEnreplacedyFieldAccess);
// Start the process with the JPA-enreplacedies as variables. They will be stored
// in the DB.
this.processInstanceId = runtimeService.startProcessInstanceByKey("JPAVariableProcess", variables).getId();
// Finish tasks
for (Task task : taskService.createTaskQuery().includeTaskLocalVariables().list()) {
taskService.complete(task.getId());
}
// Get JPAEnreplacedy Variable by ProcessInstanceHistoryLogQuery
ProcessInstanceHistoryLog log = historyService.createProcessInstanceHistoryLogQuery(processInstanceId).includeVariables().singleResult();
List<HistoricData> events = log.getHistoricData();
for (HistoricData event : events) {
Object value = ((HistoricVariableInstanceEnreplacedy) event).getValue();
replacedertTrue(value instanceof FieldAccessJPAEnreplacedy);
replacedertEquals(((FieldAccessJPAEnreplacedy) value).getValue(), simpleEnreplacedyFieldAccess.getValue());
}
}
@Deployment(resources = { "org/activiti5/standalone/jpa/HistoricJPAVariableTest.testGetJPAEnreplacedyAsHistoricLog.bpmn20.xml" })
public void testGetJPAUpdateEnreplacedyAsHistoricLog() {
setupJPAEnreplacedies();
// -----------------------------------------------------------------------------
// Simple test, Start process with JPA enreplacedies as variables
// -----------------------------------------------------------------------------
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("simpleEnreplacedyFieldAccess", simpleEnreplacedyFieldAccess);
// Start the process with the JPA-enreplacedies as variables. They will be stored in the DB.
this.processInstanceId = runtimeService.startProcessInstanceByKey("JPAVariableProcess", variables).getId();
// Finish tasks
for (Task task : taskService.createTaskQuery().includeProcessVariables().list()) {
taskService.setVariable(task.getId(), "simpleEnreplacedyFieldAccess", simpleEnreplacedyFieldAccess);
taskService.complete(task.getId());
}
// Get JPAEnreplacedy Variable by ProcessInstanceHistoryLogQuery
ProcessInstanceHistoryLog log = historyService.createProcessInstanceHistoryLogQuery(processInstanceId).includeVariableUpdates().singleResult();
List<HistoricData> events = log.getHistoricData();
for (HistoricData event : events) {
Object value = ((HistoricDetailVariableInstanceUpdateEnreplacedy) event).getValue();
replacedertTrue(value instanceof FieldAccessJPAEnreplacedy);
replacedertEquals(((FieldAccessJPAEnreplacedy) value).getValue(), simpleEnreplacedyFieldAccess.getValue());
}
}
}
19
Source : AsyncExecutorTest.java
with Apache License 2.0
from dingziyang
with Apache License 2.0
from dingziyang
private void waitForAllJobsBeingExecuted(ProcessEngine processEngine) {
waitForAllJobsBeingExecuted(processEngine, 10000L);
}
19
Source : AsyncExecutorTest.java
with Apache License 2.0
from dingziyang
with Apache License 2.0
from dingziyang
@Test
public void testAsyncScriptExecution() {
ProcessEngine processEngine = null;
try {
// Deploy
processEngine = createProcessEngine(true);
setClockToCurrentTime(processEngine);
deploy(processEngine, "AsyncExecutorTest.testAsyncScriptExecution.bpmn20.xml");
// Start process instance. Wait for all jobs to be done
processEngine.getRuntimeService().startProcessInstanceByKey("asyncScript");
waitForAllJobsBeingExecuted(processEngine);
// Verify if all is as expected
replacedert.replacedertEquals(1, processEngine.getTaskService().createTaskQuery().taskName("Task after script").count());
replacedert.replacedertEquals(0, processEngine.getManagementService().createJobQuery().count());
replacedert.replacedertEquals(0, processEngine.getManagementService().createTimerJobQuery().count());
replacedert.replacedertEquals(1, getAsyncExecutorJobCount(processEngine));
} finally {
// Clean up
cleanup(processEngine);
}
}
19
Source : AsyncExecutorTest.java
with Apache License 2.0
from dingziyang
with Apache License 2.0
from dingziyang
@Test
public void testRegularAsyncExecution() {
ProcessEngine processEngine = null;
try {
// Deploy
processEngine = createProcessEngine(true);
setClockToCurrentTime(processEngine);
deploy(processEngine, "AsyncExecutorTest.testRegularAsyncExecution.bpmn20.xml");
// Start process instance. Wait for all jobs to be done
processEngine.getRuntimeService().startProcessInstanceByKey("asyncExecutor");
// Move clock 3 minutes. Nothing should happen
addSecondsToCurrentTime(processEngine, 180L);
waitForAllJobsBeingExecuted(processEngine, 2000L);
replacedert.replacedertEquals(1, processEngine.getTaskService().createTaskQuery().taskName("The Task").count());
replacedert.replacedertEquals(0, processEngine.getTaskService().createTaskQuery().taskName("Task after timer").count());
replacedert.replacedertEquals(1, processEngine.getManagementService().createTimerJobQuery().count());
replacedert.replacedertEquals(0, getAsyncExecutorJobCount(processEngine));
// Move clock 3 minutes and 1 second. Triggers the timer
addSecondsToCurrentTime(processEngine, 181);
waitForAllJobsBeingExecuted(processEngine);
// Verify if all is as expected
replacedert.replacedertEquals(0, processEngine.getTaskService().createTaskQuery().taskName("The Task").count());
replacedert.replacedertEquals(1, processEngine.getTaskService().createTaskQuery().taskName("Task after timer").count());
replacedert.replacedertEquals(0, processEngine.getManagementService().createTimerJobQuery().count());
replacedert.replacedertEquals(1, getAsyncExecutorJobCount(processEngine));
} finally {
// Clean up
if (processEngine != null) {
cleanup(processEngine);
}
}
}
19
Source : AsyncExecutorTest.java
with Apache License 2.0
from dingziyang
with Apache License 2.0
from dingziyang
private void cleanup(ProcessEngine processEngine) {
for (org.activiti.engine.repository.Deployment deployment : processEngine.getRepositoryService().createDeploymentQuery().list()) {
processEngine.getRepositoryService().deleteDeployment(deployment.getId(), true);
}
processEngine.close();
}
19
Source : AsyncExecutorTest.java
with Apache License 2.0
from dingziyang
with Apache License 2.0
from dingziyang
private void waitForAllJobsBeingExecuted(ProcessEngine processEngine, long maxWaitTime) {
JobTestHelper.waitForJobExecutorToProcessAllJobsAndExecutableTimerJobs(processEngine.getProcessEngineConfiguration(), processEngine.getManagementService(), maxWaitTime, 500L, false);
}
19
Source : AsyncExecutorTest.java
with Apache License 2.0
from dingziyang
with Apache License 2.0
from dingziyang
private void addSecondsToCurrentTime(ProcessEngine processEngine, long nrOfSeconds) {
Clock clock = processEngine.getProcessEngineConfiguration().getClock();
clock.setCurrentTime(new Date(clock.getCurrentTime().getTime() + (nrOfSeconds * 1000L)));
processEngine.getProcessEngineConfiguration().setClock(clock);
}
19
Source : DisabledDefinitionInfoCacheTest.java
with Apache License 2.0
from dingziyang
with Apache License 2.0
from dingziyang
/**
* @author Tijs Rademakers
*/
public clreplaced DisabledDefinitionInfoCacheTest extends AbstractActivireplacedestCase {
protected static ProcessEngine cachedProcessEngine;
protected void initializeProcessEngine() {
if (cachedProcessEngine == null) {
ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("org/activiti5/engine/test/bpmn/usertask/activiti.cfg.xml");
cachedProcessEngine = processEngineConfiguration.buildProcessEngine();
}
processEngine = cachedProcessEngine;
}
@Deployment
public void testChangeFormKey() {
// first test without changing the form key
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("dynamicUserTask");
String processDefinitionId = processInstance.getProcessDefinitionId();
Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
replacedertEquals("test", task.getFormKey());
taskService.complete(task.getId());
replacedertProcessEnded(processInstance.getId());
// now test with changing the form key
ObjectNode infoNode = dynamicBpmnService.changeUserTaskFormKey("task1", "test2");
dynamicBpmnService.saveProcessDefinitionInfo(processDefinitionId, infoNode);
processInstance = runtimeService.startProcessInstanceByKey("dynamicUserTask");
task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
replacedertEquals("test", task.getFormKey());
taskService.complete(task.getId());
replacedertProcessEnded(processInstance.getId());
}
@Deployment
public void testChangeClreplacedName() {
// first test without changing the clreplaced name
Map<String, Object> varMap = new HashMap<String, Object>();
varMap.put("count", 0);
varMap.put("count2", 0);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("dynamicServiceTask", varMap);
Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
taskService.complete(task.getId());
replacedertEquals(1, runtimeService.getVariable(processInstance.getId(), "count"));
replacedertEquals(0, runtimeService.getVariable(processInstance.getId(), "count2"));
task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
taskService.complete(task.getId());
replacedertProcessEnded(processInstance.getId());
// now test with changing the clreplaced name
varMap = new HashMap<String, Object>();
varMap.put("count", 0);
varMap.put("count2", 0);
processInstance = runtimeService.startProcessInstanceByKey("dynamicServiceTask", varMap);
String processDefinitionId = processInstance.getProcessDefinitionId();
ObjectNode infoNode = dynamicBpmnService.changeServiceTaskClreplacedName("service", "org.activiti5.engine.test.bpmn.servicetask.DummyServiceTask2");
dynamicBpmnService.saveProcessDefinitionInfo(processDefinitionId, infoNode);
task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
taskService.complete(task.getId());
replacedertEquals(1, runtimeService.getVariable(processInstance.getId(), "count"));
replacedertEquals(0, runtimeService.getVariable(processInstance.getId(), "count2"));
task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
taskService.complete(task.getId());
replacedertProcessEnded(processInstance.getId());
}
}
19
Source : ActivitiMockSupport.java
with Apache License 2.0
from dingziyang
with Apache License 2.0
from dingziyang
public static boolean isMockSupportPossible(ProcessEngine processEngine) {
return processEngine instanceof ProcessEngineImpl;
}
19
Source : ActivitiRule.java
with Apache License 2.0
from dingziyang
with Apache License 2.0
from dingziyang
public void setProcessEngine(ProcessEngine processEngine) {
this.processEngine = processEngine;
initializeServices();
}
19
Source : TestHelper.java
with Apache License 2.0
from dingziyang
with Apache License 2.0
from dingziyang
// replacedertion methods ///////////////////////////////////////////////////
public static void replacedertProcessEnded(ProcessEngine processEngine, String processInstanceId) {
ProcessInstance processInstance = processEngine.getRuntimeService().createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
if (processInstance != null) {
throw new replacedertionFailedError("expected finished process instance '" + processInstanceId + "' but it was still in the db");
}
}
19
Source : PluggableActivitiTestCase.java
with Apache License 2.0
from dingziyang
with Apache License 2.0
from dingziyang
/**
* Base clreplaced for the activiti test cases.
*
* The main reason not to use our own test support clreplacedes is that we need to
* run our test suite with various configurations, e.g. with and without spring,
* standalone or on a server etc. Those requirements create some complications
* so we think it's best to use a separate base clreplaced. That way it is much easier
* for us to maintain our own codebase and at the same time provide stability
* on the test support clreplacedes that we offer as part of our api (in org.activiti5.engine.test).
*
* @author Tom Baeyens
* @author Joram Barrez
*/
public abstract clreplaced PluggableActivireplacedestCase extends AbstractActivireplacedestCase {
private static Logger pluggableActivireplacedestCaseLogger = LoggerFactory.getLogger(PluggableActivireplacedestCase.clreplaced);
protected static ProcessEngine cachedProcessEngine;
protected void initializeProcessEngine() {
if (cachedProcessEngine == null) {
pluggableActivireplacedestCaseLogger.info("No cached process engine found for test. Retrieving the default engine.");
// Just to be sure we're not getting any previously cached version
ProcessEngines.destroy();
cachedProcessEngine = ProcessEngines.getDefaultProcessEngine();
if (cachedProcessEngine == null) {
throw new ActivitiException("no default process engine available");
}
}
processEngine = cachedProcessEngine;
}
}
19
Source : XmlNamespaceProcessScopeTest.java
with Apache License 2.0
from dingziyang
with Apache License 2.0
from dingziyang
/**
* tests the scoped beans
*
* @author Josh Long
*/
@RunWith(SpringJUnit4ClreplacedRunner.clreplaced)
@ContextConfiguration("clreplacedpath:org/activiti5/spring/test/components/ScopingTests-context.xml")
@Ignore
public clreplaced XmlNamespaceProcessScopeTest {
private ProcessScopeTestEngine processScopeTestEngine;
@Autowired
private ProcessEngine processEngine;
@Before
public void before() throws Throwable {
this.processEngine.getRepositoryService().createDeployment().addClreplacedpathResource("org/activiti5/spring/test/components/spring-component-waiter.bpmn20.xml").deploy();
processScopeTestEngine = new ProcessScopeTestEngine(this.processEngine);
}
@After
public void after() {
RepositoryService repositoryService = this.processEngine.getRepositoryService();
for (Deployment deployment : repositoryService.createDeploymentQuery().list()) {
repositoryService.deleteDeployment(deployment.getId(), true);
}
}
@Test
public void testScopedProxyCreation() throws Throwable {
processScopeTestEngine.testScopedProxyCreation();
}
}
19
Source : SpringActivitiTestCase.java
with Apache License 2.0
from dingziyang
with Apache License 2.0
from dingziyang
@Override
protected void initializeProcessEngine() {
ContextConfiguration contextConfiguration = getClreplaced().getAnnotation(ContextConfiguration.clreplaced);
String[] value = contextConfiguration.value();
boolean hasOneArg = value != null && value.length == 1;
String key = hasOneArg ? value[0] : ProcessEngine.clreplaced.getName();
ProcessEngine engine = this.cachedProcessEngines.containsKey(key) ? this.cachedProcessEngines.get(key) : this.applicationContext.getBean(ProcessEngine.clreplaced);
this.cachedProcessEngines.put(key, engine);
this.processEngine = engine;
}
19
Source : ActivitiInboundGateway.java
with Apache License 2.0
from dingziyang
with Apache License 2.0
from dingziyang
/**
* As a process enters a wait-state, this forwards the
* flow into Spring Integration. Spring Integration flows
* may ultimately return a reply message and that will signal the
* execution.
*
* @author Josh Long
*/
public clreplaced ActivitiInboundGateway extends MessagingGatewaySupport {
private String executionId = "executionId";
private String processInstanceId = "processInstanceId";
private String processDefinitionId = "processDefinitionId";
private final ProcessVariableHeaderMapper headerMapper;
private ProcessEngine processEngine;
private Set<String> sync = new ConcurrentSkipListSet<String>();
public ActivitiInboundGateway(ProcessEngine processEngine, String... pvsOrHeadersToPreserve) {
Collections.addAll(this.sync, pvsOrHeadersToPreserve);
this.processEngine = processEngine;
this.headerMapper = new ProcessVariableHeaderMapper(sync);
this.initializeDefaultPreservedHeaders();
}
protected void initializeDefaultPreservedHeaders() {
this.sync.add(executionId);
this.sync.add(processDefinitionId);
this.sync.add(processInstanceId);
}
public void execute(IntegrationActivityBehavior receiveTaskActivityBehavior, DelegateExecution execution) {
Map<String, Object> stringObjectMap = new HashMap<String, Object>();
stringObjectMap.put(executionId, execution.getId());
stringObjectMap.put(processInstanceId, execution.getProcessInstanceId());
stringObjectMap.put(processDefinitionId, execution.getProcessDefinitionId());
stringObjectMap.putAll(headerMapper.toHeaders(execution.getVariables()));
MessageBuilder<?> mb = MessageBuilder.withPayload(execution).copyHeaders(stringObjectMap);
Message<?> reply = sendAndReceiveMessage(mb.build());
if (null != reply) {
Map<String, Object> vars = new HashMap<String, Object>();
headerMapper.fromHeaders(reply.getHeaders(), vars);
for (String k : vars.keySet()) {
processEngine.getRuntimeService().setVariable(execution.getId(), k, vars.get(k));
}
receiveTaskActivityBehavior.leave(execution);
}
}
public void signal(IntegrationActivityBehavior receiveTaskActivityBehavior, DelegateExecution execution, String signalName, Object data) {
receiveTaskActivityBehavior.leave(execution);
}
}
19
Source : Activiti.java
with Apache License 2.0
from dingziyang
with Apache License 2.0
from dingziyang
/**
* Any message that enters this {@link MessageHandler}
* containing a {@code executionId} parameter will trigger a
* {@link org.activiti.engine.RuntimeService#signal(String)}.
*/
public static MessageHandler signallingMessageHandler(final ProcessEngine processEngine) {
return new MessageHandler() {
@Override
public void handleMessage(Message<?> message) throws MessagingException {
String executionId = message.getHeaders().containsKey("executionId") ? (String) message.getHeaders().get("executionId") : (String) null;
if (null != executionId)
processEngine.getRuntimeService().trigger(executionId);
}
};
}
19
Source : Activiti.java
with Apache License 2.0
from dingziyang
with Apache License 2.0
from dingziyang
/**
* This is the component that you'll use in your Spring Integration
* {@link org.springframework.integration.dsl.IntegrationFlow}.
*/
public static ActivitiInboundGateway inboundGateway(ProcessEngine processEngine, String... varsToPreserve) {
return new ActivitiInboundGateway(processEngine, varsToPreserve);
}
19
Source : EndpointAutoConfiguration.java
with Apache License 2.0
from dingziyang
with Apache License 2.0
from dingziyang
@Bean
public ProcessEngineEndpoint processEngineEndpoint(ProcessEngine engine) {
return new ProcessEngineEndpoint(engine);
}
19
Source : ProcessEngineEndpoint.java
with Apache License 2.0
from dingziyang
with Apache License 2.0
from dingziyang
/**
* Registers a Boot Actuator endpoint that provides information on the
* running process instance and renders BPMN diagrams of the deployed processes.
*
* @author Josh Long
*/
// @ConfigurationProperties(prefix = "endpoints.activiti")
@Endpoint(id = "activiti")
public clreplaced ProcessEngineEndpoint {
private final ProcessEngine processEngine;
public ProcessEngineEndpoint(ProcessEngine processEngine) {
this.processEngine = processEngine;
}
@ReadOperation
public Map<String, Object> activiti() {
Map<String, Object> metrics = new HashMap<String, Object>();
// Process definitions
metrics.put("processDefinitionCount", processEngine.getRepositoryService().createProcessDefinitionQuery().count());
// List of all process definitions
List<ProcessDefinition> processDefinitions = processEngine.getRepositoryService().createProcessDefinitionQuery().orderByProcessDefinitionKey().asc().list();
List<String> processDefinitionKeys = new ArrayList<String>();
for (ProcessDefinition processDefinition : processDefinitions) {
processDefinitionKeys.add(processDefinition.getKey() + " (v" + processDefinition.getVersion() + ")");
}
metrics.put("deployedProcessDefinitions", processDefinitionKeys);
// Process instances
Map<String, Object> processInstanceCountMap = new HashMap<String, Object>();
metrics.put("runningProcessInstanceCount", processInstanceCountMap);
for (ProcessDefinition processDefinition : processDefinitions) {
processInstanceCountMap.put(processDefinition.getKey() + " (v" + processDefinition.getVersion() + ")", processEngine.getRuntimeService().createProcessInstanceQuery().processDefinitionId(processDefinition.getId()).count());
}
Map<String, Object> completedProcessInstanceCountMap = new HashMap<String, Object>();
metrics.put("completedProcessInstanceCount", completedProcessInstanceCountMap);
for (ProcessDefinition processDefinition : processDefinitions) {
completedProcessInstanceCountMap.put(processDefinition.getKey() + " (v" + processDefinition.getVersion() + ")", processEngine.getHistoryService().createHistoricProcessInstanceQuery().finished().processDefinitionId(processDefinition.getId()).count());
}
// Open tasks
metrics.put("openTaskCount", processEngine.getTaskService().createTaskQuery().count());
metrics.put("completedTaskCount", processEngine.getHistoryService().createHistoricTaskInstanceQuery().finished().count());
// Tasks completed today
metrics.put("completedTaskCountToday", processEngine.getHistoryService().createHistoricTaskInstanceQuery().finished().taskCompletedAfter(new Date(System.currentTimeMillis() - secondsForDays(1))).count());
// Process steps
metrics.put("completedActivities", processEngine.getHistoryService().createHistoricActivityInstanceQuery().finished().count());
// Process definition cache
DeploymentCache<ProcessDefinitionCacheEntry> deploymentCache = ((ProcessEngineConfigurationImpl) processEngine.getProcessEngineConfiguration()).getProcessDefinitionCache();
if (deploymentCache instanceof DefaultDeploymentCache) {
metrics.put("cachedProcessDefinitionCount", ((DefaultDeploymentCache) deploymentCache).size());
}
return metrics;
}
private long secondsForDays(int days) {
int hour = 60 * 60 * 1000;
int day = 24 * hour;
return days * day;
}
}
19
Source : AbstractProcessEngineConfiguration.java
with Apache License 2.0
from dingziyang
with Apache License 2.0
from dingziyang
public TaskService taskServiceBean(ProcessEngine processEngine) {
return processEngine.getTaskService();
}
19
Source : AbstractProcessEngineConfiguration.java
with Apache License 2.0
from dingziyang
with Apache License 2.0
from dingziyang
public HistoryService historyServiceBean(ProcessEngine processEngine) {
return processEngine.getHistoryService();
}
19
Source : AbstractProcessEngineConfiguration.java
with Apache License 2.0
from dingziyang
with Apache License 2.0
from dingziyang
public RepositoryService repositoryServiceBean(ProcessEngine processEngine) {
return processEngine.getRepositoryService();
}
19
Source : AbstractProcessEngineConfiguration.java
with Apache License 2.0
from dingziyang
with Apache License 2.0
from dingziyang
public RuntimeService runtimeServiceBean(ProcessEngine processEngine) {
return processEngine.getRuntimeService();
}
19
Source : AbstractProcessEngineConfiguration.java
with Apache License 2.0
from dingziyang
with Apache License 2.0
from dingziyang
public ManagementService managementServiceBeanBean(ProcessEngine processEngine) {
return processEngine.getManagementService();
}
19
Source : AbstractProcessEngineConfiguration.java
with Apache License 2.0
from dingziyang
with Apache License 2.0
from dingziyang
public FormService formServiceBean(ProcessEngine processEngine) {
return processEngine.getFormService();
}
19
Source : Application.java
with Apache License 2.0
from dingziyang
with Apache License 2.0
from dingziyang
@Bean
ActivitiInboundGateway inboundGateway(ProcessEngine processEngine) {
return new ActivitiInboundGateway(processEngine, "customerId", "projectId");
}
19
Source : EndpointAutoConfigurationTest.java
with Apache License 2.0
from dingziyang
with Apache License 2.0
from dingziyang
@Test
public void mvcEndpoint() throws Throwable {
AnnotationConfigEmbeddedWebApplicationContext applicationContext = new AnnotationConfigEmbeddedWebApplicationContext(CallbackEmbeddedContainerCustomizer.clreplaced, EmbeddedContainerConfiguration.clreplaced, EndpointConfiguration.clreplaced);
ProcessEngine processEngine = applicationContext.getBean(ProcessEngine.clreplaced);
org.junit.replacedert.replacedertNotNull("the processEngine should not be null", processEngine);
ProcessEngineEndpoint processEngineEndpoint = applicationContext.getBean(ProcessEngineEndpoint.clreplaced);
org.junit.replacedert.replacedertNotNull("the processEngineEndpoint should not be null", processEngineEndpoint);
RestTemplate restTemplate = applicationContext.getBean(RestTemplate.clreplaced);
ResponseEnreplacedy<Map> mapResponseEnreplacedy = restTemplate.getForEnreplacedy("http://localhost:9091/activiti/", Map.clreplaced);
Map map = mapResponseEnreplacedy.getBody();
String[] criticalKeys = { "completedTaskCount", "openTaskCount", "cachedProcessDefinitionCount" };
Map<?, ?> invokedResults = processEngineEndpoint.invoke();
for (String k : criticalKeys) {
org.junit.replacedert.replacedertTrue(map.containsKey(k));
org.junit.replacedert.replacedertEquals(((Number) map.get(k)).longValue(), ((Number) invokedResults.get(k)).longValue());
}
}
See More Examples