code
stringlengths
25
201k
docstring
stringlengths
19
96.2k
func_name
stringlengths
0
235
language
stringclasses
1 value
repo
stringlengths
8
51
path
stringlengths
11
314
url
stringlengths
62
377
license
stringclasses
7 values
public List<DelayedVariableEvent> getDelayedEvents() { if (isProcessInstanceExecution()) { return delayedEvents; } return getProcessInstance().getDelayedEvents(); }
The current delayed variable events. @return a list of DelayedVariableEvent objects
getDelayedEvents
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/pvm/runtime/PvmExecutionImpl.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/pvm/runtime/PvmExecutionImpl.java
Apache-2.0
public void clearDelayedEvents() { if (isProcessInstanceExecution()) { delayedEvents.clear(); } else { getProcessInstance().clearDelayedEvents(); } }
Cleares the current delayed variable events.
clearDelayedEvents
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/pvm/runtime/PvmExecutionImpl.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/pvm/runtime/PvmExecutionImpl.java
Apache-2.0
protected void dispatchScopeEvents(PvmExecutionImpl execution) { PvmExecutionImpl scopeExecution = execution.isScope() ? execution : execution.getParent(); List<DelayedVariableEvent> delayedEvents = new ArrayList<>(scopeExecution.getDelayedEvents()); scopeExecution.clearDelayedEvents(); Map<PvmExecutionImpl, String> activityInstanceIds = new HashMap<>(); Map<PvmExecutionImpl, String> activityIds = new HashMap<>(); initActivityIds(delayedEvents, activityInstanceIds, activityIds); //For each delayed variable event we have to check if the delayed event can be dispatched, //the check will be done with the help of the activity id and activity instance id. //That means it will be checked if the dispatching changed the execution tree in a way that we can't dispatch the //the other delayed variable events. We have to check the target scope with the last activity id and activity instance id //and also the replace pointer if it exist. Because on concurrency the replace pointer will be set on which we have //to check the latest state. for (DelayedVariableEvent event : delayedEvents) { PvmExecutionImpl targetScope = event.getTargetScope(); PvmExecutionImpl replaced = targetScope.getReplacedBy() != null ? targetScope.getReplacedBy() : targetScope; dispatchOnSameActivity(targetScope, replaced, activityIds, activityInstanceIds, event); } }
Dispatches the current delayed variable events on the scope of the given execution. @param execution the execution on which scope the delayed variable should be dispatched
dispatchScopeEvents
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/pvm/runtime/PvmExecutionImpl.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/pvm/runtime/PvmExecutionImpl.java
Apache-2.0
protected void initActivityIds(List<DelayedVariableEvent> delayedEvents, Map<PvmExecutionImpl, String> activityInstanceIds, Map<PvmExecutionImpl, String> activityIds) { for (DelayedVariableEvent event : delayedEvents) { PvmExecutionImpl targetScope = event.getTargetScope(); String targetScopeActivityInstanceId = getActivityInstanceId(targetScope); activityInstanceIds.put(targetScope, targetScopeActivityInstanceId); activityIds.put(targetScope, targetScope.getActivityId()); } }
Initializes the given maps with the target scopes and current activity id's and activity instance id's. @param delayedEvents the delayed events which contains the information about the target scope @param activityInstanceIds the map which maps target scope to activity instance id @param activityIds the map which maps target scope to activity id
initActivityIds
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/pvm/runtime/PvmExecutionImpl.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/pvm/runtime/PvmExecutionImpl.java
Apache-2.0
private void dispatchOnSameActivity(PvmExecutionImpl targetScope, PvmExecutionImpl replacedBy, Map<PvmExecutionImpl, String> activityIds, Map<PvmExecutionImpl, String> activityInstanceIds, DelayedVariableEvent delayedVariableEvent) { //check if the target scope has the same activity id and activity instance id //since the dispatching was started String currentActivityInstanceId = getActivityInstanceId(targetScope); String currentActivityId = targetScope.getActivityId(); final String lastActivityInstanceId = activityInstanceIds.get(targetScope); final String lastActivityId = activityIds.get(targetScope); boolean onSameAct = isOnSameActivity(lastActivityInstanceId, lastActivityId, currentActivityInstanceId, currentActivityId); //If not we have to check the replace pointer, //which was set if a concurrent execution was created during the dispatching. if (targetScope != replacedBy && !onSameAct) { currentActivityInstanceId = getActivityInstanceId(replacedBy); currentActivityId = replacedBy.getActivityId(); onSameAct = isOnSameActivity(lastActivityInstanceId, lastActivityId, currentActivityInstanceId, currentActivityId); } //dispatching if (onSameAct && isOnDispatchableState(targetScope)) { targetScope.dispatchEvent(delayedVariableEvent.getEvent()); } }
Dispatches the delayed variable event, if the target scope and replaced by scope (if target scope was replaced) have the same activity Id's and activity instance id's. @param targetScope the target scope on which the event should be dispatched @param replacedBy the replaced by pointer which should have the same state @param activityIds the map which maps scope to activity id @param activityInstanceIds the map which maps scope to activity instance id @param delayedVariableEvent the delayed variable event which should be dispatched
dispatchOnSameActivity
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/pvm/runtime/PvmExecutionImpl.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/pvm/runtime/PvmExecutionImpl.java
Apache-2.0
private boolean isOnDispatchableState(PvmExecutionImpl targetScope) { ActivityImpl targetActivity = targetScope.getActivity(); return //if not leaf, activity id is null -> dispatchable targetScope.getActivityId() == null || // if leaf and not scope -> dispatchable !targetActivity.isScope() || // if leaf, scope and state in default -> dispatchable (targetScope.isInState(ActivityInstanceState.DEFAULT)); }
Checks if the given execution is on a dispatchable state. That means if the current activity is not a leaf in the activity tree OR it is a leaf but not a scope OR it is a leaf, a scope and the execution is in state DEFAULT, which means not in state Starting, Execute or Ending. For this states it is prohibited to trigger conditional events, otherwise unexpected behavior can appear. @return true if the execution is on a dispatchable state, false otherwise
isOnDispatchableState
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/pvm/runtime/PvmExecutionImpl.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/pvm/runtime/PvmExecutionImpl.java
Apache-2.0
private boolean isOnSameActivity(String lastActivityInstanceId, String lastActivityId, String currentActivityInstanceId, String currentActivityId) { return //activityInstanceId's can be null on transitions, so the activityId must be equal ((lastActivityInstanceId == null && lastActivityInstanceId == currentActivityInstanceId && lastActivityId.equals(currentActivityId)) //if activityInstanceId's are not null they must be equal -> otherwise execution changed || (lastActivityInstanceId != null && lastActivityInstanceId.equals(currentActivityInstanceId) && (lastActivityId == null || lastActivityId.equals(currentActivityId)))); }
Compares the given activity instance id's and activity id's to check if the execution is on the same activity as before an operation was executed. The activity instance id's can be null on transitions. In this case the activity Id's have to be equal, otherwise the execution changed. @param lastActivityInstanceId the last activity instance id @param lastActivityId the last activity id @param currentActivityInstanceId the current activity instance id @param currentActivityId the current activity id @return true if the execution is on the same activity, otherwise false
isOnSameActivity
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/pvm/runtime/PvmExecutionImpl.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/pvm/runtime/PvmExecutionImpl.java
Apache-2.0
private String getActivityInstanceId(PvmExecutionImpl targetScope) { if (targetScope.isConcurrent()) { return targetScope.getActivityInstanceId(); } else { ActivityImpl targetActivity = targetScope.getActivity(); if ((targetActivity != null && targetActivity.getActivities().isEmpty())) { return targetScope.getActivityInstanceId(); } else { return targetScope.getParentActivityInstanceId(); } } }
Returns the activity instance id for the given execution. @param targetScope the execution for which the activity instance id should be returned @return the activity instance id
getActivityInstanceId
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/pvm/runtime/PvmExecutionImpl.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/pvm/runtime/PvmExecutionImpl.java
Apache-2.0
public boolean isAsyncAfterScopeWithoutTransition() { return activityInstanceId == null && activity.isScope() && !isActive; }
This case is special, because the execution tree is different if an async after activity is left via transition (case 1) or not (case 2). In case 1, when the execution becomes async, the scope execution is already removed. In case 2 it is not. @return true if <ul> <li>the execution is in asyncAfter state and completes <li>leaves a scope activity <li>completes the parent scope (i.e. does not leave via a transition but propagates control to the parent) </ul>
isAsyncAfterScopeWithoutTransition
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/pvm/runtime/PvmExecutionImpl.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/pvm/runtime/PvmExecutionImpl.java
Apache-2.0
public String getScriptSource(VariableScope variableScope) { return evaluateExpression(variableScope); }
A script which source code is dynamically determined during the execution. Therefore it has to be executed in the context of an atomic operation. @author Sebastian Menski
getScriptSource
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/scripting/DynamicSourceExecutableScript.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/scripting/DynamicSourceExecutableScript.java
Apache-2.0
public String getLanguage() { return language; }
The language in which the script is written. @return the language
getLanguage
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/scripting/ExecutableScript.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/scripting/ExecutableScript.java
Apache-2.0
protected void configureGroovyScriptEngine(ScriptEngine scriptEngine) { // make sure Groovy compiled scripts only hold weak references to java methods scriptEngine.getContext().setAttribute("#jsr223.groovy.engine.keep.globals", "weak", ScriptContext.ENGINE_SCOPE); }
Allows providing custom configuration for the groovy script engine. @param scriptEngine the groovy script engine to configure.
configureGroovyScriptEngine
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/scripting/engine/DefaultScriptEngineResolver.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/scripting/engine/DefaultScriptEngineResolver.java
Apache-2.0
protected void configureGraalJsScriptEngine(ScriptEngine scriptEngine) { ProcessEngineConfigurationImpl config = Context.getProcessEngineConfiguration(); if (config != null) { if (config.isConfigureScriptEngineHostAccess()) { // make sure Graal JS can provide access to the host and can lookup classes scriptEngine.getContext().setAttribute("polyglot.js.allowHostAccess", true, ScriptContext.ENGINE_SCOPE); scriptEngine.getContext().setAttribute("polyglot.js.allowHostClassLookup", true, ScriptContext.ENGINE_SCOPE); } if (config.isEnableScriptEngineLoadExternalResources()) { // make sure Graal JS can load external scripts scriptEngine.getContext().setAttribute("polyglot.js.allowIO", true, ScriptContext.ENGINE_SCOPE); } if (config.isEnableScriptEngineNashornCompatibility()) { // enable Nashorn compatibility mode scriptEngine.getContext().setAttribute("polyglot.js.nashorn-compat", true, ScriptContext.ENGINE_SCOPE); } } }
Allows providing custom configuration for the Graal JS script engine. @param scriptEngine the Graal JS script engine to configure.
configureGraalJsScriptEngine
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/scripting/engine/DefaultScriptEngineResolver.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/scripting/engine/DefaultScriptEngineResolver.java
Apache-2.0
protected List<ExecutableScript> getEnvScripts(String scriptLanguage) { Map<String, List<ExecutableScript>> environment = getEnv(scriptLanguage); List<ExecutableScript> envScripts = environment.get(scriptLanguage); if(envScripts == null) { synchronized (this) { envScripts = environment.get(scriptLanguage); if(envScripts == null) { envScripts = initEnvForLanguage(scriptLanguage); environment.put(scriptLanguage, envScripts); } } } return envScripts; }
Returns the env scripts for the given language. Performs lazy initialization of the env scripts. @param scriptLanguage the language @return a list of executable environment scripts. Never null.
getEnvScripts
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/scripting/env/ScriptingEnvironment.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/scripting/env/ScriptingEnvironment.java
Apache-2.0
protected List<ExecutableScript> initEnvForLanguage(String language) { List<ExecutableScript> scripts = new ArrayList<>(); for (ScriptEnvResolver resolver : envResolvers) { String[] resolvedScripts = resolver.resolve(language); if(resolvedScripts != null) { for (String resolvedScript : resolvedScripts) { scripts.add(scriptFactory.createScriptFromSource(language, resolvedScript)); } } } return scripts; }
Initializes the env scripts for a given language. @param language the language @return the list of env scripts. Never null.
initEnvForLanguage
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/scripting/env/ScriptingEnvironment.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/scripting/env/ScriptingEnvironment.java
Apache-2.0
public static void assertAndEnsureCleanDbAndCache(ProcessEngine processEngine) { assertAndEnsureCleanDbAndCache(processEngine, true); }
Ensures that the deployment cache and database is clean after a test. If not the cache and database will be cleared. @param processEngine the {@link ProcessEngine} to test @throws AssertionError if the deployment cache or database was not clean
assertAndEnsureCleanDbAndCache
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/test/TestHelper.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/test/TestHelper.java
Apache-2.0
public static void assertAndEnsureCleanDeploymentCache(ProcessEngine processEngine) { assertAndEnsureCleanDeploymentCache(processEngine, true); }
Ensures that the deployment cache is empty after a test. If not the cache will be cleared. @param processEngine the {@link ProcessEngine} to test @throws AssertionError if the deployment cache was not clean
assertAndEnsureCleanDeploymentCache
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/test/TestHelper.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/test/TestHelper.java
Apache-2.0
public PvmExecutionImpl getExecutionForScope(PvmScope scope) { return activityExecutionMapping.get(scope); }
@return the mapped execution for scope or <code>null</code>, if no mapping exists
getExecutionForScope
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/tree/ActivityExecutionMappingCollector.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/tree/ActivityExecutionMappingCollector.java
Apache-2.0
protected ScopeImpl nextElement() { ScopeImpl currentElement = getCurrentElement(); if (currentElement != null && ActivityImpl.class.isAssignableFrom(currentElement.getClass())) { return ((PvmActivity) currentElement).getFlowScope(); } else { return null; } }
Walks the flow scope hierarchy upwards @author Thorben Lindhauer
nextElement
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/tree/FlowScopeWalker.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/tree/FlowScopeWalker.java
Apache-2.0
public static int setBitOn(final int value, final int bitNumber) { ensureBitRange(bitNumber); // To turn on, OR with the correct mask return value | MASKS[bitNumber - 1]; }
Set bit to '1' in the given int. @param current integer value @param bitNumber number of the bit to set to '1' (right first bit starting at 1).
setBitOn
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/util/BitMaskUtil.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/util/BitMaskUtil.java
Apache-2.0
public static int setBitOff(int value, int bitNumber) { ensureBitRange(bitNumber); // To turn on, OR with the correct mask return value &~MASKS[bitNumber - 1]; }
Set bit to '0' in the given int. @param current integer value @param bitNumber number of the bit to set to '0' (right first bit starting at 1).
setBitOff
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/util/BitMaskUtil.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/util/BitMaskUtil.java
Apache-2.0
public static boolean isBitOn(int value, int bitNumber) { ensureBitRange(bitNumber); return ((value & MASKS[bitNumber - 1]) == MASKS[bitNumber - 1]); }
Check if the bit is set to '1' @param value integer to check bit @param number of bit to check (right first bit starting at 1)
isBitOn
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/util/BitMaskUtil.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/util/BitMaskUtil.java
Apache-2.0
public static ClassLoader switchToProcessEngineClassloader() { ClassLoader currentClassloader = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(ProcessEngine.class.getClassLoader()); return currentClassloader; }
Switch the current Thread ClassLoader to the ProcessEngine's to assure the loading of the engine classes during job execution. @return the current Thread ClassLoader
switchToProcessEngineClassloader
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/util/ClassLoaderUtil.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/util/ClassLoaderUtil.java
Apache-2.0
public static Map<String, Object> singletonMap(String key, Object value) { Map<String, Object> map = new HashMap<>(); map.put(key, value); return map; }
Helper method that creates a singleton map. Alternative for Collections.singletonMap(), since that method returns a generic typed map <K,T> depending on the input type, but we often need a <String, Object> map.
singletonMap
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/util/CollectionUtil.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/util/CollectionUtil.java
Apache-2.0
public static <T extends Comparable<T>> boolean areNotInAscendingOrder(T... values) { boolean excluding = false; if (values != null) { excluding = areNotInAscendingOrder(Arrays.asList(values)); } return excluding; }
Checks if any of the values are not in an ascending order. The check is done based on the {@link Comparable#compareTo(Object)} method. E.g. if we have {@code minPriority = 10}, {@code priority = 13} and {@code maxPriority = 5} and {@code Integer[] values = {minPriority, priority, maxPriority}}. Then a call to {@link CompareUtil#areNotInAscendingOrder(Comparable[] values)} will return {@code true} @param values to validate @param <T> the type of the comparable @return {@code false} if the not null values are in an ascending order or all the values are null, {@code true} otherwise
areNotInAscendingOrder
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/util/CompareUtil.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/util/CompareUtil.java
Apache-2.0
public static <T extends Comparable<T>> boolean areNotInAscendingOrder(List<T> values) { int lastNotNull = -1; for (int i = 0; i < values.size(); i++) { T value = values.get(i); if (value != null) { if (lastNotNull != -1 && values.get(lastNotNull).compareTo(value) > 0) { return true; } lastNotNull = i; } } return false; }
Checks if any of the values are not in an ascending order. The check is done based on the {@link Comparable#compareTo(Object)} method. E.g. if we have {@code minPriority = 10}, {@code priority = 13} and {@code maxPriority = 5} and {@code List<Integer> values = {minPriority, priority, maxPriority}}. Then a call to {@link CompareUtil#areNotInAscendingOrder(List values)} will return {@code true} @param values to validate @param <T> the type of the comparable @return {@code false} if the not null values are in an ascending order or all the values are null, {@code true} otherwise
areNotInAscendingOrder
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/util/CompareUtil.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/util/CompareUtil.java
Apache-2.0
public static <T> boolean elementIsNotContainedInList(T element, Collection<T> values) { if (element != null && values != null) { return !values.contains(element); } else { return false; } }
Checks if the element is not contained within the list of values. If the element, or the list are null then true is returned. @param element to check @param values to check in @param <T> the type of the element @return {@code true} if the element and values are not {@code null} and the values does not contain the element, {@code false} otherwise
elementIsNotContainedInList
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/util/CompareUtil.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/util/CompareUtil.java
Apache-2.0
public static <T> boolean elementIsNotContainedInArray(T element, T... values) { if (element != null && values != null) { return elementIsNotContainedInList(element, Arrays.asList(values)); } else { return false; } }
Checks if the element is contained within the list of values. If the element, or the list are null then true is returned. @param element to check @param values to check in @param <T> the type of the element @return {@code true} if the element and values are not {@code null} and the values does not contain the element, {@code false} otherwise
elementIsNotContainedInArray
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/util/CompareUtil.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/util/CompareUtil.java
Apache-2.0
public void signalAll() { for (SingleConsumerCondition condition : conditions) { condition.signal(); } }
Composite Condition implementation which allows multiple consumers to subscribe to signals with their own {@link SingleConsumerCondition}.
signalAll
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/util/CompositeCondition.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/util/CompositeCondition.java
Apache-2.0
public static boolean checkDatabaseType(String... databaseTypes) { return checkDatabaseType(Context.getCommandContext().getProcessEngineConfiguration(), databaseTypes); }
Checks if the currently used database is of a given database type. @param databaseTypes to check for @return true if any of the provided types match the used one. Otherwise false.
checkDatabaseType
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/util/DatabaseUtil.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/util/DatabaseUtil.java
Apache-2.0
public static boolean checkDatabaseType(ProcessEngineConfigurationImpl configuration, String... databaseTypes) { String dbType = configuration.getDatabaseType(); return Arrays.stream(databaseTypes).anyMatch(dbType::equals); }
Checks if the currently used database is of a given database type. @param configuration for the Process Engine, when a Context is not available @param databaseTypes to check for @return true if any of the provided types match the used one. Otherwise false.
checkDatabaseType
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/util/DatabaseUtil.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/util/DatabaseUtil.java
Apache-2.0
public static boolean checkDatabaseRollsBackTransactionOnError() { return checkDatabaseType(DbSqlSessionFactory.POSTGRES); }
@return true if the currently used database is known to roll back transactions on SQL errors.
checkDatabaseRollsBackTransactionOnError
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/util/DatabaseUtil.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/util/DatabaseUtil.java
Apache-2.0
@Override public R setValue(R value) { throw new UnsupportedOperationException("setValue not allowed for an ImmutablePair"); }
This is not allowed since the pair itself is immutable. @return never @throws UnsupportedOperationException
setValue
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/util/ImmutablePair.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/util/ImmutablePair.java
Apache-2.0
public static void closeSilently(Closeable closeable) { try { if(closeable != null) { closeable.close(); } } catch(IOException ignore) { LOG.debugCloseException(ignore); } }
Closes the given stream. The same as calling {@link Closeable#close()}, but errors while closing are silently ignored.
closeSilently
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/util/IoUtil.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/util/IoUtil.java
Apache-2.0
public static void flushSilently(Flushable flushable) { try { if(flushable != null) { flushable.flush(); } } catch(IOException ignore) { LOG.debugCloseException(ignore); } }
Flushes the given object. The same as calling {@link Flushable#flush()}, but errors while flushing are silently ignored.
flushSilently
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/util/IoUtil.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/util/IoUtil.java
Apache-2.0
public static String getProductVersion() { // in case the `product-info.properties` file is missing, // try to get the product version from the manifest return INSTANCE.getProperty(VERSION_PROPERTY, ProductPropertiesUtil.class.getPackage().getImplementationVersion()); }
@return the current version of the product (e.g. <code>7.15.0-SNAPSHOT</code>)
getProductVersion
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/util/ProductPropertiesUtil.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/util/ProductPropertiesUtil.java
Apache-2.0
public static Properties getProperties(String propertiesFile) { Properties productProperties = new Properties(); try (InputStream inputStream = ProductPropertiesUtil.class.getResourceAsStream(propertiesFile)) { productProperties.load(inputStream); } catch (IOException | NullPointerException e) { // if `propertiesFile` is null, the file is missing, or an error occurs during reading LOG.logMissingPropertiesFile(propertiesFile); } return productProperties; }
Reads a <code>.properties</code> file from the classpath and provides a {@link Properties} object.
getProperties
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/util/PropertiesUtil.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/util/PropertiesUtil.java
Apache-2.0
public static Field getField(String fieldName, Object object) { return getField(fieldName, object.getClass()); }
Returns the field of the given object or null if it doesnt exist.
getField
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/util/ReflectUtil.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/util/ReflectUtil.java
Apache-2.0
public static Method getSetter(String fieldName, Class<?> clazz, Class<?> fieldType) { String setterName = buildSetterName(fieldName); try { // Using getMathods(), getMathod(...) expects exact parameter type // matching and ignores inheritance-tree. Method[] methods = clazz.getMethods(); for(Method method : methods) { if(method.getName().equals(setterName)) { Class<?>[] paramTypes = method.getParameterTypes(); if(paramTypes != null && paramTypes.length == 1 && paramTypes[0].isAssignableFrom(fieldType)) { return method; } } } return null; } catch (SecurityException e) { throw LOG.unableToAccessMethod(setterName, clazz.getName()); } }
Returns the setter-method for the given field name or null if no setter exists.
getSetter
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/util/ReflectUtil.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/util/ReflectUtil.java
Apache-2.0
public static Method getMethod(Class<?> declaringType, String methodName, Class<?>... parameterTypes) { return findMethod(declaringType, methodName, parameterTypes); }
Finds a method by name and parameter types. @param declaringType the name of the class @param methodName the name of the method to look for @param parameterTypes the types of the parameters
getMethod
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/util/ReflectUtil.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/util/ReflectUtil.java
Apache-2.0
public static boolean resourceIsContainedInArray(Integer resourceTypeId, Resource[] resources) { for (Resource resource : resources) { if (resourceTypeId == resource.resourceType()) { return true; } } return false; }
@return <code>true</code> in case the resource with the provided resourceTypeId is contained by the specified list
resourceIsContainedInArray
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/util/ResourceTypeUtil.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/util/ResourceTypeUtil.java
Apache-2.0
public static Permission[] getPermissionsByResourceType(int givenResourceType) { Class<? extends Enum<? extends Permission>> clazz = PERMISSION_ENUMS.get(givenResourceType); if (clazz == null) { return Permissions.values(); } return ((Permission[]) clazz.getEnumConstants()); }
Retrieves the {@link Permission} array based on the predifined {@link ResourceTypeUtil#PERMISSION_ENUMS PERMISSION_ENUMS}
getPermissionsByResourceType
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/util/ResourceTypeUtil.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/util/ResourceTypeUtil.java
Apache-2.0
public static Permission getPermissionByNameAndResourceType(String permissionName, int resourceType) { for (Permission permission : getPermissionsByResourceType(resourceType)) { if (permission.getName().equals(permissionName)) { return permission; } } throw new BadUserRequestException( String.format("The permission '%s' is not valid for '%s' resource type.", permissionName, getResourceByType(resourceType)) ); }
Currently used only in the Rest API Returns a {@link Permission} based on the specified <code>permissionName</code> and <code>resourceType</code> @throws BadUserRequestException in case the permission is not valid for the specified resource type
getPermissionByNameAndResourceType
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/util/ResourceTypeUtil.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/util/ResourceTypeUtil.java
Apache-2.0
public static Resource getResourceByType(int resourceType) { for (Resource resource : Resources.values()) { if (resource.resourceType() == resourceType) { return resource; } } return null; }
Iterates over the {@link Resources} and returns either the resource with specified <code>resourceType</code> or <code>null</code>.
getResourceByType
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/util/ResourceTypeUtil.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/util/ResourceTypeUtil.java
Apache-2.0
public static ExecutableScript getScript(String language, String source, String resource, ExpressionManager expressionManager) { return getScript(language, source, resource, expressionManager, getScriptFactory()); }
Creates a new {@link ExecutableScript} from a source or resource. It excepts static and dynamic sources and resources. Dynamic means that the source or resource is an expression which will be evaluated during execution. @param language the language of the script @param source the source code of the script or an expression which evaluates to the source code @param resource the resource path of the script code or an expression which evaluates to the resource path @param expressionManager the expression manager to use to generate the expressions of dynamic scripts @return the newly created script @throws NotValidException if language is null or empty or both of source and resource are null or empty
getScript
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/util/ScriptUtil.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/util/ScriptUtil.java
Apache-2.0
public static ExecutableScript getScript(String language, String source, String resource, ExpressionManager expressionManager, ScriptFactory scriptFactory) { ensureNotEmpty(NotValidException.class, "Script language", language); ensureAtLeastOneNotNull(NotValidException.class, "No script source or resource was given", source, resource); if (resource != null && !resource.isEmpty()) { return getScriptFromResource(language, resource, expressionManager, scriptFactory); } else { return getScriptFormSource(language, source, expressionManager, scriptFactory); } }
Creates a new {@link ExecutableScript} from a source or resource. It excepts static and dynamic sources and resources. Dynamic means that the source or resource is an expression which will be evaluated during execution. @param language the language of the script @param source the source code of the script or an expression which evaluates to the source code @param resource the resource path of the script code or an expression which evaluates to the resource path @param expressionManager the expression manager to use to generate the expressions of dynamic scripts @param scriptFactory the script factory used to create the script @return the newly created script @throws NotValidException if language is null or empty or both of source and resource are invalid
getScript
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/util/ScriptUtil.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/util/ScriptUtil.java
Apache-2.0
public static ExecutableScript getScriptFormSource(String language, String source, ExpressionManager expressionManager, ScriptFactory scriptFactory) { ensureNotEmpty(NotValidException.class, "Script language", language); ensureNotNull(NotValidException.class, "Script source", source); if (isDynamicScriptExpression(language, source)) { Expression sourceExpression = expressionManager.createExpression(source); return getScriptFromSourceExpression(language, sourceExpression, scriptFactory); } else { return getScriptFromSource(language, source, scriptFactory); } }
Creates a new {@link ExecutableScript} from a source. It excepts static and dynamic sources. Dynamic means that the source is an expression which will be evaluated during execution. @param language the language of the script @param source the source code of the script or an expression which evaluates to the source code @param expressionManager the expression manager to use to generate the expressions of dynamic scripts @param scriptFactory the script factory used to create the script @return the newly created script @throws NotValidException if language is null or empty or source is null
getScriptFormSource
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/util/ScriptUtil.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/util/ScriptUtil.java
Apache-2.0
public static ExecutableScript getScriptFromSource(String language, String source, ScriptFactory scriptFactory) { ensureNotEmpty(NotValidException.class, "Script language", language); ensureNotNull(NotValidException.class, "Script source", source); return scriptFactory.createScriptFromSource(language, source); }
Creates a new {@link ExecutableScript} from a static source. @param language the language of the script @param source the source code of the script @param scriptFactory the script factory used to create the script @return the newly created script @throws NotValidException if language is null or empty or source is null
getScriptFromSource
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/util/ScriptUtil.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/util/ScriptUtil.java
Apache-2.0
public static ExecutableScript getScriptFromSourceExpression(String language, Expression sourceExpression, ScriptFactory scriptFactory) { ensureNotEmpty(NotValidException.class, "Script language", language); ensureNotNull(NotValidException.class, "Script source expression", sourceExpression); return scriptFactory.createScriptFromSource(language, sourceExpression); }
Creates a new {@link ExecutableScript} from a dynamic source. Dynamic means that the source is an expression which will be evaluated during execution. @param language the language of the script @param sourceExpression the expression which evaluates to the source code @param scriptFactory the script factory used to create the script @return the newly created script @throws NotValidException if language is null or empty or sourceExpression is null
getScriptFromSourceExpression
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/util/ScriptUtil.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/util/ScriptUtil.java
Apache-2.0
public static ExecutableScript getScriptFromResource(String language, String resource, ExpressionManager expressionManager, ScriptFactory scriptFactory) { ensureNotEmpty(NotValidException.class, "Script language", language); ensureNotEmpty(NotValidException.class, "Script resource", resource); if (isDynamicScriptExpression(language, resource)) { Expression resourceExpression = expressionManager.createExpression(resource); return getScriptFromResourceExpression(language, resourceExpression, scriptFactory); } else { return getScriptFromResource(language, resource, scriptFactory); } }
Creates a new {@link ExecutableScript} from a resource. It excepts static and dynamic resources. Dynamic means that the resource is an expression which will be evaluated during execution. @param language the language of the script @param resource the resource path of the script code or an expression which evaluates to the resource path @param expressionManager the expression manager to use to generate the expressions of dynamic scripts @param scriptFactory the script factory used to create the script @return the newly created script @throws NotValidException if language or resource are null or empty
getScriptFromResource
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/util/ScriptUtil.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/util/ScriptUtil.java
Apache-2.0
public static ExecutableScript getScriptFromResource(String language, String resource, ScriptFactory scriptFactory) { ensureNotEmpty(NotValidException.class, "Script language", language); ensureNotEmpty(NotValidException.class, "Script resource", resource); return scriptFactory.createScriptFromResource(language, resource); }
Creates a new {@link ExecutableScript} from a static resource. @param language the language of the script @param resource the resource path of the script code @param scriptFactory the script factory used to create the script @return the newly created script @throws NotValidException if language or resource are null or empty
getScriptFromResource
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/util/ScriptUtil.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/util/ScriptUtil.java
Apache-2.0
public static ExecutableScript getScriptFromResourceExpression(String language, Expression resourceExpression, ScriptFactory scriptFactory) { ensureNotEmpty(NotValidException.class, "Script language", language); ensureNotNull(NotValidException.class, "Script resource expression", resourceExpression); return scriptFactory.createScriptFromResource(language, resourceExpression); }
Creates a new {@link ExecutableScript} from a dynamic resource. Dynamic means that the source is an expression which will be evaluated during execution. @param language the language of the script @param resourceExpression the expression which evaluates to the resource path @param scriptFactory the script factory used to create the script @return the newly created script @throws NotValidException if language is null or empty or resourceExpression is null
getScriptFromResourceExpression
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/util/ScriptUtil.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/util/ScriptUtil.java
Apache-2.0
public static boolean isDynamicScriptExpression(String language, String value) { return StringUtil.isExpression(value) && (language != null && !JuelScriptEngineFactory.names.contains(language.toLowerCase())); }
Checks if the value is an expression for a dynamic script source or resource. @param language the language of the script @param value the value to check @return true if the value is an expression for a dynamic script source/resource, otherwise false
isDynamicScriptExpression
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/util/ScriptUtil.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/util/ScriptUtil.java
Apache-2.0
public static ScriptFactory getScriptFactory() { ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration(); if (processEngineConfiguration != null) { return processEngineConfiguration.getScriptFactory(); } else { return new ScriptFactory(); } }
Returns the configured script factory in the context or a new one.
getScriptFactory
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/util/ScriptUtil.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/util/ScriptUtil.java
Apache-2.0
public void await(long millis) { if (Thread.currentThread() != consumer) { throw new RuntimeException("Wrong usage of SingleConsumerCondition: can only await in consumer thread."); } // NOTE: may spuriously return before deadline LockSupport.parkNanos(TimeUnit.MILLISECONDS.toNanos(millis)); }
MPSC Condition implementation. <p> Implementation Notes: <ul> <li>{@link #await(long)} may spuriously return before the deadline is reached.</li> <li>if {@link #signal()} is called before the consumer thread calls {@link #await(long)}, the next call to {@link #await(long)} returns immediately.</li> </ul>
await
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/util/SingleConsumerCondition.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/util/SingleConsumerCondition.java
Apache-2.0
public static boolean isExpression(String text) { text = text.trim(); return text.startsWith("${") || text.startsWith("#{"); }
Checks whether a {@link String} seams to be an expression or not Note: In most cases you should check for composite expressions. See {@link #isCompositeExpression(String, ExpressionManager)} for more information. @param text the text to check @return true if the text seams to be an expression false otherwise
isExpression
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/util/StringUtil.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/util/StringUtil.java
Apache-2.0
public static String fromBytes(byte[] bytes) { EnsureUtil.ensureActiveCommandContext("StringUtil.fromBytes"); ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration(); return fromBytes(bytes, processEngineConfiguration.getProcessEngine()); }
Converts a byte array into a string using the current process engines default charset as returned by {@link ProcessEngineConfigurationImpl#getDefaultCharset()}. The converted string is empty if the provided byte array is empty or <code>null</code>. @param bytes the byte array @return a string representing the bytes, empty String if byte array is <code>null</code>
fromBytes
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/util/StringUtil.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/util/StringUtil.java
Apache-2.0
public static byte[] toByteArray(String string) { EnsureUtil.ensureActiveCommandContext("StringUtil.toByteArray"); ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration(); return toByteArray(string, processEngineConfiguration.getProcessEngine()); }
Gets the bytes from a string using the current process engine's default charset @param string the string to get the bytes form @return the byte array
toByteArray
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/util/StringUtil.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/util/StringUtil.java
Apache-2.0
public static byte[] toByteArray(String string, ProcessEngine processEngine) { ProcessEngineConfigurationImpl processEngineConfiguration = ((ProcessEngineImpl) processEngine).getProcessEngineConfiguration(); Charset charset = processEngineConfiguration.getDefaultCharset(); return string.getBytes(charset); }
Gets the bytes from a string using the provided process engine's default charset @param string the string to get the bytes form @param processEngine the process engine to use @return the byte array
toByteArray
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/util/StringUtil.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/util/StringUtil.java
Apache-2.0
public String getText() { return text.toString(); }
Due to the nature of SAX parsing, sometimes the characters of an element are not processed at once. So instead of a setText operation, we need to have an appendText operation.
getText
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/util/xml/Element.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/util/xml/Element.java
Apache-2.0
public void collectIds(List<String> ids) { ids.add(attribute("id")); for (Element child : elements) { child.collectIds(ids); } }
allows to recursively collect the ids of all elements in the tree.
collectIds
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/util/xml/Element.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/util/xml/Element.java
Apache-2.0
protected Object deserializeFromByteArray(byte[] object, ValueFields valueFields) throws Exception { String objectTypeName = readObjectNameFromFields(valueFields); return deserializeFromByteArray(object, objectTypeName); }
Implementations must return a byte[] representation of the provided object. The object is guaranteed not to be null. @param deserializedObject the object to serialize @return the byte array value of the object @throws exception in case the object cannot be serialized
deserializeFromByteArray
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/impl/variable/serializer/AbstractObjectValueSerializer.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/variable/serializer/AbstractObjectValueSerializer.java
Apache-2.0
public long getTotal() { return total; }
@return the total rowcount of the table from which this page is only a subset.
getTotal
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/management/TablePage.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/management/TablePage.java
Apache-2.0
public long getSize() { return rowData.size(); }
@return the actual number of rows in this page.
getSize
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/management/TablePage.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/management/TablePage.java
Apache-2.0
public MigratingProcessInstanceValidationReport getValidationReport() { return validationReport; }
A report with all instructions that cannot be applied to the given process instance
getValidationReport
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/migration/MigratingProcessInstanceValidationException.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/migration/MigratingProcessInstanceValidationException.java
Apache-2.0
public static Map<String, Object> getMocks() { Map<String, Object> mocks = mockContainer.get(); if (mocks == null) { mocks = new HashMap<String, Object>(); Mocks.mockContainer.set(mocks); } return mocks; }
Registry for mock objects. <p>Usage: <code>Mocks.register("myMock", myMock);</code></p> <p>This class lets you register mock objects that will then be used by the {@link MockElResolver}. It binds a map of mock objects to ThreadLocal. This way, the mocks can be set up independent of how the process engine configuration is built.</p> @author Nils Preusker - n.preusker@gmail.com
getMocks
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/test/mock/Mocks.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/test/mock/Mocks.java
Apache-2.0
public static void register(String key, Object value) { getMocks().put(key, value); }
This method lets you register a mock object. Make sure to register the {@link MockExpressionManager} with your process engine configuration. @param key the key under which the mock object will be registered @param value the mock object
register
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/test/mock/Mocks.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/test/mock/Mocks.java
Apache-2.0
public static Object get(Object key) { return getMocks().get(key); }
This method returns the mock object registered under the provided key or null if there is no object for the provided key. @param key the key of the requested object @return the mock object registered under the provided key or null if there is no object for the provided key
get
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/test/mock/Mocks.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/test/mock/Mocks.java
Apache-2.0
public static void reset() { if (getMocks() != null) { getMocks().clear(); } }
This method resets the internal map of mock objects.
reset
java
camunda/camunda-bpm-platform
engine/src/main/java/org/camunda/bpm/engine/test/mock/Mocks.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/test/mock/Mocks.java
Apache-2.0
@Test public void testDefaultValues() { ProcessesXml emptyProcessesXml = ProcessesXml.EMPTY_PROCESSES_XML; assertNotNull(emptyProcessesXml); assertNotNull(emptyProcessesXml.getProcessEngines()); assertEquals(0, emptyProcessesXml.getProcessEngines().size()); assertNotNull(emptyProcessesXml.getProcessArchives()); assertEquals(1, emptyProcessesXml.getProcessArchives().size()); ProcessArchiveXml processArchiveXml = emptyProcessesXml.getProcessArchives().get(0); assertNull(processArchiveXml.getName()); assertNull(processArchiveXml.getProcessEngineName()); assertNotNull(processArchiveXml.getProcessResourceNames()); assertEquals(0, processArchiveXml.getProcessResourceNames().size()); Map<String, String> properties = processArchiveXml.getProperties(); assertNotNull(properties); assertEquals(4, properties.size()); String isDeleteUponUndeploy = properties.get(ProcessArchiveXml.PROP_IS_DELETE_UPON_UNDEPLOY); assertNotNull(isDeleteUponUndeploy); assertEquals(Boolean.FALSE.toString(), isDeleteUponUndeploy); String isScanForProcessDefinitions = properties.get(ProcessArchiveXml.PROP_IS_SCAN_FOR_PROCESS_DEFINITIONS); assertNotNull(isScanForProcessDefinitions); assertEquals(Boolean.TRUE.toString(), isScanForProcessDefinitions); String isDeployChangedOnly = properties.get(ProcessArchiveXml.PROP_IS_DEPLOY_CHANGED_ONLY); assertNotNull(isDeployChangedOnly); assertEquals(Boolean.FALSE.toString(), isDeployChangedOnly); String resumePreviousBy = properties.get(ProcessArchiveXml.PROP_RESUME_PREVIOUS_BY); assertThat(resumePreviousBy).isNotNull(); assertThat(resumePreviousBy).isSameAs(ResumePreviousBy.RESUME_BY_PROCESS_DEFINITION_KEY); }
<p>Testcase verifying the default properties in the empty processes.xml</p> @author Daniel Meyer
testDefaultValues
java
camunda/camunda-bpm-platform
engine/src/test/java/org/camunda/bpm/application/impl/deployment/EmptyProcessesXmlTest.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/test/java/org/camunda/bpm/application/impl/deployment/EmptyProcessesXmlTest.java
Apache-2.0
@Test public void testCallActivityOutputExpression() { // given an instance of the calling process that calls the called process ProcessInstance instance = runtimeService.startProcessInstanceByKey("callingProcess"); // when the called process is completed Task calledProcessTask = taskService.createTaskQuery().singleResult(); taskService.complete(calledProcessTask.getId()); // then the output mapping should have successfully resolved the expression String outVariable = (String) runtimeService.getVariable(instance.getId(), "outVar"); assertEquals(CalledProcessApplication.STRING_VARIABLE_VALUE, outVariable); }
Tests that an expression for a call activity output parameter is resolved in the context of the called process definition's application.
testCallActivityOutputExpression
java
camunda/camunda-bpm-platform
engine/src/test/java/org/camunda/bpm/application/impl/el/ProcessApplicationElResolverTest.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/test/java/org/camunda/bpm/application/impl/el/ProcessApplicationElResolverTest.java
Apache-2.0
@Test public void testCallActivityConditionalOutgoingFlow() { // given an instance of the calling process that calls the called process runtimeService.startProcessInstanceByKey("callingProcessConditionalFlow"); // when the called process is completed Task calledProcessTask = taskService.createTaskQuery().singleResult(); taskService.complete(calledProcessTask.getId()); // then the conditional flow expression was resolved in the context of the calling process application, so // the following task has been reached successfully Task afterCallActivityTask = taskService.createTaskQuery().singleResult(); assertNotNull(afterCallActivityTask); assertEquals("afterCallActivityTask", afterCallActivityTask.getTaskDefinitionKey()); }
Tests that an expression on an outgoing flow leaving a call activity is resolved in the context of the calling process definition's application.
testCallActivityConditionalOutgoingFlow
java
camunda/camunda-bpm-platform
engine/src/test/java/org/camunda/bpm/application/impl/el/ProcessApplicationElResolverTest.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/test/java/org/camunda/bpm/application/impl/el/ProcessApplicationElResolverTest.java
Apache-2.0
@Test public void testDeleteBatchCascade() { // given ProcessInstance processInstance = engineRule.getRuntimeService().startProcessInstanceById(migrationPlan.getSourceProcessDefinitionId()); batch = engineRule .getRuntimeService() .newMigration(migrationPlan) .processInstanceIds(Arrays.asList(processInstance.getId())) .executeAsync(); // when authRule .init(scenario) .withUser("userId") .bindResource("batchId", batch.getId()) .start(); cascade = true; engineRule.getManagementService().deleteBatch(batch.getId(), cascade); // then if (authRule.assertScenario(scenario)) { Assert.assertEquals(0, engineRule.getManagementService().createBatchQuery().count()); Assert.assertEquals(0, engineRule.getHistoryService().createHistoricBatchQuery().count()); UserOperationLogQuery query = engineRule.getHistoryService() .createUserOperationLogQuery(); List<UserOperationLogEntry> userOperationLogEntries = query.operationType(OPERATION_TYPE_DELETE) .batchId(batch.getId()) .list(); assertEquals(1, userOperationLogEntries.size()); UserOperationLogEntry entry = userOperationLogEntries.get(0); assertEquals("cascadeToHistory", entry.getProperty()); assertEquals("true", entry.getNewValue()); assertEquals(CATEGORY_OPERATOR, entry.getCategory()); // Ensure that HistoricBatch deletion is not logged List<UserOperationLogEntry> userOperationLogHistoricEntries = query.operationType(OPERATION_TYPE_DELETE_HISTORY) .batchId(batch.getId()) .list(); assertEquals(0, userOperationLogHistoricEntries.size()); } }
Requires no additional DELETE_HISTORY authorization => consistent with deleteDeployment
testDeleteBatchCascade
java
camunda/camunda-bpm-platform
engine/src/test/java/org/camunda/bpm/engine/test/api/authorization/batch/DeleteBatchAuthorizationTest.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/test/java/org/camunda/bpm/engine/test/api/authorization/batch/DeleteBatchAuthorizationTest.java
Apache-2.0
@Test @Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml") public void testCompleteExternalTask() { // given ProcessInstance processInstance = engineRule.getRuntimeService().startProcessInstanceByKey("oneExternalTaskProcess"); List<LockedExternalTask> tasks = engineRule.getExternalTaskService() .fetchAndLock(5, "workerId") .topic("externalTaskTopic", 5000L) .execute(); LockedExternalTask task = tasks.get(0); // when authRule .init(scenario) .withUser("userId") .bindResource("processInstanceId", processInstance.getId()) .bindResource("processDefinitionKey", "oneExternalTaskProcess") .start(); testExternalTaskApi(task); // then if (authRule.assertScenario(scenario)) { assertExternalTaskResults(); } }
Represents a base class for authorization test cases to handle an already locked (single) external task. @author Christopher Zell <christopher.zell@camunda.com>
testCompleteExternalTask
java
camunda/camunda-bpm-platform
engine/src/test/java/org/camunda/bpm/engine/test/api/authorization/externaltask/HandleLockedExternalTaskAuthorizationTest.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/test/java/org/camunda/bpm/engine/test/api/authorization/externaltask/HandleLockedExternalTaskAuthorizationTest.java
Apache-2.0
public boolean assertScenario(AuthorizationScenario scenario) { interceptor.deactivate(); disableAuthorization(); scenarioInstance.tearDown(engineRule.getAuthorizationService()); scenarioInstance.assertAuthorizationException(interceptor.getLastException()); scenarioInstance = null; return scenarioSucceeded(); }
Assert the scenario conditions. If no exception or the expected one was thrown. @param scenario the scenario to assert on @return true if no exception was thrown, false otherwise
assertScenario
java
camunda/camunda-bpm-platform
engine/src/test/java/org/camunda/bpm/engine/test/api/authorization/util/AuthorizationTestRule.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/test/java/org/camunda/bpm/engine/test/api/authorization/util/AuthorizationTestRule.java
Apache-2.0
public static void assertExceptionInfo(String expectedPermissionName, String expectedResourceName, String expectedResourceId, MissingAuthorization info) { assertEquals(expectedPermissionName, info.getViolatedPermissionName()); assertEquals(expectedResourceName, info.getResourceType()); assertEquals(expectedResourceId, info.getResourceId()); }
Checks if the info has the expected parameters. @param expectedPermissionName to use @param expectedResourceName to use @param expectedResourceId to use @param info to check
assertExceptionInfo
java
camunda/camunda-bpm-platform
engine/src/test/java/org/camunda/bpm/engine/test/api/authorization/util/AuthorizationTestUtil.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/test/java/org/camunda/bpm/engine/test/api/authorization/util/AuthorizationTestUtil.java
Apache-2.0
public static Permission[] getPermissions(Authorization authorization) { int resourceType = authorization.getResourceType(); Permission[] permissionsByResourceType = ResourceTypeUtil.getPermissionsByResourceType(resourceType); return authorization.getPermissions(permissionsByResourceType); }
@return the set of permission for the given authorization
getPermissions
java
camunda/camunda-bpm-platform
engine/src/test/java/org/camunda/bpm/engine/test/api/authorization/util/AuthorizationTestUtil.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/test/java/org/camunda/bpm/engine/test/api/authorization/util/AuthorizationTestUtil.java
Apache-2.0
@Override public <T> Cache<String, T> createCache(int maxNumberOfElementsInCache) { return new MyCacheImplementation<String, T>(maxNumberOfElementsInCache); }
Uses the concurrent least recently used cache from camunda commons. @author Johannes Heinemann
createCache
java
camunda/camunda-bpm-platform
engine/src/test/java/org/camunda/bpm/engine/test/api/cfg/MyCacheFactory.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/test/java/org/camunda/bpm/engine/test/api/cfg/MyCacheFactory.java
Apache-2.0
@Test public void testTaskQueryLookupByDescriptionCaseInsensitive() { TaskQuery query = taskService.createTaskQuery(); query.taskDescription("description 1"); saveQuery(query); List<Task> tasks = filterService.list(filter.getId()); assertNotNull(tasks); assertThat(tasks).hasSize(1); query = taskService.createTaskQuery(); query.taskDescription("dEscription 2"); saveQuery(query); tasks = filterService.list(filter.getId()); assertNotNull(tasks); assertThat(tasks).hasSize(1); }
CAM-12186 Verify that search by description returns case insensitive results
testTaskQueryLookupByDescriptionCaseInsensitive
java
camunda/camunda-bpm-platform
engine/src/test/java/org/camunda/bpm/engine/test/api/filter/FilterTaskQueryTest.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/test/java/org/camunda/bpm/engine/test/api/filter/FilterTaskQueryTest.java
Apache-2.0
@Override public boolean checkPassword(final String userId, final String password) { // Create and Save a User final User user = super.createNewUser(userId); user.setPassword(password); super.saveUser(user); // Create and Save a Group final String groupId = userId+"_group"; final Group group = super.createNewGroup(groupId); group.setName(groupId); super.saveGroup(group); // Create the corresponding Membership super.createMembership(userId, groupId); return super.checkPassword(userId, password); }
To create a testcase, that tests the write a Member/Group/Membership in on step, an entry Point into the write option within the same Command Context is needed. This is done by extending the to-test class and overriding a not in scope Method. This Method will trigger the write of Member/Group/Membership in one step. <br><br> The Group will be the userId extended by _group <br><br> The checkPassword method must return true, because exactly the requested user with the requested Password will be created within this Method @author Simon Jonischkeit
checkPassword
java
camunda/camunda-bpm-platform
engine/src/test/java/org/camunda/bpm/engine/test/api/identity/plugin/TestDbIdentityServiceProviderExtension.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/test/java/org/camunda/bpm/engine/test/api/identity/plugin/TestDbIdentityServiceProviderExtension.java
Apache-2.0
@Test public void testTimestampIsInCorrectTimezone() { //given generated metric data started at DEFAULT_INTERVAL ends at 3 * DEFAULT_INTERVAL //when metric query is executed (hint last interval is returned as first) List<MetricIntervalValue> metrics = managementService.createMetricsQuery().limit(1).interval(); //then metric interval time should be less than FIRST_INTERVAL + 3 * DEFAULT_INTERVAL long metricIntervalTime = metrics.get(0).getTimestamp().getTime(); Assert.assertTrue(metricIntervalTime < firstInterval.plusMinutes(3 * DEFAULT_INTERVAL).getMillis()); //and larger than first interval time, if not than we have a timezone problem Assert.assertTrue(metricIntervalTime > firstInterval.getMillis()); //when current time is used and metric is reported Date currentTime = new Date(); MetricsRegistry metricsRegistry = processEngineConfiguration.getMetricsRegistry(); ClockUtil.setCurrentTime(currentTime); metricsRegistry.markOccurrence(ACTIVTY_INSTANCE_START, 1); processEngineConfiguration.getDbMetricsReporter().reportNow(); //then current time should be larger than metric interval time List<MetricIntervalValue> m2 = managementService.createMetricsQuery().limit(1).interval(); Assert.assertTrue(m2.get(0).getTimestamp().getTime() < currentTime.getTime()); }
Represents a test suite for the metrics interval query to check if the timestamps are read in a correct time zone. This was a problem before the column MILLISECONDS_ was added. @author Christopher Zell <christopher.zell@camunda.com>
testTimestampIsInCorrectTimezone
java
camunda/camunda-bpm-platform
engine/src/test/java/org/camunda/bpm/engine/test/api/mgmt/metrics/MetricsIntervalTimezoneTest.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/test/java/org/camunda/bpm/engine/test/api/mgmt/metrics/MetricsIntervalTimezoneTest.java
Apache-2.0
@Test public void testBatchTenantIdCase1() { // given Batch batch = batchHelper.migrateProcessInstanceAsync(sharedDefinition, sharedDefinition); // then Assert.assertNull(batch.getTenantId()); }
Source: no tenant id Target: no tenant id
testBatchTenantIdCase1
java
camunda/camunda-bpm-platform
engine/src/test/java/org/camunda/bpm/engine/test/api/multitenancy/MultiTenancyBatchTest.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/test/java/org/camunda/bpm/engine/test/api/multitenancy/MultiTenancyBatchTest.java
Apache-2.0
@Test public void testBatchTenantIdCase2() { // given Batch batch = batchHelper.migrateProcessInstanceAsync(tenant1Definition, sharedDefinition); // then Assert.assertEquals(TENANT_ONE, batch.getTenantId()); }
Source: tenant 1 Target: no tenant id
testBatchTenantIdCase2
java
camunda/camunda-bpm-platform
engine/src/test/java/org/camunda/bpm/engine/test/api/multitenancy/MultiTenancyBatchTest.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/test/java/org/camunda/bpm/engine/test/api/multitenancy/MultiTenancyBatchTest.java
Apache-2.0
private static boolean isIdGreaterThan(String id1, String id2) { return id1.compareTo(id2) > 0; }
Compares two ids @param id1 @param id2 @return true if id1 is greater than id2, false otherwise
isIdGreaterThan
java
camunda/camunda-bpm-platform
engine/src/test/java/org/camunda/bpm/engine/test/api/queries/QueryByIdAfterTest.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/test/java/org/camunda/bpm/engine/test/api/queries/QueryByIdAfterTest.java
Apache-2.0
@SuppressWarnings("unused") private static void writeToFile(InputStream is, File file) throws Exception { DataOutputStream out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(file))); int c; while((c = is.read()) != -1) { out.writeByte(c); } is.close(); out.close(); }
Might be used for debugging {@link ProcessDiagramRetrievalTest#testGetProcessDiagram()}.
writeToFile
java
camunda/camunda-bpm-platform
engine/src/test/java/org/camunda/bpm/engine/test/api/repository/diagram/ProcessDiagramRetrievalTest.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/test/java/org/camunda/bpm/engine/test/api/repository/diagram/ProcessDiagramRetrievalTest.java
Apache-2.0
public int compare(DiagramNode o1, DiagramNode o2) { if(o1.getId() == null) { return 0; } return o1.getId().compareTo(o2.getId()); }
sorts {@link DiagramNode DiagramNodes} by ID
compare
java
camunda/camunda-bpm-platform
engine/src/test/java/org/camunda/bpm/engine/test/api/repository/diagram/ProcessDiagramRetrievalTest.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/test/java/org/camunda/bpm/engine/test/api/repository/diagram/ProcessDiagramRetrievalTest.java
Apache-2.0
@Deployment(resources = { SIMPLE_SUBPROCESS, TWO_SUBPROCESSES }) @Test public void testSingleCancellationWithTwoSubProcess() { // given ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("callTwoSubProcesses"); List<ProcessInstance> instanceList = runtimeService.createProcessInstanceQuery().list(); assertNotNull(instanceList); assertEquals(3, instanceList.size()); List<Task> taskList = taskService.createTaskQuery().list(); assertNotNull(taskList); assertEquals(2, taskList.size()); List<String> activeActivityIds = runtimeService.getActiveActivityIds(processInstance.getProcessInstanceId()); assertNotNull(activeActivityIds); assertEquals(2, activeActivityIds.size()); ActivityInstance tree = runtimeService.getActivityInstance(taskList.get(0).getProcessInstanceId()); // when runtimeService .createProcessInstanceModification(taskList.get(0).getProcessInstanceId()) .cancelActivityInstance(getInstanceIdForActivity(tree, "task")) .execute(); // then // How many process Instances instanceList = runtimeService.createProcessInstanceQuery().list(); assertNotNull(instanceList); assertEquals(2, instanceList.size()); // How man call activities activeActivityIds = runtimeService.getActiveActivityIds(processInstance.getProcessInstanceId()); assertNotNull(activeActivityIds); assertEquals(1, activeActivityIds.size()); }
Test case for checking cancellation of process instances in call activity subprocesses Test that upward cancellation respects other process instances
testSingleCancellationWithTwoSubProcess
java
camunda/camunda-bpm-platform
engine/src/test/java/org/camunda/bpm/engine/test/api/runtime/ProcessInstanceModificationCancellationTest.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/test/java/org/camunda/bpm/engine/test/api/runtime/ProcessInstanceModificationCancellationTest.java
Apache-2.0
public static ModifiableBpmnModelInstance modify(BpmnModelInstance modelInstance) { return new ModifiableBpmnModelInstance(modelInstance.clone()); }
Copies the argument; following modifications are not applied to the original model instance
modify
java
camunda/camunda-bpm-platform
engine/src/test/java/org/camunda/bpm/engine/test/api/runtime/migration/ModifiableBpmnModelInstance.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/test/java/org/camunda/bpm/engine/test/api/runtime/migration/ModifiableBpmnModelInstance.java
Apache-2.0
@Test public void testTaskQueryAuthorization() { // given engineTestRule.deploy("org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml"); engineTestRule.deploy("org/camunda/bpm/engine/test/api/twoTasksProcess.bpmn20.xml"); // a process instance task with read authorization on the process ProcessInstance instance1 = runtimeService.startProcessInstanceByKey("oneTaskProcess"); Task instance1Task = taskService.createTaskQuery().processInstanceId(instance1.getId()).singleResult(); Authorization processInstanceAuthorization = authorizationService.createNewAuthorization(Authorization.AUTH_TYPE_GRANT); processInstanceAuthorization.setResource(Resources.PROCESS_DEFINITION); processInstanceAuthorization.setResourceId("oneTaskProcess"); processInstanceAuthorization.addPermission(ProcessDefinitionPermissions.READ_TASK); processInstanceAuthorization.setUserId("user"); authorizationService.saveAuthorization(processInstanceAuthorization); // a process instance task with read authorization on the task ProcessInstance instance2 = runtimeService.startProcessInstanceByKey("twoTasksProcess"); Task instance2Task = taskService.createTaskQuery().processInstanceId(instance2.getId()).singleResult(); Authorization standaloneTaskAuthorization = authorizationService.createNewAuthorization(Authorization.AUTH_TYPE_GRANT); standaloneTaskAuthorization.setResource(Resources.TASK); standaloneTaskAuthorization.setResourceId(instance2Task.getId()); standaloneTaskAuthorization.addPermission(TaskPermissions.READ); standaloneTaskAuthorization.setUserId("user"); authorizationService.saveAuthorization(standaloneTaskAuthorization); // a third task for which we have no authorization runtimeService.startProcessInstanceByKey("twoTasksProcess"); identityService.setAuthenticatedUserId("user"); engineRule.getProcessEngineConfiguration().setAuthorizationEnabled(true); // when List<Task> tasks = taskService.createTaskQuery().list(); // then assertThat(tasks).extracting("id").containsExactlyInAnyOrder(instance1Task.getId(), instance2Task.getId()); }
In this scenario (cmmn and standalone tasks) we want to perform an INNER JOIN on the process definition table. While the test cannot assert this, it makes sure that the query generally works in this case.
testTaskQueryAuthorization
java
camunda/camunda-bpm-platform
engine/src/test/java/org/camunda/bpm/engine/test/api/task/StandaloneTasksAndCmmnDisabledTest.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/test/java/org/camunda/bpm/engine/test/api/task/StandaloneTasksAndCmmnDisabledTest.java
Apache-2.0
@Test public void testQueryExcludeSubtasksSorted() throws Exception { // query all tasks, including subtasks TaskQuery query = taskService.createTaskQuery().orderByTaskAssignee().asc(); assertEquals(10, query.count()); assertEquals(10, query.list().size()); // query only parent tasks (exclude subtasks) query = taskService.createTaskQuery().excludeSubtasks().orderByTaskAssignee().desc(); assertEquals(3, query.count()); assertEquals(3, query.list().size()); }
test for task inclusion/exclusion (no other filters, order by task assignee )
testQueryExcludeSubtasksSorted
java
camunda/camunda-bpm-platform
engine/src/test/java/org/camunda/bpm/engine/test/api/task/SubTaskQueryTest.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/test/java/org/camunda/bpm/engine/test/api/task/SubTaskQueryTest.java
Apache-2.0
protected void adjustTime(int amount) { long time = now().getTime() + amount * 1000; setTime(time); }
Changes the current time about the given amount in seconds. @param amount the amount to adjust the current time
adjustTime
java
camunda/camunda-bpm-platform
engine/src/test/java/org/camunda/bpm/engine/test/api/task/TaskQueryExpressionTest.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/test/java/org/camunda/bpm/engine/test/api/task/TaskQueryExpressionTest.java
Apache-2.0
protected void startDefaultCaseWithVariable(Object variableValue, String variableName) { String caseDefinitionId = getCaseDefinitionId(); createCaseWithVariable(caseDefinitionId, variableValue, variableName); }
Starts the one deployed case at the point of the manual activity PI_HumanTask_1 with the given variable.
startDefaultCaseWithVariable
java
camunda/camunda-bpm-platform
engine/src/test/java/org/camunda/bpm/engine/test/api/task/TaskQueryTest.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/test/java/org/camunda/bpm/engine/test/api/task/TaskQueryTest.java
Apache-2.0
protected String getCaseDefinitionId() { String caseDefinitionId = repositoryService .createCaseDefinitionQuery() .singleResult() .getId(); return caseDefinitionId; }
@return the case definition id if only one case is deployed.
getCaseDefinitionId
java
camunda/camunda-bpm-platform
engine/src/test/java/org/camunda/bpm/engine/test/api/task/TaskQueryTest.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/test/java/org/camunda/bpm/engine/test/api/task/TaskQueryTest.java
Apache-2.0
@Deployment(resources = "org/camunda/bpm/engine/test/api/variables/ImplicitVariableUpdateTest.sequence.bpmn20.xml") @Test public void testSerialization() { ProcessInstance instance = runtimeService.startProcessInstanceByKey("serviceTaskProcess", Variables.createVariables() .putValue("pojo", new Pojo(1)) .putValue("delegate", new NoopDelegate())); // at this point, the value of Pojo.foo = 1 in database. Pojo.shouldUpdateFoo = true; // implicitly update the value of 'foo' during deserialization. // will read foo = 1 from database but increment it to 2 during deserialization. Pojo pojo1 = (Pojo) runtimeService.getVariable(instance.getId(), "pojo"); // foo = 2 assertThat(pojo1.getFoo()).isEqualTo(2); // at this point, the database still has value of foo as 1 because implicit update detection is disabled. // i.e : ProcessEngineConfiguration.implicitVariableUpdateDetectionEnabled = false Pojo.shouldUpdateFoo = false; // turn off the implicit update of 'foo' // read foo again from database Pojo pojo2 = (Pojo) runtimeService.getVariable(instance.getId(), "pojo"); // foo = 1 was fetched from database assertThat(pojo2.getFoo()).isEqualTo(1); }
In addition to the previous test cases, this method ensures that the variable is also not implicitly updated when only the serialized value changes (without explicit instructions to change the object)
testSerialization
java
camunda/camunda-bpm-platform
engine/src/test/java/org/camunda/bpm/engine/test/api/variables/ImplicitVariableUpdateDisabledTest.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/test/java/org/camunda/bpm/engine/test/api/variables/ImplicitVariableUpdateDisabledTest.java
Apache-2.0
@Deployment(resources = "org/camunda/bpm/engine/test/api/variables/ImplicitVariableUpdateTest.sequence.bpmn20.xml") @Test public void testSerialization() { ProcessInstance instance = runtimeService.startProcessInstanceByKey("serviceTaskProcess", Variables.createVariables() .putValue("pojo", new Pojo(1)) .putValue("delegate", new NoopDelegate())); // at this point, the value of Pojo.foo = 1 in database. Pojo.shouldUpdateFoo = true; // implicitly update the value of 'foo' during deserialization. // will read foo = 1 from database but increment it to 2 during deserialization. Pojo pojo1 = (Pojo) runtimeService.getVariable(instance.getId(), "pojo"); // foo = 2 assertThat(pojo1.getFoo()).isEqualTo(2); // at this point, the database has value of foo = 2 since the implicit update was detected and flushed. Pojo.shouldUpdateFoo = false; // turn off implicit update of 'foo' // read foo again from database Pojo pojo2 = (Pojo) runtimeService.getVariable(instance.getId(), "pojo"); // foo = 2 was fetched from database assertThat(pojo2.getFoo()).isEqualTo(2); }
In addition to the previous test cases, this method ensures that the variable is also implicitly updated when only the serialized value changes (without explicit instructions to change the object)
testSerialization
java
camunda/camunda-bpm-platform
engine/src/test/java/org/camunda/bpm/engine/test/api/variables/ImplicitVariableUpdateTest.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/test/java/org/camunda/bpm/engine/test/api/variables/ImplicitVariableUpdateTest.java
Apache-2.0
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/callactivity/CallActivity.testSubProcessLimitedDataInputOutputTypedApi.bpmn20.xml", "org/camunda/bpm/engine/test/bpmn/callactivity/simpleSubProcess.bpmn20.xml"}) @Test public void testSubProcessWithLimitedDataInputOutputTypedApi() { TypedValue superVariable = Variables.stringValue(null); VariableMap vars = Variables.createVariables(); vars.putValueTyped("superVariable", superVariable); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("subProcessDataInputOutput", vars); // one task in the subprocess should be active after starting the process instance TaskQuery taskQuery = taskService.createTaskQuery(); Task taskInSubProcess = taskQuery.singleResult(); assertThat(taskInSubProcess.getName()).isEqualTo("Task in subprocess"); assertThat(runtimeService.<TypedValue>getVariableTyped(taskInSubProcess.getProcessInstanceId(), "subVariable")).isEqualTo(superVariable); assertThat(taskService.<TypedValue>getVariableTyped(taskInSubProcess.getId(), "subVariable")).isEqualTo(superVariable); TypedValue subVariable = Variables.stringValue(null); runtimeService.setVariable(taskInSubProcess.getProcessInstanceId(), "subVariable", subVariable); // super variable is unchanged assertThat(runtimeService.<TypedValue>getVariableTyped(processInstance.getId(), "superVariable")).isEqualTo(superVariable); // Completing this task ends the subprocess which leads to a task in the super process taskService.complete(taskInSubProcess.getId()); Task taskAfterSubProcess = taskQuery.singleResult(); assertThat(taskAfterSubProcess.getName()).isEqualTo("Task in super process"); assertThat(runtimeService.<TypedValue>getVariableTyped(processInstance.getId(), "superVariable")).isEqualTo(subVariable); assertThat(taskService.<TypedValue>getVariableTyped(taskAfterSubProcess.getId(), "superVariable")).isEqualTo(subVariable); // Completing this task ends the super process which leads to a task in the super process taskService.complete(taskAfterSubProcess.getId()); testRule.assertProcessEnded(processInstance.getId()); assertEquals(0, runtimeService.createExecutionQuery().list().size()); }
Test case for handing over process variables to a sub process via the typed api and passing only certain variables
testSubProcessWithLimitedDataInputOutputTypedApi
java
camunda/camunda-bpm-platform
engine/src/test/java/org/camunda/bpm/engine/test/bpmn/callactivity/CallActivityTest.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/test/java/org/camunda/bpm/engine/test/bpmn/callactivity/CallActivityTest.java
Apache-2.0
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/callactivity/CallActivity.testSubProcessAllDataInputOutputTypedApi.bpmn20.xml", "org/camunda/bpm/engine/test/bpmn/callactivity/simpleSubProcess.bpmn20.xml"}) @Test public void testSubProcessWithAllDataInputOutputTypedApi() { TypedValue superVariable = Variables.stringValue(null); VariableMap vars = Variables.createVariables(); vars.putValueTyped("superVariable", superVariable); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("subProcessDataInputOutput", vars); // one task in the subprocess should be active after starting the process instance TaskQuery taskQuery = taskService.createTaskQuery(); Task taskInSubProcess = taskQuery.singleResult(); assertThat(taskInSubProcess.getName()).isEqualTo("Task in subprocess"); assertThat(runtimeService.<TypedValue>getVariableTyped(taskInSubProcess.getProcessInstanceId(), "superVariable")).isEqualTo(superVariable); assertThat(taskService.<TypedValue>getVariableTyped(taskInSubProcess.getId(), "superVariable")).isEqualTo(superVariable); TypedValue subVariable = Variables.stringValue(null); runtimeService.setVariable(taskInSubProcess.getProcessInstanceId(), "subVariable", subVariable); // Completing this task ends the subprocess which leads to a task in the super process taskService.complete(taskInSubProcess.getId()); Task taskAfterSubProcess = taskQuery.singleResult(); assertThat(taskAfterSubProcess.getName()).isEqualTo("Task in super process"); assertThat(runtimeService.<TypedValue>getVariableTyped(processInstance.getId(), "subVariable")).isEqualTo(subVariable); assertThat(taskService.<TypedValue>getVariableTyped(taskAfterSubProcess.getId(), "superVariable")).isEqualTo(superVariable); // Completing this task ends the super process which leads to a task in the super process taskService.complete(taskAfterSubProcess.getId()); testRule.assertProcessEnded(processInstance.getId()); assertEquals(0, runtimeService.createExecutionQuery().list().size()); }
Test case for handing over process variables to a sub process via the typed api and passing all variables
testSubProcessWithAllDataInputOutputTypedApi
java
camunda/camunda-bpm-platform
engine/src/test/java/org/camunda/bpm/engine/test/bpmn/callactivity/CallActivityTest.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/test/java/org/camunda/bpm/engine/test/bpmn/callactivity/CallActivityTest.java
Apache-2.0
@Test public void testSubProcessWithDataInputOutputWithoutTarget() { String processId = "subProcessDataInputOutputWithoutTarget"; BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(processId) .startEvent() .callActivity("callActivity") .calledElement("simpleSubProcess") .userTask() .endEvent() .done(); CallActivityBuilder callActivityBuilder = ((CallActivity) modelInstance.getModelElementById("callActivity")).builder(); // create camunda:in with source but without target CamundaIn camundaIn = modelInstance.newInstance(CamundaIn.class); camundaIn.setCamundaSource("superVariable"); callActivityBuilder.addExtensionElement(camundaIn); deployAndExpectException(modelInstance); // set target camundaIn.setCamundaTarget("subVariable"); // create camunda:in with sourceExpression but without target camundaIn = modelInstance.newInstance(CamundaIn.class); camundaIn.setCamundaSourceExpression("${x+5}"); callActivityBuilder.addExtensionElement(camundaIn); deployAndExpectException(modelInstance); // set target camundaIn.setCamundaTarget("subVariable2"); // create camunda:out with source but without target CamundaOut camundaOut = modelInstance.newInstance(CamundaOut.class); camundaOut.setCamundaSource("subVariable"); callActivityBuilder.addExtensionElement(camundaOut); deployAndExpectException(modelInstance); // set target camundaOut.setCamundaTarget("superVariable"); // create camunda:out with sourceExpression but without target camundaOut = modelInstance.newInstance(CamundaOut.class); camundaOut.setCamundaSourceExpression("${y+1}"); callActivityBuilder.addExtensionElement(camundaOut); deployAndExpectException(modelInstance); // set target camundaOut.setCamundaTarget("superVariable2"); try { String deploymentId = repositoryService.createDeployment().addModelInstance("process.bpmn", modelInstance).deploy().getId(); repositoryService.deleteDeployment(deploymentId, true); } catch (ProcessEngineException e) { fail("No exception expected"); } }
Test case for handing over process variables without target attribute set
testSubProcessWithDataInputOutputWithoutTarget
java
camunda/camunda-bpm-platform
engine/src/test/java/org/camunda/bpm/engine/test/bpmn/callactivity/CallActivityTest.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/test/java/org/camunda/bpm/engine/test/bpmn/callactivity/CallActivityTest.java
Apache-2.0
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/callactivity/CallActivity.testCallSimpleSubProcess.bpmn20.xml", "org/camunda/bpm/engine/test/bpmn/callactivity/simpleSubProcess.bpmn20.xml" }) @Test public void testDeleteProcessInstanceInCallActivity() { // given runtimeService.startProcessInstanceByKey("callSimpleSubProcess"); // one task in the subprocess should be active after starting the process instance TaskQuery taskQuery = taskService.createTaskQuery(); Task taskBeforeSubProcess = taskQuery.singleResult(); // Completing the task continues the process which leads to calling the subprocess taskService.complete(taskBeforeSubProcess.getId()); Task taskInSubProcess = taskQuery.singleResult(); List<ProcessInstance> instanceList = runtimeService.createProcessInstanceQuery().list(); assertNotNull(instanceList); assertEquals(2, instanceList.size()); // when // Delete the ProcessInstance in the sub process runtimeService.deleteProcessInstance(taskInSubProcess.getProcessInstanceId(), "Test upstream deletion"); // then // How many process Instances instanceList = runtimeService.createProcessInstanceQuery().list(); assertNotNull(instanceList); assertEquals(0, instanceList.size()); }
Test case for checking deletion of process instancess in call activity subprocesses
testDeleteProcessInstanceInCallActivity
java
camunda/camunda-bpm-platform
engine/src/test/java/org/camunda/bpm/engine/test/bpmn/callactivity/CallActivityTest.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/test/java/org/camunda/bpm/engine/test/bpmn/callactivity/CallActivityTest.java
Apache-2.0
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/callactivity/CallActivity.testTwoSubProcesses.bpmn20.xml", "org/camunda/bpm/engine/test/bpmn/callactivity/simpleSubProcess.bpmn20.xml"}) @Test public void testSingleDeletionWithTwoSubProcesses() { // given ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("callTwoSubProcesses"); List<ProcessInstance> instanceList = runtimeService.createProcessInstanceQuery().list(); assertNotNull(instanceList); assertEquals(3, instanceList.size()); List<Task> taskList = taskService.createTaskQuery().list(); assertNotNull(taskList); assertEquals(2, taskList.size()); List<String> activeActivityIds = runtimeService.getActiveActivityIds(processInstance.getProcessInstanceId()); assertNotNull(activeActivityIds); assertEquals(2, activeActivityIds.size()); // when runtimeService.deleteProcessInstance(taskList.get(0).getProcessInstanceId(), "Test upstream deletion"); // then // How many process Instances instanceList = runtimeService.createProcessInstanceQuery().list(); assertNotNull(instanceList); assertEquals(2, instanceList.size()); // How man call activities activeActivityIds = runtimeService.getActiveActivityIds(processInstance.getProcessInstanceId()); assertNotNull(activeActivityIds); assertEquals(1, activeActivityIds.size()); }
Test case for checking deletion of process instances in call activity subprocesses Checks that deletion of process Instance will resepct other process instances in the scope and stop its upward deletion propagation will stop at this point
testSingleDeletionWithTwoSubProcesses
java
camunda/camunda-bpm-platform
engine/src/test/java/org/camunda/bpm/engine/test/bpmn/callactivity/CallActivityTest.java
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/test/java/org/camunda/bpm/engine/test/bpmn/callactivity/CallActivityTest.java
Apache-2.0