use of org.activiti.engine.impl.interceptor.CommandExecutor in project Activiti by Activiti.
the class ManagementServiceTest method testDeleteJobThatWasAlreadyAcquired.
@Deployment(resources = { "org/activiti/engine/test/api/mgmt/timerOnTask.bpmn20.xml" })
public void testDeleteJobThatWasAlreadyAcquired() {
processEngineConfiguration.getClock().setCurrentTime(new Date());
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("timerOnTask");
Job timerJob = managementService.createJobQuery().processInstanceId(processInstance.getId()).singleResult();
// We need to move time at least one hour to make the timer executable
processEngineConfiguration.getClock().setCurrentTime(new Date(processEngineConfiguration.getClock().getCurrentTime().getTime() + 7200000L));
// Acquire job by running the acquire command manually
ProcessEngineImpl processEngineImpl = (ProcessEngineImpl) processEngine;
AcquireTimerJobsCmd acquireJobsCmd = new AcquireTimerJobsCmd("testLockOwner", 60000, 5);
CommandExecutor commandExecutor = processEngineImpl.getProcessEngineConfiguration().getCommandExecutor();
commandExecutor.execute(acquireJobsCmd);
// Try to delete the job. This should fail.
try {
managementService.deleteJob(timerJob.getId());
fail();
} catch (ActivitiException e) {
// Exception is expected
}
// Clean up
managementService.executeJob(timerJob.getId());
}
use of org.activiti.engine.impl.interceptor.CommandExecutor in project Activiti by Activiti.
the class JobQueryTest method deleteJobInDatabase.
private void deleteJobInDatabase() {
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutor();
commandExecutor.execute(new Command<Void>() {
public Void execute(CommandContext commandContext) {
timerEntity.delete();
return null;
}
});
}
use of org.activiti.engine.impl.interceptor.CommandExecutor in project Activiti by Activiti.
the class JobQueryTest method createJobWithoutExceptionStacktrace.
private void createJobWithoutExceptionStacktrace() {
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutor();
commandExecutor.execute(new Command<Void>() {
public Void execute(CommandContext commandContext) {
JobEntityManager jobManager = commandContext.getJobEntityManager();
timerEntity = new TimerEntity();
timerEntity.setLockOwner(UUID.randomUUID().toString());
timerEntity.setDuedate(new Date());
timerEntity.setRetries(0);
timerEntity.setExceptionMessage("I'm supposed to fail");
jobManager.insert(timerEntity);
assertNotNull(timerEntity.getId());
return null;
}
});
}
use of org.activiti.engine.impl.interceptor.CommandExecutor in project Activiti by Activiti.
the class ProcessInstanceMigrationTest method testSetProcessDefinitionVersionActivityMissing.
@Deployment(resources = { TEST_PROCESS })
public void testSetProcessDefinitionVersionActivityMissing() {
// start process instance
ProcessInstance pi = runtimeService.startProcessInstanceByKey("receiveTask");
// check that receive task has been reached
Execution execution = runtimeService.createExecutionQuery().activityId("waitState1").singleResult();
assertNotNull(execution);
// deploy new version of the process definition
org.activiti.engine.repository.Deployment deployment = repositoryService.createDeployment().addClasspathResource(TEST_PROCESS_ACTIVITY_MISSING).deploy();
assertEquals(2, repositoryService.createProcessDefinitionQuery().count());
// migrate process instance to new process definition version
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutor();
SetProcessDefinitionVersionCmd setProcessDefinitionVersionCmd = new SetProcessDefinitionVersionCmd(pi.getId(), 2);
try {
commandExecutor.execute(setProcessDefinitionVersionCmd);
fail("ActivitiException expected");
} catch (ActivitiException ae) {
assertTextPresent("The new process definition (key = 'receiveTask') does not contain the current activity (id = 'waitState1') of the process instance (id = '", ae.getMessage());
}
// undeploy "manually" deployed process definition
repositoryService.deleteDeployment(deployment.getId(), true);
}
use of org.activiti.engine.impl.interceptor.CommandExecutor in project Activiti by Activiti.
the class BpmnParseTest method testParseNamespaceInConditionExpressionType.
@Deployment
public void testParseNamespaceInConditionExpressionType() {
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutor();
ProcessDefinitionEntity processDefinitionEntity = commandExecutor.execute(new Command<ProcessDefinitionEntity>() {
public ProcessDefinitionEntity execute(CommandContext commandContext) {
return Context.getProcessEngineConfiguration().getDeploymentManager().findDeployedLatestProcessDefinitionByKey("resolvableNamespacesProcess");
}
});
// Test that the process definition has been deployed
assertNotNull(processDefinitionEntity);
ActivityImpl activity = processDefinitionEntity.findActivity("ExclusiveGateway_1");
assertNotNull(activity);
// Test that the conditions has been resolved
for (PvmTransition transition : activity.getOutgoingTransitions()) {
if (transition.getDestination().getId().equals("Task_2")) {
assertTrue(transition.getProperty("conditionText").equals("#{approved}"));
} else if (transition.getDestination().getId().equals("Task_3")) {
assertTrue(transition.getProperty("conditionText").equals("#{!approved}"));
} else {
fail("Something went wrong");
}
}
}
Aggregations