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 static String convertXmlDocumentToString(DomDocument document) { StringWriter stringWriter = new StringWriter(); StreamResult result = new StreamResult(stringWriter); transformDocumentToXml(document, result); return stringWriter.toString(); }
Converts a {@link DomDocument} to its String representation @param document the XML document to convert
convertXmlDocumentToString
java
camunda/camunda-bpm-platform
model-api/xml-model/src/main/java/org/camunda/bpm/model/xml/impl/util/IoUtil.java
https://github.com/camunda/camunda-bpm-platform/blob/master/model-api/xml-model/src/main/java/org/camunda/bpm/model/xml/impl/util/IoUtil.java
Apache-2.0
public static void writeDocumentToOutputStream(DomDocument document, OutputStream outputStream) { StreamResult result = new StreamResult(outputStream); transformDocumentToXml(document, result); }
Writes a {@link DomDocument} to an {@link OutputStream} by transforming the DOM to XML. @param document the DOM document to write @param outputStream the {@link OutputStream} to write to
writeDocumentToOutputStream
java
camunda/camunda-bpm-platform
model-api/xml-model/src/main/java/org/camunda/bpm/model/xml/impl/util/IoUtil.java
https://github.com/camunda/camunda-bpm-platform/blob/master/model-api/xml-model/src/main/java/org/camunda/bpm/model/xml/impl/util/IoUtil.java
Apache-2.0
public static void transformDocumentToXml(DomDocument document, StreamResult result) { TransformerFactory transformerFactory = TransformerFactory.newInstance(); try { Transformer transformer = transformerFactory.newTransformer(); transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); synchronized(document) { transformer.transform(document.getDomSource(), result); } } catch (TransformerConfigurationException e) { throw new ModelIoException("Unable to create a transformer for the model", e); } catch (TransformerException e) { throw new ModelIoException("Unable to transform model to xml", e); } }
Transforms a {@link DomDocument} to XML output. @param document the DOM document to transform @param result the {@link StreamResult} to write to
transformDocumentToXml
java
camunda/camunda-bpm-platform
model-api/xml-model/src/main/java/org/camunda/bpm/model/xml/impl/util/IoUtil.java
https://github.com/camunda/camunda-bpm-platform/blob/master/model-api/xml-model/src/main/java/org/camunda/bpm/model/xml/impl/util/IoUtil.java
Apache-2.0
public static ModelElementInstance getModelElement(DomElement domElement, ModelInstanceImpl modelInstance) { ModelElementInstance modelElement = domElement.getModelElementInstance(); if(modelElement == null) { ModelElementTypeImpl modelType = getModelElement(domElement, modelInstance, domElement.getNamespaceURI()); modelElement = modelType.newInstance(modelInstance, domElement); domElement.setModelElementInstance(modelElement); } return modelElement; }
Returns the {@link ModelElementInstanceImpl ModelElement} for a DOM element. If the model element does not yet exist, it is created and linked to the DOM. @param domElement the child element to create a new {@link ModelElementInstanceImpl ModelElement} for @return the child model element
getModelElement
java
camunda/camunda-bpm-platform
model-api/xml-model/src/main/java/org/camunda/bpm/model/xml/impl/util/ModelUtil.java
https://github.com/camunda/camunda-bpm-platform/blob/master/model-api/xml-model/src/main/java/org/camunda/bpm/model/xml/impl/util/ModelUtil.java
Apache-2.0
@SuppressWarnings("unchecked") public static <T extends ModelElementInstance> Collection<T> getModelElementCollection(Collection<DomElement> view, ModelInstanceImpl model) { List<ModelElementInstance> resultList = new ArrayList<ModelElementInstance>(); for (DomElement element : view) { resultList.add(getModelElement(element, model)); } return (Collection<T>) resultList; }
Get a collection of all model element instances in a view @param view the collection of DOM elements to find the model element instances for @param model the model of the elements @return the collection of model element instances of the view
getModelElementCollection
java
camunda/camunda-bpm-platform
model-api/xml-model/src/main/java/org/camunda/bpm/model/xml/impl/util/ModelUtil.java
https://github.com/camunda/camunda-bpm-platform/blob/master/model-api/xml-model/src/main/java/org/camunda/bpm/model/xml/impl/util/ModelUtil.java
Apache-2.0
public static int getIndexOfElementType(ModelElementInstance modelElement, List<ModelElementType> childElementTypes) { for (int index = 0; index < childElementTypes.size(); index++) { ModelElementType childElementType = childElementTypes.get(index); Class<? extends ModelElementInstance> instanceType = childElementType.getInstanceType(); if(instanceType.isAssignableFrom(modelElement.getClass())) { return index; } } Collection<String> childElementTypeNames = new ArrayList<String>(); for (ModelElementType childElementType : childElementTypes) { childElementTypeNames.add(childElementType.getTypeName()); } throw new ModelException("New child is not a valid child element type: " + modelElement.getElementType().getTypeName() + "; valid types are: " + childElementTypeNames); }
Find the index of the type of a model element in a list of element types @param modelElement the model element which type is searched for @param childElementTypes the list to search the type @return the index of the model element type in the list or -1 if it is not found
getIndexOfElementType
java
camunda/camunda-bpm-platform
model-api/xml-model/src/main/java/org/camunda/bpm/model/xml/impl/util/ModelUtil.java
https://github.com/camunda/camunda-bpm-platform/blob/master/model-api/xml-model/src/main/java/org/camunda/bpm/model/xml/impl/util/ModelUtil.java
Apache-2.0
public static Collection<ModelElementType> calculateAllExtendingTypes(Model model, Collection<ModelElementType> baseTypes) { Set<ModelElementType> allExtendingTypes = new HashSet<ModelElementType>(); for (ModelElementType baseType : baseTypes) { ModelElementTypeImpl modelElementTypeImpl = (ModelElementTypeImpl) model.getType(baseType.getInstanceType()); modelElementTypeImpl.resolveExtendingTypes(allExtendingTypes); } return allExtendingTypes; }
Calculate a collection of all extending types for the given base types @param baseTypes the collection of types to calculate the union of all extending types
calculateAllExtendingTypes
java
camunda/camunda-bpm-platform
model-api/xml-model/src/main/java/org/camunda/bpm/model/xml/impl/util/ModelUtil.java
https://github.com/camunda/camunda-bpm-platform/blob/master/model-api/xml-model/src/main/java/org/camunda/bpm/model/xml/impl/util/ModelUtil.java
Apache-2.0
public static Collection<ModelElementType> calculateAllBaseTypes(ModelElementType type) { List<ModelElementType> baseTypes = new ArrayList<ModelElementType>(); ModelElementTypeImpl typeImpl = (ModelElementTypeImpl) type; typeImpl.resolveBaseTypes(baseTypes); return baseTypes; }
Calculate a collection of all base types for the given type
calculateAllBaseTypes
java
camunda/camunda-bpm-platform
model-api/xml-model/src/main/java/org/camunda/bpm/model/xml/impl/util/ModelUtil.java
https://github.com/camunda/camunda-bpm-platform/blob/master/model-api/xml-model/src/main/java/org/camunda/bpm/model/xml/impl/util/ModelUtil.java
Apache-2.0
public static void setNewIdentifier(ModelElementType type, ModelElementInstance modelElementInstance, String newId, boolean withReferenceUpdate) { Attribute<?> id = type.getAttribute(ID_ATTRIBUTE_NAME); if (id != null && id instanceof StringAttribute && id.isIdAttribute()) { ((StringAttribute) id).setValue(modelElementInstance, newId, withReferenceUpdate); } }
Set new identifier if the type has a String id attribute @param type the type of the model element @param modelElementInstance the model element instance to set the id @param newId new identifier @param withReferenceUpdate true to update id references in other elements, false otherwise
setNewIdentifier
java
camunda/camunda-bpm-platform
model-api/xml-model/src/main/java/org/camunda/bpm/model/xml/impl/util/ModelUtil.java
https://github.com/camunda/camunda-bpm-platform/blob/master/model-api/xml-model/src/main/java/org/camunda/bpm/model/xml/impl/util/ModelUtil.java
Apache-2.0
public static void setGeneratedUniqueIdentifier(ModelElementType type, ModelElementInstance modelElementInstance) { setGeneratedUniqueIdentifier(type, modelElementInstance, true); }
Set unique identifier if the type has a String id attribute @param type the type of the model element @param modelElementInstance the model element instance to set the id
setGeneratedUniqueIdentifier
java
camunda/camunda-bpm-platform
model-api/xml-model/src/main/java/org/camunda/bpm/model/xml/impl/util/ModelUtil.java
https://github.com/camunda/camunda-bpm-platform/blob/master/model-api/xml-model/src/main/java/org/camunda/bpm/model/xml/impl/util/ModelUtil.java
Apache-2.0
public static <T> T createInstance(Class<T> type, Object... parameters) { // get types for parameters Class<?>[] parameterTypes = new Class<?>[parameters.length]; for (int i = 0; i < parameters.length; i++) { Object parameter = parameters[i]; parameterTypes[i] = parameter.getClass(); } try { // create instance Constructor<T> constructor = type.getConstructor(parameterTypes); return constructor.newInstance(parameters); } catch (Exception e) { throw new ModelException("Exception while creating an instance of type "+type, e); } }
Create a new instance of the provided type @param type the class to create a new instance of @param parameters the parameters to pass to the constructor @return the created instance
createInstance
java
camunda/camunda-bpm-platform
model-api/xml-model/src/main/java/org/camunda/bpm/model/xml/impl/util/ReflectUtil.java
https://github.com/camunda/camunda-bpm-platform/blob/master/model-api/xml-model/src/main/java/org/camunda/bpm/model/xml/impl/util/ReflectUtil.java
Apache-2.0
public static List<String> splitCommaSeparatedList(String text) { if (text == null || text.isEmpty()) { return Collections.emptyList(); } Matcher matcher = pattern.matcher(text); List<String> parts = new ArrayList<String>(); while(matcher.find()) { parts.add(matcher.group().trim()); } return parts; }
Splits a comma separated list in to single Strings. The list can contain expressions with commas in it. @param text the comma separated list @return the Strings of the list or an empty List if text is empty or null
splitCommaSeparatedList
java
camunda/camunda-bpm-platform
model-api/xml-model/src/main/java/org/camunda/bpm/model/xml/impl/util/StringUtil.java
https://github.com/camunda/camunda-bpm-platform/blob/master/model-api/xml-model/src/main/java/org/camunda/bpm/model/xml/impl/util/StringUtil.java
Apache-2.0
@Deployment(order=1, name=PA1) public static WebArchive archive1() { JavaArchive processArchiveJar = ShrinkWrap.create(JavaArchive.class, "test-v1.jar") .addAsResource("org/camunda/bpm/integrationtest/deployment/war/testDeployProcessArchiveUnchanged.bpmn20.xml", "process.bpmn") .addAsResource("META-INF/processes.xml"); WebArchive archive = ShrinkWrap.create(WebArchive.class, "pa1.war") .addAsWebInfResource("org/camunda/bpm/integrationtest/beans.xml", "beans.xml") .addAsLibraries(DeploymentHelper.getEngineCdi()) .addAsLibraries(processArchiveJar) .addClass(AbstractFoxPlatformIntegrationTest.class) .addClass(TestWarDeploymentDeployChangedOnlyWithJarAsLib.class); TestContainer.addContainerSpecificResources(archive); return archive; }
<pre> |-- pa1.war |-- WEB-INF |-- lib/ |-- test-v1.jar |-- META-INF/processes.xml |-- process.bpmn </pre>
archive1
java
camunda/camunda-bpm-platform
qa/integration-tests-engine/src/test/java/org/camunda/bpm/integrationtest/deployment/war/TestWarDeploymentDeployChangedOnlyWithJarAsLib.java
https://github.com/camunda/camunda-bpm-platform/blob/master/qa/integration-tests-engine/src/test/java/org/camunda/bpm/integrationtest/deployment/war/TestWarDeploymentDeployChangedOnlyWithJarAsLib.java
Apache-2.0
@Override public void execute(DelegateExecution execution) throws Exception { invocationCounter++; execution.setVariable("invocationCounter", invocationCounter); }
A {@link RequestScoped} bean @author Daniel Meyer
execute
java
camunda/camunda-bpm-platform
qa/integration-tests-engine/src/test/java/org/camunda/bpm/integrationtest/functional/cdi/beans/RequestScopedDelegateBean.java
https://github.com/camunda/camunda-bpm-platform/blob/master/qa/integration-tests-engine/src/test/java/org/camunda/bpm/integrationtest/functional/cdi/beans/RequestScopedDelegateBean.java
Apache-2.0
public static void assertAndEnsureCleanDb(ProcessEngine processEngine) { ProcessEngineConfigurationImpl processEngineConfiguration = ((ProcessEngineImpl) processEngine).getProcessEngineConfiguration(); String databaseTablePrefix = processEngineConfiguration.getDatabaseTablePrefix().trim(); Map<String, Long> tableCounts = processEngine.getManagementService().getTableCount(); StringBuilder outputMessage = new StringBuilder(); for (String tableName : tableCounts.keySet()) { String tableNameWithoutPrefix = tableName.replace(databaseTablePrefix, ""); if (!TABLENAMES_EXCLUDED_FROM_DB_CLEAN_CHECK.contains(tableNameWithoutPrefix)) { Long count = tableCounts.get(tableName); if (count!=0L) { outputMessage.append("\t").append(tableName).append(": ").append(count).append(" record(s)\n"); } } } if (outputMessage.length() > 0) { outputMessage.insert(0, "DB NOT CLEAN: \n"); /** skip drop and recreate if a table prefix is used */ if (databaseTablePrefix.isEmpty()) { processEngineConfiguration .getCommandExecutorSchemaOperations() .execute(new Command<Object>() { public Object execute(CommandContext commandContext) { PersistenceSession persistenceSession = commandContext.getSession(PersistenceSession.class); persistenceSession.dbSchemaDrop(); persistenceSession.dbSchemaCreate(); HistoryLevelSetupCommand.dbCreateHistoryLevel(commandContext); return null; } }); } Assert.fail(outputMessage.toString()); } }
Ensures that the database is clean after the test. This means the test has to remove all resources it entered to the database. If the DB is not clean, it is cleaned by performing a create a drop. @param processEngine the {@link ProcessEngine} to check @param fail if true the method will throw an {@link AssertionError} if the database is not clean @return the database summary if fail is set to false or null if database was clean @throws AssertionError if the database was not clean and fail is set to true
assertAndEnsureCleanDb
java
camunda/camunda-bpm-platform
qa/integration-tests-engine/src/test/java/org/camunda/bpm/integrationtest/functional/database/PurgeDatabaseTest.java
https://github.com/camunda/camunda-bpm-platform/blob/master/qa/integration-tests-engine/src/test/java/org/camunda/bpm/integrationtest/functional/database/PurgeDatabaseTest.java
Apache-2.0
public Object execute(CommandContext commandContext) { PersistenceSession persistenceSession = commandContext.getSession(PersistenceSession.class); persistenceSession.dbSchemaDrop(); persistenceSession.dbSchemaCreate(); HistoryLevelSetupCommand.dbCreateHistoryLevel(commandContext); return null; }
skip drop and recreate if a table prefix is used
execute
java
camunda/camunda-bpm-platform
qa/integration-tests-engine/src/test/java/org/camunda/bpm/integrationtest/functional/database/PurgeDatabaseTest.java
https://github.com/camunda/camunda-bpm-platform/blob/master/qa/integration-tests-engine/src/test/java/org/camunda/bpm/integrationtest/functional/database/PurgeDatabaseTest.java
Apache-2.0
@Override public void execute(DelegateExecution execution) throws Exception { execution.setVariable("result", businessInterface.doStartProcess()); }
A CDI bean delegating to the local business interface of a SLSB from a different application. @author Daniel Meyer
execute
java
camunda/camunda-bpm-platform
qa/integration-tests-engine/src/test/java/org/camunda/bpm/integrationtest/functional/ejb/local/bean/InvokeStartProcessDelegateSLSB.java
https://github.com/camunda/camunda-bpm-platform/blob/master/qa/integration-tests-engine/src/test/java/org/camunda/bpm/integrationtest/functional/ejb/local/bean/InvokeStartProcessDelegateSLSB.java
Apache-2.0
@Override public void execute(DelegateExecution execution) throws Exception { execution.setVariable("result", businessInterface.doBusiness()); }
A CDI bean delegating to the local business interface of a SFSB from a different application. @author Daniel Meyer
execute
java
camunda/camunda-bpm-platform
qa/integration-tests-engine/src/test/java/org/camunda/bpm/integrationtest/functional/ejb/local/bean/LocalSFSBClientDelegateBean.java
https://github.com/camunda/camunda-bpm-platform/blob/master/qa/integration-tests-engine/src/test/java/org/camunda/bpm/integrationtest/functional/ejb/local/bean/LocalSFSBClientDelegateBean.java
Apache-2.0
public boolean doBusiness() { return true; }
A SFSB with a local business interface @author Daniel Meyer
doBusiness
java
camunda/camunda-bpm-platform
qa/integration-tests-engine/src/test/java/org/camunda/bpm/integrationtest/functional/ejb/local/bean/LocalSFSBean.java
https://github.com/camunda/camunda-bpm-platform/blob/master/qa/integration-tests-engine/src/test/java/org/camunda/bpm/integrationtest/functional/ejb/local/bean/LocalSFSBean.java
Apache-2.0
public boolean doStartProcess() { BpmPlatform.getDefaultProcessEngine() .getRuntimeService() .startProcessInstanceByKey("callbackProcess"); return true; }
A SLSB with a local business interface @author Daniel Meyer
doStartProcess
java
camunda/camunda-bpm-platform
qa/integration-tests-engine/src/test/java/org/camunda/bpm/integrationtest/functional/ejb/local/bean/StartProcessSLSB.java
https://github.com/camunda/camunda-bpm-platform/blob/master/qa/integration-tests-engine/src/test/java/org/camunda/bpm/integrationtest/functional/ejb/local/bean/StartProcessSLSB.java
Apache-2.0
@Override public void execute(DelegateExecution execution) throws Exception { BusinessInterface businessInterface = (BusinessInterface) new InitialContext().lookup("java:global/" + TestConstants.getAppName() + "service/" + "RemoteSFSBean!org.camunda.bpm.integrationtest.functional.ejb.remote.bean.BusinessInterface"); execution.setVariable("result", businessInterface.doBusiness()); }
A CDI bean delegating to the remote business interface of a SFSB from a different application. @author Daniel Meyer
execute
java
camunda/camunda-bpm-platform
qa/integration-tests-engine/src/test/java/org/camunda/bpm/integrationtest/functional/ejb/remote/bean/RemoteSFSBClientDelegateBean.java
https://github.com/camunda/camunda-bpm-platform/blob/master/qa/integration-tests-engine/src/test/java/org/camunda/bpm/integrationtest/functional/ejb/remote/bean/RemoteSFSBClientDelegateBean.java
Apache-2.0
@Override public void execute(DelegateExecution execution) throws Exception { BusinessInterface businessInterface = (BusinessInterface) new InitialContext().lookup("java:global/" + TestConstants.getAppName() + "service/" + "RemoteSingletonBean!org.camunda.bpm.integrationtest.functional.ejb.remote.bean.BusinessInterface"); execution.setVariable("result", businessInterface.doBusiness()); }
A CDI bean delegating to the remote business interface of a Singleton Bean from a different application. @author Daniel Meyer
execute
java
camunda/camunda-bpm-platform
qa/integration-tests-engine/src/test/java/org/camunda/bpm/integrationtest/functional/ejb/remote/bean/RemoteSingletonBeanClientDelegateBean.java
https://github.com/camunda/camunda-bpm-platform/blob/master/qa/integration-tests-engine/src/test/java/org/camunda/bpm/integrationtest/functional/ejb/remote/bean/RemoteSingletonBeanClientDelegateBean.java
Apache-2.0
@Override public void execute(DelegateExecution execution) throws Exception { BusinessInterface businessInterface = (BusinessInterface) new InitialContext().lookup("java:global/" + TestConstants.getAppName() + "service/" + "RemoteSLSBean!org.camunda.bpm.integrationtest.functional.ejb.remote.bean.BusinessInterface"); execution.setVariable("result", businessInterface.doBusiness()); }
A CDI bean delegating to the remote business interface of a SLSB from a different application. @author Daniel Meyer
execute
java
camunda/camunda-bpm-platform
qa/integration-tests-engine/src/test/java/org/camunda/bpm/integrationtest/functional/ejb/remote/bean/RemoteSLSBClientDelegateBean.java
https://github.com/camunda/camunda-bpm-platform/blob/master/qa/integration-tests-engine/src/test/java/org/camunda/bpm/integrationtest/functional/ejb/remote/bean/RemoteSLSBClientDelegateBean.java
Apache-2.0
public int incrementAndGet() { return ++invocations; }
Simple request scoped bean keeping an invocation count. @author Daniel Meyer
incrementAndGet
java
camunda/camunda-bpm-platform
qa/integration-tests-engine/src/test/java/org/camunda/bpm/integrationtest/functional/ejb/request/beans/InvocationCounter.java
https://github.com/camunda/camunda-bpm-platform/blob/master/qa/integration-tests-engine/src/test/java/org/camunda/bpm/integrationtest/functional/ejb/request/beans/InvocationCounter.java
Apache-2.0
public void execute(DelegateExecution execution) throws Exception { invocationCounter++; execution.setVariable("invocationCounter", invocationCounter); }
A request scoped Stateful Session Bean acting as as a JavaDelegate @author Daniel Meyer
execute
java
camunda/camunda-bpm-platform
qa/integration-tests-engine/src/test/java/org/camunda/bpm/integrationtest/functional/ejb/request/beans/RequestScopedSFSBDelegate.java
https://github.com/camunda/camunda-bpm-platform/blob/master/qa/integration-tests-engine/src/test/java/org/camunda/bpm/integrationtest/functional/ejb/request/beans/RequestScopedSFSBDelegate.java
Apache-2.0
public void testLogWithSingleFormatParameter() { logInfo("001", "This is a test of the SLF4J array formatter return type: {}", "Test test"); }
Verify that camunda commons log a messages with a single format parameter. The return type of {@link MessageFormatter#format(String, Object)} changed with slf4j-api:1.6.0
testLogWithSingleFormatParameter
java
camunda/camunda-bpm-platform
qa/integration-tests-engine/src/test/java/org/camunda/bpm/integrationtest/functional/slf4j/TestLogger.java
https://github.com/camunda/camunda-bpm-platform/blob/master/qa/integration-tests-engine/src/test/java/org/camunda/bpm/integrationtest/functional/slf4j/TestLogger.java
Apache-2.0
public void testLogWithTwoFormatParameters() { logInfo("002", "This is a test of the SLF4J array formatter return type: {}, {}", "Test test", 123); }
Verify that camunda commons log a messages with two format parameters. The return type of {@link MessageFormatter#format(String, Object, Object)} changed with slf4j-api:1.6.0
testLogWithTwoFormatParameters
java
camunda/camunda-bpm-platform
qa/integration-tests-engine/src/test/java/org/camunda/bpm/integrationtest/functional/slf4j/TestLogger.java
https://github.com/camunda/camunda-bpm-platform/blob/master/qa/integration-tests-engine/src/test/java/org/camunda/bpm/integrationtest/functional/slf4j/TestLogger.java
Apache-2.0
public void testLogWithArrayFormatter() { // we must used at least 3 parameters to reach the array formatter logInfo("003", "This is a test of the SLF4J array formatter return type: {}, {}, {}, {}", "Test test", 123, true, "it seems to work so slf4j >= 1.6.0 is used"); }
Verify that camunda commons log a messages which uses the array formatter (more than two format parameters). The return type of {@link MessageFormatter#arrayFormat(String, Object[])} changed with slf4j-api:1.6.0
testLogWithArrayFormatter
java
camunda/camunda-bpm-platform
qa/integration-tests-engine/src/test/java/org/camunda/bpm/integrationtest/functional/slf4j/TestLogger.java
https://github.com/camunda/camunda-bpm-platform/blob/master/qa/integration-tests-engine/src/test/java/org/camunda/bpm/integrationtest/functional/slf4j/TestLogger.java
Apache-2.0
@Test public void testPaLocalFormatApplies() throws JsonProcessingException, IOException { // given a process instance final ProcessInstance pi = runtimeService.startProcessInstanceByKey("testProcess"); // when setting a variable in the context of a process application Date date = new Date(JsonSerializable.ONE_DAY_IN_MILLIS * 10); // 10th of January 1970 JsonSerializable jsonSerializable = new JsonSerializable(date); try { ProcessApplicationContext.setCurrentProcessApplication(ReferenceStoringProcessApplication.INSTANCE); runtimeService.setVariable(pi.getId(), "jsonSerializable", Variables.objectValue(jsonSerializable).serializationDataFormat(SerializationDataFormats.JSON).create()); } finally { ProcessApplicationContext.clear(); } // then the process-application-local data format has been used to serialize the value ObjectValue objectValue = runtimeService.getVariableTyped(pi.getId(), "jsonSerializable", false); String serializedValue = objectValue.getValueSerialized(); String expectedSerializedValue = jsonSerializable.toExpectedJsonString(JsonDataFormatConfigurator.DATE_FORMAT); ObjectMapper objectMapper = new ObjectMapper(); JsonNode actualJsonTree = objectMapper.readTree(serializedValue); JsonNode expectedJsonTree = objectMapper.readTree(expectedSerializedValue); // JsonNode#equals makes a deep comparison Assert.assertEquals(expectedJsonTree, actualJsonTree); }
Tests that the PA-local data format applies when a variable is set in the context of it
testPaLocalFormatApplies
java
camunda/camunda-bpm-platform
qa/integration-tests-engine/src/test/java/org/camunda/bpm/integrationtest/functional/spin/PaDataFormatConfiguratorTest.java
https://github.com/camunda/camunda-bpm-platform/blob/master/qa/integration-tests-engine/src/test/java/org/camunda/bpm/integrationtest/functional/spin/PaDataFormatConfiguratorTest.java
Apache-2.0
@Test public void testPaLocalFormatDoesNotApply() throws JsonProcessingException, IOException { // given a process instance ProcessInstance pi = runtimeService.startProcessInstanceByKey("testProcess"); // when setting a variable without a process-application cotnext Date date = new Date(JsonSerializable.ONE_DAY_IN_MILLIS * 10); // 10th of January 1970 JsonSerializable jsonSerializable = new JsonSerializable(date); runtimeService.setVariable(pi.getId(), "jsonSerializable", Variables.objectValue(jsonSerializable).serializationDataFormat(SerializationDataFormats.JSON).create()); // then the global data format is applied ObjectValue objectValue = runtimeService.getVariableTyped(pi.getId(), "jsonSerializable", false); String serializedValue = objectValue.getValueSerialized(); String expectedSerializedValue = jsonSerializable.toExpectedJsonString(); ObjectMapper objectMapper = new ObjectMapper(); JsonNode actualJsonTree = objectMapper.readTree(serializedValue); JsonNode expectedJsonTree = objectMapper.readTree(expectedSerializedValue); // JsonNode#equals makes a deep comparison Assert.assertEquals(expectedJsonTree, actualJsonTree); }
Tests that the PA-local format does not apply if the value is set outside of the context of the process application
testPaLocalFormatDoesNotApply
java
camunda/camunda-bpm-platform
qa/integration-tests-engine/src/test/java/org/camunda/bpm/integrationtest/functional/spin/PaDataFormatConfiguratorTest.java
https://github.com/camunda/camunda-bpm-platform/blob/master/qa/integration-tests-engine/src/test/java/org/camunda/bpm/integrationtest/functional/spin/PaDataFormatConfiguratorTest.java
Apache-2.0
@Test public void customFormatCanBeUsedForVariableSerialization() { final ProcessInstance pi = runtimeService.startProcessInstanceByKey("testProcess", Variables.createVariables() .putValue("serializedObject", serializedObjectValue("foo") .serializationDataFormat(FooDataFormat.NAME) .objectTypeName(Foo.class.getName()))); ObjectValue objectValue = null; try { ProcessApplicationContext.setCurrentProcessApplication(ReferenceStoringProcessApplication.INSTANCE); objectValue = runtimeService.getVariableTyped(pi.getId(), "serializedObject", true); } finally { ProcessApplicationContext.clear(); } Object value = objectValue.getValue(); Assert.assertNotNull(value); Assert.assertTrue(value instanceof Foo); }
Tests that 1) a serialized value can be set OUT OF process application context even if the data format is not available (using the fallback serializer) 2) and that this value can be deserialized IN process application context by using the PA-local serializer
customFormatCanBeUsedForVariableSerialization
java
camunda/camunda-bpm-platform
qa/integration-tests-engine/src/test/java/org/camunda/bpm/integrationtest/functional/spin/PaDataFormatProviderTest.java
https://github.com/camunda/camunda-bpm-platform/blob/master/qa/integration-tests-engine/src/test/java/org/camunda/bpm/integrationtest/functional/spin/PaDataFormatProviderTest.java
Apache-2.0
@PostDeploy public void postDeploy() { INSTANCE = this; }
{@link org.camunda.bpm.application.impl.ServletProcessApplication} is fine on all containers as the tests don't require Java EE features @author Thorben Lindhauer
postDeploy
java
camunda/camunda-bpm-platform
qa/integration-tests-engine/src/test/java/org/camunda/bpm/integrationtest/functional/spin/ReferenceStoringProcessApplication.java
https://github.com/camunda/camunda-bpm-platform/blob/master/qa/integration-tests-engine/src/test/java/org/camunda/bpm/integrationtest/functional/spin/ReferenceStoringProcessApplication.java
Apache-2.0
public String toExpectedJsonString(DateFormat dateFormat) { StringBuilder jsonBuilder = new StringBuilder(); jsonBuilder.append("{\"dateProperty\":\""); jsonBuilder.append(dateFormat.format(dateProperty)); jsonBuilder.append("\"}"); return jsonBuilder.toString(); }
Serializes the value according to the given date format
toExpectedJsonString
java
camunda/camunda-bpm-platform
qa/integration-tests-engine/src/test/java/org/camunda/bpm/integrationtest/functional/spin/dataformat/JsonSerializable.java
https://github.com/camunda/camunda-bpm-platform/blob/master/qa/integration-tests-engine/src/test/java/org/camunda/bpm/integrationtest/functional/spin/dataformat/JsonSerializable.java
Apache-2.0
@Test public void testPolymorphicSerialization() throws JSONException { JSONObject historicVariableUpdate = getFirstHistoricVariableUpdates(); // variable update specific property assertTrue(historicVariableUpdate.has("variableName")); }
Tests that a feature implemented via Jackson-2 annotations works: polymorphic serialization of historic details
testPolymorphicSerialization
java
camunda/camunda-bpm-platform
qa/integration-tests-webapps/integration-tests/src/main/java/org/camunda/bpm/rest/RestIT.java
https://github.com/camunda/camunda-bpm-platform/blob/master/qa/integration-tests-webapps/integration-tests/src/main/java/org/camunda/bpm/rest/RestIT.java
Apache-2.0
public boolean isAlreadySignaled() { int newState = this.state.incrementAndGet(); return newState == 0; }
Sets the run into waiting state and returns if the run was already signaled. Note: This method will change the state of the run to waiting. @return true if the run was already signaled, false otherwise
isAlreadySignaled
java
camunda/camunda-bpm-platform
qa/performance-tests-engine/src/main/java/org/camunda/bpm/qa/performance/engine/framework/PerfTestRun.java
https://github.com/camunda/camunda-bpm-platform/blob/master/qa/performance-tests-engine/src/main/java/org/camunda/bpm/qa/performance/engine/framework/PerfTestRun.java
Apache-2.0
public void completedStep(PerfTestRun run, PerfTestStep currentStep) { PerfTestStep nextStep = currentStep.getNextStep(); if(nextStep != null) { // if test has more steps, execute the next step run.setCurrentStep(nextStep); executor.execute(run); } else { // performance test run is completed completedRun(run); } }
Invoked when a {@link PerfTestRun} completed a step @param run the current Run @param currentStep the completed step
completedStep
java
camunda/camunda-bpm-platform
qa/performance-tests-engine/src/main/java/org/camunda/bpm/qa/performance/engine/framework/PerfTestRunner.java
https://github.com/camunda/camunda-bpm-platform/blob/master/qa/performance-tests-engine/src/main/java/org/camunda/bpm/qa/performance/engine/framework/PerfTestRunner.java
Apache-2.0
@Override protected Integer initialValue() { return THREAD_ID_GENERATOR.getAndIncrement(); }
The thread id which identifies the current thread.
initialValue
java
camunda/camunda-bpm-platform
qa/performance-tests-engine/src/main/java/org/camunda/bpm/qa/performance/engine/loadgenerator/tasks/GenerateMetricsTask.java
https://github.com/camunda/camunda-bpm-platform/blob/master/qa/performance-tests-engine/src/main/java/org/camunda/bpm/qa/performance/engine/loadgenerator/tasks/GenerateMetricsTask.java
Apache-2.0
@Override protected Long initialValue() { return MS_COUNT_PER_YEAR * THREAD_ID.get(); }
The start time on which the thread should begin to generate metrics. Each thread has his own start time, which is calculated with his id and the milliseconds per year. That means each thread generated data in a different year.
initialValue
java
camunda/camunda-bpm-platform
qa/performance-tests-engine/src/main/java/org/camunda/bpm/qa/performance/engine/loadgenerator/tasks/GenerateMetricsTask.java
https://github.com/camunda/camunda-bpm-platform/blob/master/qa/performance-tests-engine/src/main/java/org/camunda/bpm/qa/performance/engine/loadgenerator/tasks/GenerateMetricsTask.java
Apache-2.0
@Override public void run() { //set up long startTime = START_TIME.get(); MetricsRegistry metricsRegistry = processEngineConfiguration.getMetricsRegistry(); Set<String> metricNames = metricsRegistry.getDbMeters().keySet(); //generate metric for (int i = 0; i < ITERATION_PER_EXECUTION; i++) { ClockUtil.setCurrentTime(new Date(startTime)); for (String metricName : metricNames) { //mark occurence metricsRegistry.markOccurrence(metricName, 1); } processEngineConfiguration.getDbMetricsReporter().reportNow(); startTime += INTERVAL; } START_TIME.set(startTime); }
The process engine configuration, which is used for the metric reporting.
run
java
camunda/camunda-bpm-platform
qa/performance-tests-engine/src/main/java/org/camunda/bpm/qa/performance/engine/loadgenerator/tasks/GenerateMetricsTask.java
https://github.com/camunda/camunda-bpm-platform/blob/master/qa/performance-tests-engine/src/main/java/org/camunda/bpm/qa/performance/engine/loadgenerator/tasks/GenerateMetricsTask.java
Apache-2.0
@Override public void postInit(ProcessEngineConfigurationImpl processEngineConfiguration) { SqlSessionFactory sqlSessionFactory = processEngineConfiguration.getSqlSessionFactory(); // wrap the SqlSessionFactory using a statement logger StatementLogSqlSessionFactory wrappedSessionFactory = new StatementLogSqlSessionFactory(sqlSessionFactory); processEngineConfiguration.setSqlSessionFactory(wrappedSessionFactory); // replace the sqlSessionFacorty used by the DbSqlSessionFactory as well DbSqlSessionFactory dbSqlSessionFactory = processEngineConfiguration.getDbSqlSessionFactory(); dbSqlSessionFactory.setSqlSessionFactory(wrappedSessionFactory); }
<p>ProcessEnginePlugin activating statement logging.</p> <p>Wraps the MyBatis {@link SqlSessionFactory} used by the process engine using the {@link StatementLogSqlSessionFactory} allowing us to intercept the sql statements executed by the process engine and gain insight into the Database communication.</p> @author Daniel Meyer
postInit
java
camunda/camunda-bpm-platform
qa/performance-tests-engine/src/main/java/org/camunda/bpm/qa/performance/engine/sqlstatementlog/StatementLogProcessEnginePlugin.java
https://github.com/camunda/camunda-bpm-platform/blob/master/qa/performance-tests-engine/src/main/java/org/camunda/bpm/qa/performance/engine/sqlstatementlog/StatementLogProcessEnginePlugin.java
Apache-2.0
public static List<SqlStatementLog> stopLogging() { List<SqlStatementLog> log = threadStatementLog.get(); threadStatementLog.remove(); return log; }
stops logging statement executed by the current thread and returns the list of logged statements. @return the {@link List} of logged sql statements
stopLogging
java
camunda/camunda-bpm-platform
qa/performance-tests-engine/src/main/java/org/camunda/bpm/qa/performance/engine/sqlstatementlog/StatementLogSqlSession.java
https://github.com/camunda/camunda-bpm-platform/blob/master/qa/performance-tests-engine/src/main/java/org/camunda/bpm/qa/performance/engine/sqlstatementlog/StatementLogSqlSession.java
Apache-2.0
public static void startLogging() { threadStatementLog.set(new ArrayList<StatementLogSqlSession.SqlStatementLog>()); }
starts logging any statements executed by the calling thread.
startLogging
java
camunda/camunda-bpm-platform
qa/performance-tests-engine/src/main/java/org/camunda/bpm/qa/performance/engine/sqlstatementlog/StatementLogSqlSession.java
https://github.com/camunda/camunda-bpm-platform/blob/master/qa/performance-tests-engine/src/main/java/org/camunda/bpm/qa/performance/engine/sqlstatementlog/StatementLogSqlSession.java
Apache-2.0
@Override public SqlSession openSession() { return new StatementLogSqlSession(super.openSession()); }
{@link DelegatingSqlSessionFactory} wrapping the created sessions using a {@link StatementLogSqlSession. @author Daniel Meyer
openSession
java
camunda/camunda-bpm-platform
qa/performance-tests-engine/src/main/java/org/camunda/bpm/qa/performance/engine/sqlstatementlog/StatementLogSqlSessionFactory.java
https://github.com/camunda/camunda-bpm-platform/blob/master/qa/performance-tests-engine/src/main/java/org/camunda/bpm/qa/performance/engine/sqlstatementlog/StatementLogSqlSessionFactory.java
Apache-2.0
@Override public void execute(PerfTestRunContext context) { DecisionService decisionService = processEngine.getDecisionService(); decisionService.evaluateDecisionTableByKey(decisionDefinitionKey, variables); }
Evaluate a decision table using the DecisionService of the engine. @author Philipp Ossler
execute
java
camunda/camunda-bpm-platform
qa/performance-tests-engine/src/main/java/org/camunda/bpm/qa/performance/engine/steps/EvaluateDecisionTableStep.java
https://github.com/camunda/camunda-bpm-platform/blob/master/qa/performance-tests-engine/src/main/java/org/camunda/bpm/qa/performance/engine/steps/EvaluateDecisionTableStep.java
Apache-2.0
@Override public void notify(DelegateExecution execution) throws Exception { PerfTestRunContext perfTestRunContext = PerfTestRunContext.currentContext.get(); if(perfTestRunContext != null) { perfTestRunContext.setVariable(EXECUTION_ID, execution.getId()); } }
<p>{@link ExecutionListener} recording the current execution id in the {@link PerfTestRunContext} using the key {@link PerfTestConstants#EXECUTION_ID}.</p> <p>This is mainly used for removing the necessity for querying for the execution Id.</p> @author Daniel Meyer
notify
java
camunda/camunda-bpm-platform
qa/performance-tests-engine/src/main/java/org/camunda/bpm/qa/performance/engine/steps/ExecutionIdRecorder.java
https://github.com/camunda/camunda-bpm-platform/blob/master/qa/performance-tests-engine/src/main/java/org/camunda/bpm/qa/performance/engine/steps/ExecutionIdRecorder.java
Apache-2.0
public void notify(DelegateTask delegateTask) { PerfTestRunContext perfTestRunContext = PerfTestRunContext.currentContext.get(); if(perfTestRunContext != null) { perfTestRunContext.setVariable(TASK_ID, delegateTask.getId()); } }
<p>{@link TaskListener} recording the current task id in the {@link PerfTestRunContext} using the key {@link PerfTestConstants#TASK_ID}.</p> <p>This is mainly used for removing the necessity for querying for the task Id.</p> @author Daniel Meyer
notify
java
camunda/camunda-bpm-platform
qa/performance-tests-engine/src/main/java/org/camunda/bpm/qa/performance/engine/steps/TaskIdRecorder.java
https://github.com/camunda/camunda-bpm-platform/blob/master/qa/performance-tests-engine/src/main/java/org/camunda/bpm/qa/performance/engine/steps/TaskIdRecorder.java
Apache-2.0
public static void main(String[] args) { ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration .createProcessEngineConfigurationFromResource("camunda.cfg.xml"); ProcessEngine processEngine = processEngineConfiguration.buildProcessEngine(); // register test scenarios ScenarioRunner runner = new ScenarioRunner(processEngine, ENGINE_VERSION); // compensation runner.setupScenarios(DeployProcessWithoutIsExecutableAttributeScenario.class); processEngine.close(); }
Sets up scenarios for migration from 7.5.0 @author Thorben Lindhauer @author Christopher Zell
main
java
camunda/camunda-bpm-platform
qa/test-db-instance-migration/test-fixture-75/src/main/java/org/camunda/bpm/qa/upgrade/TestFixture.java
https://github.com/camunda/camunda-bpm-platform/blob/master/qa/test-db-instance-migration/test-fixture-75/src/main/java/org/camunda/bpm/qa/upgrade/TestFixture.java
Apache-2.0
public static void main(String[] args) { ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration .createProcessEngineConfigurationFromResource("camunda.cfg.xml"); ProcessEngine processEngine = processEngineConfiguration.buildProcessEngine(); // register test scenarios ScenarioRunner runner = new ScenarioRunner(processEngine, ENGINE_VERSION); // compensation runner.setupScenarios(DeployUserWithoutSaltForPasswordHashingScenario.class); processEngine.close(); }
Sets up scenarios for migration from 7.6.0
main
java
camunda/camunda-bpm-platform
qa/test-db-instance-migration/test-fixture-76/src/main/java/org/camunda/bpm/qa/upgrade/TestFixture.java
https://github.com/camunda/camunda-bpm-platform/blob/master/qa/test-db-instance-migration/test-fixture-76/src/main/java/org/camunda/bpm/qa/upgrade/TestFixture.java
Apache-2.0
public static JobState ofAllProcessEngineJobs(ProcessEngine engine) { var managementService = engine.getManagementService(); var engineConfig = (ProcessEngineConfigurationImpl) engine.getProcessEngineConfiguration(); var commandExecutor = engineConfig.getCommandExecutorTxRequired(); var allJobs = managementService.createJobQuery() .list(); return new JobState(allJobs, commandExecutor); }
Creates a {@link JobState} from a given process engine @param engine the process engine @return the job state
ofAllProcessEngineJobs
java
camunda/camunda-bpm-platform
qa/test-db-instance-migration/test-migration/src/test/java/org/camunda/bpm/qa/upgrade/scenarios7210/jobexecutor/JobState.java
https://github.com/camunda/camunda-bpm-platform/blob/master/qa/test-db-instance-migration/test-migration/src/test/java/org/camunda/bpm/qa/upgrade/scenarios7210/jobexecutor/JobState.java
Apache-2.0
private boolean hasLockExpirationTimeChanged(JobEntity job, Date originalLockExpirationTime) { var currentLockExpirationTime = job.getLockExpirationTime(); if (originalLockExpirationTime == null && currentLockExpirationTime == null) { return false; } if (originalLockExpirationTime == null && currentLockExpirationTime != null) { // the job has been locked - case return true; } if (originalLockExpirationTime != null && currentLockExpirationTime == null) { // the job has been unlocked - case return true; } return originalLockExpirationTime.compareTo(currentLockExpirationTime) != 0; }
Returns true if the lock expiration time has changed. This involves changes in the lockExpiration state. <p> Note: The conditionals of this method are on purpose left verbose (they would be further simplified) to make the cases more distinct visibly to the reader. @param job the job to check for lock state changes @param originalLockExpirationTime the original expiration time @return true if the job lock state has changed, false otherwise
hasLockExpirationTimeChanged
java
camunda/camunda-bpm-platform
qa/test-db-instance-migration/test-migration/src/test/java/org/camunda/bpm/qa/upgrade/scenarios7210/jobexecutor/JobState.java
https://github.com/camunda/camunda-bpm-platform/blob/master/qa/test-db-instance-migration/test-migration/src/test/java/org/camunda/bpm/qa/upgrade/scenarios7210/jobexecutor/JobState.java
Apache-2.0
private boolean hasLockOwnerChanged(JobEntity job, String originalLockOwner) { var currentLockOwner = job.getLockOwner(); if (originalLockOwner == null && currentLockOwner == null) { return false; } if (originalLockOwner == null && currentLockOwner != null) { return true; } if (originalLockOwner != null && currentLockOwner == null) { return true; } return originalLockOwner.equals(currentLockOwner); }
Returns true if the lock owner has changed. <p> Note: The conditionals of this method are on purpose left verbose (they would be further simplified) to make the cases more distinct visibly to the reader. @param job the job to check for lock owner changes @param originalLockOwner the original lock owner property has changed @return true if the job lock owner has changed, false otherwise
hasLockOwnerChanged
java
camunda/camunda-bpm-platform
qa/test-db-instance-migration/test-migration/src/test/java/org/camunda/bpm/qa/upgrade/scenarios7210/jobexecutor/JobState.java
https://github.com/camunda/camunda-bpm-platform/blob/master/qa/test-db-instance-migration/test-migration/src/test/java/org/camunda/bpm/qa/upgrade/scenarios7210/jobexecutor/JobState.java
Apache-2.0
@Test @ScenarioUnderTest("createJob.1") public void testSuspensionState() { // given Job job = rule.getManagementService().createJobQuery().jobId(rule.getBuisnessKey()).singleResult(); // then Assert.assertNotNull(job); Assert.assertFalse(job.isSuspended()); }
This actually tests migration from 7.0 jobs (where there was no suspension state) to 7.4 (where suspension state is a not-null column). @author Thorben Lindhauer
testSuspensionState
java
camunda/camunda-bpm-platform
qa/test-db-instance-migration/test-migration/src/test/java/org/camunda/bpm/qa/upgrade/scenarios730/job/JobMigrationScenarioTest.java
https://github.com/camunda/camunda-bpm-platform/blob/master/qa/test-db-instance-migration/test-migration/src/test/java/org/camunda/bpm/qa/upgrade/scenarios730/job/JobMigrationScenarioTest.java
Apache-2.0
public static void main(String[] args) { org.camunda.bpm.qa.rolling.update.TestFixture.main(new String[]{RollingUpdateConstants.NEW_ENGINE_TAG}); }
Creates process instances with the new engine for the rolling updates. Executes the utility test fixture class with the current engine version. @author Christopher Zell
main
java
camunda/camunda-bpm-platform
qa/test-db-rolling-update/create-new-engine/src/main/java/org/camunda/bpm/qa/rolling/update/TestNewEngineMain.java
https://github.com/camunda/camunda-bpm-platform/blob/master/qa/test-db-rolling-update/create-new-engine/src/main/java/org/camunda/bpm/qa/rolling/update/TestNewEngineMain.java
Apache-2.0
public static void main(String[] args) { org.camunda.bpm.qa.rolling.update.TestFixture.main(new String[]{RollingUpdateConstants.OLD_ENGINE_TAG}); }
Creates old engine for the rolling updates. Creates engine and process instances, executes the utility test fixture class with the current old engine version. @author Christopher Zell
main
java
camunda/camunda-bpm-platform
qa/test-db-rolling-update/create-old-engine/src/main/java/org/camunda/bpm/qa/rolling/update/CreateOldEngineMain.java
https://github.com/camunda/camunda-bpm-platform/blob/master/qa/test-db-rolling-update/create-old-engine/src/main/java/org/camunda/bpm/qa/rolling/update/CreateOldEngineMain.java
Apache-2.0
public static void main(String[] args) { String tag = DEFAULT_TAG; if (args.length > 0) { tag = args[0]; } currentFixtureTag = tag; ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration .createProcessEngineConfigurationFromResource("camunda.cfg.xml"); ProcessEngine processEngine = processEngineConfiguration.buildProcessEngine(); // register test scenarios ScenarioRunner runner = new ScenarioRunner(processEngine, tag); // compensation //rolling upgrade test scenarios runner.setupScenarios(ProcessWithUserTaskScenario.class); runner.setupScenarios(ProcessWithAsyncServiceTaskScenario.class); runner.setupScenarios(ProcessWithUserTaskAndTimerScenario.class); runner.setupScenarios(DeploymentWhichShouldBeDeletedScenario.class); runner.setupScenarios(ProcessWithParallelGatewayScenario.class); runner.setupScenarios(ProcessWithParallelGatewayAndServiceTaskScenario.class); runner.setupScenarios(ProcessWithCallActivityScenario.class); runner.setupScenarios(ProcessWithMultiInstanceCallActivityScenario.class); runner.setupScenarios(ProcessWithExternalTaskScenario.class); runner.setupScenarios(ProcessWithEventSubProcessScenario.class); runner.setupScenarios(JobTimestampsUpdateScenario.class); runner.setupScenarios(IncidentTimestampUpdateScenario.class); if (RollingUpdateConstants.NEW_ENGINE_TAG.equals(currentFixtureTag)) { // create data with new engine runner.setupScenarios(HistoryCleanupScenario.class); runner.setupScenarios(EmptyStringVariableScenario.class); runner.setupScenarios(SetRemovalTimeToProcessInstanceScenario.class); } processEngine.close(); processEngineConfiguration = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration .createProcessEngineConfigurationFromResource("camunda.auth.cfg.xml"); processEngine = processEngineConfiguration.buildProcessEngine(); // register test auth scenarios runner = new ScenarioRunner(processEngine, tag); runner.setupScenarios(AuthorizationScenario.class); processEngine.close(); }
Sets up scenarios for rolling updates. @author Thorben Lindhauer @author Christopher Zell
main
java
camunda/camunda-bpm-platform
qa/test-db-rolling-update/rolling-update-util/src/main/java/org/camunda/bpm/qa/rolling/update/TestFixture.java
https://github.com/camunda/camunda-bpm-platform/blob/master/qa/test-db-rolling-update/rolling-update-util/src/main/java/org/camunda/bpm/qa/rolling/update/TestFixture.java
Apache-2.0
@Test @ScenarioUnderTest("init.1") public void testCompleteProcessWithUserTask() { //given deployed process with process instance String processDefinitionId = rule.processInstance().getProcessDefinitionId(); ProcessDefinition procDef = rule.getRepositoryService() .createProcessDefinitionQuery() .processDefinitionId(processDefinitionId) .singleResult(); //when deployment is deleted rule.getRepositoryService().deleteDeployment(procDef.getDeploymentId(),true); //then process instance is ended rule.assertScenarioEnded(); }
This test ensures that the old engine can delete an existing deployment with a process instance from the new schema. @author Christopher Zell <christopher.zell@camunda.com>
testCompleteProcessWithUserTask
java
camunda/camunda-bpm-platform
qa/test-db-rolling-update/test-old-engine/src/test/java/org/camunda/bpm/qa/rolling/update/DeleteDeploymentTest.java
https://github.com/camunda/camunda-bpm-platform/blob/master/qa/test-db-rolling-update/test-old-engine/src/test/java/org/camunda/bpm/qa/rolling/update/DeleteDeploymentTest.java
Apache-2.0
@Test @ScenarioUnderTest("init.1") public void testCompleteWithAsyncServiceTask() { //given process with async service task ProcessInstance oldInstance = rule.processInstance(); Assert.assertNotNull(oldInstance); Job job = rule.jobQuery().singleResult(); Assert.assertNotNull(job); //when job is executed rule.getManagementService().executeJob(job.getId()); //then existing job will executed and process instance ends rule.assertScenarioEnded(); }
This test ensures that the old engine can complete an existing process with service task on the new schema. @author Christopher Zell <christopher.zell@camunda.com>
testCompleteWithAsyncServiceTask
java
camunda/camunda-bpm-platform
qa/test-db-rolling-update/test-old-engine/src/test/java/org/camunda/bpm/qa/rolling/update/task/CompleteProcessWithAsyncServiceTaskTest.java
https://github.com/camunda/camunda-bpm-platform/blob/master/qa/test-db-rolling-update/test-old-engine/src/test/java/org/camunda/bpm/qa/rolling/update/task/CompleteProcessWithAsyncServiceTaskTest.java
Apache-2.0
@Test @ScenarioUnderTest("init.1") public void testCompleteProcessWithUserTaskAndTimer() throws InterruptedException { //given a process instance with user task and timer boundary event Job job = rule.jobQuery().singleResult(); Assert.assertNotNull(job); //job is not available since timer is set to 2 mintues in the future Assert.assertFalse(!job.isSuspended() && job.getRetries() > 0 && (job.getDuedate() == null || ClockUtil.getCurrentTime().after(job.getDuedate()))); //when time is incremented by five minutes ClockUtil.setCurrentTime(new Date(ClockUtil.getCurrentTime().getTime() + 60 * 1000 * 5)); //then job is available and timer should executed and process instance ends job = rule.jobQuery().singleResult(); Assert.assertTrue(!job.isSuspended() && job.getRetries() > 0 && (job.getDuedate() == null || ClockUtil.getCurrentTime().after(job.getDuedate()))); rule.getManagementService().executeJob(job.getId()); rule.assertScenarioEnded(); }
This test ensures that the old engine can complete an existing process with user task and timer on the new schema. @author Christopher Zell <christopher.zell@camunda.com>
testCompleteProcessWithUserTaskAndTimer
java
camunda/camunda-bpm-platform
qa/test-db-rolling-update/test-old-engine/src/test/java/org/camunda/bpm/qa/rolling/update/task/CompleteProcessWithUserTaskAndTimerTest.java
https://github.com/camunda/camunda-bpm-platform/blob/master/qa/test-db-rolling-update/test-old-engine/src/test/java/org/camunda/bpm/qa/rolling/update/task/CompleteProcessWithUserTaskAndTimerTest.java
Apache-2.0
@Test @ScenarioUnderTest("init.1") public void testCompleteProcessWithUserTask() { //given an already started process instance ProcessInstance oldInstance = rule.processInstance(); Assert.assertNotNull(oldInstance); //which waits on an user task TaskService taskService = rule.getTaskService(); Task userTask = taskService.createTaskQuery().processInstanceId(oldInstance.getId()).singleResult(); Assert.assertNotNull(userTask); //when completing the user task taskService.complete(userTask.getId()); //then there exists no more tasks //and the process instance is also completed Assert.assertEquals(0, rule.taskQuery().count()); rule.assertScenarioEnded(); }
This test ensures that the old engine can complete an existing process with user task on the new schema. @author Christopher Zell <christopher.zell@camunda.com>
testCompleteProcessWithUserTask
java
camunda/camunda-bpm-platform
qa/test-db-rolling-update/test-old-engine/src/test/java/org/camunda/bpm/qa/rolling/update/task/CompleteProcessWithUserTaskTest.java
https://github.com/camunda/camunda-bpm-platform/blob/master/qa/test-db-rolling-update/test-old-engine/src/test/java/org/camunda/bpm/qa/rolling/update/task/CompleteProcessWithUserTaskTest.java
Apache-2.0
@Override protected void initCommandExecutorDbSchemaOperations() { if (commandExecutorSchemaOperations == null) { List<CommandInterceptor> commandInterceptorsDbSchemaOperations = new ArrayList<>(); commandInterceptorsDbSchemaOperations.add(new LogInterceptor()); commandInterceptorsDbSchemaOperations.add(new CommandCounterInterceptor(this)); commandInterceptorsDbSchemaOperations.add(new JakartaTransactionInterceptor(transactionManager, false, this)); commandInterceptorsDbSchemaOperations.add(new CommandContextInterceptor(dbSchemaOperationsCommandContextFactory, this)); commandInterceptorsDbSchemaOperations.add(actualCommandExecutor); commandExecutorSchemaOperations = initInterceptorChain(commandInterceptorsDbSchemaOperations); } }
We need to make sure, that the root command always calls {@link TransactionManager#begin} in its interceptor chain since Agroal does not support deferred/lazy enlistment. This is why we override this method to add the {@link JakartaTransactionInterceptor} to the interceptor chain.
initCommandExecutorDbSchemaOperations
java
camunda/camunda-bpm-platform
quarkus-extension/engine/runtime/src/main/java/org/camunda/bpm/quarkus/engine/extension/QuarkusProcessEngineConfiguration.java
https://github.com/camunda/camunda-bpm-platform/blob/master/quarkus-extension/engine/runtime/src/main/java/org/camunda/bpm/quarkus/engine/extension/QuarkusProcessEngineConfiguration.java
Apache-2.0
protected <T> T getBeanFromContainer(Class<T> beanClass, BeanContainer beanContainer) { try (BeanContainer.Instance<T> beanManager = beanContainer.beanInstanceFactory(beanClass).create()) { return beanManager.get(); } }
Retrieves a bean of the given class from the bean container. @param beanClass the class of the desired bean to fetch from the container @param beanContainer the bean container @param <T> the type of the bean to fetch @return the bean
getBeanFromContainer
java
camunda/camunda-bpm-platform
quarkus-extension/engine/runtime/src/main/java/org/camunda/bpm/quarkus/engine/extension/impl/CamundaEngineRecorder.java
https://github.com/camunda/camunda-bpm-platform/blob/master/quarkus-extension/engine/runtime/src/main/java/org/camunda/bpm/quarkus/engine/extension/impl/CamundaEngineRecorder.java
Apache-2.0
public static DataFormats getInstance() { return INSTANCE; }
Provides the global instance of the DataFormats manager. @return the global instance.
getInstance
java
camunda/camunda-bpm-platform
spin/core/src/main/java/org/camunda/spin/DataFormats.java
https://github.com/camunda/camunda-bpm-platform/blob/master/spin/core/src/main/java/org/camunda/spin/DataFormats.java
Apache-2.0
@SuppressWarnings("unchecked") public static DataFormat<SpinXmlElement> xml() { return (DataFormat<SpinXmlElement>) getDataFormat(XML_DATAFORMAT_NAME); }
Returns the global xml data format that can be provided with configuration that applies to any Spin xml operation.
xml
java
camunda/camunda-bpm-platform
spin/core/src/main/java/org/camunda/spin/DataFormats.java
https://github.com/camunda/camunda-bpm-platform/blob/master/spin/core/src/main/java/org/camunda/spin/DataFormats.java
Apache-2.0
@SuppressWarnings("unchecked") public static DataFormat<SpinJsonNode> json() { return (DataFormat<SpinJsonNode>) getDataFormat(JSON_DATAFORMAT_NAME); }
Returns the global json data format that can be provided with configuration that applies to any Spin json operation.
json
java
camunda/camunda-bpm-platform
spin/core/src/main/java/org/camunda/spin/DataFormats.java
https://github.com/camunda/camunda-bpm-platform/blob/master/spin/core/src/main/java/org/camunda/spin/DataFormats.java
Apache-2.0
public static DataFormat<? extends Spin<?>> getDataFormat(String dataFormatName) { return INSTANCE.getDataFormatByName(dataFormatName); }
Returns the registered data format for the given name. @param dataFormatName the name of the data format @return the data format or null if non is registered for this name
getDataFormat
java
camunda/camunda-bpm-platform
spin/core/src/main/java/org/camunda/spin/DataFormats.java
https://github.com/camunda/camunda-bpm-platform/blob/master/spin/core/src/main/java/org/camunda/spin/DataFormats.java
Apache-2.0
public static <T extends Spin<?>> T S(Object input, DataFormat<T> format) { return SpinFactory.INSTANCE.createSpin(input, format); }
Creates a spin wrapper for a data input of a given data format. @param input the input to wrap @param format the data format of the input @return the spin wrapper for the input @throws IllegalArgumentException in case an argument of illegal type is provided (such as 'null')
S
java
camunda/camunda-bpm-platform
spin/core/src/main/java/org/camunda/spin/Spin.java
https://github.com/camunda/camunda-bpm-platform/blob/master/spin/core/src/main/java/org/camunda/spin/Spin.java
Apache-2.0
public static <T extends Spin<?>> T S(Object input, String dataFormatName) { return SpinFactory.INSTANCE.createSpin(input, dataFormatName); }
Creates a spin wrapper for a data input of a given data format. @param input the input to wrap @param dataFormatName the data format name of the input @return the spin wrapper for the input @throws IllegalArgumentException in case an argument of illegal type is provided (such as 'null')
S
java
camunda/camunda-bpm-platform
spin/core/src/main/java/org/camunda/spin/Spin.java
https://github.com/camunda/camunda-bpm-platform/blob/master/spin/core/src/main/java/org/camunda/spin/Spin.java
Apache-2.0
public static <T extends Spin<?>> T S(Object input) { return SpinFactory.INSTANCE.createSpin(input); }
Creates a spin wrapper for a data input. The data format of the input is auto detected. @param input the input to wrap @return the spin wrapper for the input @throws IllegalArgumentException in case an argument of illegal type is provided (such as 'null')
S
java
camunda/camunda-bpm-platform
spin/core/src/main/java/org/camunda/spin/Spin.java
https://github.com/camunda/camunda-bpm-platform/blob/master/spin/core/src/main/java/org/camunda/spin/Spin.java
Apache-2.0
public static SpinXmlElement XML(Object input) { return SpinFactory.INSTANCE.createSpin(input, DataFormats.xml()); }
Creates a spin wrapper for a data input. The data format of the input is assumed to be XML. @param input the input to wrap @return the spin wrapper for the input @throws IllegalArgumentException in case an argument of illegal type is provided (such as 'null')
XML
java
camunda/camunda-bpm-platform
spin/core/src/main/java/org/camunda/spin/Spin.java
https://github.com/camunda/camunda-bpm-platform/blob/master/spin/core/src/main/java/org/camunda/spin/Spin.java
Apache-2.0
public static SpinJsonNode JSON(Object input) { return SpinFactory.INSTANCE.createSpin(input, DataFormats.json()); }
Creates a spin wrapper for a data input. The data format of the input is assumed to be JSON. @param input the input to wrap @return the spin wrapper for the input @throws IllegalArgumentException in case an argument of illegal type is provided (such as 'null')
JSON
java
camunda/camunda-bpm-platform
spin/core/src/main/java/org/camunda/spin/Spin.java
https://github.com/camunda/camunda-bpm-platform/blob/master/spin/core/src/main/java/org/camunda/spin/Spin.java
Apache-2.0
public int getCurrentRewindableCapacity() { return buffer.length - pos; }
@return the number of characters that can still be read and rewound.
getCurrentRewindableCapacity
java
camunda/camunda-bpm-platform
spin/core/src/main/java/org/camunda/spin/impl/util/RewindableReader.java
https://github.com/camunda/camunda-bpm-platform/blob/master/spin/core/src/main/java/org/camunda/spin/impl/util/RewindableReader.java
Apache-2.0
public static String getStringFromReader(Reader reader) throws IOException { return getStringFromReader(reader, true); }
Convert an {@link Reader} to a {@link String} @param reader the {@link Reader} to convert @return the resulting {@link String} @throws IOException
getStringFromReader
java
camunda/camunda-bpm-platform
spin/core/src/main/java/org/camunda/spin/impl/util/SpinIoUtil.java
https://github.com/camunda/camunda-bpm-platform/blob/master/spin/core/src/main/java/org/camunda/spin/impl/util/SpinIoUtil.java
Apache-2.0
public static Class<?> loadClass(String classname, DataFormat<?> dataFormat) { // first try context classoader ClassLoader cl = Thread.currentThread().getContextClassLoader(); if(cl != null) { LOG.tryLoadingClass(classname, cl); try { return cl.loadClass(classname); } catch(Exception e) { // ignore } } // else try the classloader which loaded the dataformat cl = dataFormat.getClass().getClassLoader(); try { LOG.tryLoadingClass(classname, cl); return cl.loadClass(classname); } catch (ClassNotFoundException e) { throw LOG.classNotFound(classname, e); } }
Used by dataformats if they need to load a class @param classname the name of the @param dataFormat @return
loadClass
java
camunda/camunda-bpm-platform
spin/core/src/main/java/org/camunda/spin/impl/util/SpinReflectUtil.java
https://github.com/camunda/camunda-bpm-platform/blob/master/spin/core/src/main/java/org/camunda/spin/impl/util/SpinReflectUtil.java
Apache-2.0
public static String getExtension(String language) { language = language.toLowerCase(); if("ecmascript".equals(language)) { language = "javascript"; } return extensions.get(language); }
Get file extension for script language. @param language the language name @return the file extension as string or null if the language is not in the set of languages supported by spin
getExtension
java
camunda/camunda-bpm-platform
spin/core/src/main/java/org/camunda/spin/scripting/SpinScriptEnv.java
https://github.com/camunda/camunda-bpm-platform/blob/master/spin/core/src/main/java/org/camunda/spin/scripting/SpinScriptEnv.java
Apache-2.0
default DataFormat<?> createInstance(Map<String, Object> configurationProperties) { return createInstance(); }
@return an instance of the data format provided by this implementation configured using the passed configuration properties.
createInstance
java
camunda/camunda-bpm-platform
spin/core/src/main/java/org/camunda/spin/spi/DataFormatProvider.java
https://github.com/camunda/camunda-bpm-platform/blob/master/spin/core/src/main/java/org/camunda/spin/spi/DataFormatProvider.java
Apache-2.0
public boolean canRead(Reader input, int readLimit) { char[] firstCharacters = new char[readLimit]; try { input.read(firstCharacters, 0, readLimit); } catch (IOException e) { throw LOG.unableToReadFromReader(e); } Pattern pattern = getInputDetectionPattern(); return pattern.matcher(new String(firstCharacters)).find(); }
Can be used as a base class to determine whether an input reader is readable by applying regular expression matching. @author Lindhauer
canRead
java
camunda/camunda-bpm-platform
spin/core/src/main/java/org/camunda/spin/spi/TextBasedDataFormatReader.java
https://github.com/camunda/camunda-bpm-platform/blob/master/spin/core/src/main/java/org/camunda/spin/spi/TextBasedDataFormatReader.java
Apache-2.0
private ScriptEngine createScriptEngine(Description description) { org.camunda.spin.impl.test.ScriptEngine annotation = description.getTestClass().getAnnotation(org.camunda.spin.impl.test.ScriptEngine.class); if (annotation == null) { return null; } else { String language = annotation.value(); if (!cachedEngines.containsKey(language)) { ScriptEngine engine = new ScriptEngineManager().getEngineByName(language); if (engine == null) { throw LOG.noScriptEngineFoundForLanguage(language); } if (GRAAL_JS_SCRIPT_ENGINE_NAME.equals(engine.getFactory().getEngineName())) { configureGraalJsScriptEngine(engine); } cachedEngines.put(language, engine); } return cachedEngines.get(language); } }
Create script engine from {@literal @}{@link org.camunda.spin.impl.test.ScriptEngine} Annotation. The created script engines will be cached to speedup subsequent creations. @param description the {@link Description} of the test method @return the script engine or null if no suitable found
createScriptEngine
java
camunda/camunda-bpm-platform
spin/core/src/test/java/org/camunda/spin/impl/test/ScriptEngineRule.java
https://github.com/camunda/camunda-bpm-platform/blob/master/spin/core/src/test/java/org/camunda/spin/impl/test/ScriptEngineRule.java
Apache-2.0
private void loadScript(Description description) throws Throwable { scriptEngine = getScriptEngine(description); if (scriptEngine == null) { return; } script = getScript(description); collectScriptVariables(description); if (scriptEngine.getFactory().getLanguageName().equalsIgnoreCase("ruby")) { // set magic property to remove all internal variables of the ruby scripting engine // otherwise global variables will live forever variables.put("org.jruby.embed.clear.variables", true); } boolean execute = isExecuteScript(description); if (execute) { executeScript(); } }
Load a script and the script variables defined. Also execute the script if {@link Script#execute()} is {@link true}. @param description the description of the test method @throws Throwable
loadScript
java
camunda/camunda-bpm-platform
spin/core/src/test/java/org/camunda/spin/impl/test/ScriptRule.java
https://github.com/camunda/camunda-bpm-platform/blob/master/spin/core/src/test/java/org/camunda/spin/impl/test/ScriptRule.java
Apache-2.0
private ScriptEngine getScriptEngine(Description description) { try { ScriptEngineRule scriptEngineRule = (ScriptEngineRule) description.getTestClass().getField("scriptEngine").get(null); return scriptEngineRule.getScriptEngine(); } catch (NoSuchFieldException e) { return null; } catch (IllegalAccessException e) { return null; } }
Returns the {@link ScriptEngine} of the {@link ScriptEngineRule} of the test class. @param description the description of the test method @return the script engine found or null
getScriptEngine
java
camunda/camunda-bpm-platform
spin/core/src/test/java/org/camunda/spin/impl/test/ScriptRule.java
https://github.com/camunda/camunda-bpm-platform/blob/master/spin/core/src/test/java/org/camunda/spin/impl/test/ScriptRule.java
Apache-2.0
private String getScript(Description description) { Script scriptAnnotation = description.getAnnotation(Script.class); if (scriptAnnotation == null) { return null; } String scriptBasename = getScriptBasename(scriptAnnotation, description); scriptPath = getScriptPath(scriptBasename, description); File file = SpinIoUtil.getClasspathFile(scriptPath, description.getTestClass().getClassLoader()); return SpinIoUtil.fileAsString(file); }
Return the script as {@link String} based on the {@literal @}{@link Script} annotation of the test method. @param description the description of the test method @return the script as string or null if no script was found
getScript
java
camunda/camunda-bpm-platform
spin/core/src/test/java/org/camunda/spin/impl/test/ScriptRule.java
https://github.com/camunda/camunda-bpm-platform/blob/master/spin/core/src/test/java/org/camunda/spin/impl/test/ScriptRule.java
Apache-2.0
private void collectScriptVariables(Description description) { ScriptVariable scriptVariable = description.getAnnotation(ScriptVariable.class); collectScriptVariable(scriptVariable, description); Script script = description.getAnnotation(Script.class); if (script != null) { for (ScriptVariable variable : script.variables()) { collectScriptVariable(variable, description); } } }
Collect all {@literal @}{@link ScriptVariable} annotations of the test method and save the variables in the {@link #variables} field. @param description the description of the test method
collectScriptVariables
java
camunda/camunda-bpm-platform
spin/core/src/test/java/org/camunda/spin/impl/test/ScriptRule.java
https://github.com/camunda/camunda-bpm-platform/blob/master/spin/core/src/test/java/org/camunda/spin/impl/test/ScriptRule.java
Apache-2.0
private void collectScriptVariable(ScriptVariable scriptVariable, Description description) { if (scriptVariable == null) { return; } String name = scriptVariable.name(); String value = scriptVariable.value(); String filename = scriptVariable.file(); boolean isNull = scriptVariable.isNull(); if (isNull) { variables.put(name, null); LOG.scriptVariableFound(name, "isNull", null); } else if (!filename.isEmpty()) { Reader fileAsReader = SpinIoUtil.classpathResourceAsReader(filename); variables.put(name, fileAsReader); LOG.scriptVariableFound(name, "reader", filename); } else { variables.put(name, value); LOG.scriptVariableFound(name, "string", value); } }
Extract the variable of a single {@literal @}{@link ScriptVariable} annotation. @param scriptVariable the annotation @param description the description of the test method
collectScriptVariable
java
camunda/camunda-bpm-platform
spin/core/src/test/java/org/camunda/spin/impl/test/ScriptRule.java
https://github.com/camunda/camunda-bpm-platform/blob/master/spin/core/src/test/java/org/camunda/spin/impl/test/ScriptRule.java
Apache-2.0
private boolean isExecuteScript(Description description) { Script annotation = description.getAnnotation(Script.class); return annotation != null && annotation.execute(); }
Determines if the script should be executed before the call of the java test method. @param description the description of the test method @return true if the script should be executed in front or false otherwise
isExecuteScript
java
camunda/camunda-bpm-platform
spin/core/src/test/java/org/camunda/spin/impl/test/ScriptRule.java
https://github.com/camunda/camunda-bpm-platform/blob/master/spin/core/src/test/java/org/camunda/spin/impl/test/ScriptRule.java
Apache-2.0
private void executeScript() throws Throwable { if (scriptEngine != null) { try { String environment = SpinScriptEnv.get(scriptEngine.getFactory().getLanguageName()); Bindings bindings = new SimpleBindings(variables); LOG.executeScriptWithScriptEngine(scriptPath, scriptEngine.getFactory().getEngineName()); scriptEngine.eval(environment, bindings); scriptEngine.eval(script, bindings); } catch (ScriptException e) { if ("graal.js".equalsIgnoreCase(scriptEngine.getFactory().getEngineName())) { throw e.getCause(); } throw LOG.scriptExecutionError(scriptPath, e); } } }
Executes the script with the set variables. @throws Throwable @throws SpinScriptException if an error occurs during the script execution
executeScript
java
camunda/camunda-bpm-platform
spin/core/src/test/java/org/camunda/spin/impl/test/ScriptRule.java
https://github.com/camunda/camunda-bpm-platform/blob/master/spin/core/src/test/java/org/camunda/spin/impl/test/ScriptRule.java
Apache-2.0
public ScriptRule execute(Map<String, Object> scriptVariables) throws Throwable { variables.putAll(scriptVariables); executeScript(); return this; }
Execute the script and add the given variables to the script variables. @param scriptVariables the variables to set additionally @return this script rule @throws Throwable @throws SpinScriptException if an error occurs during the script execution
execute
java
camunda/camunda-bpm-platform
spin/core/src/test/java/org/camunda/spin/impl/test/ScriptRule.java
https://github.com/camunda/camunda-bpm-platform/blob/master/spin/core/src/test/java/org/camunda/spin/impl/test/ScriptRule.java
Apache-2.0
public ScriptRule execute() throws Throwable { executeScript(); return this; }
Execute the script @return this script rule @throws Throwable @throws SpinScriptException if an error occurs during the script execution
execute
java
camunda/camunda-bpm-platform
spin/core/src/test/java/org/camunda/spin/impl/test/ScriptRule.java
https://github.com/camunda/camunda-bpm-platform/blob/master/spin/core/src/test/java/org/camunda/spin/impl/test/ScriptRule.java
Apache-2.0
private String getScriptBasename(Script scriptAnnotation, Description description) { String scriptBasename = scriptAnnotation.value(); if (scriptBasename.isEmpty()) { scriptBasename = scriptAnnotation.name(); } if (scriptBasename.isEmpty()) { scriptBasename = description.getTestClass().getSimpleName() + "." + description.getMethodName(); } return scriptBasename; }
Determines the base filename of the script. @param scriptAnnotation the script annotation of the test method @param description the description of the test method @return the base filename of the script
getScriptBasename
java
camunda/camunda-bpm-platform
spin/core/src/test/java/org/camunda/spin/impl/test/ScriptRule.java
https://github.com/camunda/camunda-bpm-platform/blob/master/spin/core/src/test/java/org/camunda/spin/impl/test/ScriptRule.java
Apache-2.0
private String getPackageDirectoryPath(Description description) { String packageName = description.getTestClass().getPackage().getName(); return replaceDotsWithPathSeparators(packageName) + File.separator; }
Returns the directory path of the package. @param description the description of the test method @return the directory for the package
getPackageDirectoryPath
java
camunda/camunda-bpm-platform
spin/core/src/test/java/org/camunda/spin/impl/test/ScriptRule.java
https://github.com/camunda/camunda-bpm-platform/blob/master/spin/core/src/test/java/org/camunda/spin/impl/test/ScriptRule.java
Apache-2.0
private String replaceDotsWithPathSeparators(String path) { return path.replace(".", File.separator); }
Replace all dots in the path with the {@link File#separator} character. @param path the path to process @return the processed path
replaceDotsWithPathSeparators
java
camunda/camunda-bpm-platform
spin/core/src/test/java/org/camunda/spin/impl/test/ScriptRule.java
https://github.com/camunda/camunda-bpm-platform/blob/master/spin/core/src/test/java/org/camunda/spin/impl/test/ScriptRule.java
Apache-2.0
private String getScriptPath(String scriptBasename, Description description) { return getPackageDirectoryPath(description) + scriptBasename + getScriptExtension(); }
Returns the full path of the script based on package and basename. @param scriptBasename the basename of the script file @param description the description of the test method @return the full path
getScriptPath
java
camunda/camunda-bpm-platform
spin/core/src/test/java/org/camunda/spin/impl/test/ScriptRule.java
https://github.com/camunda/camunda-bpm-platform/blob/master/spin/core/src/test/java/org/camunda/spin/impl/test/ScriptRule.java
Apache-2.0
private String getScriptExtension() { String languageName = scriptEngine.getFactory().getLanguageName(); String extension = SpinScriptEnv.getExtension(languageName); if (extension == null) { LOG.noScriptExtensionFoundForScriptLanguage(languageName); return ""; } else { return "." + extension; } }
Returns the script file extension based on the {@link ScriptEngine} language. @return the file extension or empty string if none was found
getScriptExtension
java
camunda/camunda-bpm-platform
spin/core/src/test/java/org/camunda/spin/impl/test/ScriptRule.java
https://github.com/camunda/camunda-bpm-platform/blob/master/spin/core/src/test/java/org/camunda/spin/impl/test/ScriptRule.java
Apache-2.0
@SuppressWarnings("unchecked") public <T> T getVariable(String name) { try { if (scriptEngine.getFactory().getLanguageName().equals("ECMAScript")) { return (T) getVariableJs(name); } else { return (T) variables.get(name); } } catch(ClassCastException e) { throw LOG.cannotCastVariableError(name, e); } }
Returns the value of a named script variable @param name the name of the variable @return the value of the variable or null if the variable does not exist.
getVariable
java
camunda/camunda-bpm-platform
spin/core/src/test/java/org/camunda/spin/impl/test/ScriptRule.java
https://github.com/camunda/camunda-bpm-platform/blob/master/spin/core/src/test/java/org/camunda/spin/impl/test/ScriptRule.java
Apache-2.0
@SuppressWarnings("unchecked") private Object getVariableJs(String name) { Object variable = variables.get(name); if (variable == null) { if (variables.containsKey("nashorn.global")) { variable = ((Map<String, Object>) variables.get("nashorn.global")).get(name); } else if (variables.containsKey("polyglot.context")) { Value member = ((org.graalvm.polyglot.Context)variables.get("polyglot.context")).getBindings("js").getMember(name); variable = member == null ? null : member.as(Object.class); } } return variable; }
If JavaScript engine is used the variable may be placed in the global variable map. @param name the name of the variable @return the variable if found or null
getVariableJs
java
camunda/camunda-bpm-platform
spin/core/src/test/java/org/camunda/spin/impl/test/ScriptRule.java
https://github.com/camunda/camunda-bpm-platform/blob/master/spin/core/src/test/java/org/camunda/spin/impl/test/ScriptRule.java
Apache-2.0
public ScriptRule setVariable(String name, Object value) { variables.put(name, value); return this; }
Set the variable with the given name @param name the name of the variable @param value value of the variable @return this script rule
setVariable
java
camunda/camunda-bpm-platform
spin/core/src/test/java/org/camunda/spin/impl/test/ScriptRule.java
https://github.com/camunda/camunda-bpm-platform/blob/master/spin/core/src/test/java/org/camunda/spin/impl/test/ScriptRule.java
Apache-2.0
public SpinJsonDataFormatException unableToParseInput(Exception e) { return new SpinJsonDataFormatException(exceptionMessage("001", "Unable to parse input into json node"), e); }
@author Thorben Lindhauer @author Stefan Hentschel
unableToParseInput
java
camunda/camunda-bpm-platform
spin/dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/JacksonJsonLogger.java
https://github.com/camunda/camunda-bpm-platform/blob/master/spin/dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/JacksonJsonLogger.java
Apache-2.0
public <C> C mapTo(String type) { DataFormatMapper mapper = dataFormat.getMapper(); return mapper.mapInternalToJava(jsonNode, type); }
Maps the json represented by this object to a java object of the given type. Argument is to be supplied in Jackson's canonical type string format (see {@link JavaType#toCanonical()}).<br> Note: the desired target type is not validated and needs to be trusted. @throws SpinJsonException if the json representation cannot be mapped to the specified type @throws SpinJsonDataFormatException if the parameter does not match a valid type
mapTo
java
camunda/camunda-bpm-platform
spin/dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/JacksonJsonNode.java
https://github.com/camunda/camunda-bpm-platform/blob/master/spin/dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/JacksonJsonNode.java
Apache-2.0
public String getCanonicalTypeName(Object object) { ensureNotNull("object", object); for (TypeDetector typeDetector : typeDetectors) { if (typeDetector.canHandle(object)) { return typeDetector.detectType(object); } } throw LOG.unableToDetectCanonicalType(object); }
Identifies the canonical type of an object heuristically. @return the canonical type identifier of the object's class according to Jackson's type format (see {@link TypeFactory#constructFromCanonical(String)})
getCanonicalTypeName
java
camunda/camunda-bpm-platform
spin/dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/format/JacksonJsonDataFormat.java
https://github.com/camunda/camunda-bpm-platform/blob/master/spin/dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/format/JacksonJsonDataFormat.java
Apache-2.0
static boolean bindingsArePresent(Class<?> erasedType, int expectedTypeParametersCount) { if (erasedType == null) { return false; } TypeVariable<? extends Class<?>>[] typeParameters = erasedType.getTypeParameters(); if (typeParameters.length == 0) { return false; } if (typeParameters.length != expectedTypeParametersCount) { throw new IllegalArgumentException( "Cannot create TypeBindings for class " + erasedType.getName() + " with " + expectedTypeParametersCount + " type parameter: class expects " + typeParameters.length + " type parameters."); } return true; }
Checks if the erased type has the correct number of type bindings. @param erasedType class of the type. @param expectedTypeParametersCount expected number of bindings. @return true if the number of type binding matches expected value.
bindingsArePresent
java
camunda/camunda-bpm-platform
spin/dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/format/TypeHelper.java
https://github.com/camunda/camunda-bpm-platform/blob/master/spin/dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/format/TypeHelper.java
Apache-2.0
static JavaType constructType(Object value) { TypeFactory typeFactory = TypeFactory.defaultInstance(); if (value instanceof Collection<?>) { Collection<?> collection = (Collection<?>) value; int size = collection.size(); if (size > 0) { Iterator<?> iterator = collection.iterator(); Object element = null; do { element = iterator.next(); if (bindingsArePresent(value.getClass(), 1) && (element != null || size == 1)) { JavaType elementType = constructType(element); return typeFactory.constructCollectionType(guessCollectionType(value), elementType); } } while (iterator.hasNext() && element == null); } } else if (value instanceof Map<?, ?>) { Map<?, ?> map = (Map<?, ?>) value; int size = map.size(); if (size > 0) { Set<? extends Map.Entry<?, ?>> entries = map.entrySet(); Iterator<? extends Map.Entry<?, ?>> iterator = entries.iterator(); Map.Entry<?, ?> entry = null; do { entry = iterator.next(); if (bindingsArePresent(value.getClass(), 2) && (entry.getValue() != null || size == 1)) { JavaType keyType = constructType(entry.getKey()); JavaType valueType = constructType(entry.getValue()); return typeFactory.constructMapType(Map.class, keyType, valueType); } } while (iterator.hasNext() && entry.getValue() == null); JavaType keyType = constructType(entry.getKey()); return typeFactory.constructMapType(Map.class, keyType, TypeFactory.unknownType()); } } if (value != null) { return typeFactory.constructType(value.getClass()); } else { return TypeFactory.unknownType(); } }
Constructs Java type based on the content values. @param value value with values. @return Java type.
constructType
java
camunda/camunda-bpm-platform
spin/dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/format/TypeHelper.java
https://github.com/camunda/camunda-bpm-platform/blob/master/spin/dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/format/TypeHelper.java
Apache-2.0
@SuppressWarnings({ "rawtypes", "unchecked" }) static Class<? extends Collection> guessCollectionType(Object value) { if (value instanceof Collection<?>) { return (Class<? extends Collection>) value.getClass(); } else { throw new IllegalArgumentException( "Could not detect class for " + value + " of type " + value.getClass().getName()); } }
Guess collection class. @param value collection. @return class of th collection implementation.
guessCollectionType
java
camunda/camunda-bpm-platform
spin/dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/format/TypeHelper.java
https://github.com/camunda/camunda-bpm-platform/blob/master/spin/dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/format/TypeHelper.java
Apache-2.0