![JAR search and dependency download from the Maven repository](/logo.png)
org.camunda.bpm.scenario.impl.DeferredExecutable Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of camunda-bpm-assert-scenario Show documentation
Show all versions of camunda-bpm-assert-scenario Show documentation
Camunda BPM Assert Scenario allows you to specify the actions
needed at process wait states before you start the process instances
executing your test scenario. As a consequence, writing such tests is
easier and faster than ever before. And refactoring and changing large
process models and their test suites can almost be done in the blink
of an eye: ;-) Done! Check it out and judge yourself!
package org.camunda.bpm.scenario.impl;
import org.camunda.bpm.engine.history.HistoricActivityInstance;
import org.camunda.bpm.scenario.defer.Deferred;
import org.camunda.bpm.scenario.impl.util.Log;
import org.camunda.bpm.scenario.impl.util.Time;
import java.util.Date;
/**
* @author Martin Schimak
*/
public class DeferredExecutable extends AbstractExecutable {
private static int sequence;
private Integer id = ++sequence;
private Date isExecutableAt;
private Deferred action;
protected DeferredExecutable(ProcessRunnerImpl runner, HistoricActivityInstance instance, String period, Deferred action) {
super(runner);
this.delegate = instance;
this.isExecutableAt = Time.dateAfter(period);
this.action = action;
Log.Action.Deferring_Action.log(
instance.getActivityType(),
instance.getActivityName(),
instance.getActivityId(),
runner.getProcessDefinitionKey(),
instance.getProcessInstanceId(),
action.toString(),
isExecutableAt
);
Deferreds.add(this);
}
@Override
public String getExecutionId() {
return delegate.getExecutionId();
}
@Override
protected HistoricActivityInstance getDelegate() {
return getHistoryService().createHistoricActivityInstanceQuery().activityInstanceId(delegate.getId()).unfinished().singleResult();
}
@Override
protected Date isExecutableAt() {
return isExecutableAt;
}
@Override
public void execute() {
if (getDelegate() != null) {
Time.set(isExecutableAt());
try {
Log.Action.Executing_Action.log(
delegate.getActivityType(),
delegate.getActivityName(),
delegate.getActivityId(),
runner.getProcessDefinitionKey(),
delegate.getProcessInstanceId(),
action.toString(),
isExecutableAt
);
action.execute();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
Deferreds.remove(this);
}
@Override
public int compareTo(AbstractExecutable other) {
int compare = super.compareTo(other);
return compare == 0 ? id.compareTo(((DeferredExecutable) other).id) : compare;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy