diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/.clirr-jenkins-ignore.xml b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/.clirr-jenkins-ignore.xml
new file mode 100644
index 0000000000000000000000000000000000000000..2bfa1a887573cd337ec387d9fb14af2edcbf17bf
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/.clirr-jenkins-ignore.xml
@@ -0,0 +1,20 @@
+
+
+
+ **
+ 5000
+ **
+
+
+
+ **
+ 7012
+ *
+
+
+
+ **
+ 7013
+ *
+
+
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/.gitignore b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..d4e8132a12f8c24783e62d0d740eb078b9e16a0f
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/.gitignore
@@ -0,0 +1,20 @@
+.idea
+target
+.classpath
+.project
+.settings
+build.properties
+bin
+.metadata
+transaction.log
+nbactions*.xml
+nb-configuration.xml
+/webapps/fox-platform-tasklist/server-work
+dependency-reduced-pom.xml
+faces-config.NavData
+dependency-reduced-pom.xml
+*.iml
+*.sublime-project
+*.sublime-workspace
+*.swp
+
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/README.md b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..316bc82b0e3b0d73ac55f0144c36dfc9c2a24a49
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/README.md
@@ -0,0 +1,80 @@
+camunda-spin
+============
+
+
+ Home |
+ Documentation |
+ Forum |
+ Issues |
+ License |
+ Contribute
+
+
+Library for simple XML and JSON processing on the JVM (Java Virtual Machine), targeting Java and
+JVM-based scripting languages such as Groovy, JRuby, Jython, Javascript and Java Expression
+Language.
+
+# Why Spin?
+
+Spin is useful when you need to work with complex, text-based data formats (such as XML or JSON)
+without mapping to Java Objects.
+
+Spin provides a comprehensible fluent API for working with different data formats through
+lightweight wrapper objects:
+
+Given the following XML document as `String` or `InputStream`:
+
+```xml
+
+
+ Jonny P
+ Bobby G
+ Mary T
+
+```
+
+It can directly be worked on with Spin:
+
+```java
+import static org.camunda.spin.Spin.*;
+
+// get id of first customer
+XML( xmlInput ).childElements("customer")
+ .get(0)
+ .attr("id")
+ .value();
+
+// create new customer
+SpinXmlTreeElement kate = XML( " " )
+ .attr("id", "0004")
+ .append( XML("Kate S ") );
+
+// append to existing list
+XML( xmlInput ).append(kate);
+
+// query by Id:
+XML( xmlInput ).xPath("/customers/customer[@id='0002']").element();
+```
+
+
+# FAQ
+
+## Why should I use Spin instead of the Java DOM API?
+
+Java provides a built-in Dom API along with a Parser. Spin provides a lightweight Wrapper around
+the Dom API which makes it easier to work with than the Dom API. You can access the underlying Dom object
+at any time by unwrapping it:
+
+```java
+Element e = XML( xmlSource ).childElement("customer").unwrap();
+```
+
+
+# Contributing
+
+Have a look at our [contribution guide](https://github.com/camunda/camunda-bpm-platform/blob/master/CONTRIBUTING.md) for how to contribute to this repository.
+
+
+# License:
+
+The source files in this repository are made available under the [Apache License Version 2.0](../LICENSE).
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/bom/pom.xml b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/bom/pom.xml
new file mode 100644
index 0000000000000000000000000000000000000000..cab3e0af0e6ed7a9ffc3ec81414f97ca4fd90866
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/bom/pom.xml
@@ -0,0 +1,91 @@
+
+ 4.0.0
+
+
+
+ org.camunda.bpm
+ camunda-root
+ 7.24.0-SNAPSHOT
+ ../../pom.xml
+
+
+ org.camunda.spin
+ camunda-spin-bom
+ camunda spin - bom
+ 7.24.0-SNAPSHOT
+ pom
+
+
+ Note: 7.24.0 is the last community edition release published on Maven Central. This library will not receive any new versions or releases. However, if you are interested in extended maintenance you could look into our enterprise edition. Get in touch with us: https://camunda.com/contact/
+
+
+
+
+
+
+ org.camunda.spin
+ camunda-spin-core
+ ${project.version}
+
+
+
+ org.camunda.spin
+ camunda-spin-core
+ test-jar
+ ${project.version}
+
+
+
+ org.camunda.spin
+ camunda-spin-dataformat-all
+ ${project.version}
+
+
+
+ org.camunda.spin
+ camunda-spin-dataformat-json-jackson
+
+
+ org.camunda.spin
+ camunda-spin-dataformat-xml-dom
+
+
+ jakarta.xml.bind
+ jakarta.xml.bind-api
+
+
+ com.sun.xml.bind
+ jaxb-impl
+
+
+
+
+
+ org.camunda.spin
+ camunda-spin-dataformat-json-jackson
+ ${project.version}
+
+
+
+ org.camunda.spin
+ camunda-spin-dataformat-xml-dom
+ ${project.version}
+
+
+
+ org.camunda.spin
+ camunda-spin-dataformat-xml-dom-jakarta
+ ${project.version}
+
+
+
+
+
+ https://github.com/camunda/camunda-bpm-platform
+ scm:git:git@github.com:camunda/camunda-bpm-platform.git
+ scm:git:git@github.com:camunda/camunda-bpm-platform.git
+ HEAD
+
+
+
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/pom.xml b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/pom.xml
new file mode 100644
index 0000000000000000000000000000000000000000..b2713865047c80e5b00382b85fdbf722ac408e17
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/pom.xml
@@ -0,0 +1,269 @@
+
+ 4.0.0
+
+
+ Note: 7.24.0 is the last community edition release published on Maven Central. This library will not receive any new versions or releases. However, if you are interested in extended maintenance you could look into our enterprise edition. Get in touch with us: https://camunda.com/contact/
+
+
+
+ org.camunda.spin
+ camunda-spin-root
+ 7.24.0-SNAPSHOT
+
+
+ camunda-spin-core
+ camunda Spin - core
+
+
+
+
+ org.camunda.commons
+ camunda-commons-logging
+
+
+
+ org.camunda.commons
+ camunda-commons-utils
+
+
+
+ junit
+ junit
+ provided
+
+
+
+ org.assertj
+ assertj-core
+ test
+
+
+
+ org.apache.groovy
+ groovy-jsr223
+ test
+
+
+
+ org.python
+ jython
+ test
+
+
+
+ org.jruby
+ jruby-complete
+ test
+
+
+
+ org.graalvm.js
+ js
+ test
+
+
+
+ org.graalvm.js
+ js-scriptengine
+ test
+
+
+
+
+ ch.qos.logback
+ logback-classic
+ test
+
+
+
+ net.javacrumbs.json-unit
+ json-unit-fluent
+ test
+
+
+
+ org.powermock
+ powermock-module-junit4
+ test
+
+
+ org.powermock
+ powermock-api-mockito2
+ test
+
+
+
+
+
+
+ disable-javascript-tests
+
+ (,1.8)
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+ -XX:PermSize=128m
+
+ **/javascript/**
+
+
+
+
+
+
+
+
+ jdk-9-and-onwards
+
+ [9,)
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+ -XX:PermSize=128m
+
+ **/DataFormatLoadingTest.java
+
+
+
+
+
+
+
+ jdk-15-and-onwards
+
+ [15,)
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+
+ **/*NashornTest.java
+
+
+
+
+
+
+
+
+ jdk-16-and-onwards
+
+ [16,)
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+
+ -XX:MetaspaceSize=128m
+
+
+ **/*NashornTest.java
+
+
+
+
+
+
+
+
+
+ check-api-compatibility
+
+ (,)
+
+
+
+
+ org.codehaus.mojo
+ clirr-maven-plugin
+ 2.8
+
+ ${spin.version.old}
+ true
+
+ org/camunda/spin/impl/**
+
+
+
+
+ all
+ verify
+
+ check-no-fork
+
+
+ ${project.build.directory}/clirr-all.txt
+ false
+ false
+
+
+
+ restrictive
+ verify
+
+ check-no-fork
+
+
+ ${project.build.directory}/clirr-restrictive.txt
+ true
+ ../.clirr-jenkins-ignore.xml
+
+
+
+
+
+
+
+
+
+
+
+
+ org.apache.felix
+ maven-bundle-plugin
+
+
+
+ org.junit*;resolution:=optional,
+ *
+
+
+
+
+
+ bundle-manifest
+ process-classes
+
+ manifest
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+
+
+
+ test-jar
+
+
+
+
+
+
+
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/DataFormats.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/DataFormats.java
new file mode 100644
index 0000000000000000000000000000000000000000..52241d61223808ffb4f328cf88339caeab353b6c
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/DataFormats.java
@@ -0,0 +1,236 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.ServiceLoader;
+import java.util.Set;
+
+import org.camunda.spin.impl.logging.SpinCoreLogger;
+import org.camunda.spin.impl.logging.SpinLogger;
+import org.camunda.spin.json.SpinJsonNode;
+import org.camunda.spin.spi.DataFormat;
+import org.camunda.spin.spi.DataFormatConfigurator;
+import org.camunda.spin.spi.DataFormatProvider;
+import org.camunda.spin.xml.SpinXmlElement;
+
+/**
+ * Provides access to all builtin data formats.
+ *
+ * @author Sebastian Menski
+ * @author Daniel Meyer
+ */
+public class DataFormats {
+
+ private static SpinCoreLogger LOG = SpinLogger.CORE_LOGGER;
+
+ public static String JSON_DATAFORMAT_NAME = "application/json";
+
+ public static String XML_DATAFORMAT_NAME = "application/xml";
+
+ /** The global instance of the manager */
+ static DataFormats INSTANCE = new DataFormats();
+
+ /**
+ * Provides the global instance of the DataFormats manager.
+ * @return the global instance.
+ */
+ public static DataFormats getInstance() {
+ return INSTANCE;
+ }
+
+ /**
+ * Returns the global xml data format that can be provided with
+ * configuration that applies to any Spin xml operation.
+ */
+ @SuppressWarnings("unchecked")
+ public static DataFormat xml() {
+ return (DataFormat) getDataFormat(XML_DATAFORMAT_NAME);
+ }
+
+ /**
+ * Returns the global json data format that can be provided with
+ * configuration that applies to any Spin json operation.
+ */
+ @SuppressWarnings("unchecked")
+ public static DataFormat json() {
+ return (DataFormat) getDataFormat(JSON_DATAFORMAT_NAME);
+ }
+
+ /**
+ * 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
+ */
+ public static DataFormat extends Spin>> getDataFormat(String dataFormatName) {
+ return INSTANCE.getDataFormatByName(dataFormatName);
+ }
+
+ /**
+ * @return a set of all registered data formats
+ */
+ public static Set>> getAvailableDataFormats() {
+ return INSTANCE.getAllAvailableDataFormats();
+ }
+
+ // instance /////////////////////////////////////////////////////
+
+ protected Map> availableDataFormats;
+
+ public Set>> getAllAvailableDataFormats() {
+ ensureDataformatsInitialized();
+ return new HashSet<>(availableDataFormats.values());
+ }
+
+ public DataFormat extends Spin>> getDataFormatByName(String name) {
+ ensureDataformatsInitialized();
+ return availableDataFormats.get(name);
+ }
+
+ /**
+ * Detect all available dataformats on the classpath using a {@link ServiceLoader}.
+ */
+ protected void ensureDataformatsInitialized() {
+ if(availableDataFormats == null) {
+ synchronized(DataFormats.class) {
+ if(availableDataFormats == null) {
+ registerDataFormats(null);
+ }
+ }
+ }
+ }
+
+ public void registerDataFormats(ClassLoader classloader) {
+ registerDataFormats(classloader, Collections.EMPTY_LIST, Collections.EMPTY_MAP);
+ }
+
+ public void registerDataFormats(ClassLoader classloader,
+ List configurators) {
+ registerDataFormats(classloader, configurators, Collections.EMPTY_MAP);
+ }
+ public void registerDataFormats(ClassLoader classloader,
+ List configurators,
+ Map configurationProperties) {
+
+ Map> dataFormats = new HashMap<>();
+
+ if(classloader == null) {
+ classloader = DataFormats.class.getClassLoader();
+ }
+
+ // discover available custom dataformat providers on the classpath
+ registerCustomDataFormats(dataFormats, classloader, configurationProperties);
+
+ // discover and apply data format configurators on the classpath
+ applyConfigurators(dataFormats, classloader, configurators);
+
+ LOG.logDataFormats(dataFormats.values());
+
+ this.availableDataFormats = dataFormats;
+ }
+
+ protected void registerCustomDataFormats(Map> dataFormats, ClassLoader classloader) {
+ registerCustomDataFormats(dataFormats, classloader, Collections.EMPTY_MAP);
+ }
+
+ protected void registerCustomDataFormats(Map> dataFormats,
+ ClassLoader classloader,
+ Map configurationProperties) {
+ // use java.util.ServiceLoader to load custom DataFormatProvider instances on the classpath
+ ServiceLoader providerLoader = ServiceLoader.load(DataFormatProvider.class, classloader);
+
+ for (DataFormatProvider provider : providerLoader) {
+ LOG.logDataFormatProvider(provider);
+ registerProvider(dataFormats, provider, configurationProperties);
+ }
+ }
+
+ protected void registerProvider(Map> dataFormats,
+ DataFormatProvider provider) {
+ registerProvider(dataFormats, provider, Collections.EMPTY_MAP);
+ }
+
+ protected void registerProvider(Map> dataFormats,
+ DataFormatProvider provider,
+ Map configurationProperties) {
+
+ String dataFormatName = provider.getDataFormatName();
+
+ if(dataFormats.containsKey(dataFormatName)) {
+ throw LOG.multipleProvidersForDataformat(dataFormatName);
+ }
+ else {
+ DataFormat> dataFormatInstance = provider.createInstance(configurationProperties);
+ dataFormats.put(dataFormatName, dataFormatInstance);
+ }
+ }
+
+ @SuppressWarnings("rawtypes")
+ protected void applyConfigurators(Map> dataFormats, ClassLoader classloader) {
+ applyConfigurators(dataFormats, classloader, Collections.EMPTY_LIST);
+ }
+
+ protected void applyConfigurators(Map> dataFormats,
+ ClassLoader classloader,
+ List dataFormatConfigurators) {
+
+ ServiceLoader configuratorLoader = ServiceLoader.load(DataFormatConfigurator.class, classloader);
+
+ // apply SPI configurators
+ for (DataFormatConfigurator configurator : configuratorLoader) {
+ LOG.logDataFormatConfigurator(configurator);
+ applyConfigurator(dataFormats, configurator);
+ }
+
+ // apply additional, non-SPI, configurators
+ for (DataFormatConfigurator configurator : dataFormatConfigurators) {
+ LOG.logDataFormatConfigurator(configurator);
+ applyConfigurator(dataFormats, configurator);
+ }
+ }
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ protected void applyConfigurator(Map> dataFormats, DataFormatConfigurator configurator) {
+ for (DataFormat> dataFormat : dataFormats.values()) {
+ if (configurator.getDataFormatClass().isAssignableFrom(dataFormat.getClass())) {
+ configurator.configure(dataFormat);
+ }
+ }
+ }
+
+ public static void loadDataFormats() {
+ loadDataFormats(null);
+ }
+
+ public static void loadDataFormats(ClassLoader classloader) {
+ INSTANCE.registerDataFormats(classloader);
+ }
+
+ public static void loadDataFormats(ClassLoader classloader, List configurators) {
+ INSTANCE.registerDataFormats(classloader, configurators);
+ }
+
+ public static void loadDataFormats(ClassLoader classloader, Map configurationProperties) {
+ INSTANCE.registerDataFormats(classloader, Collections.EMPTY_LIST, configurationProperties);
+ }
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/DeserializationTypeValidator.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/DeserializationTypeValidator.java
new file mode 100644
index 0000000000000000000000000000000000000000..479eef4978b994eb75dc902ca55166a36afd17f1
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/DeserializationTypeValidator.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin;
+
+public interface DeserializationTypeValidator {
+
+ boolean validate(String type);
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/Spin.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/Spin.java
new file mode 100644
index 0000000000000000000000000000000000000000..34c0cf34dd4a991134b5684c587266bcffce70d1
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/Spin.java
@@ -0,0 +1,143 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin;
+
+import java.io.Writer;
+
+import org.camunda.spin.json.SpinJsonNode;
+import org.camunda.spin.spi.DataFormat;
+import org.camunda.spin.xml.SpinXmlElement;
+
+/**
+ *
+ * @author Sebastian Menski
+ * @author Daniel Meyer
+ */
+public abstract class Spin> {
+
+ /**
+ * 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')
+ */
+ public static > T S(Object input, DataFormat 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 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')
+ */
+ public static > T S(Object input, String dataFormatName) {
+ return SpinFactory.INSTANCE.createSpin(input, dataFormatName);
+ }
+
+ /**
+ * 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')
+ */
+ public static > T S(Object input) {
+ return SpinFactory.INSTANCE.createSpin(input);
+ }
+
+ /**
+ * 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')
+ */
+ 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 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')
+ */
+ public static SpinJsonNode JSON(Object input) {
+ return SpinFactory.INSTANCE.createSpin(input, DataFormats.json());
+ }
+
+ /**
+ * Provides the name of the dataformat used by this spin.
+ *
+ * @return the name of the dataformat used by this Spin.
+ */
+ public abstract String getDataFormatName();
+
+ /**
+ * Return the wrapped object. The return type of this method
+ * depends on the concrete data format.
+ *
+ * @return the object wrapped by this wrapper.
+ */
+ public abstract Object unwrap();
+
+ /**
+ * Returns the wrapped object as string representation.
+ *
+ * @return the string representation
+ */
+ public abstract String toString();
+
+ /**
+ * Writes the wrapped object to a existing writer.
+ *
+ * @param writer the writer to write to
+ */
+ public abstract void writeToWriter(Writer writer);
+
+ /**
+ * Maps the wrapped object to an instance of a java class.
+ *
+ * @param type the java class to map to
+ * @return the mapped object
+ */
+ public abstract C mapTo(Class type);
+
+ /**
+ * Maps the wrapped object to a java object.
+ * The object is determined based on the configuration string
+ * which is data format specific.
+ *
+ * @param type the class name to map to
+ * @return the mapped object
+ */
+ public abstract C mapTo(String type);
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/SpinCollection.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/SpinCollection.java
new file mode 100644
index 0000000000000000000000000000000000000000..4615a0908522fc2c2847210816005e51edc5c774
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/SpinCollection.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin;
+
+import java.util.Collection;
+
+/**
+ *
+ * @author Sebastian Menski
+ * @author Daniel Meyer
+ */
+public interface SpinCollection> extends Collection {
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/SpinFactory.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/SpinFactory.java
new file mode 100644
index 0000000000000000000000000000000000000000..5f5ab72fc68d60c76720d136dc3b7d15f38ddc54
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/SpinFactory.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin;
+
+import org.camunda.spin.impl.SpinFactoryImpl;
+import org.camunda.spin.spi.DataFormat;
+
+/**
+ *
+ * @author Sebastian Menski
+ * @author Daniel Meyer
+ */
+public abstract class SpinFactory {
+
+ /**
+ * The singleton instance of the SpinFactory.
+ */
+ public static SpinFactory INSTANCE = new SpinFactoryImpl();
+
+ public abstract > T createSpin(Object parameter);
+
+ public abstract > T createSpin(Object parameter, DataFormat format);
+
+ public abstract > T createSpin(Object parameter, String dataFormatName);
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/SpinFileNotFoundException.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/SpinFileNotFoundException.java
new file mode 100644
index 0000000000000000000000000000000000000000..6a40c15cb60eb78e9bd28be5f5c72bac66c1302b
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/SpinFileNotFoundException.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin;
+
+import org.camunda.spin.SpinRuntimeException;
+
+/**
+ * @author Sebastian Menski
+ */
+public class SpinFileNotFoundException extends SpinRuntimeException {
+
+ private static final long serialVersionUID = 1L;
+
+ public SpinFileNotFoundException(String message) {
+ super(message);
+ }
+
+ public SpinFileNotFoundException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/SpinList.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/SpinList.java
new file mode 100644
index 0000000000000000000000000000000000000000..02fafe7b1cfe3e860ecbb479fc8af774775dc31f
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/SpinList.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin;
+
+import java.util.List;
+
+/**
+ * @author Sebastian Menski
+ */
+public interface SpinList> extends List {
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/SpinRuntimeException.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/SpinRuntimeException.java
new file mode 100644
index 0000000000000000000000000000000000000000..f5c5604fba8dcb7786b65e841414ba595e7f200e
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/SpinRuntimeException.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin;
+
+/**
+ * @author Sebastian Menski
+ */
+public class SpinRuntimeException extends RuntimeException {
+
+ private static final long serialVersionUID = 1L;
+
+ public SpinRuntimeException(String message) {
+ super(message);
+ }
+
+ public SpinRuntimeException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/SpinScriptException.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/SpinScriptException.java
new file mode 100644
index 0000000000000000000000000000000000000000..31de35a7d04b6e9872341f4c8475f76d736ee8ce
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/SpinScriptException.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin;
+
+/**
+ * @author Sebastian Menski
+ */
+public class SpinScriptException extends SpinRuntimeException {
+
+ private static final long serialVersionUID = 1L;
+
+ public SpinScriptException(String message) {
+ super(message);
+ }
+
+ public SpinScriptException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/impl/SpinFactoryImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/impl/SpinFactoryImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..49003802b8e6ec705f1c7a1109b9e24f93f36783
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/impl/SpinFactoryImpl.java
@@ -0,0 +1,171 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.impl;
+
+import static org.camunda.commons.utils.EnsureUtil.ensureNotNull;
+
+import java.io.IOException;
+import java.io.Reader;
+
+import org.camunda.spin.DataFormats;
+import org.camunda.spin.Spin;
+import org.camunda.spin.SpinFactory;
+import org.camunda.spin.impl.logging.SpinCoreLogger;
+import org.camunda.spin.impl.util.RewindableReader;
+import org.camunda.spin.impl.util.SpinIoUtil;
+import org.camunda.spin.spi.DataFormat;
+import org.camunda.spin.spi.DataFormatMapper;
+import org.camunda.spin.spi.DataFormatReader;
+import org.camunda.spin.spi.SpinDataFormatException;
+
+/**
+ * @author Daniel Meyer
+ * @author Sebastian Menski
+ *
+ */
+public class SpinFactoryImpl extends SpinFactory {
+
+ private static final SpinCoreLogger LOG = SpinCoreLogger.CORE_LOGGER;
+
+ private static final int READ_SIZE = 256;
+
+ @SuppressWarnings("unchecked")
+ public > T createSpin(Object parameter) {
+ ensureNotNull("parameter", parameter);
+
+ if (parameter instanceof String) {
+ return createSpinFromString((String) parameter);
+
+ } else if (parameter instanceof Reader) {
+ return createSpinFromReader((Reader) parameter);
+
+ } else if (parameter instanceof Spin) {
+ return createSpinFromSpin((T) parameter);
+
+ } else {
+ throw LOG.unsupportedInputParameter(parameter.getClass());
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public > T createSpin(Object parameter, DataFormat format) {
+ ensureNotNull("parameter", parameter);
+ ensureNotNull("format", format);
+
+ if (parameter instanceof String) {
+ return createSpinFromString((String) parameter, format);
+
+ } else if (parameter instanceof Reader) {
+ return createSpinFromReader((Reader) parameter, format);
+
+ } else if (parameter instanceof Spin) {
+ return createSpinFromSpin((T) parameter, format);
+
+ } else {
+ return createSpinFromObject(parameter, format);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public > T createSpin(Object parameter, String dataFormatName) {
+ ensureNotNull("dataFormatName", dataFormatName);
+
+ DataFormat dataFormat = (DataFormat) DataFormats.getDataFormat(dataFormatName);
+
+ return createSpin(parameter, dataFormat);
+ }
+
+ /**
+ *
+ * @throws SpinDataFormatException in case the parameter cannot be read using this data format
+ * @throws IllegalArgumentException in case the parameter is null or dd:
+ */
+ public > T createSpinFromSpin(T parameter) {
+ ensureNotNull("parameter", parameter);
+
+ return parameter;
+ }
+
+ public > T createSpinFromString(String parameter) {
+ ensureNotNull("parameter", parameter);
+
+ Reader input = SpinIoUtil.stringAsReader(parameter);
+ return createSpin(input);
+ }
+
+ @SuppressWarnings("unchecked")
+ public > T createSpinFromReader(Reader parameter) {
+ ensureNotNull("parameter", parameter);
+
+ RewindableReader rewindableReader = new RewindableReader(parameter, READ_SIZE);
+
+ DataFormat matchingDataFormat = null;
+ for (DataFormat> format : DataFormats.getAvailableDataFormats()) {
+ if (format.getReader().canRead(rewindableReader, rewindableReader.getRewindBufferSize())) {
+ matchingDataFormat = (DataFormat) format;
+ }
+
+ try {
+ rewindableReader.rewind();
+ } catch (IOException e) {
+ throw LOG.unableToReadFromReader(e);
+ }
+
+ }
+
+ if (matchingDataFormat == null) {
+ throw LOG.unrecognizableDataFormatException();
+ }
+
+ return createSpin(rewindableReader, matchingDataFormat);
+ }
+
+ /**
+ *
+ * @throws SpinDataFormatException in case the parameter cannot be read using this data format
+ * @throws IllegalArgumentException in case the parameter is null or dd:
+ */
+ public > T createSpinFromSpin(T parameter, DataFormat format) {
+ ensureNotNull("parameter", parameter);
+
+ return parameter;
+ }
+
+ public > T createSpinFromString(String parameter, DataFormat format) {
+ ensureNotNull("parameter", parameter);
+
+ Reader input = SpinIoUtil.stringAsReader(parameter);
+ return createSpin(input, format);
+ }
+
+ public > T createSpinFromReader(Reader parameter, DataFormat format) {
+ ensureNotNull("parameter", parameter);
+
+ DataFormatReader reader = format.getReader();
+ Object dataFormatInput = reader.readInput(parameter);
+ return format.createWrapperInstance(dataFormatInput);
+ }
+
+ public > T createSpinFromObject(Object parameter, DataFormat format) {
+ ensureNotNull("parameter", parameter);
+
+ DataFormatMapper mapper = format.getMapper();
+ Object dataFormatInput = mapper.mapJavaToInternal(parameter);
+
+ return format.createWrapperInstance(dataFormatInput);
+ }
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/impl/SpinListImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/impl/SpinListImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..fe8248478aba9e2a828f164dd732178b5db2100a
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/impl/SpinListImpl.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.impl;
+
+import org.camunda.spin.Spin;
+import org.camunda.spin.SpinList;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+/**
+ * @author Sebastian Menski
+ */
+public class SpinListImpl> extends ArrayList implements SpinList {
+
+ private static final long serialVersionUID = 1L;
+
+ public SpinListImpl() {
+ super();
+ }
+
+ public SpinListImpl(int initialCapacity) {
+ super(initialCapacity);
+ }
+
+ public SpinListImpl(Collection extends E> c) {
+ super(c);
+ }
+
+ public SpinListImpl(Iterable iterable) {
+ super();
+ for (E e : iterable) {
+ add(e);
+ }
+ }
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/impl/logging/SpinCoreLogger.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/impl/logging/SpinCoreLogger.java
new file mode 100644
index 0000000000000000000000000000000000000000..6fec7250bff5e184f94c26418ff249fb92e84cac
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/impl/logging/SpinCoreLogger.java
@@ -0,0 +1,107 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.impl.logging;
+
+import java.io.IOException;
+import java.util.Collection;
+
+import org.camunda.spin.SpinFileNotFoundException;
+import org.camunda.spin.SpinRuntimeException;
+import org.camunda.spin.SpinScriptException;
+import org.camunda.spin.spi.DataFormat;
+import org.camunda.spin.spi.DataFormatConfigurator;
+import org.camunda.spin.spi.DataFormatProvider;
+import org.camunda.spin.spi.SpinDataFormatException;
+
+
+/**
+ * The Logger for the core api.
+ *
+ * @author Daniel Meyer
+ * @author Sebastian Menski
+ *
+ */
+public class SpinCoreLogger extends SpinLogger {
+
+ public IllegalArgumentException unsupportedInputParameter(Class> parameterClass) {
+ return new IllegalArgumentException(exceptionMessage("001", "Unsupported input of type '{}'", parameterClass.getName()));
+ }
+
+ public SpinFileNotFoundException fileNotFoundException(String filename, Throwable cause) {
+ return new SpinFileNotFoundException(exceptionMessage("002", "Unable to find file with path '{}'", filename), cause);
+ }
+
+ public SpinFileNotFoundException fileNotFoundException(String filename) {
+ return fileNotFoundException(filename, null);
+ }
+
+ public SpinRuntimeException unableToReadFromReader(Exception e) {
+ return new SpinRuntimeException(exceptionMessage("003", "Unable to read from reader"), e);
+ }
+
+ public SpinDataFormatException unrecognizableDataFormatException() {
+ return new SpinDataFormatException(exceptionMessage("004", "No matching data format detected"));
+ }
+
+ public SpinScriptException noScriptEnvFoundForLanguage(String scriptLanguage, String path) {
+ return new SpinScriptException(exceptionMessage("006", "No script script env found for script language '{}' at path '{}'", scriptLanguage, path));
+ }
+
+ public IOException unableToRewindReader() {
+ return new IOException(exceptionMessage("007", "Unable to rewind input stream: rewind buffering limit exceeded"));
+ }
+
+ public SpinDataFormatException multipleProvidersForDataformat(String dataFormatName) {
+ return new SpinDataFormatException(exceptionMessage("008", "Multiple providers found for dataformat '{}'", dataFormatName));
+ }
+
+ public void logDataFormats(Collection> formats) {
+ if (isInfoEnabled()) {
+ for (DataFormat> format : formats) {
+ logDataFormat(format);
+ }
+ }
+ }
+
+ protected void logDataFormat(DataFormat> dataFormat) {
+ logInfo("009", "Discovered Spin data format: {}[name = {}]", dataFormat.getClass().getName(), dataFormat.getName());
+ }
+
+ public void logDataFormatProvider(DataFormatProvider provider) {
+ if (isInfoEnabled()) {
+ logInfo("010", "Discovered Spin data format provider: {}[name = {}]",
+ provider.getClass().getName(), provider.getDataFormatName());
+ }
+ }
+
+ @SuppressWarnings("rawtypes")
+ public void logDataFormatConfigurator(DataFormatConfigurator configurator) {
+ if (isInfoEnabled()) {
+ logInfo("011", "Discovered Spin data format configurator: {}[dataformat = {}]",
+ configurator.getClass(), configurator.getDataFormatClass().getName());
+ }
+ }
+
+
+ public SpinDataFormatException classNotFound(String classname, ClassNotFoundException cause) {
+ return new SpinDataFormatException(exceptionMessage("012", "Class {} not found ", classname), cause);
+ }
+
+ public void tryLoadingClass(String classname, ClassLoader cl) {
+ logDebug("013", "Try loading class '{}' using classloader '{}'.", classname, cl);
+ }
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/impl/logging/SpinLogger.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/impl/logging/SpinLogger.java
new file mode 100644
index 0000000000000000000000000000000000000000..362947e33a11fe3754eede65fc508254be726738
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/impl/logging/SpinLogger.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.impl.logging;
+
+import org.camunda.commons.logging.BaseLogger;
+
+/**
+ * @author Daniel Meyer
+ *
+ */
+public abstract class SpinLogger extends BaseLogger {
+
+ public static final String PROJECT_CODE = "SPIN";
+
+ public static final SpinCoreLogger CORE_LOGGER = BaseLogger.createLogger(SpinCoreLogger.class, PROJECT_CODE, "org.camunda.spin", "01");
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/impl/util/RewindableReader.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/impl/util/RewindableReader.java
new file mode 100644
index 0000000000000000000000000000000000000000..33a223d2f8750a34bd6c17c9b2b5f5657167f679
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/impl/util/RewindableReader.java
@@ -0,0 +1,131 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.impl.util;
+
+import java.io.IOException;
+import java.io.PushbackReader;
+import java.io.Reader;
+
+import org.camunda.spin.impl.logging.SpinCoreLogger;
+import org.camunda.spin.impl.logging.SpinLogger;
+
+/**
+ * Caches the initial characters that are read from the supplied {@link Reader} and
+ * allows to rewind these. As soon as more than size characters have been read,
+ * rewinding fails.
+ *
+ * @author Thorben Lindhauer
+ */
+public class RewindableReader extends Reader {
+
+ private static final SpinCoreLogger LOG = SpinLogger.CORE_LOGGER;
+
+ protected PushbackReader wrappedReader;
+
+ protected char[] buffer;
+ protected int pos;
+ protected boolean rewindable;
+
+ public RewindableReader(Reader input, int size) {
+ this.wrappedReader = new PushbackReader(input, size);
+ this.buffer = new char[size];
+ this.pos = 0;
+ this.rewindable = true;
+ }
+
+ public int read(char[] cbuf, int off, int len) throws IOException {
+ int charactersRead = wrappedReader.read(cbuf, off, len);
+
+ if (charactersRead > 0) {
+ if (rewindable && pos + charactersRead > buffer.length) {
+ rewindable = false;
+ }
+
+ if (pos < buffer.length) {
+ int freeBufferSpace = buffer.length - pos;
+ int insertableCharacters = Math.min(charactersRead, freeBufferSpace);
+ System.arraycopy(cbuf, off, buffer, pos, insertableCharacters);
+ pos += insertableCharacters;
+ }
+ }
+
+ return charactersRead;
+ }
+
+ public int read() throws IOException {
+ int nextCharacter = wrappedReader.read();
+
+ if (nextCharacter != -1) {
+ if (pos < buffer.length) {
+ buffer[pos] = (char) nextCharacter;
+ pos++;
+ } else if (rewindable && pos >= buffer.length) {
+ rewindable = false;
+ }
+ }
+
+ return nextCharacter;
+ }
+
+ public void close() throws IOException {
+ wrappedReader.close();
+ }
+
+ public synchronized void mark(int readlimit) throws IOException {
+ wrappedReader.mark(readlimit);
+ }
+
+ public boolean markSupported() {
+ return wrappedReader.markSupported();
+ }
+
+ public synchronized void reset() throws IOException {
+ wrappedReader.reset();
+ }
+
+ public long skip(long n) throws IOException {
+ return wrappedReader.skip(n);
+ }
+
+ /**
+ * Rewinds the reader such that the initial characters are returned when invoking read().
+ *
+ * Throws an exception if more than the buffering limit has already been read.
+ * @throws IOException
+ */
+ public void rewind() throws IOException {
+ if (!rewindable) {
+ throw LOG.unableToRewindReader();
+ }
+
+ wrappedReader.unread(buffer, 0, pos);
+ pos = 0;
+ }
+
+ public int getRewindBufferSize() {
+ return buffer.length;
+ }
+
+ /**
+ *
+ * @return the number of characters that can still be read and rewound.
+ */
+ public int getCurrentRewindableCapacity() {
+ return buffer.length - pos;
+ }
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/impl/util/SpinIoUtil.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/impl/util/SpinIoUtil.java
new file mode 100644
index 0000000000000000000000000000000000000000..ef742df3476ec22479a0fcb420b16460cd49bdc6
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/impl/util/SpinIoUtil.java
@@ -0,0 +1,139 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.impl.util;
+
+import org.camunda.commons.utils.IoUtil;
+import org.camunda.spin.impl.logging.SpinCoreLogger;
+import org.camunda.spin.impl.logging.SpinLogger;
+
+import java.io.*;
+import java.nio.charset.Charset;
+
+/**
+ * @author Daniel Meyer
+ *
+ */
+public class SpinIoUtil extends IoUtil {
+
+ public static final Charset ENCODING_CHARSET = Charset.forName("UTF-8");
+
+ private static final SpinCoreLogger LOG = SpinLogger.CORE_LOGGER;
+
+ /**
+ * Converts a {@link OutputStream} to an {@link InputStream} by coping the data directly.
+ * WARNING: Do not use for large data (>100MB). Only for testing purpose.
+ *
+ * @param outputStream the {@link OutputStream} to convert
+ * @return the resulting {@link InputStream}
+ */
+ public static InputStream convertOutputStreamToInputStream(OutputStream outputStream) {
+ byte[] data = ((ByteArrayOutputStream) outputStream).toByteArray();
+ return new ByteArrayInputStream(data);
+ }
+
+ /**
+ * Convert an {@link InputStream} to a {@link String}
+ *
+ * @param inputStream the {@link InputStream} to convert
+ * @return the resulting {@link String}
+ * @throws IOException
+ */
+ public static String getStringFromInputStream(InputStream inputStream) throws IOException {
+ return getStringFromInputStream(inputStream, true);
+ }
+
+ /**
+ * Convert an {@link InputStream} to a {@link String}
+ *
+ * @param inputStream the {@link InputStream} to convert
+ * @param trim trigger if whitespaces are trimmed in the output
+ * @return the resulting {@link String}
+ * @throws IOException
+ */
+ public static String getStringFromInputStream(InputStream inputStream, boolean trim) throws IOException {
+ BufferedReader bufferedReader = null;
+ StringBuilder stringBuilder = new StringBuilder();
+ try {
+ bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
+ String line;
+ while ((line = bufferedReader.readLine()) != null) {
+ if (trim) {
+ stringBuilder.append(line.trim());
+ } else {
+ stringBuilder.append(line).append("\n");
+ }
+ }
+ } finally {
+ closeSilently(bufferedReader);
+ }
+
+ return stringBuilder.toString();
+ }
+
+ /**
+ * Convert an {@link Reader} to a {@link String}
+ *
+ * @param reader the {@link Reader} to convert
+ * @return the resulting {@link String}
+ * @throws IOException
+ */
+ 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
+ * @param trim trigger if whitespaces are trimmed in the output
+ * @return the resulting {@link String}
+ * @throws IOException
+ */
+ public static String getStringFromReader(Reader reader, boolean trim) throws IOException {
+ BufferedReader bufferedReader = null;
+ StringBuilder stringBuilder = new StringBuilder();
+ try {
+ bufferedReader = new BufferedReader(reader);
+ String line;
+ while ((line = bufferedReader.readLine()) != null) {
+ if (trim) {
+ stringBuilder.append(line.trim());
+ } else {
+ stringBuilder.append(line).append("\n");
+ }
+ }
+ } finally {
+ closeSilently(bufferedReader);
+ }
+
+ return stringBuilder.toString();
+ }
+
+ public static Reader classpathResourceAsReader(String fileName) {
+ try {
+ File classpathFile = getClasspathFile(fileName);
+ return new FileReader(classpathFile);
+ } catch (FileNotFoundException e) {
+ throw LOG.fileNotFoundException(fileName, e);
+ }
+ }
+
+ public static Reader stringAsReader(String string) {
+ return new StringReader(string);
+ }
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/impl/util/SpinReflectUtil.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/impl/util/SpinReflectUtil.java
new file mode 100644
index 0000000000000000000000000000000000000000..677d5f606698437d0829c68abc35a2739d65020e
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/impl/util/SpinReflectUtil.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.impl.util;
+
+import org.camunda.spin.impl.logging.SpinCoreLogger;
+import org.camunda.spin.spi.DataFormat;
+
+/**
+ * @author Daniel Meyer
+ *
+ */
+public class SpinReflectUtil {
+
+ private final static SpinCoreLogger LOG = SpinCoreLogger.CORE_LOGGER;
+
+ /**
+ * Used by dataformats if they need to load a class
+ *
+ * @param classname the name of the
+ * @param dataFormat
+ * @return
+ */
+ 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);
+ }
+
+ }
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/json/SpinJsonDataFormatException.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/json/SpinJsonDataFormatException.java
new file mode 100644
index 0000000000000000000000000000000000000000..f25b93e041d7c9994e45e2ab9d6ecb210561a1cf
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/json/SpinJsonDataFormatException.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.json;
+
+import org.camunda.spin.spi.SpinDataFormatException;
+
+public class SpinJsonDataFormatException extends SpinDataFormatException {
+
+ public SpinJsonDataFormatException(String message) {
+ super(message);
+ }
+
+ public SpinJsonDataFormatException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ private static final long serialVersionUID = 1L;
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/json/SpinJsonException.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/json/SpinJsonException.java
new file mode 100644
index 0000000000000000000000000000000000000000..0d66e4d6d8ba689b234b8e201eb82aa53ae8aee4
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/json/SpinJsonException.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.json;
+
+import org.camunda.spin.SpinRuntimeException;
+
+/**
+ * @author Stefan Hentschel
+ */
+public class SpinJsonException extends SpinRuntimeException {
+
+ private static final long serialVersionUID = 1L;
+
+ public SpinJsonException(String message) {
+ super(message);
+ }
+
+ public SpinJsonException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/json/SpinJsonNode.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/json/SpinJsonNode.java
new file mode 100644
index 0000000000000000000000000000000000000000..58883022abc0a30b715a62532429c7a561335be7
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/json/SpinJsonNode.java
@@ -0,0 +1,352 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.json;
+
+import org.camunda.spin.Spin;
+import org.camunda.spin.SpinList;
+import org.camunda.spin.spi.SpinDataFormatException;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * A json node.
+ *
+ * @author Thorben Lindhauer
+ * @author Stefan Hentschel
+ */
+public abstract class SpinJsonNode extends Spin {
+
+ /**
+ * Fetches the first index of the searched object in an array.
+ *
+ * @param searchObject Object for which the index should be searched.
+ * @return {@link Integer} index of searchObject.
+ * @throws SpinJsonException if the current node is not an array.
+ * @throws SpinJsonPropertyException if object is not found.
+ */
+ public abstract Integer indexOf(Object searchObject);
+
+ /**
+ * Fetches the last index of the searched object in an array.
+ *
+ * @param searchObject Object for which the index should be searched.
+ * @return {@link Integer} index of searchObject.
+ * @throws SpinJsonException if the current node is not an array.
+ * @throws SpinJsonPropertyException if object is not found.
+ */
+ public abstract Integer lastIndexOf(Object searchObject);
+
+ /**
+ * Returns {@code true} if the array contains the specified object.
+ *
+ * @param searchObject Object for which the array should be searched.
+ * @return {@code true} if the array contains the object.
+ * @throws SpinJsonException if the current node is not an array.
+ */
+ public abstract boolean contains(Object searchObject);
+
+ /**
+ * Check if this node is an object node.
+ *
+ * @return true if the node is an object, false otherwise
+ */
+ public abstract boolean isObject();
+
+ /**
+ * Check if this node has a property with the given name.
+ *
+ * @param name the name of the property
+ * @return true if this node has a property with this name, false otherwise
+ */
+ public abstract boolean hasProp(String name);
+
+ /**
+ * Get the property of this node with the given name.
+ *
+ * @param name the name of the property
+ * @return {@link SpinJsonNode} representation of the property
+ */
+ public abstract SpinJsonNode prop(String name);
+
+ /**
+ * Set a new String property in this node.
+ *
+ * @param name the name of the new property
+ * @param newProperty the new String property
+ * @return {@link SpinJsonNode} representation of the current node
+ */
+ public abstract SpinJsonNode prop(String name, String newProperty);
+
+ /**
+ * Set a new Number property in this node.
+ *
+ * @param name the name of the new property
+ * @param newProperty the new Number property
+ * @return {@link SpinJsonNode} representation of the current node
+ */
+ public abstract SpinJsonNode prop(String name, Number newProperty);
+
+ /**
+ * Set a new int property in this node.
+ *
+ * @param name the name of the new property
+ * @param newProperty the new int property
+ * @return {@link SpinJsonNode} representation of the current node
+ */
+ public abstract SpinJsonNode prop(String name, int newProperty);
+
+ /**
+ * Set a new float property in this node.
+ *
+ * @param name the name of the new property
+ * @param newProperty the new float property
+ * @return {@link SpinJsonNode} representation of the current node
+ */
+ public abstract SpinJsonNode prop(String name, float newProperty);
+
+ /**
+ * Set a new long property in this node.
+ *
+ * @param name the name of the new property
+ * @param newProperty the new long property
+ * @return {@link SpinJsonNode} representation of the current node
+ */
+ public abstract SpinJsonNode prop(String name, long newProperty);
+
+ /**
+ * Set a new boolean property in this node.
+ *
+ * @param name the name of the new property
+ * @param newProperty the new boolean property
+ * @return {@link SpinJsonNode} representation of the current node
+ */
+ public abstract SpinJsonNode prop(String name, boolean newProperty);
+
+ /**
+ * Set a new Boolean property in this node.
+ *
+ * @param name the name of the new property
+ * @param newProperty the new Boolean property
+ * @return {@link SpinJsonNode} representation of the current node
+ */
+ public abstract SpinJsonNode prop(String name, Boolean newProperty);
+
+ /**
+ * Set a new List property in this node.
+ *
+ * @param name the name of the new property
+ * @param newProperty the new List property
+ * @return {@link SpinJsonNode} representation of the current node
+ */
+ public abstract SpinJsonNode prop(String name, List newProperty);
+
+ /**
+ * Set a new Map property in this node.
+ *
+ * @param name the name of the new property
+ * @param newProperty the new Map property
+ * @return {@link SpinJsonNode} representation of the current node
+ */
+ public abstract SpinJsonNode prop(String name, Map newProperty);
+
+ /**
+ * Set a new SpinJsonNode Object property in this node.
+ *
+ * @param name the name of the new property
+ * @param newProperty the new SpinJsonNode Object property
+ * @return {@link SpinJsonNode} representation of the current node
+ */
+ public abstract SpinJsonNode prop(String name, SpinJsonNode newProperty);
+
+ /**
+ * Remove a property of the given node by name.
+ * @param name name of the property
+ * @return {@link SpinJsonNode} representation of the current node
+ */
+ public abstract SpinJsonNode deleteProp(String name);
+
+ /**
+ * Removes a number of properties by a given list of names.
+ * @param names list of names
+ * @return {@link SpinJsonNode} representation of the current node
+ */
+ public abstract SpinJsonNode deleteProp(List names);
+
+ /**
+ * Appends a object to the end of the current array node
+ * @param property property which should be append
+ * @return {@link SpinJsonNode} representation of the current node
+ */
+ public abstract SpinJsonNode append(Object property);
+
+ /**
+ * Appends an object at a specific point in an array
+ *
+ * @param index Index in current node where the new property should be appended.
+ * @param property Object which should be appended.
+ * @return {@link SpinJsonNode} representation of the current node.
+ * @throws IllegalArgumentException if index is out of bound.
+ */
+ public abstract SpinJsonNode insertAt(int index, Object property);
+
+ /**
+ * Inserts an object BEFORE an specific object in an array
+ *
+ * @param searchObject Object which is searched
+ * @param insertObject Object which will be inserted
+ * @return {@link SpinJsonNode} representation of the current node
+ */
+ public abstract SpinJsonNode insertBefore(Object searchObject, Object insertObject);
+
+ /**
+ * Inserts an object AFTER an specific object in an array
+ *
+ * @param searchObject Object which is searched
+ * @param insertObject Object which will be inserted
+ * @return {@link SpinJsonNode} representation of the current node
+ */
+ public abstract SpinJsonNode insertAfter(Object searchObject, Object insertObject);
+
+ /**
+ * Removes the first appearance of an object from the current array
+ *
+ * @param property object which should be deleted
+ * @return {@link SpinJsonNode} representation of the current node
+ */
+ public abstract SpinJsonNode remove(Object property);
+
+ /**
+ * Removes the last appearance of an object from the current array
+ *
+ * @param property object which should be deleted
+ * @return {@link SpinJsonNode} representation of the current node
+ *
+ */
+ public abstract SpinJsonNode removeLast(Object property);
+
+ /**
+ * removes an object at the specific index of the current array
+ *
+ * @param index Index of the array
+ * @return {@link SpinJsonNode} representation of the current node
+ * @throws IllegalArgumentException if index is out of bound.
+ */
+ public abstract SpinJsonNode removeAt(int index);
+
+ /**
+ * Check if this node is a boolean value.
+ *
+ * @return true if this node is a boolean value, false otherwise
+ */
+ public abstract Boolean isBoolean();
+
+ /**
+ * Get this node as a boolean value.
+ *
+ * @return the boolean value of this node
+ * @throws SpinDataFormatException if this node is not a boolean value
+ */
+ public abstract Boolean boolValue();
+
+ /**
+ * Check if this node is a number value.
+ *
+ * @return true if this node is a number value, false otherwise
+ */
+ public abstract Boolean isNumber();
+
+ /**
+ * Get this node as a number value.
+ *
+ * @return the number value of this node
+ * @throws SpinDataFormatException if this node is not a number value
+ */
+ public abstract Number numberValue();
+
+ /**
+ * Check if this node is a string value.
+ *
+ * @return true if this node is a string value, false otherwise
+ */
+ public abstract Boolean isString();
+
+ /**
+ * Get this node as a string value.
+ *
+ * @return the string value of this node
+ * @throws SpinDataFormatException if this node is not a string value
+ */
+ public abstract String stringValue();
+
+ /**
+ * Check if this node represents a null value.
+ *
+ * @return true if this node is a null value, false otherwise
+ */
+ public abstract Boolean isNull();
+
+ /**
+ * Check if this node is a value.
+ *
+ * @return true if this node is a value, false otherwise
+ */
+ public abstract Boolean isValue();
+
+ /**
+ * Gets the actual value of the node, in case it is a Boolean/String/Number/Null node.
+ * In that case a Java Boolean/String/Number or null is returned.
+ *
+ * @return the value of this node
+ * @throws SpinDataFormatException if this node is not a Boolean/String/Number/Nul value
+ */
+ public abstract Object value();
+
+ /**
+ * Check if this node is a array value.
+ *
+ * @return true if this node is a array value, false otherwise
+ */
+ public abstract Boolean isArray();
+
+ /**
+ * Get this node as list.
+ * If the current node is an array, this method returns a {@link SpinList} which contains copies of all
+ * JSON nodes contained in the current node. Changes to the the elements in the list will not propagate
+ * to the original nodes.
+ *
+ * @return the list value of this node
+ * @throws SpinDataFormatException if this node is not an array
+ */
+ public abstract SpinList elements();
+
+ /**
+ * Get the field names of this node (i.e. the property names).
+ *
+ * @return the list of field names
+ * @throws SpinDataFormatException if this node is not a array value
+ */
+ public abstract List fieldNames();
+
+ /**
+ * Creates a JsonPath query on this element.
+ *
+ * @param expression the JsonPath expression
+ * @return the JsonPath query
+ */
+ public abstract SpinJsonPathQuery jsonPath(String expression);
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/json/SpinJsonPathException.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/json/SpinJsonPathException.java
new file mode 100644
index 0000000000000000000000000000000000000000..8eb1638bd03848cd66073c618fbf8b15937e7ff0
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/json/SpinJsonPathException.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.json;
+
+import org.camunda.spin.SpinRuntimeException;
+
+/**
+ * @author Stefan Hentschel
+ */
+public class SpinJsonPathException extends SpinRuntimeException {
+
+ private static final long serialVersionUID = 1L;
+
+ public SpinJsonPathException(String message) {
+ super(message);
+ }
+
+ public SpinJsonPathException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/json/SpinJsonPathQuery.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/json/SpinJsonPathQuery.java
new file mode 100644
index 0000000000000000000000000000000000000000..8e855ce58477fe55c40e7780d71eee0c642b3a36
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/json/SpinJsonPathQuery.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.json;
+
+import org.camunda.spin.SpinList;
+
+/**
+ * @author Stefan Hentschel
+ */
+public interface SpinJsonPathQuery {
+
+ /**
+ * Fetches the node from the result of JsonPath.
+ *
+ * @return {@link SpinJsonNode} representation of the found node
+ * @throws SpinJsonPathException if node value is not a valid json path expression or the path is not found.
+ */
+ SpinJsonNode element();
+
+ /**
+ * Fetches the list of nodes from the result of JsonPath.
+ *
+ * @return {@link SpinList} list of found nodes
+ * @throws SpinJsonDataFormatException if node value is not Array.
+ */
+ SpinList elementList();
+
+ /**
+ * Fetches the string value from the result of JsonPath.
+ *
+ * @return String value of found node
+ * @throws SpinJsonDataFormatException if node value is not String.
+ */
+ String stringValue();
+
+ /**
+ * Fetches the number value from the result of JsonPath.
+ *
+ * @return Number value of found node
+ * @throws SpinJsonDataFormatException if node value is not Number.
+ */
+ Number numberValue();
+
+ /**
+ * Fetches the boolean value from the result of JsonPath.
+ *
+ * @return Boolean value of found node
+ * @throws SpinJsonDataFormatException if node value is not Boolean.
+ */
+ Boolean boolValue();
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/json/SpinJsonPropertyException.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/json/SpinJsonPropertyException.java
new file mode 100644
index 0000000000000000000000000000000000000000..210fecb8eff144e64d58bbf46e427ddbc6b81a8a
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/json/SpinJsonPropertyException.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.json;
+
+/**
+ * @author Stefan Hentschel
+ */
+public class SpinJsonPropertyException extends SpinJsonException {
+
+ private static final long serialVersionUID = 1L;
+
+ public SpinJsonPropertyException(String message) {
+ super(message);
+ }
+
+ public SpinJsonPropertyException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/scripting/SpinScriptEnv.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/scripting/SpinScriptEnv.java
new file mode 100644
index 0000000000000000000000000000000000000000..e0ecdf722939cf7f0f8d8bb0ca3d654d3690288c
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/scripting/SpinScriptEnv.java
@@ -0,0 +1,111 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.scripting;
+
+import org.camunda.spin.SpinScriptException;
+import org.camunda.spin.impl.logging.SpinCoreLogger;
+import org.camunda.spin.impl.logging.SpinLogger;
+import org.camunda.spin.impl.util.SpinIoUtil;
+
+import javax.script.ScriptEngine;
+
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Spin provides a set of environment scripts for known scripting languages.
+ * These scripts make it easier to use spin in a scripting language. Users can
+ * execute these scripts before they execute their custom scripts.
+ *
+ * @author Daniel Meyer
+ *
+ */
+public class SpinScriptEnv {
+
+ private static final SpinCoreLogger LOG = SpinLogger.CORE_LOGGER;
+
+ private static final String ENV_PATH_TEMPLATE = "script/env/%s/spin.%s";
+
+ /**
+ * Mapping of known {@link ScriptEngine} language names and
+ * file extensions of corresponding script files.
+ */
+ public static final Map extensions = new HashMap();
+ static {
+ extensions.put("python", "py");
+ extensions.put("javascript", "js");
+ extensions.put("groovy", "groovy");
+ extensions.put("ruby", "rb");
+ }
+
+ /**
+ * 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
+ */
+ public static String getExtension(String language) {
+ language = language.toLowerCase();
+ if("ecmascript".equals(language)) {
+ language = "javascript";
+ }
+ return extensions.get(language);
+ }
+
+ /**
+ * Get the spin scripting environment
+ *
+ * @param language the language name
+ * @return the environment script as string or null if the language is
+ * not in the set of languages supported by spin.
+ */
+ public static String get(String language) {
+ language = language.toLowerCase();
+ if("ecmascript".equals(language)) {
+ language = "javascript";
+ }
+
+ String extension = extensions.get(language);
+ if(extension == null) {
+ return null;
+
+ } else {
+ return loadScriptEnv(language, extension);
+
+ }
+ }
+
+ protected static String loadScriptEnv(String language, String extension) {
+ String scriptEnvPath = String.format(ENV_PATH_TEMPLATE, language, extension);
+ InputStream envResource = SpinScriptException.class.getClassLoader().getResourceAsStream(scriptEnvPath);
+
+ if(envResource == null) {
+ throw LOG.noScriptEnvFoundForLanguage(language, scriptEnvPath);
+
+ } else {
+ try {
+ return SpinIoUtil.inputStreamAsString(envResource);
+
+ } finally {
+ SpinIoUtil.closeSilently(envResource);
+
+ }
+ }
+ }
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/spi/DataFormat.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/spi/DataFormat.java
new file mode 100644
index 0000000000000000000000000000000000000000..962db9338af1e2b9ddccbdfce37fe7049f9ea8b7
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/spi/DataFormat.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.spi;
+
+import org.camunda.spin.Spin;
+
+/**
+ *
+ * @author Sebastian Menski
+ * @author Daniel Meyer
+ */
+public interface DataFormat> {
+
+ String getName();
+
+ Class extends T> getWrapperType();
+
+ T createWrapperInstance(Object parameter);
+
+ DataFormatReader getReader();
+
+ DataFormatWriter getWriter();
+
+ /**
+ * @return the DataFormatMapper used by this data format
+ */
+ DataFormatMapper getMapper();
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/spi/DataFormatConfigurator.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/spi/DataFormatConfigurator.java
new file mode 100644
index 0000000000000000000000000000000000000000..94fff521064a9b6616ce95db8cc3470886020e48
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/spi/DataFormatConfigurator.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.spi;
+
+/**
+ * Can be used to configure data formats of a certain type.
+ * An implementation will be supplied with all discovered data formats
+ * of the specified class. {@link DataFormat#getName()} may be used to further
+ * restrict configuration to data formats with a specific name.
+ *
+ * @author Thorben Lindhauer
+ */
+public interface DataFormatConfigurator> {
+
+ /**
+ * @return the dataformat class this configurator can configure (including subclasses)
+ */
+ Class getDataFormatClass();
+
+ /**
+ * Applies configuration to the desired format.
+ * This method is invoked with all dataformats of the required type.
+ */
+ void configure(T dataFormat);
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/spi/DataFormatMapper.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/spi/DataFormatMapper.java
new file mode 100644
index 0000000000000000000000000000000000000000..15d98da355e013bb5f9d82bee5e55f9edc7a975a
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/spi/DataFormatMapper.java
@@ -0,0 +1,101 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.spi;
+
+import org.camunda.spin.DeserializationTypeValidator;
+
+/**
+ * Maps a java object to the data format's internal representation and vice versa.
+ *
+ * @author Thorben Lindhauer
+ */
+public interface DataFormatMapper {
+
+ /**
+ * Returns true if this mapper can map the provided Java Object.
+ *
+ * @param parameter the java object to check
+ * @return true if this object can be mapped.
+ */
+ public boolean canMap(Object parameter);
+
+ /**
+ * Maps a java object to a data format's internal data representation.
+ *
+ * @param parameter object that is mapped
+ * @return the data format's internal representation of that object
+ */
+ public Object mapJavaToInternal(Object parameter);
+
+ /**
+ * Maps the internal representation of a data format to a java object of the
+ * desired class. The desired class is not validated prior to the mapping.
+ *
+ * @param parameter the object to be mapped
+ * @param type the class to map the object to
+ * @return a java object of the specified class that was populated with the input
+ * parameter
+ */
+ public T mapInternalToJava(Object parameter, Class type);
+
+ /**
+ * Maps the internal representation of a data format to a java object of the
+ * desired class. The desired class is validated by the validator
+ * prior to the mapping.
+ *
+ * @param parameter the object to be mapped
+ * @param type the class to map the object to
+ * @param validator the validator for the target class
+ * @return a java object of the specified class that was populated with the input
+ * parameter
+ */
+
+ public T mapInternalToJava(Object parameter, Class type, DeserializationTypeValidator validator);
+
+ /**
+ * Maps the internal representation of a data format to a java object of the
+ * desired class. The type identifier is given in a data format specific format. Its
+ * interpretation is data-format-specific. For example, it can be used to express generic
+ * type information that cannot be expressed by a {@link Class} object.
+ * The desired class is not validated prior to the mapping.
+ *
+ * @param parameter the object to be mapped
+ * @param typeIdentifier a data-format-specific type identifier that describes
+ * the class to map to
+ * @return a java object of the specified type that was populated with the input
+ * parameter
+ */
+ public T mapInternalToJava(Object parameter, String typeIdentifier);
+
+ /**
+ * Maps the internal representation of a data format to a java object of the
+ * desired class. The type identifier is given in a data format specific format. Its
+ * interpretation is data-format-specific. For example, it can be used to express generic
+ * type information that cannot be expressed by a {@link Class} object.
+ * The desired class is validated by the validator prior to the mapping.
+ *
+ * @param parameter the object to be mapped
+ * @param typeIdentifier a data-format-specific type identifier that describes
+ * the class to map to
+ * @param validator the validator for the target class
+ * @return a java object of the specified type that was populated with the input
+ * parameter
+ */
+ public T mapInternalToJava(Object parameter, String typeIdentifier, DeserializationTypeValidator validator);
+
+ String getCanonicalTypeName(Object object);
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/spi/DataFormatProvider.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/spi/DataFormatProvider.java
new file mode 100644
index 0000000000000000000000000000000000000000..642ae93531ff90e947492f2ca518e16232ada800
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/spi/DataFormatProvider.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.spi;
+
+import java.util.Map;
+
+/**
+ * @author Daniel Meyer
+ *
+ */
+public interface DataFormatProvider {
+
+ /**
+ * @return the name of the data format provided by the implementation
+ */
+ String getDataFormatName();
+
+ /**
+ * @return an instance of the data format provided by this implementation
+ */
+ DataFormat> createInstance();
+
+ /**
+ * @return an instance of the data format provided by this implementation configured using the
+ * passed configuration properties.
+ */
+ default DataFormat> createInstance(Map configurationProperties) {
+ return createInstance();
+ };
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/spi/DataFormatReader.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/spi/DataFormatReader.java
new file mode 100644
index 0000000000000000000000000000000000000000..7ecc9558749dc2e901d84cabc10dc86a24ce4a77
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/spi/DataFormatReader.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.spi;
+
+import java.io.Reader;
+
+import org.camunda.spin.Spin;
+
+/**
+ * Reads the internal representation of a {@link Spin} object from its serialized representation.
+ *
+ * @author Daniel Meyer
+ * @author Sebastian Menski
+ * @author Thorben Lindhauer
+ *
+ */
+public interface DataFormatReader {
+
+ /**
+ * Returns true if this reader estimates to be able to consume the input data.
+ * Implementations may not read more than readLimit
+ * bytes from the supplied reader.
+ *
+ * @param reader reader that can be read from to detect a data format
+ * @param readLimit positive number that poses a restriction on how many characters
+ * an implementation may read. Reading beyond this limit may lead to incomplete
+ * input when the method {@link #readInput(Reader)} is invoked.
+ * @return true if this reader is able to consume the input
+ */
+ boolean canRead(Reader reader, int readLimit);
+
+ /**
+ * Read (or parse) a reader into this data format's input structure.
+ * For example, an Xml-Based data format may return an
+ * internal tree structure which can be used for traversing the xml tree.
+ *
+ * @param reader a {@link Reader} providing the data source
+ * @return the read or parsed input
+ * @throws SpinDataFormatException in case the reader cannot read the input
+ */
+ Object readInput(Reader reader);
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/spi/DataFormatWriter.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/spi/DataFormatWriter.java
new file mode 100644
index 0000000000000000000000000000000000000000..2149d3e1f7ee791c11deab40240a61f1b05988f3
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/spi/DataFormatWriter.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.spi;
+
+import java.io.Writer;
+
+/**
+ * @author Daniel Meyer
+ *
+ */
+public interface DataFormatWriter {
+
+ /**
+ * Writes the internal representation, as provided by input
+ * to the supplied writer according to the data format
+ * that the implementation belongs to.
+ * For example, an XML data format writer writes XML.
+ *
+ * @param writer The writer to write the output to
+ * @param input The object to write. Can be safely cast to the internal
+ * format of the data format.
+ */
+ public void writeToWriter(Writer writer, Object input);
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/spi/SpinDataFormatException.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/spi/SpinDataFormatException.java
new file mode 100644
index 0000000000000000000000000000000000000000..94896fea3fb2459ca86960fe57e157ffe0809470
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/spi/SpinDataFormatException.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.spi;
+
+import org.camunda.spin.SpinRuntimeException;
+
+/**
+ * Indicates an error in the underlying DataFormat layer
+ *
+ * @author Daniel Meyer
+ *
+ */
+public class SpinDataFormatException extends SpinRuntimeException {
+
+ private static final long serialVersionUID = 1L;
+
+ public SpinDataFormatException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public SpinDataFormatException(String message) {
+ super(message);
+ }
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/spi/TextBasedDataFormatReader.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/spi/TextBasedDataFormatReader.java
new file mode 100644
index 0000000000000000000000000000000000000000..a8fdb314b384b33e662a1ec6acf8ebccd54fed53
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/spi/TextBasedDataFormatReader.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.spi;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.util.regex.Pattern;
+
+import org.camunda.spin.impl.logging.SpinCoreLogger;
+
+/**
+ * Can be used as a base class to determine whether an input reader
+ * is readable by applying regular expression matching.
+ *
+ * @author Lindhauer
+ */
+public abstract class TextBasedDataFormatReader implements DataFormatReader {
+
+ private static final SpinCoreLogger LOG = SpinCoreLogger.CORE_LOGGER;
+
+ 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();
+ }
+
+ protected abstract Pattern getInputDetectionPattern();
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/spi/TypeDetector.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/spi/TypeDetector.java
new file mode 100644
index 0000000000000000000000000000000000000000..9470ec23d5d65e1a9dd9e253b183bd8a52b8cb66
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/spi/TypeDetector.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.spi;
+
+/**
+ * Detects the canonical type string of a supplied object
+ *
+ * @author Thorben Lindhauer
+ */
+public interface TypeDetector {
+
+ boolean canHandle(Object object);
+
+ String detectType(Object object);
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/xml/SpinXPathException.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/xml/SpinXPathException.java
new file mode 100644
index 0000000000000000000000000000000000000000..d82fa4b0dc47c445c8653cfa716412d5d94e1b1b
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/xml/SpinXPathException.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.xml;
+
+import org.camunda.spin.SpinRuntimeException;
+
+/**
+ * Indicates an error during a XPath evaluation.
+ *
+ * @author Sebastian Menski
+ */
+public class SpinXPathException extends SpinRuntimeException {
+
+ private static final long serialVersionUID = 1L;
+
+ public SpinXPathException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public SpinXPathException(String message) {
+ super(message);
+ }
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/xml/SpinXPathQuery.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/xml/SpinXPathQuery.java
new file mode 100644
index 0000000000000000000000000000000000000000..0270fadd85d83fce3c804a9092ebca22fcc125bd
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/xml/SpinXPathQuery.java
@@ -0,0 +1,93 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.xml;
+
+import org.camunda.spin.SpinList;
+
+import java.util.Map;
+
+/**
+ * @author Sebastian Menski
+ */
+public abstract class SpinXPathQuery {
+
+ /**
+ * Returns the XPath query result as element.
+ *
+ * @return the wrapped XML element
+ */
+ public abstract SpinXmlElement element();
+
+ /**
+ * Returns the XPath query result as a element list.
+ *
+ * @return the wrapped XML element list
+ */
+ public abstract SpinList elementList();
+
+ /**
+ * Returns the XPath query result as attribute.
+ *
+ * @return the wrapped XML attribute
+ */
+ public abstract SpinXmlAttribute attribute();
+
+ /**
+ * Returns the XPath query result as a attribute list.
+ *
+ * @return the wrapped XML attribute list
+ */
+ public abstract SpinList attributeList();
+
+ /**
+ * Returns the XPath query result as a string.
+ *
+ * @return the string result
+ */
+ public abstract String string();
+
+ /**
+ * Returns the XPath query result as a double.
+ *
+ * @return the double result
+ */
+ public abstract Double number();
+
+ /**
+ * Returns the XPath query result as a boolean.
+ *
+ * @return the boolean result
+ */
+ public abstract Boolean bool();
+
+ /**
+ * Maps a prefix, uri pair to a namespace.
+ *
+ * @param prefix prefix for the namespace.
+ * @param namespace uri of the namespace
+ * @return itself
+ */
+ public abstract SpinXPathQuery ns(String prefix, String namespace);
+
+ /**
+ * Maps a map of prefix, uri pairs to namespaces
+ * @param namespaces Map of the prefix, uri pairs.
+ * @return itself
+ */
+ public abstract SpinXPathQuery ns(Map namespaces);
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/xml/SpinXmlAttribute.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/xml/SpinXmlAttribute.java
new file mode 100644
index 0000000000000000000000000000000000000000..b80c3a2aa9f7b92c5e607ad7f537f4755f2dc416
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/xml/SpinXmlAttribute.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.xml;
+
+import java.io.Writer;
+
+/**
+ * An attribute in a tree-oriented XML data format.
+ *
+ * @author Sebastian Menski
+ * @author Daniel Meyer
+ *
+ */
+public abstract class SpinXmlAttribute extends SpinXmlNode {
+
+ /**
+ * Returns the value of the attribute as {@link String}.
+ *
+ * @return the string value of the attribute
+ */
+ public abstract String value();
+
+ /**
+ * Sets the value of the attribute.
+ *
+ * @param value the value to set
+ * @return the wrapped xml dom attribute
+ * @throws SpinXmlNodeException if the value is null
+ */
+ public abstract SpinXmlAttribute value(String value);
+
+ /**
+ * Removes the attribute.
+ *
+ * @return the wrapped owner {@link SpinXmlElement tree element}
+ */
+ public abstract SpinXmlElement remove();
+
+ /**
+ * Returns the wrapped XML attribute value as string representation.
+ *
+ * @return the string representation
+ */
+ public abstract String toString();
+
+ /**
+ * Writes the wrapped XML attribute value to an existing writer.
+ *
+ * @param writer the writer to write to
+ */
+ public abstract void writeToWriter(Writer writer);
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/xml/SpinXmlAttributeException.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/xml/SpinXmlAttributeException.java
new file mode 100644
index 0000000000000000000000000000000000000000..efcdb21df30364f13c20a235c098aed73dbdcaea
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/xml/SpinXmlAttributeException.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.xml;
+
+/**
+ * Indicates an error in the underlying xml tree attribute.
+ *
+ * @author Sebastian Menski
+ */
+public class SpinXmlAttributeException extends SpinXmlNodeException {
+
+ private static final long serialVersionUID = 1L;
+
+ public SpinXmlAttributeException(String message) {
+ super(message);
+ }
+
+ public SpinXmlAttributeException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/xml/SpinXmlDataFormatException.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/xml/SpinXmlDataFormatException.java
new file mode 100644
index 0000000000000000000000000000000000000000..89ccc7e2a4ca353885819578633b1a227fc0782e
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/xml/SpinXmlDataFormatException.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.xml;
+
+import org.camunda.spin.spi.SpinDataFormatException;
+
+/**
+ * @author Daniel Meyer
+ *
+ */
+public class SpinXmlDataFormatException extends SpinDataFormatException {
+
+ private static final long serialVersionUID = 1L;
+
+ public SpinXmlDataFormatException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public SpinXmlDataFormatException(String message) {
+ super(message);
+ }
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/xml/SpinXmlElement.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/xml/SpinXmlElement.java
new file mode 100644
index 0000000000000000000000000000000000000000..df9e5aa7cfab73c76e134efa95fd23cfce76ca5c
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/xml/SpinXmlElement.java
@@ -0,0 +1,323 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.xml;
+
+import java.io.Writer;
+import java.util.Collection;
+import java.util.List;
+
+import org.camunda.spin.SpinList;
+
+/**
+ * An element in a tree-oriented XML data format.
+ *
+ * @author Sebastian Menski
+ * @author Daniel Meyer
+ *
+ */
+public abstract class SpinXmlElement extends SpinXmlNode {
+
+ /**
+ * Checks whether this element has a attribute with an empty namespace and the given name.
+ *
+ * @param attributeName the name of the attribute
+ * @return true if the element has an attribute with this name under the local namespace, false otherwise
+ * @throws IllegalArgumentException if the attributeName is null
+ */
+ public abstract boolean hasAttr(String attributeName);
+
+ /**
+ * Returns the wrapped attribute for an empty namespace and the given name.
+ *
+ * @param attributeName the name of the attribute
+ * @return the wrapped {@link SpinXmlAttribute attribute}
+ * @throws IllegalArgumentException if the attributeName is null
+ * @throws SpinXmlAttributeException if the attribute is not found
+ */
+ public abstract SpinXmlAttribute attr(String attributeName);
+
+ /**
+ * Sets the attribute value in the local namespace of this element.
+ *
+ * @param attributeName the name of the attribute
+ * @param value the value to set
+ * @return the wrapped {@link SpinXmlElement element}
+ * @throws IllegalArgumentException if the attributeName or value is null
+ */
+ public abstract SpinXmlElement attr(String attributeName, String value);
+
+ /**
+ * Removes the attribute with an empty namespace.
+ *
+ * @param attributeName the name of the attribute
+ * @return the wrapped {@link SpinXmlElement element}
+ * @throws IllegalArgumentException if the attributeName is null
+ */
+ public abstract SpinXmlElement removeAttr(String attributeName);
+
+ /**
+ * Checks whether this element has a attribute with the given namespace and name.
+ *
+ * @param namespace the namespace of the attribute
+ * @param attributeName the name of the attribute
+ * @return true if the element has an attribute with this name under given namespace, false otherwise
+ * @throws IllegalArgumentException if the attributeName is null
+ */
+ public abstract boolean hasAttrNs(String namespace, String attributeName);
+
+ /**
+ * Returns the wrapped attribute for the given namespace and name.
+ *
+ * @param namespace the namespace of the attribute
+ * @param attributeName the name of the attribute
+ * @return the wrapped {@link SpinXmlAttribute attribute}
+ * @throws IllegalArgumentException if attributeName or value is null
+ * @throws SpinXmlElementImplementationException if the attribute cannot be set in the underlying implementation
+ */
+ public abstract SpinXmlAttribute attrNs(String namespace, String attributeName);
+
+ /**
+ * Sets the attribute value in the given namespace.
+ *
+ * @param namespace the namespace of the attribute
+ * @param attributeName the name of the attribute
+ * @param value the value to set
+ * @return the wrapped {@link SpinXmlElement element}
+ * @throws IllegalArgumentException if attributeName or value is null
+ * @throws SpinXmlElementImplementationException if the attribute cannot be set in the underlying implementation
+ */
+ public abstract SpinXmlElement attrNs(String namespace, String attributeName, String value);
+
+ /**
+ * Removes the attribute under the given namespace.
+ *
+ * @param namespace the namespace of the attribute
+ * @param attributeName the name of the attribute
+ * @return the wrapped {@link SpinXmlElement element}
+ * @throws IllegalArgumentException if the attributeName is null
+ */
+ public abstract SpinXmlElement removeAttrNs(String namespace, String attributeName);
+
+ /**
+ * Returns all wrapped attributes of this element.
+ *
+ * @return the wrapped attributes or an empty list of no attributes are found
+ */
+ public abstract SpinList attrs();
+
+ /**
+ * Returns all wrapped attributes for the given namespace.
+ *
+ * @param namespace the namespace of the attributes
+ * @return the wrapped attributes or an empty list of no attributes are found
+ */
+ public abstract SpinList attrs(String namespace);
+
+ /**
+ * Returns all names of the attributes of this element.
+ *
+ * @return the names of the attributes
+ */
+ public abstract List attrNames();
+
+ /**
+ * Returns all names of the attributes in the given namespace.
+ *
+ * @return the names of the attributes
+ */
+ public abstract List attrNames(String namespace);
+
+ /**
+ * Returns the text content of an element.
+ *
+ * @return the text content or an empty string if non exists
+ */
+ public abstract String textContent();
+
+ /**
+ * Sets the text content of an element.
+ * @param textContent the text content to set
+ * @return the wrapped {@link SpinXmlElement element}
+ * @throws IllegalArgumentException if the textContent is null
+ */
+ public abstract SpinXmlElement textContent(String textContent);
+
+ /**
+ * Returns a single wrapped child element for the given name
+ * in the local namespace of this element.
+ *
+ * @param elementName the element name
+ * @return the wrapped child {@link SpinXmlElement element}
+ * @throws IllegalArgumentException if the elementName is null
+ * @throws SpinXmlElementException if none or more than one child element is found
+ */
+ public abstract SpinXmlElement childElement(String elementName);
+
+ /**
+ * Returns a single wrapped child {@link SpinXmlElement element} for the given namespace
+ * and name.
+ *
+ * @param namespace the namespace of the element
+ * @param elementName the element name
+ * @return the wrapped child {@link SpinXmlElement element}
+ * @throws IllegalArgumentException if the elementName is null
+ * @throws SpinXmlElementException if none or more than one child element is found
+ */
+ public abstract SpinXmlElement childElement(String namespace, String elementName);
+
+ /**
+ * Returns all child elements of this {@link SpinXmlElement elements}.
+ *
+ * @return list of wrapped child {@link SpinXmlElement elements}
+ */
+ public abstract SpinList childElements();
+
+ /**
+ * Returns all child {@link SpinXmlElement elements} with a given name in the local namespace
+ * of this element.
+ *
+ * @param elementName the element name
+ * @return a collection of wrapped {@link SpinXmlElement elements}
+ * @throws IllegalArgumentException if the element name is null
+ * @throws SpinXmlElementException if no child element was found
+ */
+ public abstract SpinList childElements(String elementName);
+
+ /**
+ * Returns all child {@link SpinXmlElement elements} with a given namespace and name.
+ *
+ * @param namespace the namespace of the element
+ * @param elementName the element name
+ * @return a collection of wrapped {@link SpinXmlElement elements}
+ * @throws IllegalArgumentException if the element name is null
+ * @throws SpinXmlElementException if no child element was found
+ */
+ public abstract SpinList childElements(String namespace, String elementName);
+
+ /**
+ * Appends child elements to this {@link SpinXmlElement element}.
+ *
+ * @param childElements the child elements to append
+ * @return the wrapped {@link SpinXmlElement element}
+ * @throws IllegalArgumentException if the childElements is null or one of them
+ * @throws SpinXmlElementImplementationException if a child element cannot be appended in the underlying implementation
+ */
+ public abstract SpinXmlElement append(SpinXmlElement... childElements);
+
+ /**
+ * Appends child elements to this {@link SpinXmlElement element}.
+ *
+ * @param childElements the child elements to append
+ * @return the wrapped {@link SpinXmlElement element}
+ * @throws IllegalArgumentException if the childElements is null or one of them
+ * @throws SpinXmlElementImplementationException if a child element cannot be appended in the underlying implementation
+ */
+ public abstract SpinXmlElement append(Collection childElements);
+
+ /**
+ * Appends a child element to this element before the existing child element.
+ *
+ * @param childElement the child element to append
+ * @param existingChildElement the child element to append before
+ * @return the wrapped {@link SpinXmlElement element}
+ * @throws IllegalArgumentException if the child element or existing child element is null
+ * @throws SpinXmlElementException if the existing child element is not a child of this element
+ * @throws SpinXmlElementImplementationException if the new child element cannot be inserted in the underlying implementation
+ */
+ public abstract SpinXmlElement appendBefore(SpinXmlElement childElement, SpinXmlElement existingChildElement);
+
+ /**
+ * Appends a child element to this {@link SpinXmlElement element} after the existing child {@link SpinXmlElement element}.
+ *
+ * @param childElement the child element to append
+ * @param existingChildElement the child element to append after
+ * @return the wrapped {@link SpinXmlElement element}
+ * @throws IllegalArgumentException if the child element or existing child element is null
+ * @throws SpinXmlElementException if the existing child element is not a child of this element
+ * @throws SpinXmlElementImplementationException if the new child element cannot be inserted in the underlying implementation
+ */
+ public abstract SpinXmlElement appendAfter(SpinXmlElement childElement, SpinXmlElement existingChildElement);
+
+ /**
+ * Removes all child elements from this element.
+ *
+ * @param childElements the child elements to remove
+ * @return the wrapped {@link SpinXmlElement element}
+ * @throws IllegalArgumentException if child elements is null or any of them
+ * @throws SpinXmlElementException if one of the child elements does not exist
+ * @throws SpinXmlElementImplementationException if the child element cannot be removed in the underlying implementation
+ */
+ public abstract SpinXmlElement remove(SpinXmlElement... childElements);
+
+ /**
+ * Removes all child elements from this element.
+ *
+ * @param childElements the child elements to remove
+ * @return the wrapped {@link SpinXmlElement element}
+ * @throws IllegalArgumentException if child elements is null or any of them
+ * @throws SpinXmlElementException if one of the child elements does not exist
+ * @throws SpinXmlElementImplementationException if the child element cannot be removed in the underlying implementation
+ */
+ public abstract SpinXmlElement remove(Collection childElements);
+
+ /**
+ * Replaces this element by an new one.
+ *
+ * @param newChildElement the new element
+ * @return the new wrapped {@link SpinXmlElement element}
+ * @throws IllegalArgumentException if the new element is null or has the wrong type
+ * @throws SpinXmlElementException if this element has no parent element
+ * @throws SpinXmlElementImplementationException if the element cannot be replaced in the underlying implementation
+ */
+ public abstract SpinXmlElement replace(SpinXmlElement newChildElement);
+
+ /**
+ * Replaces an existing child element with a new one.
+ *
+ * @param existingChildElement the existing child element to replace
+ * @param newChildElement the new child element
+ * @return the wrapped {@link SpinXmlElement element}
+ * @throws IllegalArgumentException if any of the child elements is null
+ * @throws SpinXmlElementException if the existing element is not a child element of this
+ * @throws SpinXmlElementImplementationException if the child cannot be replaced in the underlying implementation
+ */
+ public abstract SpinXmlElement replaceChild(SpinXmlElement existingChildElement, SpinXmlElement newChildElement);
+
+ /**
+ * Creates a XPath query on this element.
+ *
+ * @param expression the XPath expression
+ * @return the XPath query
+ */
+ public abstract SpinXPathQuery xPath(String expression);
+
+ /**
+ * Returns the wrapped XML element as string representation.
+ *
+ * @return the string representation
+ * @throws SpinXmlElementException if the element cannot be transformed or no new transformer can be created
+ */
+ public abstract String toString();
+
+ /**
+ * Writes the wrapped XML element to a existing writer.
+ *
+ * @param writer the writer to write to
+ * @throws SpinXmlElementException if the element cannot be transformed or no new transformer can be created
+ */
+ public abstract void writeToWriter(Writer writer);
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/xml/SpinXmlElementException.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/xml/SpinXmlElementException.java
new file mode 100644
index 0000000000000000000000000000000000000000..100ba6fdb181bc6bb630b085abfeaf965c5d9e0f
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/xml/SpinXmlElementException.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.xml;
+
+/**
+ * Indicates an error in the underlying xml tree element.
+ *
+ * @author Sebastian Menski
+ */
+public class SpinXmlElementException extends SpinXmlNodeException {
+
+ private static final long serialVersionUID = 1L;
+
+ public SpinXmlElementException(String message) {
+ super(message);
+ }
+
+ public SpinXmlElementException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/xml/SpinXmlElementImplementationException.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/xml/SpinXmlElementImplementationException.java
new file mode 100644
index 0000000000000000000000000000000000000000..79cb6ea6a1552f77c424719807304328914ba6c3
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/xml/SpinXmlElementImplementationException.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.xml;
+
+/**
+ * Indicates an error in the underlying xml tree element implementation.
+ *
+ * @author Sebastian Menski
+ */
+public class SpinXmlElementImplementationException extends SpinXmlElementException {
+
+ private static final long serialVersionUID = 1L;
+
+ public SpinXmlElementImplementationException(String message) {
+ super(message);
+ }
+
+ public SpinXmlElementImplementationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/xml/SpinXmlNode.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/xml/SpinXmlNode.java
new file mode 100644
index 0000000000000000000000000000000000000000..522d11600f91ece551eb0d9b5f8fc32d75747e67
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/xml/SpinXmlNode.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.xml;
+
+import org.camunda.spin.Spin;
+
+/**
+ * An element in a tree-oriented XML data format.
+ *
+ * @author Sebastian Menski
+ * @author Daniel Meyer
+ *
+ */
+public abstract class SpinXmlNode> extends Spin {
+
+ /**
+ * Returns the local name of the node without namespace or prefix.
+ *
+ * @return the name of the node
+ */
+ public abstract String name();
+
+ /**
+ * Returns the namespace uri of the node and not the prefix.
+ *
+ * @return the namespace of the node
+ */
+ public abstract String namespace();
+
+ /**
+ * Returns the prefix of the node and not the namespace uri.
+ *
+ * @return the prefix of the node
+ */
+ public abstract String prefix();
+
+ /**
+ * Checks if the node has a given prefix.
+ *
+ * @param prefix the prefix to check
+ * @return true if the name has the same prefix
+ */
+ public abstract boolean hasPrefix(String prefix);
+
+ /**
+ * Checks if the node has a given namespace.
+ *
+ * @param namespace the namespace to check
+ * @return true if the node has the same namespace
+ */
+ public abstract boolean hasNamespace(String namespace);
+
+ /**
+ * Maps XML into specific class
+ *
+ * @param type Class to which the Xml should be mapped
+ * @return mapped Class
+ *
+ * @throws SpinDataFormatException in case the input cannot be mapped to class for several reasons
+ */
+ public abstract C mapTo(Class type);
+
+ /**
+ * Maps Xml into specific class
+ *
+ * @param canonicalName canonical name of the class
+ * @return mapped class
+ *
+ * @throws SpinDataFormatException in case the input cannot be mapped to class for several reasons
+ */
+ public abstract C mapTo(String canonicalName);
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/xml/SpinXmlNodeException.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/xml/SpinXmlNodeException.java
new file mode 100644
index 0000000000000000000000000000000000000000..8d6c7d26b1c571e7a941ee1748f1a0c4049fbd00
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/java/org/camunda/spin/xml/SpinXmlNodeException.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.xml;
+
+import org.camunda.spin.SpinRuntimeException;
+
+/**
+ * Indicates an error in the underlying xml tree node.
+ *
+ * @author Sebastian Menski
+ */
+public class SpinXmlNodeException extends SpinRuntimeException {
+
+ private static final long serialVersionUID = 1L;
+
+ public SpinXmlNodeException(String message) {
+ super(message);
+ }
+
+ public SpinXmlNodeException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/resources/script/env/groovy/spin.groovy b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/resources/script/env/groovy/spin.groovy
new file mode 100644
index 0000000000000000000000000000000000000000..64aacbad00c6fdfe2e1fbbc2a5a6d7dedbf1d733
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/resources/script/env/groovy/spin.groovy
@@ -0,0 +1,21 @@
+/* Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * This is the default environment for using camunda Spin in Groovy applications.
+ */
+
+/*
+ * Bind the Spin S(...) function to the variable S.
+ */
+S = org.camunda.spin.Spin.&S
\ No newline at end of file
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/resources/script/env/javascript/spin.js b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/resources/script/env/javascript/spin.js
new file mode 100644
index 0000000000000000000000000000000000000000..4364b93284f9586959d9811087c697c06559477c
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/resources/script/env/javascript/spin.js
@@ -0,0 +1,21 @@
+/* Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * This is the default environment for using camunda Spin in Javascript applications.
+ */
+
+/**
+ * Bind the Spin S function to the variable S.
+ */
+var S = Java.type('org.camunda.spin.Spin').S;
\ No newline at end of file
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/resources/script/env/python/spin.py b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/resources/script/env/python/spin.py
new file mode 100644
index 0000000000000000000000000000000000000000..2bacca2808ab49f8c0295a8d35fcbd390a55d053
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/resources/script/env/python/spin.py
@@ -0,0 +1,18 @@
+"""
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+"""
+
+# This is the default environment for using camunda Spin in Python applications.
+
+# Import the Spin S(...) function.
+import org.camunda.spin.Spin.S as S
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/resources/script/env/ruby/spin.rb b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/resources/script/env/ruby/spin.rb
new file mode 100644
index 0000000000000000000000000000000000000000..49fce4db72de5d0aa2643985a5c1fc2a039fc842
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/main/resources/script/env/ruby/spin.rb
@@ -0,0 +1,21 @@
+=begin
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+=end
+
+# This is the default environment for using camunda Spin in Ruby applications.
+
+# expose Spin's S(...) function globally
+def S(*args)
+ org.camunda.spin.Spin.S(*args)
+end
+
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/DataFormatsTest.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/DataFormatsTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..6ede27e76fd91330055c0d2af7d9dd58dba9df39
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/DataFormatsTest.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * @author Thorben Lindhauer
+ *
+ */
+public class DataFormatsTest {
+
+ @Test
+ public void testCustomClassLoaderForInitialization() {
+ // when initializing data formats with a class loader
+ DataFormats dataFormats = new DataFormats();
+ dataFormats.registerDataFormats(DataFormats.class.getClassLoader());
+
+ // then the operation was successful
+ Assert.assertEquals(0, dataFormats.getAllAvailableDataFormats().size());
+
+ // note: this checks the existence of API that allows to initialize
+ // data formats with a custom class loader; the functionality is actually tested
+ // as part of the platform integration tests
+ }
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/SpinCreateTest.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/SpinCreateTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..d335ee9eadabcde148c029965503f2f2df3c7ff1
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/SpinCreateTest.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin;
+
+import static org.assertj.core.api.Assertions.fail;
+import static org.camunda.spin.Spin.S;
+
+import org.camunda.spin.spi.DataFormat;
+import org.junit.Test;
+
+/**
+ * @author Thorben Lindhauer
+ *
+ */
+public class SpinCreateTest {
+
+ @Test
+ public void shouldFailForNonExistingDataFormat() {
+ try {
+ S("{}", "a non-existing format");
+ fail("expected exception");
+ } catch (IllegalArgumentException e) {
+ // happy path
+ }
+
+ try {
+ DataFormat> dataFormat = null;
+ S("{}", dataFormat);
+ fail("expected exception");
+ } catch (IllegalArgumentException e) {
+ // happy path
+ }
+ }
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/impl/test/Script.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/impl/test/Script.java
new file mode 100644
index 0000000000000000000000000000000000000000..1e656464a631e8151307b32f1408e945663e9029
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/impl/test/Script.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.impl.test;
+
+import org.junit.rules.TestRule;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Method annotation to signal a script test for the {@link ScriptRule} {@link TestRule}.
+ * The name of the script is optional and if omitted the package name is used as directory
+ * and the ClassName.MethodName.ScriptExtension as filename. Additionally a list of
+ * variables can be defined and the execute flag decides whether the script is execute
+ * before the test function is called.
+ *
+ * The script variables can be accessed trough the {@link ScriptRule#variables}
+ * field.
+ *
+ * Example usage:
+ *
+ *
+ * {@literal @}Test
+ * {@literal @}Script
+ * public void scriptNameWithoutExtension() {
+ * \\...
+ * }
+ *
+ * {@literal @}Test
+ * {@literal @}Script("scriptNameWithoutExtension")
+ * public void notTheScriptName() {
+ * \\...
+ * }
+ *
+ * {@literal @}Test
+ * {@literal @}Script(
+ * name = "scriptNameWithoutExtension",
+ * variables = {
+ * {@literal @}ScriptVariable(name="a", value="b"),
+ * {@literal @}ScriptVariable(name="f", file="test.xml")
+ * }
+ * )
+ * public void notTheScriptName() {
+ * \\...
+ * }
+ *
+ * {@literal @}Test
+ * {@literal @}Script(
+ * name = "scriptNameWithoutExtension",
+ * execute = false
+ * )
+ * public void notTheScriptName() {
+ * Map variables = Collections.singletonMap("a", "b");
+ * script.execute(variables)
+ * assertEquals("b", script.variables.get("a"))
+ * }
+ *
+ *
+ *
+ * @author Sebastian Menski
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+public @interface Script {
+
+ String value() default "";
+
+ String name() default "";
+
+ ScriptVariable[] variables() default {};
+
+ boolean execute() default true;
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/impl/test/ScriptEngine.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/impl/test/ScriptEngine.java
new file mode 100644
index 0000000000000000000000000000000000000000..3b38456b99a76b92e3a16de5a14eca4a1cbd4324
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/impl/test/ScriptEngine.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.impl.test;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotation to define a {@link ScriptEngine} of a test class
+ * using the {@link ScriptEngineRule}.
+ *
+ *
+ * {@literal @}ScriptEngine("python")
+ * public class SpinXmlPythonTest extends SpinXmlScriptTest {
+ * // ...
+ * }
+ *
+ *
+ * @author Sebastian Menski
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+public @interface ScriptEngine {
+
+ String value();
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/impl/test/ScriptEngineRule.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/impl/test/ScriptEngineRule.java
new file mode 100644
index 0000000000000000000000000000000000000000..e8828c6e829625c2f225d913eb5829e1e584500b
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/impl/test/ScriptEngineRule.java
@@ -0,0 +1,102 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.impl.test;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.script.ScriptContext;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+
+import org.junit.ClassRule;
+import org.junit.rules.TestRule;
+import org.junit.runner.Description;
+import org.junit.runners.model.Statement;
+
+/**
+ * A jUnit4 {@link ClassRule} to define create a {@link ScriptEngine}
+ * base on {@literal @}{@link ScriptEngineRule} annotation.
+ *
+ * @author Sebastian Menski
+ */
+public class ScriptEngineRule implements TestRule {
+
+ private static final SpinTestLogger LOG = SpinTestLogger.TEST_LOGGER;
+
+ private static final Map cachedEngines = new HashMap<>();
+
+ private static final String GRAAL_JS_SCRIPT_ENGINE_NAME = "Graal.js";
+
+ private javax.script.ScriptEngine scriptEngine;
+
+
+ public Statement apply(final Statement base, final Description description) {
+ return new Statement() {
+ public void evaluate() throws Throwable {
+ scriptEngine = createScriptEngine(description);
+ if (scriptEngine != null) {
+ LOG.scriptEngineFoundForLanguage(scriptEngine.getFactory().getLanguageName());
+ }
+ base.evaluate();
+ }
+ };
+ }
+
+ /**
+ * 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
+ */
+ 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);
+ }
+ }
+
+ /**
+ * Get the script engine defined by the {@literal @}{@link org.camunda.spin.impl.test.ScriptEngine} Annotation
+ *
+ * @return the script engine or null if no script engine was found
+ */
+ public ScriptEngine getScriptEngine() {
+ return scriptEngine;
+ }
+
+ protected void configureGraalJsScriptEngine(ScriptEngine scriptEngine) {
+ // make sure GraalVM JS can provide access 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);
+ }
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/impl/test/ScriptRule.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/impl/test/ScriptRule.java
new file mode 100644
index 0000000000000000000000000000000000000000..4070209899c1d3d23b64c6a3a021622500597b3d
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/impl/test/ScriptRule.java
@@ -0,0 +1,368 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.impl.test;
+
+import java.io.File;
+import java.io.Reader;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.script.Bindings;
+import javax.script.ScriptEngine;
+import javax.script.ScriptException;
+import javax.script.SimpleBindings;
+
+import org.camunda.spin.SpinScriptException;
+import org.camunda.spin.impl.util.SpinIoUtil;
+import org.camunda.spin.scripting.SpinScriptEnv;
+import org.graalvm.polyglot.Value;
+import org.junit.ClassRule;
+import org.junit.rules.TestRule;
+import org.junit.runner.Description;
+import org.junit.runners.model.Statement;
+
+/**
+ * A jUnit4 {@link TestRule} to load and execute a script. To
+ * execute a {@link org.camunda.spin.impl.test.ScriptEngine} {@link ClassRule}
+ * is used to obtain a {@link ScriptEngine}.
+ *
+ * @author Sebastian Menski
+ * @author Daniel Meyer
+ */
+public class ScriptRule implements TestRule {
+
+ private static final SpinTestLogger LOG = SpinTestLogger.TEST_LOGGER;
+
+ private String script;
+ private String scriptPath;
+ private ScriptEngine scriptEngine;
+
+ /**
+ * The variables of the script accessed during script execution.
+ */
+ protected final Map variables = new HashMap<>();
+
+ public Statement apply(final Statement base, final Description description) {
+ return new Statement() {
+ public void evaluate() throws Throwable {
+ loadScript(description);
+ base.evaluate();
+ tearDownVariables();
+ }
+ };
+ }
+
+ protected void tearDownVariables() {
+ for (Object variable : variables.values()) {
+ if (variable != null && Reader.class.isAssignableFrom(variable.getClass())) {
+ Reader reader = (Reader) variable;
+ SpinIoUtil.closeSilently(reader);
+ }
+ }
+ }
+
+ /**
+ * 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
+ */
+ 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();
+ }
+ }
+
+ /**
+ * 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
+ */
+ 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;
+ }
+ }
+
+ /**
+ * 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
+ */
+ 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);
+ }
+
+ /**
+ * 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
+ */
+ 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);
+ }
+ }
+ }
+
+ /**
+ * Extract the variable of a single {@literal @}{@link ScriptVariable} annotation.
+ *
+ * @param scriptVariable the annotation
+ * @param description the description of the test method
+ */
+ 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);
+ }
+ }
+
+ /**
+ * 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
+ */
+ private boolean isExecuteScript(Description description) {
+ Script annotation = description.getAnnotation(Script.class);
+ return annotation != null && annotation.execute();
+ }
+
+ /**
+ * Executes the script with the set variables.
+ * @throws Throwable
+ *
+ * @throws SpinScriptException if an error occurs during the script execution
+ */
+ 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);
+ }
+ }
+ }
+
+ /**
+ * 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
+ */
+ public ScriptRule execute(Map scriptVariables) throws Throwable {
+ variables.putAll(scriptVariables);
+ executeScript();
+ return this;
+ }
+
+ /**
+ * Execute the script
+ *
+ * @return this script rule
+ * @throws Throwable
+ * @throws SpinScriptException if an error occurs during the script execution
+ */
+ public ScriptRule execute() throws Throwable {
+ executeScript();
+ return this;
+ }
+
+ /**
+ * 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
+ */
+ 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;
+ }
+
+ /**
+ * Returns the directory path of the package.
+ *
+ * @param description the description of the test method
+ * @return the directory for the package
+ */
+ private String getPackageDirectoryPath(Description description) {
+ String packageName = description.getTestClass().getPackage().getName();
+ return replaceDotsWithPathSeparators(packageName) + File.separator;
+ }
+
+ /**
+ * Replace all dots in the path with the {@link File#separator} character.
+ *
+ * @param path the path to process
+ * @return the processed path
+ */
+ private String replaceDotsWithPathSeparators(String path) {
+ return path.replace(".", File.separator);
+ }
+
+ /**
+ * 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
+ */
+ private String getScriptPath(String scriptBasename, Description description) {
+ return getPackageDirectoryPath(description) + scriptBasename + getScriptExtension();
+ }
+
+ /**
+ * Returns the script file extension based on the {@link ScriptEngine} language.
+ *
+ * @return the file extension or empty string if none was found
+ */
+ 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 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.
+ */
+ @SuppressWarnings("unchecked")
+ public 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);
+ }
+ }
+
+ /**
+ * 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
+ */
+ @SuppressWarnings("unchecked")
+ private Object getVariableJs(String name) {
+ Object variable = variables.get(name);
+ if (variable == null) {
+ if (variables.containsKey("nashorn.global")) {
+ variable = ((Map) 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;
+ }
+
+ /**
+ * Set the variable with the given name
+ * @param name the name of the variable
+ * @param value value of the variable
+ * @return this script rule
+ */
+ public ScriptRule setVariable(String name, Object value) {
+ variables.put(name, value);
+ return this;
+ }
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/impl/test/ScriptRuleTest.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/impl/test/ScriptRuleTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..ea403c273cda00e02d11907ccccb54a707598a9a
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/impl/test/ScriptRuleTest.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.impl.test;
+
+import org.junit.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * @author Sebastian Menski
+ */
+public abstract class ScriptRuleTest extends ScriptTest {
+
+ @Test
+ @Script
+ public void shouldSetFoo() {
+ Object foo = script.getVariable("foo");
+ assertThat(foo).isNotNull();
+
+ Object bar = script.getVariable("bar");
+ assertThat(bar).isNull();
+ }
+
+ @Test
+ @Script
+ public void shouldSetBar() {
+ Object foo = script.getVariable("foo");
+ assertThat(foo).isNull();
+
+ Object bar = script.getVariable("bar");
+ assertThat(bar).isNotNull();
+ }
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/impl/test/ScriptTest.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/impl/test/ScriptTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..425add7f349b12c9b9046b587997f24848013437
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/impl/test/ScriptTest.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.impl.test;
+
+import java.util.Map;
+
+import org.camunda.spin.SpinScriptException;
+import org.junit.ClassRule;
+import org.junit.Rule;
+
+/**
+ * Base script test which loads an engine and provides the
+ * script as field.
+ *
+ * @author Sebastian Menski
+ */
+public abstract class ScriptTest {
+
+ @ClassRule
+ public static ScriptEngineRule scriptEngine = new ScriptEngineRule();
+
+ @Rule
+ public ScriptRule script = new ScriptRule();
+
+ protected void failingWithException() throws Throwable {
+ try {
+ script.execute();
+ }
+ catch (SpinScriptException e) {
+ throw e.getCause().getCause().getCause();
+ }
+ }
+
+ protected void failingWithException(Map variables) throws Throwable {
+ try {
+ script.execute(variables);
+ }
+ catch (SpinScriptException e) {
+ throw e.getCause().getCause().getCause();
+ }
+ }
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/impl/test/ScriptVariable.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/impl/test/ScriptVariable.java
new file mode 100644
index 0000000000000000000000000000000000000000..749eaea60a244623a296dabd8afa007fb5156dde
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/impl/test/ScriptVariable.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.impl.test;
+
+import java.lang.annotation.*;
+
+/**
+ * Annotation to define script variable bindings. Either used directly
+ * in on the test method (if only one variable should be defined)
+ *
+ *
+ * {@literal @}Test
+ * {@literal @}Script
+ * {@literal @}ScriptVariable(name="input", value="test")
+ * public void shouldAccessInputVariable() {
+ * //...
+ * }
+ *
+ *
+ * or in a list as the variables argument of the {@literal @}{@link Script} Annotation
+ *
+ *
+ * {@literal @}Test
+ * {@literal @}Script{
+ * variables = {
+ * @ScriptVariable(name="input", value="test"),
+ * @ScriptVariable(name="customerFile", file="customer.xml"),
+ * }
+ * }
+ * public void shouldAccessInputVariableAndCustomers() {
+ * //...
+ * }
+ *
+ *
+ * @author Sebastian Menski
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+public @interface ScriptVariable {
+
+ String name();
+
+ String value() default "";
+
+ String file() default "";
+
+ boolean isNull() default false;
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/impl/test/SpinTestLogger.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/impl/test/SpinTestLogger.java
new file mode 100644
index 0000000000000000000000000000000000000000..b30fa5d68f7e471a206463dcdc4bf6508c518698
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/impl/test/SpinTestLogger.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.impl.test;
+
+import org.camunda.commons.logging.BaseLogger;
+import org.camunda.spin.SpinRuntimeException;
+import org.camunda.spin.SpinScriptException;
+import org.camunda.spin.impl.logging.SpinLogger;
+
+/**
+ * Logger for test cases.
+ *
+ * @author Sebastian Menski
+ */
+public class SpinTestLogger extends SpinLogger {
+
+ public static final SpinTestLogger TEST_LOGGER = BaseLogger.createLogger(SpinTestLogger.class, PROJECT_CODE, "org.camunda.spin.test", "02");
+
+ public void scriptEngineFoundForLanguage(String scriptLanguage) {
+ logInfo("001", "Script engine found for script language '{}'", scriptLanguage);
+ }
+
+ public void scriptLoaded(String scriptPath) {
+ logInfo("002", "Script loaded with filename '{}'", scriptPath);
+ }
+
+ public void scriptVariableFound(String name, String type, String value) {
+ logInfo("003", "Script variable found with name '{}', type '{}' and value '{}'", name, type, value);
+ }
+
+ public void noScriptExtensionFoundForScriptLanguage(String languageName) {
+ logWarn("004", "No script extension found for script language '{}'", languageName);
+ }
+
+ public void testDisabled(String reason) {
+ logInfo("005", "Test disabled because '{}'", reason);
+ }
+
+ public void executeScriptWithScriptEngine(String scriptPath, String engineName) {
+ logInfo("006", "Execute script '{}' with script engine '{}'", scriptPath, engineName);
+ }
+
+ public SpinScriptException noScriptEngineFoundForLanguage(String scriptLanguage) {
+ return new SpinScriptException(exceptionMessage("002", "No script engine found for script language '{}'", scriptLanguage));
+ }
+
+ public SpinScriptException scriptExecutionError(String scriptPath, Throwable cause) {
+ return new SpinScriptException(exceptionMessage("004", "Error during execution of script '{}'", scriptPath), cause);
+ }
+
+ public SpinScriptException cannotCastVariableError(String name, Throwable e) {
+ return new SpinScriptException(exceptionMessage("005", "Cannot cast variable '{}', wrong type", name), e);
+ }
+
+ public SpinScriptException unableToUnwrapRhinoJsVariable(String name, Throwable e) {
+ return new SpinScriptException(exceptionMessage("006", "Unable to unwrap rhinojs variable with name '{}'", name), e);
+ }
+
+ public SpinScriptException unableToFindUnwrapMethod(Throwable e) {
+ return new SpinScriptException(exceptionMessage("007", "Unable to find unwrap method of NativeJavaObject"));
+ }
+
+ public SpinRuntimeException unableToUnwrapRhinoJsWrappedException(String message) {
+ return new SpinScriptException(exceptionMessage("008", "Unable to unwrap rhinojs wrapped exception with message '{}'", message));
+ }
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/impl/test/script/GroovyScriptRuleTest.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/impl/test/script/GroovyScriptRuleTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..bfa88c590cff853736991bdb4949ec25e3071e1e
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/impl/test/script/GroovyScriptRuleTest.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.impl.test.script;
+
+import org.camunda.spin.impl.test.ScriptEngine;
+import org.camunda.spin.impl.test.ScriptRuleTest;
+
+/**
+ * @author Sebastian Menski
+ */
+@ScriptEngine("groovy")
+public class GroovyScriptRuleTest extends ScriptRuleTest {
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/impl/test/script/JavascriptScriptRuleNashornTest.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/impl/test/script/JavascriptScriptRuleNashornTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..919a5c019186686acc191897d0d8ffdc0908d27d
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/impl/test/script/JavascriptScriptRuleNashornTest.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.impl.test.script;
+
+import org.camunda.spin.impl.test.ScriptEngine;
+import org.camunda.spin.impl.test.ScriptRuleTest;
+
+@ScriptEngine("nashorn")
+public class JavascriptScriptRuleNashornTest extends ScriptRuleTest {
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/impl/test/script/JavascriptScriptRuleTest.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/impl/test/script/JavascriptScriptRuleTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..445a1e84e4e55e4c62b31da5a58d7e840b1d447f
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/impl/test/script/JavascriptScriptRuleTest.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.impl.test.script;
+
+import org.camunda.spin.impl.test.ScriptEngine;
+import org.camunda.spin.impl.test.ScriptRuleTest;
+
+/**
+ * @author Sebastian Menski
+ */
+@ScriptEngine("graal.js")
+public class JavascriptScriptRuleTest extends ScriptRuleTest {
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/impl/test/script/PythonScriptRuleTest.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/impl/test/script/PythonScriptRuleTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..68ecabab1fb92f1c4bf4d7994f615533ea302010
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/impl/test/script/PythonScriptRuleTest.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.impl.test.script;
+
+import org.camunda.spin.impl.test.ScriptEngine;
+import org.camunda.spin.impl.test.ScriptRuleTest;
+
+/**
+ * @author Sebastian Menski
+ */
+@ScriptEngine("python")
+public class PythonScriptRuleTest extends ScriptRuleTest {
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/impl/test/script/RubyScriptRuleTest.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/impl/test/script/RubyScriptRuleTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..76d5159ba7b41bec080a39e30f9a8ef8baf5a762
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/impl/test/script/RubyScriptRuleTest.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.impl.test.script;
+
+import org.camunda.spin.impl.test.ScriptEngine;
+import org.camunda.spin.impl.test.ScriptRuleTest;
+
+/**
+ * @author Sebastian Menski
+ */
+@ScriptEngine("ruby")
+public class RubyScriptRuleTest extends ScriptRuleTest {
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/impl/util/RewindableReaderTest.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/impl/util/RewindableReaderTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..815bcacf2165f2441311c0af3f9000896eee52ea
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/impl/util/RewindableReaderTest.java
@@ -0,0 +1,216 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.impl.util;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.fail;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.io.StringReader;
+import java.util.Arrays;
+
+import org.junit.After;
+import org.junit.Test;
+
+public class RewindableReaderTest {
+
+ private static final String EXAMPLE_INPUT_STRING = "a long string with content";
+ private static final int DEFAULT_BUFFER_SIZE = 10;
+
+ protected RewindableReader reader;
+
+ @Test
+ public void shouldRead() throws IOException {
+ // read(char[])
+ reader = newReaderInstance(EXAMPLE_INPUT_STRING, DEFAULT_BUFFER_SIZE);
+ assertThat(reader.getRewindBufferSize()).isEqualTo(DEFAULT_BUFFER_SIZE);
+ assertThat(reader.getCurrentRewindableCapacity()).isEqualTo(DEFAULT_BUFFER_SIZE);
+
+ char[] buffer = new char[5];
+ int charactersRead = reader.read(buffer);
+
+ String bufferAsString = new String(buffer);
+
+ assertThat(charactersRead).isEqualTo(5);
+ assertThat(reader.getCurrentRewindableCapacity()).isEqualTo(DEFAULT_BUFFER_SIZE - 5);
+
+ assertThat(bufferAsString).isEqualTo(EXAMPLE_INPUT_STRING.substring(0, 5));
+
+ reader.close();
+
+ // read(char[], off, len)
+ reader = newReaderInstance(EXAMPLE_INPUT_STRING, DEFAULT_BUFFER_SIZE);
+
+ buffer = new char[5];
+ charactersRead = reader.read(buffer, 2, 3);
+
+ assertThat(charactersRead).isEqualTo(3);
+
+ assertThat(buffer[0]).isEqualTo((char) 0);
+ assertThat(buffer[1]).isEqualTo((char) 0);
+
+ bufferAsString = new String(Arrays.copyOfRange(buffer, 2, 4));
+ assertThat(bufferAsString).isEqualTo(EXAMPLE_INPUT_STRING.substring(0, 2));
+
+ // read()
+ reader = newReaderInstance(EXAMPLE_INPUT_STRING, DEFAULT_BUFFER_SIZE);
+
+ char charRead = (char) reader.read();
+ assertThat(charRead).isEqualTo('a');
+
+ reader.close();
+ }
+
+ @Test
+ public void shouldRewind() throws IOException {
+ reader = newReaderInstance(EXAMPLE_INPUT_STRING, DEFAULT_BUFFER_SIZE);
+
+ char[] buffer = new char[5];
+ reader.read(buffer);
+
+ reader.rewind();
+
+ assertThat(SpinIoUtil.getStringFromReader(reader)).isEqualTo(EXAMPLE_INPUT_STRING);
+ }
+
+ @Test
+ public void shouldRewindAfterRepeatedRead() throws IOException {
+ reader = newReaderInstance(EXAMPLE_INPUT_STRING, DEFAULT_BUFFER_SIZE);
+
+ char[] buffer = new char[5];
+ reader.read(buffer);
+ reader.read(buffer);
+
+ reader.rewind();
+
+ assertThat(SpinIoUtil.getStringFromReader(reader)).isEqualTo(EXAMPLE_INPUT_STRING);
+ }
+
+ @Test
+ public void shouldReadAndRewindWhenEndOfInputIsReached() throws IOException {
+ String input = EXAMPLE_INPUT_STRING.substring(0, 5);
+
+ reader = newReaderInstance(input, DEFAULT_BUFFER_SIZE);
+
+ char[] buffer = new char[10];
+ int charactersRead = reader.read(buffer);
+ String bufferAsString =
+ new String(Arrays.copyOfRange(buffer, 0, charactersRead));
+
+ assertThat(charactersRead).isEqualTo(5);
+ assertThat(bufferAsString).isEqualTo(input);
+
+ charactersRead = reader.read(buffer);
+ assertThat(charactersRead).isEqualTo(-1);
+
+ reader.rewind();
+
+ charactersRead = reader.read(buffer);
+ bufferAsString =
+ new String(Arrays.copyOfRange(buffer, 0, charactersRead));
+
+ assertThat(charactersRead).isEqualTo(5);
+ assertThat(bufferAsString).isEqualTo(input);
+ }
+
+ @Test
+ public void shouldReadRemainder() throws IOException {
+ reader = newReaderInstance(EXAMPLE_INPUT_STRING, DEFAULT_BUFFER_SIZE);
+
+ char[] buffer = new char[5];
+ reader.read(buffer);
+
+ assertThat(SpinIoUtil.getStringFromReader(reader)).isEqualTo(EXAMPLE_INPUT_STRING.substring(5));
+ }
+
+ /**
+ * When reading more characters than fits into the reader's buffer
+ * @throws IOException
+ */
+ @Test
+ public void shouldFailWhenRewindLimitExceeded() throws IOException {
+ // exceeding with read(char[])
+ reader = newReaderInstance(EXAMPLE_INPUT_STRING, DEFAULT_BUFFER_SIZE);
+
+ char[] buffer = new char[DEFAULT_BUFFER_SIZE + 5];
+ reader.read(buffer);
+
+ assertThat(SpinIoUtil.getStringFromReader(reader))
+ .isEqualTo(EXAMPLE_INPUT_STRING.substring(DEFAULT_BUFFER_SIZE + 5));
+
+ try {
+ reader.rewind();
+ fail("IOException expected");
+ } catch (IOException e) {
+ // happy path
+ }
+
+ // exceeding with read()
+ reader = newReaderInstance(EXAMPLE_INPUT_STRING, DEFAULT_BUFFER_SIZE);
+
+ buffer = new char[DEFAULT_BUFFER_SIZE];
+ reader.read(buffer);
+ reader.read();
+
+ try {
+ reader.rewind();
+ fail("IOException expected");
+ } catch (IOException e) {
+ // happy path
+ }
+
+ // repeated read(char[])
+ reader = newReaderInstance(EXAMPLE_INPUT_STRING, DEFAULT_BUFFER_SIZE);
+
+ buffer = new char[DEFAULT_BUFFER_SIZE];
+ reader.read(buffer);
+ reader.read(buffer);
+
+ try {
+ reader.rewind();
+ fail("IOException expected");
+ } catch (IOException e) {
+ // happy path
+ }
+ }
+
+ @Test
+ public void shouldRewindWhenNothingWasRead() throws IOException {
+ reader = newReaderInstance("", DEFAULT_BUFFER_SIZE);
+
+ int charRead = reader.read();
+ assertThat(charRead).isEqualTo(-1);
+
+ reader.rewind();
+
+ charRead = reader.read();
+ assertThat(charRead).isEqualTo(-1);
+ }
+
+ @After
+ public void closeReader() {
+ if (reader != null) {
+ SpinIoUtil.closeSilently(reader);
+ }
+ }
+
+ protected RewindableReader newReaderInstance(String input, int bufferSize) {
+ Reader reader = new StringReader(input);
+ return new RewindableReader(reader, bufferSize);
+ }
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/spi/CustomDataFormatProvider.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/spi/CustomDataFormatProvider.java
new file mode 100644
index 0000000000000000000000000000000000000000..9c7ca135c22aae0680b2bbd9c7d60969340fcea0
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/spi/CustomDataFormatProvider.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.spi;
+
+
+import java.util.Map;
+
+/**
+ * @author Thorben Lindhauer
+ *
+ */
+public class CustomDataFormatProvider implements DataFormatProvider {
+
+ public static final String NAME = "test-data-format";
+ public static final ExampleCustomDataFormat DATA_FORMAT = new ExampleCustomDataFormat(NAME);
+
+ @Override
+ public String getDataFormatName() {
+ return NAME;
+ }
+
+ @Override
+ public DataFormat> createInstance() {
+ return DATA_FORMAT;
+ }
+
+ @Override
+ public DataFormat> createInstance(Map configurationProperties) {
+ boolean conditionalProperty = (boolean) configurationProperties.getOrDefault("conditional-prop", false);
+ DATA_FORMAT.setConditionalProperty(conditionalProperty);
+ return DATA_FORMAT;
+ }
+
+}
+
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/spi/DataFormatLoadingTest.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/spi/DataFormatLoadingTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..edb5d9b61e76b6a7db81899b5c4a8785b538bb94
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/spi/DataFormatLoadingTest.java
@@ -0,0 +1,176 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.spi;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.powermock.api.mockito.PowerMockito.mock;
+import static org.powermock.api.mockito.PowerMockito.mockStatic;
+import static org.powermock.api.mockito.PowerMockito.when;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.ServiceLoader;
+
+import org.camunda.spin.DataFormats;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Matchers;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+/**
+ * Note: The @RunWith and @PrepareForTest annotations are required by powermock to be able
+ * to mock static methods provided by the JDK (i.e. ServiceLoader.load(..) in our case).
+ * See https://code.google.com/p/powermock/wiki/MockSystem and
+ * https://code.google.com/p/powermock/wiki/MockStatic
+ *
+ * @author Thorben Lindhauer
+ */
+@RunWith(PowerMockRunner.class)
+public class DataFormatLoadingTest {
+
+ protected ServiceLoader mockServiceLoader;
+
+ @SuppressWarnings("rawtypes")
+ protected ServiceLoader mockConfiguratorLoader;
+
+ @Before
+ @SuppressWarnings("unchecked")
+ public void setUp() {
+ mockStatic(ServiceLoader.class);
+
+ mockServiceLoader = mock(ServiceLoader.class);
+ when(ServiceLoader.load(Matchers.eq(DataFormatProvider.class), Matchers.any(ClassLoader.class)))
+ .thenReturn(mockServiceLoader);
+
+ mockConfiguratorLoader = mock(ServiceLoader.class);
+ when(ServiceLoader.load(Matchers.eq(DataFormatConfigurator.class), Matchers.any(ClassLoader.class)))
+ .thenReturn(mockConfiguratorLoader);
+ }
+
+ @Test
+ @PrepareForTest( { DataFormats.class })
+ public void testCustomDataFormatProvider() {
+ // given a custom data format provider that is returned by the service loader API
+ mockProviders(new CustomDataFormatProvider());
+ mockConfigurators();
+
+ // when the custom data format is requested
+ DataFormat> customDataFormat = DataFormats.getDataFormat(CustomDataFormatProvider.NAME);
+
+ // then it should be properly returned
+ assertThat(customDataFormat).isNotNull();
+ assertThat(customDataFormat).isSameAs(CustomDataFormatProvider.DATA_FORMAT);
+ }
+
+
+ @Test
+ @PrepareForTest( { DataFormats.class })
+ public void testConfigureDataFormat() {
+ // given a custom data format provider that is returned by the service loader API
+ mockProviders(new CustomDataFormatProvider());
+ mockConfigurators(new ExampleCustomDataFormatConfigurator());
+
+ DataFormat> format = DataFormats.getDataFormat(CustomDataFormatProvider.NAME);
+ assertThat(format).isSameAs(CustomDataFormatProvider.DATA_FORMAT);
+
+ // then the configuration was applied
+ ExampleCustomDataFormat customFormat = (ExampleCustomDataFormat) format;
+ assertThat(customFormat.getProperty()).isEqualTo(ExampleCustomDataFormatConfigurator.UPDATED_PROPERTY);
+ }
+
+ @Test
+ @PrepareForTest(DataFormats.class)
+ public void testConfigureDataFormatWithConfiguratorList() {
+ // given a custom data format provider that is returned by the service loader API
+ mockProviders(new CustomDataFormatProvider());
+ mockConfigurators();
+ DataFormatConfigurator configurator = new ExampleCustomDataFormatConfigurator();
+
+ // when a list of data format configurators is passed to the "load" method
+ DataFormats.loadDataFormats(DataFormats.class.getClassLoader(),
+ Collections.singletonList(configurator));
+
+ // then the configuration was applied
+ ExampleCustomDataFormat customFormat = (ExampleCustomDataFormat) DataFormats
+ .getDataFormat(CustomDataFormatProvider.NAME);
+ assertThat(customFormat.getProperty())
+ .isEqualTo(ExampleCustomDataFormatConfigurator.UPDATED_PROPERTY);
+ }
+
+ @Test
+ @PrepareForTest(DataFormats.class)
+ public void testRegisterDataFormatWithConfiguratorList() {
+ // given a custom data format provider that is returned by the service loader API
+ mockProviders(new CustomDataFormatProvider());
+ mockConfigurators();
+ DataFormatConfigurator configurator = new ExampleCustomDataFormatConfigurator();
+
+ // when a list of data format configurators is passed to the "load" method
+ DataFormats.getInstance().registerDataFormats(DataFormats.class.getClassLoader(),
+ Collections.singletonList(configurator));
+
+ // then the configuration was applied
+ ExampleCustomDataFormat customFormat = (ExampleCustomDataFormat) DataFormats
+ .getDataFormat(CustomDataFormatProvider.NAME);
+ assertThat(customFormat.getProperty())
+ .isEqualTo(ExampleCustomDataFormatConfigurator.UPDATED_PROPERTY);
+ }
+
+ @Test
+ @PrepareForTest(DataFormats.class)
+ public void shouldPassConfiguratorPropertiesToProvider() {
+ // given a custom data format provider that is returned by the service loader API
+ mockProviders(new CustomDataFormatProvider());
+ mockConfigurators();
+
+ // when a map of configuration properties is passed to the "load" method
+ DataFormats.getInstance().registerDataFormats(DataFormats.class.getClassLoader(),
+ Collections.EMPTY_LIST,
+ Collections.singletonMap("conditional-prop", true));
+
+ // then the configuration property is applied
+ ExampleCustomDataFormat customFormat = (ExampleCustomDataFormat) DataFormats
+ .getDataFormat(CustomDataFormatProvider.NAME);
+ assertThat(customFormat.isConditionalProperty())
+ .isTrue();
+ }
+
+ protected void mockProviders(final DataFormatProvider... providers) {
+ when(mockServiceLoader.iterator()).thenAnswer(new Answer>() {
+
+ @Override
+ public Iterator answer(InvocationOnMock invocation) throws Throwable {
+ return Arrays.asList(providers).iterator();
+ }
+ });
+ }
+
+ protected void mockConfigurators(final DataFormatConfigurator>... configurators) {
+ when(mockConfiguratorLoader.iterator()).thenAnswer(new Answer>>() {
+
+ @Override
+ public Iterator> answer(InvocationOnMock invocation) throws Throwable {
+ return Arrays.asList(configurators).iterator();
+ }
+ });
+ }
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/spi/ExampleCustomDataFormat.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/spi/ExampleCustomDataFormat.java
new file mode 100644
index 0000000000000000000000000000000000000000..9fd34385bc148d9bd27006e2e0b2f7588e8997f8
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/spi/ExampleCustomDataFormat.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.spi;
+
+import org.camunda.spin.json.SpinJsonNode;
+
+/**
+ * @author Thorben Lindhauer
+ *
+ */
+public class ExampleCustomDataFormat implements DataFormat {
+
+ protected String name;
+ protected String property = "defaultValue";
+ protected boolean conditionalProperty = false;
+
+ public ExampleCustomDataFormat(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public Class extends SpinJsonNode> getWrapperType() {
+ return null;
+ }
+
+ @Override
+ public SpinJsonNode createWrapperInstance(Object parameter) {
+ return null;
+ }
+
+ @Override
+ public DataFormatReader getReader() {
+ return null;
+ }
+
+ @Override
+ public DataFormatWriter getWriter() {
+ return null;
+ }
+
+ @Override
+ public DataFormatMapper getMapper() {
+ return null;
+ }
+
+ public String getProperty() {
+ return property;
+ }
+
+ public void setProperty(String property) {
+ this.property = property;
+ }
+
+ public boolean isConditionalProperty() {
+ return conditionalProperty;
+ }
+
+ public void setConditionalProperty(boolean conditionalProperty) {
+ this.conditionalProperty = conditionalProperty;
+ }
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/spi/ExampleCustomDataFormatConfigurator.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/spi/ExampleCustomDataFormatConfigurator.java
new file mode 100644
index 0000000000000000000000000000000000000000..94d063d7ffc05e24e20711e765162740a2bab2e4
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/java/org/camunda/spin/spi/ExampleCustomDataFormatConfigurator.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.spi;
+
+
+
+/**
+ * @author Thorben Lindhauer
+ *
+ */
+public class ExampleCustomDataFormatConfigurator implements DataFormatConfigurator {
+
+ public static final String UPDATED_PROPERTY = "updatedProperty";
+
+ @Override
+ public Class getDataFormatClass() {
+ return ExampleCustomDataFormat.class;
+ }
+
+ @Override
+ public void configure(ExampleCustomDataFormat dataFormat) {
+ dataFormat.setProperty(UPDATED_PROPERTY);
+ }
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/resources/logback-test.xml b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/resources/logback-test.xml
new file mode 100644
index 0000000000000000000000000000000000000000..650a86c01c0c57d0a7ce102937833fd744fbd8d6
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/resources/logback-test.xml
@@ -0,0 +1,11 @@
+
+
+
+ %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
+
+
+
+
+
+
+
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/resources/org/camunda/spin/impl/test/script/GroovyScriptRuleTest.shouldSetBar.groovy b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/resources/org/camunda/spin/impl/test/script/GroovyScriptRuleTest.shouldSetBar.groovy
new file mode 100644
index 0000000000000000000000000000000000000000..ee84c16fc3e3f04fbffec05d68b0dbee2dab3cf5
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/resources/org/camunda/spin/impl/test/script/GroovyScriptRuleTest.shouldSetBar.groovy
@@ -0,0 +1 @@
+bar = 'bar'
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/resources/org/camunda/spin/impl/test/script/GroovyScriptRuleTest.shouldSetFoo.groovy b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/resources/org/camunda/spin/impl/test/script/GroovyScriptRuleTest.shouldSetFoo.groovy
new file mode 100644
index 0000000000000000000000000000000000000000..7d854c9e36441850a2b7b6017b6d1731109d8e2f
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/resources/org/camunda/spin/impl/test/script/GroovyScriptRuleTest.shouldSetFoo.groovy
@@ -0,0 +1 @@
+foo = 'foo'
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/resources/org/camunda/spin/impl/test/script/JavascriptScriptRuleNashornTest.shouldSetBar.js b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/resources/org/camunda/spin/impl/test/script/JavascriptScriptRuleNashornTest.shouldSetBar.js
new file mode 100644
index 0000000000000000000000000000000000000000..ee84c16fc3e3f04fbffec05d68b0dbee2dab3cf5
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/resources/org/camunda/spin/impl/test/script/JavascriptScriptRuleNashornTest.shouldSetBar.js
@@ -0,0 +1 @@
+bar = 'bar'
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/resources/org/camunda/spin/impl/test/script/JavascriptScriptRuleNashornTest.shouldSetFoo.js b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/resources/org/camunda/spin/impl/test/script/JavascriptScriptRuleNashornTest.shouldSetFoo.js
new file mode 100644
index 0000000000000000000000000000000000000000..7d854c9e36441850a2b7b6017b6d1731109d8e2f
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/resources/org/camunda/spin/impl/test/script/JavascriptScriptRuleNashornTest.shouldSetFoo.js
@@ -0,0 +1 @@
+foo = 'foo'
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/resources/org/camunda/spin/impl/test/script/JavascriptScriptRuleTest.shouldSetBar.js b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/resources/org/camunda/spin/impl/test/script/JavascriptScriptRuleTest.shouldSetBar.js
new file mode 100644
index 0000000000000000000000000000000000000000..ee84c16fc3e3f04fbffec05d68b0dbee2dab3cf5
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/resources/org/camunda/spin/impl/test/script/JavascriptScriptRuleTest.shouldSetBar.js
@@ -0,0 +1 @@
+bar = 'bar'
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/resources/org/camunda/spin/impl/test/script/JavascriptScriptRuleTest.shouldSetFoo.js b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/resources/org/camunda/spin/impl/test/script/JavascriptScriptRuleTest.shouldSetFoo.js
new file mode 100644
index 0000000000000000000000000000000000000000..7d854c9e36441850a2b7b6017b6d1731109d8e2f
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/resources/org/camunda/spin/impl/test/script/JavascriptScriptRuleTest.shouldSetFoo.js
@@ -0,0 +1 @@
+foo = 'foo'
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/resources/org/camunda/spin/impl/test/script/PythonScriptRuleTest.shouldSetBar.py b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/resources/org/camunda/spin/impl/test/script/PythonScriptRuleTest.shouldSetBar.py
new file mode 100644
index 0000000000000000000000000000000000000000..ee84c16fc3e3f04fbffec05d68b0dbee2dab3cf5
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/resources/org/camunda/spin/impl/test/script/PythonScriptRuleTest.shouldSetBar.py
@@ -0,0 +1 @@
+bar = 'bar'
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/resources/org/camunda/spin/impl/test/script/PythonScriptRuleTest.shouldSetFoo.py b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/resources/org/camunda/spin/impl/test/script/PythonScriptRuleTest.shouldSetFoo.py
new file mode 100644
index 0000000000000000000000000000000000000000..7d854c9e36441850a2b7b6017b6d1731109d8e2f
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/resources/org/camunda/spin/impl/test/script/PythonScriptRuleTest.shouldSetFoo.py
@@ -0,0 +1 @@
+foo = 'foo'
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/resources/org/camunda/spin/impl/test/script/RubyScriptRuleTest.shouldSetBar.rb b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/resources/org/camunda/spin/impl/test/script/RubyScriptRuleTest.shouldSetBar.rb
new file mode 100644
index 0000000000000000000000000000000000000000..b48812b77411979f8939b117cd6ba5078fda4ff4
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/resources/org/camunda/spin/impl/test/script/RubyScriptRuleTest.shouldSetBar.rb
@@ -0,0 +1 @@
+$bar = 'bar'
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/resources/org/camunda/spin/impl/test/script/RubyScriptRuleTest.shouldSetFoo.rb b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/resources/org/camunda/spin/impl/test/script/RubyScriptRuleTest.shouldSetFoo.rb
new file mode 100644
index 0000000000000000000000000000000000000000..3da8b9ea806914c9539fcaf75d26a76a72014f66
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/core/src/test/resources/org/camunda/spin/impl/test/script/RubyScriptRuleTest.shouldSetFoo.rb
@@ -0,0 +1 @@
+$foo = 'foo'
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-all/pom.xml b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-all/pom.xml
new file mode 100644
index 0000000000000000000000000000000000000000..a91e031700ebc237f26d53c6cfab15ef22c22f36
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-all/pom.xml
@@ -0,0 +1,192 @@
+
+ 4.0.0
+
+
+ Note: 7.24.0 is the last community edition release published on Maven Central. This library will not receive any new versions or releases. However, if you are interested in extended maintenance you could look into our enterprise edition. Get in touch with us: https://camunda.com/contact/
+
+
+
+ org.camunda.spin
+ camunda-spin-root
+ 7.24.0-SNAPSHOT
+
+
+ camunda-spin-dataformat-all
+ camunda Spin - all dataformats in one
+
+
+
+ false
+
+ compile|runtime
+
+
+
+
+
+ org.camunda.spin
+ camunda-spin-dataformat-json-jackson
+
+
+
+ org.camunda.spin
+ camunda-spin-dataformat-xml-dom
+
+
+
+ jakarta.xml.bind
+ jakarta.xml.bind-api
+
+
+
+ com.sun.xml.bind
+ jaxb-impl
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-shade-plugin
+ 3.5.0
+
+
+ package
+
+ shade
+
+
+ true
+ true
+ true
+
+
+ org.camunda.commons:*
+ org.camunda.spin:camunda-spin-core
+ org.slf4j:*
+
+
+
+
+ com.fasterxml
+ spinjar.com.fasterxml
+
+
+ com.jayway
+ spinjar.com.jayway
+
+
+ net.minidev
+ spinjar.com.minidev
+
+
+ org.objectweb
+ spinjar.com.objectweb
+
+
+
+ com.sun.istack
+ spinjar.com.sun.istack
+
+
+ com.sun.activation
+ spinjar.com.sun.activation
+
+
+ com.sun.xml.bind
+ spinjar.com.sun.xml.bind
+
+
+ com.sun.xml.txw2
+ spinjar.com.sun.xml.txw2
+
+
+ javax.xml.bind
+ spinjar.javax.xml.bind
+
+
+ javax.activation
+ spinjar.javax.activation
+
+
+
+
+
+
+
+ com.sun.xml.bind:*
+
+ META-INF/services/javax.xml.bind.JAXBContext
+
+
+
+ *:*
+
+ module-info.class
+
+
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-javadoc-plugin
+
+ true
+ true
+ org.camunda.spin:*
+
+
+ junit
+ junit
+ ${version.junit}
+
+
+
+
+
+ org.apache.felix
+ maven-bundle-plugin
+
+ false
+
+
+ ${project.groupId}*
+
+
+ !spinjar*,
+ !org.junit*,
+ !org.slf4j.impl,
+ !com.fasterxml*,
+ !com.jayway,
+ !net.minidev.json*,
+ !org.codehaus.jackson*,
+ org.slf4j,
+ org.camunda.commons.utils,
+ org.camunda.commons.logging,
+ *
+
+ .
+ *;inline=true
+ true
+
+
+
+
+ bundle-manifest
+ process-classes
+
+ manifest
+
+
+
+
+
+
+
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-all/src/main/resources/META-INF/MANIFEST.MF b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-all/src/main/resources/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-all/src/main/resources/META-INF/services/spinjar.javax.xml.bind.JAXBContext b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-all/src/main/resources/META-INF/services/spinjar.javax.xml.bind.JAXBContext
new file mode 100644
index 0000000000000000000000000000000000000000..c32c73ab18f2e1bcbe81a23f0d82a47571a224cd
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-all/src/main/resources/META-INF/services/spinjar.javax.xml.bind.JAXBContext
@@ -0,0 +1 @@
+spinjar.com.sun.xml.bind.v2.ContextFactory
\ No newline at end of file
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/pom.xml b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/pom.xml
new file mode 100644
index 0000000000000000000000000000000000000000..f6580328c6295c5c655fd697585e0ecb3023898d
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/pom.xml
@@ -0,0 +1,267 @@
+
+ 4.0.0
+
+
+ Note: 7.24.0 is the last community edition release published on Maven Central. This library will not receive any new versions or releases. However, if you are interested in extended maintenance you could look into our enterprise edition. Get in touch with us: https://camunda.com/contact/
+
+
+
+ org.camunda.spin
+ camunda-spin-root
+ 7.24.0-SNAPSHOT
+
+
+ camunda-spin-dataformat-json-jackson
+ camunda Spin - Jackson JSON data format
+
+
+
+ org.camunda.spin
+ camunda-spin-core
+
+
+
+ org.camunda.commons
+ camunda-commons-logging
+
+
+
+ org.camunda.commons
+ camunda-commons-utils
+
+
+
+ com.fasterxml.jackson.core
+ jackson-core
+
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+
+
+
+ com.jayway.jsonpath
+ json-path
+
+
+ asm
+ org.ow2.asm
+
+
+
+
+
+ junit
+ junit
+ test
+
+
+
+ org.assertj
+ assertj-core
+ test
+
+
+
+ org.apache.groovy
+ groovy-jsr223
+ test
+
+
+
+ org.apache.groovy
+ groovy-json
+ test
+
+
+
+ org.python
+ jython
+ test
+
+
+
+ org.jruby
+ jruby-complete
+ test
+
+
+
+ org.graalvm.js
+ js
+ test
+
+
+
+ org.graalvm.js
+ js-scriptengine
+ test
+
+
+
+ ch.qos.logback
+ logback-classic
+ test
+
+
+
+ net.javacrumbs.json-unit
+ json-unit-fluent
+ test
+
+
+
+ org.powermock
+ powermock-module-junit4
+ test
+
+
+
+ org.powermock
+ powermock-api-mockito2
+ test
+
+
+
+ org.camunda.spin
+ camunda-spin-core
+ test-jar
+ test
+
+
+
+
+
+ disable-javascript-tests
+
+ (,1.8)
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+ -XX:PermSize=128m -XX:MaxPermSize=256m
+
+ **/javascript/**
+
+
+
+
+
+
+
+
+ jdk-15-and-onwards
+
+ [15,)
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+
+ **/nashorn/**
+
+
+
+
+
+
+
+
+ jdk-16-and-onwards
+
+ [16,)
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+
+ -XX:MetaspaceSize=128m
+
+
+ **/nashorn/**
+
+
+
+
+
+
+
+
+
+ check-api-compatibility
+
+ (,)
+
+
+
+
+ org.codehaus.mojo
+ clirr-maven-plugin
+ 2.8
+
+ ${spin.version.old}
+ true
+
+ org/camunda/spin/impl/**
+
+
+
+
+ all
+ verify
+
+ check-no-fork
+
+
+ ${project.build.directory}/clirr-all.txt
+ false
+ false
+
+
+
+ restrictive
+ verify
+
+ check-no-fork
+
+
+ ${project.build.directory}/clirr-restrictive.txt
+ true
+ ../.clirr-jenkins-ignore.xml
+
+
+
+
+
+
+
+
+
+
+
+
+ org.apache.felix
+ maven-bundle-plugin
+
+
+ bundle-manifest
+ process-classes
+
+ manifest
+
+
+
+
+
+
+
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/JacksonJsonLogger.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/JacksonJsonLogger.java
new file mode 100644
index 0000000000000000000000000000000000000000..8d07cfe32b5a3eb68e1d9c200524bcc5771975cd
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/JacksonJsonLogger.java
@@ -0,0 +1,118 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.impl.json.jackson;
+
+import org.camunda.commons.logging.BaseLogger;
+import org.camunda.spin.impl.logging.SpinLogger;
+import org.camunda.spin.json.SpinJsonDataFormatException;
+import org.camunda.spin.json.SpinJsonException;
+import org.camunda.spin.json.SpinJsonNode;
+import org.camunda.spin.json.SpinJsonPathException;
+import org.camunda.spin.json.SpinJsonPropertyException;
+
+import com.fasterxml.jackson.databind.JavaType;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.JsonNodeType;
+import com.jayway.jsonpath.PathNotFoundException;
+
+/**
+ * @author Thorben Lindhauer
+ * @author Stefan Hentschel
+ */
+public class JacksonJsonLogger extends SpinLogger {
+
+ public static final String PROJECT_CODE = SpinLogger.PROJECT_CODE + "/JACKSON-JSON";
+ public static final JacksonJsonLogger JSON_TREE_LOGGER = BaseLogger.createLogger(JacksonJsonLogger.class, PROJECT_CODE, "org.camunda.spin.json", "01");
+
+ public SpinJsonDataFormatException unableToParseInput(Exception e) {
+ return new SpinJsonDataFormatException(exceptionMessage("001", "Unable to parse input into json node"), e);
+ }
+
+ /**
+ * Exception handler if we are unable to parse a json value into a java representation
+ *
+ * @param expectedType Name of the expected Type
+ * @param type Type of the json node
+ * @return SpinJsonDataFormatException
+ */
+ public SpinJsonDataFormatException unableToParseValue(String expectedType, JsonNodeType type) {
+ return new SpinJsonDataFormatException(exceptionMessage("002", "Expected '{}', got '{}'", expectedType, type.toString()));
+ }
+
+ public SpinJsonDataFormatException unableToWriteJsonNode(Exception cause) {
+ return new SpinJsonDataFormatException(exceptionMessage("003", "Unable to write json node"), cause);
+ }
+
+ public SpinJsonException unableToFindProperty(String propertyName) {
+ return new SpinJsonPropertyException(exceptionMessage("004", "Unable to find '{}'", propertyName));
+ }
+
+ public SpinJsonException unableToCreateNode(String objectType) {
+ return new SpinJsonPropertyException(exceptionMessage("005", "Unable to create node for object of type '{}'", objectType));
+ }
+
+ public SpinJsonException unableToDeserialize(JsonNode jsonNode, JavaType type, Exception cause) {
+ return new SpinJsonException(
+ exceptionMessage("006", "Cannot deserialize '{}...' to java type '{}'",
+ jsonNode.toString().substring(0, 10), type), cause);
+ }
+
+ public SpinJsonDataFormatException unableToConstructJavaType(String fromString, Exception cause) {
+ return new SpinJsonDataFormatException(
+ exceptionMessage("007", "Cannot construct java type from string '{}'", fromString), cause);
+ }
+
+ public SpinJsonDataFormatException unableToDetectCanonicalType(Object parameter) {
+ return new SpinJsonDataFormatException(exceptionMessage("008", "Cannot detect canonical data type for parameter '{}'", parameter));
+ }
+
+ public SpinJsonDataFormatException unableToMapInput(Object input, Exception cause) {
+ return new SpinJsonDataFormatException(exceptionMessage("009", "Unable to map object '{}' to json node", input), cause);
+ }
+
+ public SpinJsonException unableToModifyNode(String nodeName) {
+ return new SpinJsonException(exceptionMessage("010", "Unable to modify node of type '{}'. Node is not a list.", nodeName));
+ }
+
+ public SpinJsonException unableToGetIndex(String nodeName) {
+ return new SpinJsonException(exceptionMessage("011", "Unable to get index from '{}'. Node is not a list.", nodeName));
+ }
+
+ public IndexOutOfBoundsException indexOutOfBounds(Integer index, Integer size) {
+ return new IndexOutOfBoundsException(exceptionMessage("012", "Index is out of bound! Index: '{}', Size: '{}'", index, size));
+ }
+
+ public SpinJsonPathException unableToEvaluateJsonPathExpressionOnNode(SpinJsonNode node, Exception cause) {
+ return new SpinJsonPathException(
+ exceptionMessage("013", "Unable to evaluate JsonPath expression on element '{}'", node.getClass().getName()), cause);
+ }
+
+ public SpinJsonPathException unableToCompileJsonPathExpression(String expression, Exception cause) {
+ return new SpinJsonPathException(
+ exceptionMessage("014", "Unable to compile '{}'!", expression), cause);
+ }
+
+ public SpinJsonPathException unableToCastJsonPathResultTo(Class> castClass, Exception cause) {
+ return new SpinJsonPathException(
+ exceptionMessage("015", "Unable to cast JsonPath expression to '{}'", castClass.getName()), cause);
+ }
+
+ public SpinJsonPathException invalidJsonPath(Class> castClass, Exception cause) {
+ return new SpinJsonPathException(
+ exceptionMessage("017", "Invalid json path to '{}'", castClass.getName()), cause);
+ }
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/JacksonJsonNode.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/JacksonJsonNode.java
new file mode 100644
index 0000000000000000000000000000000000000000..455d27859884f2d1994695f432c6004777574ded
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/JacksonJsonNode.java
@@ -0,0 +1,501 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.impl.json.jackson;
+
+import static org.camunda.commons.utils.EnsureUtil.ensureNotNull;
+
+import java.io.StringWriter;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.camunda.spin.SpinList;
+import org.camunda.spin.impl.SpinListImpl;
+import org.camunda.spin.impl.json.jackson.format.JacksonJsonDataFormat;
+import org.camunda.spin.impl.json.jackson.format.JacksonJsonDataFormatMapper;
+import org.camunda.spin.impl.json.jackson.query.JacksonJsonPathQuery;
+import org.camunda.spin.json.SpinJsonDataFormatException;
+import org.camunda.spin.json.SpinJsonException;
+import org.camunda.spin.json.SpinJsonNode;
+import org.camunda.spin.json.SpinJsonPathQuery;
+import org.camunda.spin.spi.DataFormatMapper;
+
+import com.fasterxml.jackson.databind.JavaType;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.JsonNodeType;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.jayway.jsonpath.InvalidPathException;
+import com.jayway.jsonpath.JsonPath;
+
+/**
+ * Wrapper for a Jackson Json Tree Node.
+ *
+ * @author Thorben Lindhauer
+ * @author Stefan Hentschel
+ */
+public class JacksonJsonNode extends SpinJsonNode {
+
+ private static final JacksonJsonLogger LOG = JacksonJsonLogger.JSON_TREE_LOGGER;
+
+ protected final JsonNode jsonNode;
+ protected final JacksonJsonDataFormat dataFormat;
+
+
+ public JacksonJsonNode(JsonNode jsonNode, JacksonJsonDataFormat dataFormat) {
+ this.jsonNode = jsonNode;
+ this.dataFormat = dataFormat;
+ }
+
+ public String getDataFormatName() {
+ return dataFormat.getName();
+ }
+
+ public JsonNode unwrap() {
+ return jsonNode;
+ }
+
+ public String toString() {
+ StringWriter writer = new StringWriter();
+ writeToWriter(writer);
+ return writer.toString();
+ }
+
+ public void writeToWriter(Writer writer) {
+ dataFormat.getWriter().writeToWriter(writer, jsonNode);
+ }
+
+ /**
+ * fetch correct array index if index is less than 0
+ *
+ * ArrayNode will convert all negative integers into 0...
+ *
+ * @param index wanted index
+ * @return {@link Integer} new index
+ */
+ protected Integer getCorrectIndex(Integer index) {
+ Integer size = jsonNode.size();
+ Integer newIndex = index;
+
+ // reverse walking through the array
+ if(index < 0) {
+ newIndex = size + index;
+ }
+
+ // the negative index would be greater than the size a second time!
+ if(newIndex < 0) {
+ throw LOG.indexOutOfBounds(index, size);
+ }
+
+ // the index is greater as the actual size
+ if(index > size) {
+ throw LOG.indexOutOfBounds(index, size);
+ }
+
+ return newIndex;
+ }
+
+ protected int lookupArray(JsonNode searchNode, int direction) {
+ if(!this.isArray()) {
+ throw LOG.unableToGetIndex(jsonNode.getNodeType().name());
+ }
+ int i = direction>0 ? 0 : jsonNode.size() - 1;
+ for (; i < jsonNode.size() && i >= 0; i += direction) {
+ if (jsonNode.get(i).equals(searchNode)){
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ public Integer indexOf(Object searchObject) {
+ ensureNotNull("searchObject", searchObject);
+ JsonNode node = dataFormat.createJsonNode(searchObject);
+ int res = lookupArray(node, 1);
+ if(res == -1){
+ throw LOG.unableToFindProperty(node.asText());
+ }
+ return res;
+ }
+
+ public Integer lastIndexOf(Object searchObject) {
+ ensureNotNull("searchObject", searchObject);
+ JsonNode node = dataFormat.createJsonNode(searchObject);
+ int res = lookupArray(node, -1);
+ if(res == -1){
+ throw LOG.unableToFindProperty(node.asText());
+ }
+ return res;
+ }
+
+ public boolean contains(Object searchObject) {
+ ensureNotNull("searchObject", searchObject);
+ JsonNode node = dataFormat.createJsonNode(searchObject);
+ int res = lookupArray(node, 1);
+ return res != -1;
+ }
+
+ public boolean isObject() {
+ return jsonNode.isObject();
+ }
+
+ public boolean hasProp(String name) {
+ return jsonNode.has(name);
+ }
+
+ public SpinJsonNode prop(String name) {
+ ensureNotNull("name", name);
+ if(jsonNode.has(name)) {
+ JsonNode property = jsonNode.get(name);
+ return dataFormat.createWrapperInstance(property);
+ } else {
+ throw LOG.unableToFindProperty(name);
+ }
+ }
+
+ public SpinJsonNode prop(String name, String newProperty) {
+ ObjectNode node = (ObjectNode) jsonNode;
+
+ node.put(name, newProperty);
+
+ return this;
+ }
+
+ public SpinJsonNode prop(String name, Number newProperty) {
+ ObjectNode node = (ObjectNode) jsonNode;
+
+ // Numbers magic because Jackson has no native .put(Number value)
+ if (newProperty == null) {
+ node.putNull(name);
+ } else if(newProperty instanceof Long) {
+ node.put(name, newProperty.longValue());
+ } else if(newProperty instanceof Integer) {
+ node.put(name, newProperty.intValue());
+ } else if(newProperty instanceof Float) {
+ node.put(name, newProperty.floatValue());
+ } else {
+ // convert any other sub class of Number into Float
+ node.put(name, newProperty.floatValue());
+ }
+
+ return this;
+ }
+
+ public SpinJsonNode prop(String name, int newProperty) {
+ return prop(name, (Number) newProperty);
+ }
+
+ public SpinJsonNode prop(String name, float newProperty) {
+ return prop(name, (Number) newProperty);
+ }
+
+ public SpinJsonNode prop(String name, long newProperty) {
+ return prop(name, (Number) newProperty);
+ }
+
+ public SpinJsonNode prop(String name, boolean newProperty) {
+ return prop(name, (Boolean) newProperty);
+ }
+
+ public SpinJsonNode prop(String name, Boolean newProperty) {
+ ObjectNode node = (ObjectNode) jsonNode;
+
+ node.put(name, newProperty);
+
+ return this;
+ }
+
+ public SpinJsonNode prop(String name, List newProperty) {
+ ObjectNode node = (ObjectNode) jsonNode;
+
+ node.set(name, dataFormat.createJsonNode(newProperty));
+
+ return this;
+ }
+
+ public SpinJsonNode propList(String name, List newProperty) {
+ return prop(name, newProperty);
+ }
+
+ public SpinJsonNode prop(String name, Map newProperty) {
+ ObjectNode node = (ObjectNode) jsonNode;
+
+ node.set(name, dataFormat.createJsonNode(newProperty));
+
+ return this;
+ }
+
+ public SpinJsonNode prop(String name, SpinJsonNode newProperty) {
+ ObjectNode node = (ObjectNode) jsonNode;
+
+ if (newProperty != null) {
+ node.set(name, (JsonNode) newProperty.unwrap());
+ }
+ else {
+ node.putNull(name);
+ }
+
+ return this;
+ }
+
+ public SpinJsonNode deleteProp(String name) {
+ ensureNotNull("name", name);
+
+ if(jsonNode.has(name)) {
+ ObjectNode node = (ObjectNode) jsonNode;
+ node.remove(name);
+ return this;
+ } else {
+ throw LOG.unableToFindProperty(name);
+ }
+ }
+
+ public SpinJsonNode deleteProp(List names) {
+ ensureNotNull("names", names);
+
+ for(String name: names) {
+ deleteProp(name);
+ }
+
+ return this;
+ }
+
+ public SpinJsonNode append(Object property) {
+ ensureNotNull("property", property);
+ if(jsonNode.isArray()) {
+ ArrayNode node = (ArrayNode) jsonNode;
+
+ node.add(dataFormat.createJsonNode(property));
+
+ return this;
+ } else {
+ throw LOG.unableToModifyNode(jsonNode.getNodeType().name());
+ }
+ }
+
+ public SpinJsonNode insertAt(int index, Object property) {
+ ensureNotNull("property", property);
+
+ if(jsonNode.isArray()) {
+ index = getCorrectIndex(index);
+ ArrayNode node = (ArrayNode) jsonNode;
+
+ node.insert(index, dataFormat.createJsonNode(property));
+
+ return this;
+ } else {
+ throw LOG.unableToModifyNode(jsonNode.getNodeType().name());
+ }
+ }
+
+ public SpinJsonNode insertBefore(Object searchObject, Object insertObject) {
+ ensureNotNull("searchObject", searchObject);
+ ensureNotNull("insertObject", insertObject);
+ if(this.isArray()) {
+ Integer i = indexOf(searchObject);
+
+ return insertAt(i, insertObject);
+
+ } else {
+ throw LOG.unableToCreateNode(jsonNode.getNodeType().name());
+ }
+ }
+
+ public SpinJsonNode insertAfter(Object searchObject, Object insertObject) {
+ ensureNotNull("searchObject", searchObject);
+ ensureNotNull("insertObject", insertObject);
+ if(this.isArray()) {
+ Integer i = indexOf(searchObject);
+
+ return insertAt(i + 1, insertObject);
+
+ } else {
+ throw LOG.unableToCreateNode(jsonNode.getNodeType().name());
+ }
+ }
+
+ public SpinJsonNode remove(Object property) {
+ return removeAt(indexOf(property));
+ }
+
+ public SpinJsonNode removeLast(Object property) {
+ return removeAt(lastIndexOf(property));
+ }
+
+ public SpinJsonNode removeAt(int index) {
+ if(this.isArray()) {
+ ArrayNode node = (ArrayNode) jsonNode;
+
+ node.remove(getCorrectIndex(index));
+
+ return this;
+ } else {
+ throw LOG.unableToModifyNode(jsonNode.getNodeType().name());
+ }
+ }
+
+ public Boolean isBoolean() {
+ return jsonNode.isBoolean();
+ }
+
+ public Boolean boolValue() {
+ if(jsonNode.isBoolean()) {
+ return jsonNode.booleanValue();
+ } else {
+ throw LOG.unableToParseValue(Boolean.class.getSimpleName(), jsonNode.getNodeType());
+ }
+ }
+
+ public Boolean isNumber() {
+ return jsonNode.isNumber();
+ }
+
+ public Number numberValue() {
+ if(jsonNode.isNumber()) {
+ return jsonNode.numberValue();
+ } else {
+ throw LOG.unableToParseValue(Number.class.getSimpleName(), jsonNode.getNodeType());
+ }
+ }
+
+ public Boolean isString() {
+ return jsonNode.isTextual();
+ }
+
+ public String stringValue() {
+ if(jsonNode.isTextual()) {
+ return jsonNode.textValue();
+ } else {
+ throw LOG.unableToParseValue(String.class.getSimpleName(), jsonNode.getNodeType());
+ }
+ }
+
+ public Boolean isNull() {
+ return jsonNode.isNull();
+ }
+
+ public Boolean isValue() {
+ return jsonNode.isValueNode();
+ }
+
+ public Object value() {
+ if(jsonNode.isBoolean()) {
+ return jsonNode.booleanValue();
+ }
+
+ if(jsonNode.isNumber()) {
+ return jsonNode.numberValue();
+ }
+
+ if(jsonNode.isTextual()) {
+ return jsonNode.textValue();
+ }
+
+ if (jsonNode.isNull()) {
+ return null;
+ }
+
+ throw LOG.unableToParseValue("String/Number/Boolean/Null", jsonNode.getNodeType());
+ }
+
+ public Boolean isArray() {
+ return jsonNode.isArray();
+ }
+
+ public SpinList elements() {
+ if(jsonNode.isArray()) {
+ Iterator iterator = jsonNode.elements();
+ SpinList list = new SpinListImpl();
+ while(iterator.hasNext()) {
+ SpinJsonNode node = dataFormat.createWrapperInstance(iterator.next());
+ list.add(node);
+ }
+
+ return list;
+ } else {
+ throw LOG.unableToParseValue(SpinList.class.getSimpleName(), jsonNode.getNodeType());
+ }
+ }
+
+ public List fieldNames() {
+ if(jsonNode.isContainerNode()) {
+ Iterator iterator = jsonNode.fieldNames();
+ List list = new ArrayList();
+ while(iterator.hasNext()) {
+ list.add(iterator.next());
+ }
+
+ return list;
+ } else {
+ throw LOG.unableToParseValue("Array/Object", jsonNode.getNodeType());
+ }
+ }
+
+ public JsonNodeType getNodeType() {
+ return jsonNode.getNodeType();
+ }
+
+ public SpinJsonPathQuery jsonPath(String expression) {
+ ensureNotNull("expression", expression);
+ try {
+ JsonPath query = JsonPath.compile(expression);
+ return new JacksonJsonPathQuery(this, query, dataFormat);
+ } catch(InvalidPathException pex) {
+ throw LOG.unableToCompileJsonPathExpression(expression, pex);
+ } catch(IllegalArgumentException aex) {
+ throw LOG.unableToCompileJsonPathExpression(expression, aex);
+ }
+ }
+
+ /**
+ * Maps the json represented by this object to a java object of the given type.
+ * 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
+ */
+ public C mapTo(Class 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()}).
+ * 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
+ */
+ public 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.
+ * 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
+ */
+ public C mapTo(JavaType type) {
+ JacksonJsonDataFormatMapper mapper = dataFormat.getMapper();
+ return mapper.mapInternalToJava(jsonNode, type);
+ }
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/format/AbstractJacksonJsonTypeDetector.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/format/AbstractJacksonJsonTypeDetector.java
new file mode 100644
index 0000000000000000000000000000000000000000..18a88eb48de385c9d0f1871c62ac4b26c570c59e
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/format/AbstractJacksonJsonTypeDetector.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.impl.json.jackson.format;
+
+import org.camunda.spin.spi.DataFormat;
+import org.camunda.spin.spi.TypeDetector;
+
+public abstract class AbstractJacksonJsonTypeDetector implements TypeDetector {
+
+ public boolean appliesTo(DataFormat> dataFormat) {
+ return dataFormat instanceof JacksonJsonDataFormat;
+ }
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/format/DefaultJsonJacksonTypeDetector.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/format/DefaultJsonJacksonTypeDetector.java
new file mode 100644
index 0000000000000000000000000000000000000000..de9836ad9df0d12ea1d2eb3e3c5700ad7927efbd
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/format/DefaultJsonJacksonTypeDetector.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.impl.json.jackson.format;
+
+import com.fasterxml.jackson.databind.type.TypeFactory;
+
+public class DefaultJsonJacksonTypeDetector extends AbstractJacksonJsonTypeDetector {
+
+ public boolean canHandle(Object object) {
+ return true;
+ }
+
+ public String detectType(Object object) {
+ Class> type = object.getClass();
+ return TypeFactory.defaultInstance().constructType(type).toCanonical();
+ }
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/format/JacksonJsonDataFormat.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/format/JacksonJsonDataFormat.java
new file mode 100644
index 0000000000000000000000000000000000000000..38c12d46ec3e9d8b91a8941888a4390bf327c201
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/format/JacksonJsonDataFormat.java
@@ -0,0 +1,307 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.impl.json.jackson.format;
+
+import static org.camunda.commons.utils.EnsureUtil.ensureNotNull;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import com.jayway.jsonpath.spi.json.JacksonJsonProvider;
+import com.jayway.jsonpath.spi.mapper.JacksonMappingProvider;
+import org.camunda.spin.DataFormats;
+import org.camunda.spin.impl.json.jackson.JacksonJsonLogger;
+import org.camunda.spin.impl.json.jackson.JacksonJsonNode;
+import org.camunda.spin.json.SpinJsonDataFormatException;
+import org.camunda.spin.json.SpinJsonNode;
+import org.camunda.spin.spi.DataFormat;
+import org.camunda.spin.spi.TypeDetector;
+
+import com.fasterxml.jackson.databind.JavaType;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.fasterxml.jackson.databind.type.TypeFactory;
+import com.jayway.jsonpath.Configuration;
+import com.jayway.jsonpath.Configuration.ConfigurationBuilder;
+
+/**
+ * Spin data format that can wrap Json content and uses
+ * Jackson as its implementation.
+ * Caches an instance of {@link ObjectMapper} according to the advice given in the
+ * Jackson documentation .
+ *
+ *
+ * @author Thorben Lindhauer
+ * @author Stefan Hentschel
+ */
+public class JacksonJsonDataFormat implements DataFormat {
+
+ public static final String DATA_FORMAT_NAME = DataFormats.JSON_DATAFORMAT_NAME;
+
+ private static final JacksonJsonLogger LOG = JacksonJsonLogger.JSON_TREE_LOGGER;
+
+ /** The Jackson Object Mapper used by this dataformat */
+ protected ObjectMapper objectMapper;
+
+ /** The JsonPath configuration */
+ protected Configuration jsonPathConfiguration;
+
+ protected List typeDetectors;
+
+ protected JacksonJsonDataFormatReader dataFormatReader;
+ protected JacksonJsonDataFormatWriter dataFormatWriter;
+ protected JacksonJsonDataFormatMapper dataFormatMapper;
+
+ protected final String name;
+
+ public JacksonJsonDataFormat(String name) {
+ this(name, new ObjectMapper());
+ }
+
+ public JacksonJsonDataFormat(String name, ObjectMapper objectMapper) {
+
+ this(name, objectMapper,
+ new ConfigurationBuilder()
+ .jsonProvider(new JacksonJsonProvider(objectMapper))
+ .mappingProvider(new JacksonMappingProvider(objectMapper))
+ .build());
+ }
+
+ public JacksonJsonDataFormat(String name, ObjectMapper objectMapper, Configuration jsonPathConfiguration) {
+ this.name = name;
+ this.objectMapper = objectMapper;
+ this.jsonPathConfiguration = jsonPathConfiguration;
+ init();
+ }
+
+
+ // initialization /////////////////////////////////////////////
+
+ protected void init() {
+ initReader();
+ initWriter();
+ initMapper();
+ initTypeDetectors();
+ }
+
+ protected void initMapper() {
+ this.dataFormatMapper = new JacksonJsonDataFormatMapper(this);
+ }
+
+ protected void initWriter() {
+ this.dataFormatWriter = new JacksonJsonDataFormatWriter(this);
+ }
+
+ protected void initReader() {
+ this.dataFormatReader = new JacksonJsonDataFormatReader(this);
+ }
+
+
+ protected void initTypeDetectors() {
+ typeDetectors = new ArrayList<>();
+ typeDetectors.add(new ListJacksonJsonTypeDetector());
+ typeDetectors.add(new DefaultJsonJacksonTypeDetector());
+ }
+
+ // interface implementation ///////////////////////////////////
+
+ public String getName() {
+ return DATA_FORMAT_NAME;
+ }
+
+ public Class extends SpinJsonNode> getWrapperType() {
+ return JacksonJsonNode.class;
+ }
+
+ public SpinJsonNode createWrapperInstance(Object parameter) {
+ return new JacksonJsonNode((JsonNode) parameter, this);
+ }
+
+ /**
+ * 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)})
+ */
+ public String getCanonicalTypeName(Object object) {
+ ensureNotNull("object", object);
+
+ for (TypeDetector typeDetector : typeDetectors) {
+ if (typeDetector.canHandle(object)) {
+ return typeDetector.detectType(object);
+ }
+ }
+
+ throw LOG.unableToDetectCanonicalType(object);
+ }
+
+ /**
+ * Constructs a {@link JavaType} object based on the parameter, which
+ * has to follow Jackson's canonical type string format.
+ *
+ * @param canonicalString canonical string representation of the type
+ * @return the constructed java type
+ * @throws SpinJsonDataFormatException if no type can be constructed from the given parameter
+ */
+ public JavaType constructJavaTypeFromCanonicalString(String canonicalString) {
+ try {
+ return TypeFactory.defaultInstance().constructFromCanonical(canonicalString);
+ } catch (IllegalArgumentException e) {
+ throw LOG.unableToConstructJavaType(canonicalString, e);
+ }
+ }
+
+ public void addTypeDetector(TypeDetector typeDetector) {
+ typeDetectors.add(0, typeDetector);
+ }
+
+ public JacksonJsonDataFormatMapper getMapper() {
+ return dataFormatMapper;
+ }
+
+ public JacksonJsonDataFormatReader getReader() {
+ return dataFormatReader;
+ }
+
+ public JacksonJsonDataFormatWriter getWriter() {
+ return dataFormatWriter;
+ }
+
+ // resources //////////////////////////////////////////////////
+
+ /**
+ * Returns a {@link Configuration} object for jayway json path
+ * which uses this dataformat's object mapper as {@link JsonProvider}.
+ *
+ * @return the {@link Configuration} for jsonpath
+ */
+ public Configuration getJsonPathConfiguration() {
+ return jsonPathConfiguration;
+ }
+
+ public void setJsonPathConfiguration(Configuration jsonPathConfiguration) {
+ this.jsonPathConfiguration = jsonPathConfiguration;
+ }
+
+ /**
+ * Returns the configured Jackson {@link ObjectMapper} instance.
+ * @return the configured object mapper.
+ */
+ public ObjectMapper getObjectMapper() {
+ return objectMapper;
+ }
+
+ public void setObjectMapper(ObjectMapper objectMapper) {
+ this.objectMapper = objectMapper;
+ }
+
+ // helper functions //////////////////////////////////////////
+
+ @SuppressWarnings("unchecked")
+ public JsonNode createJsonNode(Object parameter) {
+ if(parameter instanceof SpinJsonNode) {
+ return (JsonNode) ((SpinJsonNode) parameter).unwrap();
+
+ } else if(parameter instanceof String) {
+ return createJsonNode((String) parameter);
+
+ } else if(parameter instanceof Integer) {
+ return createJsonNode((Integer) parameter);
+
+ } else if(parameter instanceof Boolean) {
+ return createJsonNode((Boolean) parameter);
+
+ } else if(parameter instanceof Float) {
+ return createJsonNode((Float) parameter);
+
+ } else if(parameter instanceof Long) {
+ return createJsonNode((Long) parameter);
+
+ } else if(parameter instanceof Number) {
+ return createJsonNode(((Number) parameter).doubleValue());
+
+ } else if(parameter instanceof List) {
+ return createJsonNode((List) parameter);
+
+ } else if(parameter instanceof Map) {
+ return createJsonNode((Map) parameter);
+
+ } else if (parameter == null) {
+ return createNullJsonNode();
+ } else {
+ throw LOG.unableToCreateNode(parameter.getClass().getSimpleName());
+ }
+ }
+
+ public JsonNode createJsonNode(String parameter) {
+ return objectMapper.getNodeFactory().textNode(parameter);
+ }
+
+ public JsonNode createJsonNode(Integer parameter) {
+ return objectMapper.getNodeFactory().numberNode(parameter);
+ }
+
+ public JsonNode createJsonNode(Float parameter) {
+ return objectMapper.getNodeFactory().numberNode(parameter);
+ }
+
+ public JsonNode createJsonNode(Double parameter) {
+ return objectMapper.getNodeFactory().numberNode(parameter);
+ }
+
+ public JsonNode createJsonNode(Long parameter) {
+ return objectMapper.getNodeFactory().numberNode(parameter);
+ }
+
+ public JsonNode createJsonNode(Boolean parameter) {
+ return objectMapper.getNodeFactory().booleanNode(parameter);
+ }
+
+ public JsonNode createJsonNode(List parameter) {
+ if (parameter != null) {
+ ArrayNode node = objectMapper.getNodeFactory().arrayNode();
+ for(Object entry : parameter) {
+ node.add(createJsonNode(entry));
+ }
+ return node;
+ }
+ else {
+ return createNullJsonNode();
+ }
+
+ }
+
+ public JsonNode createJsonNode(Map parameter) {
+ if (parameter != null) {
+ ObjectNode node = objectMapper.getNodeFactory().objectNode();
+ for (Map.Entry entry : parameter.entrySet()) {
+ node.set(entry.getKey(), createJsonNode(entry.getValue()));
+ }
+ return node;
+ }
+ else {
+ return createNullJsonNode();
+ }
+ }
+
+ public JsonNode createNullJsonNode() {
+ return objectMapper.getNodeFactory().nullNode();
+ }
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/format/JacksonJsonDataFormatMapper.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/format/JacksonJsonDataFormatMapper.java
new file mode 100644
index 0000000000000000000000000000000000000000..54c846edf18e98064420266db56118047f8e21e2
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/format/JacksonJsonDataFormatMapper.java
@@ -0,0 +1,140 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.impl.json.jackson.format;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.camunda.spin.DeserializationTypeValidator;
+import org.camunda.spin.SpinRuntimeException;
+import org.camunda.spin.impl.json.jackson.JacksonJsonLogger;
+import org.camunda.spin.spi.DataFormatMapper;
+
+import com.fasterxml.jackson.databind.JavaType;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.type.TypeFactory;
+
+public class JacksonJsonDataFormatMapper implements DataFormatMapper {
+
+ private static final JacksonJsonLogger LOG = JacksonJsonLogger.JSON_TREE_LOGGER;
+
+ protected JacksonJsonDataFormat format;
+
+ public JacksonJsonDataFormatMapper(JacksonJsonDataFormat format) {
+ this.format = format;
+ }
+
+ public boolean canMap(Object parameter) {
+ // Jackson ObjectMapper#canSerialize() method was removed
+ // due to causing performance issues in high load scenarios
+ return parameter != null;
+ }
+
+ public String getCanonicalTypeName(Object object) {
+ return format.getCanonicalTypeName(object);
+ }
+
+ public Object mapJavaToInternal(Object parameter) {
+ ObjectMapper mapper = format.getObjectMapper();
+ try {
+ return mapper.valueToTree(parameter);
+ } catch (IllegalArgumentException e) {
+ throw LOG.unableToMapInput(parameter, e);
+ }
+ }
+
+ public T mapInternalToJava(Object parameter, Class type) {
+ return mapInternalToJava(parameter, type, null);
+ }
+
+ @Override
+ public T mapInternalToJava(Object parameter, Class type, DeserializationTypeValidator validator) {
+ JavaType javaType = TypeFactory.defaultInstance().constructType(type);
+ return mapInternalToJava(parameter, javaType, validator);
+ }
+
+ public T mapInternalToJava(Object parameter, String typeIdentifier) {
+ return mapInternalToJava(parameter, typeIdentifier, null);
+ }
+
+ @Override
+ public T mapInternalToJava(Object parameter, String typeIdentifier, DeserializationTypeValidator validator) {
+ try {
+ //sometimes the class identifier is at once a fully qualified class name
+ final Class> aClass = Class.forName(typeIdentifier, true, Thread.currentThread().getContextClassLoader());
+ return (T) mapInternalToJava(parameter, aClass, validator);
+ } catch (ClassNotFoundException e) {
+ JavaType javaType = format.constructJavaTypeFromCanonicalString(typeIdentifier);
+ T result = mapInternalToJava(parameter, javaType, validator);
+ return result;
+ }
+ }
+
+ public C mapInternalToJava(Object parameter, JavaType type) {
+ return mapInternalToJava(parameter, type, null);
+ }
+
+ public C mapInternalToJava(Object parameter, JavaType type, DeserializationTypeValidator validator) {
+ JsonNode jsonNode = (JsonNode) parameter;
+ try {
+ validateType(type, validator);
+ ObjectMapper mapper = format.getObjectMapper();
+ return mapper.readValue(mapper.treeAsTokens(jsonNode), type);
+ } catch (IOException | SpinRuntimeException e) {
+ throw LOG.unableToDeserialize(jsonNode, type, e);
+ }
+ }
+
+ /**
+ * Validate the type with the help of the validator.
+ * Note: when adjusting this method, please also consider adjusting
+ * the {@code AbstractVariablesResource#validateType} in the REST API
+ */
+ protected void validateType(JavaType type, DeserializationTypeValidator validator) {
+ if (validator != null) {
+ List invalidTypes = new ArrayList<>();
+ validateType(type, validator, invalidTypes);
+ if (!invalidTypes.isEmpty()) {
+ throw new SpinRuntimeException("The following classes are not whitelisted for deserialization: " + invalidTypes);
+ }
+ }
+ }
+
+ protected void validateType(JavaType type, DeserializationTypeValidator validator, List invalidTypes) {
+ if (!type.isPrimitive()) {
+ if (!type.isArrayType()) {
+ validateTypeInternal(type, validator, invalidTypes);
+ }
+ if (type.isMapLikeType()) {
+ validateType(type.getKeyType(), validator, invalidTypes);
+ }
+ if (type.isContainerType() || type.hasContentType()) {
+ validateType(type.getContentType(), validator, invalidTypes);
+ }
+ }
+ }
+
+ protected void validateTypeInternal(JavaType type, DeserializationTypeValidator validator, List invalidTypes) {
+ String className = type.getRawClass().getName();
+ if (!validator.validate(className) && !invalidTypes.contains(className)) {
+ invalidTypes.add(className);
+ }
+ }
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/format/JacksonJsonDataFormatProvider.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/format/JacksonJsonDataFormatProvider.java
new file mode 100644
index 0000000000000000000000000000000000000000..3d878643dc18068c7e105254ee2826c1bf55fcb9
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/format/JacksonJsonDataFormatProvider.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.impl.json.jackson.format;
+
+import static org.camunda.spin.DataFormats.JSON_DATAFORMAT_NAME;
+
+import java.util.Set;
+
+import org.camunda.spin.spi.DataFormat;
+import org.camunda.spin.spi.DataFormatProvider;
+
+/**
+ * Provides the {@link JacksonJsonDataFormat} with default configuration.
+ *
+ * @author Daniel Meyer
+ *
+ */
+public class JacksonJsonDataFormatProvider implements DataFormatProvider {
+
+ protected Set names;
+
+ public String getDataFormatName() {
+ return JSON_DATAFORMAT_NAME;
+ }
+
+ public DataFormat> createInstance() {
+ return new JacksonJsonDataFormat(JSON_DATAFORMAT_NAME);
+ }
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/format/JacksonJsonDataFormatReader.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/format/JacksonJsonDataFormatReader.java
new file mode 100644
index 0000000000000000000000000000000000000000..1707e1f1eaca1f61f13ed57632a3930cb295cbee
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/format/JacksonJsonDataFormatReader.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.impl.json.jackson.format;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.util.regex.Pattern;
+
+import com.fasterxml.jackson.databind.node.MissingNode;
+import org.camunda.spin.impl.json.jackson.JacksonJsonLogger;
+import org.camunda.spin.spi.TextBasedDataFormatReader;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+/**
+ * @author Thorben Lindhauer
+ */
+public class JacksonJsonDataFormatReader extends TextBasedDataFormatReader {
+
+ private static final JacksonJsonLogger JSON_LOGGER = JacksonJsonLogger.JSON_TREE_LOGGER;
+ private static final Pattern INPUT_MATCHING_PATTERN = Pattern.compile("\\A(\\s)*[{\\[]");
+
+ protected JacksonJsonDataFormat format;
+
+ public JacksonJsonDataFormatReader(JacksonJsonDataFormat format) {
+ this.format = format;
+ }
+
+ public Object readInput(Reader input) {
+ ObjectMapper mapper = format.getObjectMapper();
+
+ try {
+ final JsonNode jsonNode = mapper.readTree(input);
+ if (jsonNode instanceof MissingNode) {
+ throw new IOException("Input is empty");
+ }
+ return jsonNode;
+ }
+ catch (JsonProcessingException e) {
+ throw JSON_LOGGER.unableToParseInput(e);
+ }
+ catch (IOException e) {
+ throw JSON_LOGGER.unableToParseInput(e);
+ }
+ }
+
+ protected Pattern getInputDetectionPattern() {
+ return INPUT_MATCHING_PATTERN;
+ }
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/format/JacksonJsonDataFormatWriter.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/format/JacksonJsonDataFormatWriter.java
new file mode 100644
index 0000000000000000000000000000000000000000..260eda83f2ceaaa5381cfee0cb22441e81f5d6ea
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/format/JacksonJsonDataFormatWriter.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.impl.json.jackson.format;
+
+import java.io.IOException;
+import java.io.Writer;
+
+import org.camunda.spin.impl.json.jackson.JacksonJsonLogger;
+import org.camunda.spin.spi.DataFormatWriter;
+
+import com.fasterxml.jackson.core.JsonFactory;
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+/**
+ * @author Daniel Meyer
+ *
+ */
+public class JacksonJsonDataFormatWriter implements DataFormatWriter {
+
+ private static final JacksonJsonLogger LOG = JacksonJsonLogger.JSON_TREE_LOGGER;
+
+ protected JacksonJsonDataFormat dataFormat;
+
+ public JacksonJsonDataFormatWriter(JacksonJsonDataFormat dataFormat) {
+ this.dataFormat = dataFormat;
+ }
+
+ public void writeToWriter(Writer writer, Object input) {
+ final ObjectMapper objectMapper = dataFormat.getObjectMapper();
+ final JsonFactory factory = objectMapper.getFactory();
+
+ try {
+ JsonGenerator generator = factory.createGenerator(writer);
+ objectMapper.writeTree(generator, (JsonNode) input);
+ }
+ catch (IOException e) {
+ throw LOG.unableToWriteJsonNode(e);
+ }
+
+ }
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/format/ListJacksonJsonTypeDetector.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/format/ListJacksonJsonTypeDetector.java
new file mode 100644
index 0000000000000000000000000000000000000000..6e6952dd01f2669d9ec808517a6f7aec6de1d788
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/format/ListJacksonJsonTypeDetector.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.impl.json.jackson.format;
+
+import java.lang.reflect.TypeVariable;
+import java.util.List;
+
+import com.fasterxml.jackson.databind.JavaType;
+import com.fasterxml.jackson.databind.type.TypeFactory;
+
+public class ListJacksonJsonTypeDetector extends AbstractJacksonJsonTypeDetector {
+
+ public boolean canHandle(Object object) {
+ return object instanceof List;
+ }
+
+ public String detectType(Object object) {
+ return constructType(object).toCanonical();
+ }
+
+ protected JavaType constructType(Object object) {
+ TypeFactory typeFactory = TypeFactory.defaultInstance();
+
+ if (object instanceof List && !((List>) object).isEmpty()) {
+ List> list = (List>) object;
+ Object firstElement = list.get(0);
+ if (bindingsArePresent(list.getClass())) {
+ final JavaType elementType = constructType(firstElement);
+ return typeFactory.constructCollectionType(list.getClass(), elementType);
+ }
+ }
+ return typeFactory.constructType(object.getClass());
+ }
+
+ private boolean bindingsArePresent(Class> erasedType) {
+ TypeVariable>[] vars = erasedType.getTypeParameters();
+ int varLen = (vars == null) ? 0 : vars.length;
+ if (varLen == 0) {
+ return false;
+ }
+ if (varLen != 1) {
+ throw new IllegalArgumentException("Cannot create TypeBindings for class " + erasedType.getName() + " with 1 type parameter: class expects " + varLen);
+ }
+ return true;
+ }
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/format/MapJacksonJsonTypeDetector.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/format/MapJacksonJsonTypeDetector.java
new file mode 100644
index 0000000000000000000000000000000000000000..9998097a46e02da8c2f5f74065ddd1e754cf7775
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/format/MapJacksonJsonTypeDetector.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.impl.json.jackson.format;
+
+import org.camunda.spin.spi.TypeDetector;
+
+import java.util.Map;
+
+import static org.camunda.spin.impl.json.jackson.format.TypeHelper.constructType;
+
+/**
+ * Detects erased types of Map classes.
+ * To use it, make sure to call {@link JacksonJsonDataFormat#addTypeDetector(TypeDetector)}
+ * to activate it.
+ */
+public class MapJacksonJsonTypeDetector extends AbstractJacksonJsonTypeDetector {
+
+ /**
+ * Object instance to use.
+ */
+ public static MapJacksonJsonTypeDetector INSTANCE = new MapJacksonJsonTypeDetector();
+
+ @Override
+ public boolean canHandle(Object value) {
+ return value instanceof Map, ?>;
+ }
+
+ @Override
+ public String detectType(Object value) {
+ return constructType(value).toCanonical();
+ }
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/format/SetJacksonJsonTypeDetector.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/format/SetJacksonJsonTypeDetector.java
new file mode 100644
index 0000000000000000000000000000000000000000..175895290231e04b40d9767af8011a56e5cf94d8
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/format/SetJacksonJsonTypeDetector.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.impl.json.jackson.format;
+
+import org.camunda.spin.spi.TypeDetector;
+
+import java.util.Set;
+
+import static org.camunda.spin.impl.json.jackson.format.TypeHelper.constructType;
+
+/**
+ * Detects erased types of Set classes.
+ * To use it, make sure to call {@link JacksonJsonDataFormat#addTypeDetector(TypeDetector)}
+ * to activate it.
+ */
+public class SetJacksonJsonTypeDetector extends AbstractJacksonJsonTypeDetector {
+
+ /**
+ * Object instance to use.
+ */
+ public static SetJacksonJsonTypeDetector INSTANCE = new SetJacksonJsonTypeDetector();
+
+ @Override
+ public boolean canHandle(Object value) {
+ return value instanceof Set>;
+ }
+
+ @Override
+ public String detectType(Object value) {
+ return constructType(value).toCanonical();
+ }
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/format/TypeHelper.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/format/TypeHelper.java
new file mode 100644
index 0000000000000000000000000000000000000000..a3a2c05fcc4dddbb2b26b7dba51aa22b2fdfecd6
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/format/TypeHelper.java
@@ -0,0 +1,131 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.impl.json.jackson.format;
+
+import com.fasterxml.jackson.databind.JavaType;
+import com.fasterxml.jackson.databind.type.TypeFactory;
+
+import java.lang.reflect.TypeVariable;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Collection of helper methods to construct types.
+ */
+public class TypeHelper {
+
+ /**
+ * 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.
+ */
+ 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;
+ }
+
+ /**
+ * Constructs Java type based on the content values.
+ *
+ * @param value value with values.
+ * @return Java type.
+ */
+ 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();
+
+ }
+ }
+
+ /**
+ * Guess collection class.
+ *
+ * @param value collection.
+ * @return class of th collection implementation.
+ */
+ @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());
+ }
+ }
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/query/JacksonJsonPathQuery.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/query/JacksonJsonPathQuery.java
new file mode 100644
index 0000000000000000000000000000000000000000..a0bedaf0a67f8dec0f4a0badb199d899ab32994d
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/query/JacksonJsonPathQuery.java
@@ -0,0 +1,102 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.impl.json.jackson.query;
+
+import com.jayway.jsonpath.InvalidPathException;
+import org.camunda.spin.SpinList;
+import org.camunda.spin.impl.json.jackson.JacksonJsonLogger;
+import org.camunda.spin.impl.json.jackson.JacksonJsonNode;
+import org.camunda.spin.impl.json.jackson.format.JacksonJsonDataFormat;
+import org.camunda.spin.json.SpinJsonNode;
+import org.camunda.spin.json.SpinJsonPathQuery;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.jayway.jsonpath.JsonPath;
+import com.jayway.jsonpath.PathNotFoundException;
+
+/**
+ * @author Stefan Hentschel
+ */
+public class JacksonJsonPathQuery implements SpinJsonPathQuery {
+
+ private static final JacksonJsonLogger LOG = JacksonJsonLogger.JSON_TREE_LOGGER;
+
+ protected final SpinJsonNode spinJsonNode;
+ protected final JsonPath query;
+ protected final JacksonJsonDataFormat dataFormat;
+
+ public JacksonJsonPathQuery(JacksonJsonNode jacksonJsonNode, JsonPath query, JacksonJsonDataFormat dataFormat) {
+ this.spinJsonNode = jacksonJsonNode;
+ this.query = query;
+ this.dataFormat = dataFormat;
+ }
+
+ public SpinJsonNode element() {
+ try {
+ Object result = query.read(spinJsonNode.toString(), dataFormat.getJsonPathConfiguration());
+ JsonNode node;
+ if (result != null) {
+ node = dataFormat.createJsonNode(result);
+ } else {
+ node = dataFormat.createNullJsonNode();
+ }
+ return dataFormat.createWrapperInstance(node);
+ } catch(PathNotFoundException pex) {
+ throw LOG.unableToEvaluateJsonPathExpressionOnNode(spinJsonNode, pex);
+ } catch (ClassCastException cex) {
+ throw LOG.unableToCastJsonPathResultTo(SpinJsonNode.class, cex);
+ } catch(InvalidPathException iex) {
+ throw LOG.invalidJsonPath(SpinJsonNode.class, iex);
+ }
+ }
+
+ public SpinList elementList() {
+ JacksonJsonNode node = (JacksonJsonNode) element();
+ if(node.isArray()) {
+ return node.elements();
+ } else {
+ throw LOG.unableToParseValue(SpinList.class.getSimpleName(), node.getNodeType());
+ }
+ }
+
+ public String stringValue() {
+ JacksonJsonNode node = (JacksonJsonNode) element();
+ if(node.isString()) {
+ return node.stringValue();
+ } else {
+ throw LOG.unableToParseValue(String.class.getSimpleName(), node.getNodeType());
+ }
+ }
+
+ public Number numberValue() {
+ JacksonJsonNode node = (JacksonJsonNode) element();
+ if(node.isNumber()) {
+ return node.numberValue();
+ } else {
+ throw LOG.unableToParseValue(Number.class.getSimpleName(), node.getNodeType());
+ }
+ }
+
+ public Boolean boolValue() {
+ JacksonJsonNode node = (JacksonJsonNode) element();
+ if(node.isBoolean()) {
+ return node.boolValue();
+ } else {
+ throw LOG.unableToParseValue(Boolean.class.getSimpleName(), node.getNodeType());
+ }
+ }
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/main/resources/META-INF/services/org.camunda.spin.spi.DataFormatProvider b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/main/resources/META-INF/services/org.camunda.spin.spi.DataFormatProvider
new file mode 100644
index 0000000000000000000000000000000000000000..cb302c5dff72e3e43259bc8ad937e4e38c8bc801
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/main/resources/META-INF/services/org.camunda.spin.spi.DataFormatProvider
@@ -0,0 +1 @@
+org.camunda.spin.impl.json.jackson.format.JacksonJsonDataFormatProvider
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/groovy/json/tree/JsonTreeCreateGroovyTest.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/groovy/json/tree/JsonTreeCreateGroovyTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..f606bf5f3205a26543b6070c47085ebe766af44c
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/groovy/json/tree/JsonTreeCreateGroovyTest.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.groovy.json.tree;
+
+import org.camunda.spin.impl.test.ScriptEngine;
+import org.camunda.spin.json.tree.JsonTreeCreateScriptTest;
+
+/**
+ * @author Thorben Lindhauer
+ *
+ */
+@ScriptEngine("groovy")
+public class JsonTreeCreateGroovyTest extends JsonTreeCreateScriptTest {
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/groovy/json/tree/JsonTreeEditListPropertyGroovyTest.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/groovy/json/tree/JsonTreeEditListPropertyGroovyTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..b8ec8067e1e887b55d3fa7562324540cefc1dc1f
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/groovy/json/tree/JsonTreeEditListPropertyGroovyTest.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.groovy.json.tree;
+
+import org.camunda.spin.impl.test.ScriptEngine;
+import org.camunda.spin.json.tree.JsonTreeEditListPropertyScriptTest;
+
+/**
+ * @author Stefan Hentschel
+ *
+ */
+@ScriptEngine("groovy")
+public class JsonTreeEditListPropertyGroovyTest extends JsonTreeEditListPropertyScriptTest {
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/groovy/json/tree/JsonTreeJsonPathGroovyTest.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/groovy/json/tree/JsonTreeJsonPathGroovyTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..d2e3b193b25ea189109750695aadf86d20900455
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/groovy/json/tree/JsonTreeJsonPathGroovyTest.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.groovy.json.tree;
+
+import org.camunda.spin.impl.test.ScriptEngine;
+import org.camunda.spin.json.tree.JsonTreeJsonPathScriptTest;
+
+/**
+ * @author Thorben Lindhauer
+ *
+ */
+@ScriptEngine("groovy")
+public class JsonTreeJsonPathGroovyTest extends JsonTreeJsonPathScriptTest {
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/groovy/json/tree/JsonTreeMapJsonToJavaGroovyTest.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/groovy/json/tree/JsonTreeMapJsonToJavaGroovyTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..86dd97ab294693821676daf652648c67f768e466
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/groovy/json/tree/JsonTreeMapJsonToJavaGroovyTest.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.groovy.json.tree;
+
+import org.camunda.spin.impl.test.ScriptEngine;
+import org.camunda.spin.json.tree.JsonTreeMapJsonToJavaScriptTest;
+
+/**
+ * @author Sebastian Menski
+ */
+@ScriptEngine("groovy")
+public class JsonTreeMapJsonToJavaGroovyTest extends JsonTreeMapJsonToJavaScriptTest {
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/groovy/json/tree/JsonTreeMapObjectToJsonGroovyTest.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/groovy/json/tree/JsonTreeMapObjectToJsonGroovyTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..0921fbb0775406e0c2c32f60477fac9cf6c9db6f
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/groovy/json/tree/JsonTreeMapObjectToJsonGroovyTest.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.groovy.json.tree;
+
+import org.camunda.spin.impl.test.ScriptEngine;
+import org.camunda.spin.json.tree.JsonTreeMapObjectToJsonScriptTest;
+
+/**
+ * @author Thorben Lindhauer
+ *
+ */
+@ScriptEngine("groovy")
+public class JsonTreeMapObjectToJsonGroovyTest extends JsonTreeMapObjectToJsonScriptTest {
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/groovy/json/tree/JsonTreeReadPropertyGroovyTest.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/groovy/json/tree/JsonTreeReadPropertyGroovyTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..18bca5f06296e31bab0fbc6862516d8a3993f6a0
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/groovy/json/tree/JsonTreeReadPropertyGroovyTest.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.groovy.json.tree;
+
+import org.camunda.spin.impl.test.ScriptEngine;
+import org.camunda.spin.json.tree.JsonTreeReadPropertyScriptTest;
+
+/**
+ * @author Thorben Lindhauer
+ *
+ */
+@ScriptEngine("groovy")
+public class JsonTreeReadPropertyGroovyTest extends JsonTreeReadPropertyScriptTest {
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/groovy/json/tree/JsonTreeRemovePropertyGroovyTest.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/groovy/json/tree/JsonTreeRemovePropertyGroovyTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..81bbd87311cec81d445947d3db49257e4a3f2f41
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/groovy/json/tree/JsonTreeRemovePropertyGroovyTest.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.groovy.json.tree;
+
+import org.camunda.spin.impl.test.ScriptEngine;
+import org.camunda.spin.json.tree.JsonTreeRemovePropertyScriptTest;
+
+/**
+ * @author Thorben Lindhauer
+ *
+ */
+@ScriptEngine("groovy")
+public class JsonTreeRemovePropertyGroovyTest extends JsonTreeRemovePropertyScriptTest {
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/groovy/json/tree/JsonTreeSetPropertyGroovyTest.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/groovy/json/tree/JsonTreeSetPropertyGroovyTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..1068afebb73ef9944d983225169cebcf0db1360d
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/groovy/json/tree/JsonTreeSetPropertyGroovyTest.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.groovy.json.tree;
+
+import org.camunda.spin.impl.test.ScriptEngine;
+import org.camunda.spin.json.tree.JsonTreeSetPropertyScriptTest;
+
+/**
+ * @author Thorben Lindhauer
+ *
+ */
+@ScriptEngine("groovy")
+public class JsonTreeSetPropertyGroovyTest extends JsonTreeSetPropertyScriptTest {
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/impl/json/jackson/format/JsonDeserializationValidationTest.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/impl/json/jackson/format/JsonDeserializationValidationTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..267e8ee13930251749680cc8ea3745235d951a98
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/impl/json/jackson/format/JsonDeserializationValidationTest.java
@@ -0,0 +1,257 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.impl.json.jackson.format;
+
+import static org.mockito.Mockito.times;
+
+import org.camunda.spin.DeserializationTypeValidator;
+import org.camunda.spin.SpinRuntimeException;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.mockito.Mockito;
+
+import com.fasterxml.jackson.databind.JavaType;
+import com.fasterxml.jackson.databind.type.TypeFactory;
+
+public class JsonDeserializationValidationTest {
+
+ protected DeserializationTypeValidator validator;
+ protected static JacksonJsonDataFormat format;
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ @BeforeClass
+ public static void setUpMocks() {
+ format = new JacksonJsonDataFormat("test");
+ }
+
+ @AfterClass
+ public static void tearDown() {
+ format = null;
+ }
+
+ @Test
+ public void shouldValidateNothingForPrimitiveClass() {
+ // given
+ JavaType type = TypeFactory.defaultInstance().constructType(int.class);
+ validator = createValidatorMock(true);
+
+ // when
+ format.getMapper().validateType(type, validator);
+
+ // then
+ Mockito.verifyZeroInteractions(validator);
+ }
+
+ @Test
+ public void shouldValidateBaseTypeOnlyForBaseClass() {
+ // given
+ JavaType type = TypeFactory.defaultInstance().constructType(String.class);
+ validator = createValidatorMock(true);
+
+ // when
+ format.getMapper().validateType(type, validator);
+
+ // then
+ Mockito.verify(validator).validate("java.lang.String");
+ Mockito.verifyNoMoreInteractions(validator);
+ }
+
+ @Test
+ public void shouldValidateBaseTypeOnlyForComplexClass() {
+ // given
+ JavaType type = TypeFactory.defaultInstance().constructType(Complex.class);
+ validator = createValidatorMock(true);
+
+ // when
+ format.getMapper().validateType(type, validator);
+
+ // then
+ Mockito.verify(validator).validate("org.camunda.spin.impl.json.jackson.format.JsonDeserializationValidationTest$Complex");
+ Mockito.verifyNoMoreInteractions(validator);
+ }
+
+ @Test
+ public void shouldValidateContentTypeOnlyForArrayClass() {
+ // given
+ JavaType type = TypeFactory.defaultInstance().constructType(Integer[].class);
+ validator = createValidatorMock(true);
+
+ // when
+ format.getMapper().validateType(type, validator);
+
+ // then
+ Mockito.verify(validator).validate("java.lang.Integer");
+ Mockito.verifyNoMoreInteractions(validator);
+ }
+
+ @Test
+ public void shouldValidateCollectionAndContentTypeForCollectionClass() {
+ // given
+ JavaType type = TypeFactory.defaultInstance().constructFromCanonical("java.util.ArrayList");
+ validator = createValidatorMock(true);
+
+ // when
+ format.getMapper().validateType(type, validator);
+
+ // then
+ Mockito.verify(validator).validate("java.util.ArrayList");
+ Mockito.verify(validator).validate("java.lang.String");
+ Mockito.verifyNoMoreInteractions(validator);
+ }
+
+ @Test
+ public void shouldValidateCollectionAndContentTypeForNestedCollectionClass() {
+ // given
+ JavaType type = TypeFactory.defaultInstance().constructFromCanonical("java.util.ArrayList>");
+ validator = createValidatorMock(true);
+
+ // when
+ format.getMapper().validateType(type, validator);
+
+ // then
+ Mockito.verify(validator, times(2)).validate("java.util.ArrayList");
+ Mockito.verify(validator).validate("java.lang.String");
+ Mockito.verifyNoMoreInteractions(validator);
+ }
+
+ @Test
+ public void shouldValidateMapAndKeyAndContentTypeForMapClass() {
+ // given
+ JavaType type = TypeFactory.defaultInstance().constructFromCanonical("java.util.HashMap");
+ validator = createValidatorMock(true);
+
+ // when
+ format.getMapper().validateType(type, validator);
+
+ // then
+ Mockito.verify(validator).validate("java.util.HashMap");
+ Mockito.verify(validator).validate("java.lang.String");
+ Mockito.verify(validator).validate("java.lang.Integer");
+ Mockito.verifyNoMoreInteractions(validator);
+ }
+
+ @Test
+ public void shouldFailForSimpleClass() {
+ // given
+ JavaType type = TypeFactory.defaultInstance().constructType(String.class);
+ validator = createValidatorMock(false);
+
+ // then
+ thrown.expect(SpinRuntimeException.class);
+ thrown.expectMessage("[java.lang.String]");
+
+ // when
+ format.getMapper().validateType(type, validator);
+ }
+
+ @Test
+ public void shouldFailForComplexClass() {
+ // given
+ JavaType type = TypeFactory.defaultInstance().constructType(Complex.class);
+ validator = createValidatorMock(false);
+
+ // then
+ thrown.expect(SpinRuntimeException.class);
+ thrown.expectMessage("[org.camunda.spin.impl.json.jackson.format.JsonDeserializationValidationTest$Complex]");
+
+ // when
+ format.getMapper().validateType(type, validator);
+ }
+
+ @Test
+ public void shouldFailForArrayClass() {
+ // given
+ JavaType type = TypeFactory.defaultInstance().constructType(Integer[].class);
+ validator = createValidatorMock(false);
+
+ // then
+ thrown.expect(SpinRuntimeException.class);
+ thrown.expectMessage("[java.lang.Integer]");
+
+ // when
+ format.getMapper().validateType(type, validator);
+ }
+
+ @Test
+ public void shouldFailForCollectionClass() {
+ // given
+ JavaType type = TypeFactory.defaultInstance().constructFromCanonical("java.util.ArrayList");
+ validator = createValidatorMock(false);
+
+ // then
+ thrown.expect(SpinRuntimeException.class);
+ thrown.expectMessage("[java.util.ArrayList, java.lang.String]");
+
+ // when
+ format.getMapper().validateType(type, validator);
+ }
+
+ @Test
+ public void shouldFailForMapClass() {
+ // given
+ JavaType type = TypeFactory.defaultInstance().constructFromCanonical("java.util.HashMap");
+ validator = createValidatorMock(false);
+
+ // then
+ thrown.expect(SpinRuntimeException.class);
+ thrown.expectMessage("[java.util.HashMap, java.lang.String, java.lang.Integer]");
+
+ // when
+ format.getMapper().validateType(type, validator);
+ }
+
+ @Test
+ public void shouldFailOnceForMapClass() {
+ // given
+ JavaType type = TypeFactory.defaultInstance().constructFromCanonical("java.util.HashMap");
+ validator = createValidatorMock(false);
+
+ // then
+ thrown.expect(SpinRuntimeException.class);
+ thrown.expectMessage("[java.util.HashMap, java.lang.String]");
+
+ // when
+ format.getMapper().validateType(type, validator);
+ }
+
+ public static class Complex {
+ private Nested nested;
+
+ public Nested getNested() {
+ return nested;
+ }
+ }
+
+ public static class Nested {
+ private int testInt;
+
+ public int getTestInt() {
+ return testInt;
+ }
+ }
+
+ protected DeserializationTypeValidator createValidatorMock(boolean result) {
+ DeserializationTypeValidator newValidator = Mockito.mock(DeserializationTypeValidator.class);
+ Mockito.when(newValidator.validate(Mockito.anyString())).thenReturn(result);
+ return newValidator;
+ }
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/javascript/json/tree/JsonTreeCreateJavascriptTest.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/javascript/json/tree/JsonTreeCreateJavascriptTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..8e179061d97cb9c3f450ada306109c30ab0a577c
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/javascript/json/tree/JsonTreeCreateJavascriptTest.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.javascript.json.tree;
+
+import org.camunda.spin.impl.test.ScriptEngine;
+import org.camunda.spin.json.tree.JsonTreeCreateScriptTest;
+
+/**
+ * @author Thorben Lindhauer
+ *
+ */
+@ScriptEngine("graal.js")
+public class JsonTreeCreateJavascriptTest extends JsonTreeCreateScriptTest {
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/javascript/json/tree/JsonTreeEditListPropertyJavascriptTest.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/javascript/json/tree/JsonTreeEditListPropertyJavascriptTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..506a4fdfa69ca44fc518138b7b191d858cfa7f83
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/javascript/json/tree/JsonTreeEditListPropertyJavascriptTest.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.javascript.json.tree;
+
+import org.camunda.spin.impl.test.ScriptEngine;
+import org.camunda.spin.json.tree.JsonTreeEditListPropertyScriptTest;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * @author Stefan Hentschel
+ *
+ */
+@ScriptEngine("graal.js")
+public class JsonTreeEditListPropertyJavascriptTest extends JsonTreeEditListPropertyScriptTest {
+
+ /**
+ * Ignored since javascript implementation changed
+ * see: https://app.camunda.com/jira/browse/CAM-3612
+ */
+ @Test
+ @Ignore
+ public void shouldFailInsertAtWithWrongObject() throws Throwable {
+ }
+
+ /**
+ * Ignored since javascript implementation changed
+ * see: https://app.camunda.com/jira/browse/CAM-3612
+ */
+ @Test
+ @Ignore
+ public void shouldFailInsertWrongObjectAfterSearchObject() throws Throwable {
+ }
+
+ /**
+ * Ignored since javascript implementation changed
+ * see: https://app.camunda.com/jira/browse/CAM-3612
+ */
+ @Test
+ @Ignore
+ public void shouldFailAppendWrongNode() throws Throwable {
+ }
+
+ /**
+ * Ignored since javascript implementation changed
+ * see: https://app.camunda.com/jira/browse/CAM-3612
+ */
+ @Test
+ @Ignore
+ public void shouldFailInsertWrongObjectBeforeSearchObject() throws Throwable {
+ }
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/javascript/json/tree/JsonTreeJsonPathJavascriptTest.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/javascript/json/tree/JsonTreeJsonPathJavascriptTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..98869dbad4df78f4db575533609de7caf7e21bb1
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/javascript/json/tree/JsonTreeJsonPathJavascriptTest.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.javascript.json.tree;
+
+import org.camunda.spin.impl.test.ScriptEngine;
+import org.camunda.spin.json.tree.JsonTreeJsonPathScriptTest;
+
+/**
+ * @author Thorben Lindhauer
+ *
+ */
+@ScriptEngine("graal.js")
+public class JsonTreeJsonPathJavascriptTest extends JsonTreeJsonPathScriptTest {
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/javascript/json/tree/JsonTreeMapJsonToJavaJavascriptTest.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/javascript/json/tree/JsonTreeMapJsonToJavaJavascriptTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..9e6b67b813d890d363d1b0b0108fa8ecb26a4ed4
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/javascript/json/tree/JsonTreeMapJsonToJavaJavascriptTest.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.javascript.json.tree;
+
+import org.camunda.spin.impl.test.ScriptEngine;
+import org.camunda.spin.json.tree.JsonTreeMapJsonToJavaScriptTest;
+
+/**
+ * @author Sebastian Menski
+ */
+@ScriptEngine("graal.js")
+public class JsonTreeMapJsonToJavaJavascriptTest extends JsonTreeMapJsonToJavaScriptTest {
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/javascript/json/tree/JsonTreeMapObjectToJsonJavascriptTest.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/javascript/json/tree/JsonTreeMapObjectToJsonJavascriptTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..01bbf7a3e0f854b719e5a9584981ce35a90bd6b5
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/javascript/json/tree/JsonTreeMapObjectToJsonJavascriptTest.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.javascript.json.tree;
+
+import org.camunda.spin.impl.test.ScriptEngine;
+import org.camunda.spin.json.tree.JsonTreeMapObjectToJsonScriptTest;
+import org.junit.Ignore;
+
+/**
+ * Note: Jackson is apparently not able to map graal.js's internal representations
+ * of javascript objects and arrays.
+ *
+ * @author Thorben Lindhauer
+ */
+@Ignore
+@ScriptEngine("graal.js")
+public class JsonTreeMapObjectToJsonJavascriptTest extends JsonTreeMapObjectToJsonScriptTest {
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/javascript/json/tree/JsonTreeReadPropertyJavascriptTest.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/javascript/json/tree/JsonTreeReadPropertyJavascriptTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..0511dff5b76c2d4ea560d6b20c670ee5323654de
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/javascript/json/tree/JsonTreeReadPropertyJavascriptTest.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.javascript.json.tree;
+
+import org.camunda.spin.impl.test.ScriptEngine;
+import org.camunda.spin.json.tree.JsonTreeReadPropertyScriptTest;
+
+/**
+ * @author Thorben Lindhauer
+ *
+ */
+@ScriptEngine("graal.js")
+public class JsonTreeReadPropertyJavascriptTest extends JsonTreeReadPropertyScriptTest {
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/javascript/json/tree/JsonTreeRemovePropertyJavascriptTest.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/javascript/json/tree/JsonTreeRemovePropertyJavascriptTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..0f3a1f5552e9363c28decf0c82eda96180259dad
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/javascript/json/tree/JsonTreeRemovePropertyJavascriptTest.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.javascript.json.tree;
+
+import org.camunda.spin.impl.test.ScriptEngine;
+import org.camunda.spin.json.tree.JsonTreeRemovePropertyScriptTest;
+
+/**
+ * @author Thorben Lindhauer
+ *
+ */
+@ScriptEngine("graal.js")
+public class JsonTreeRemovePropertyJavascriptTest extends JsonTreeRemovePropertyScriptTest {
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/javascript/json/tree/JsonTreeSetPropertyJavascriptTest.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/javascript/json/tree/JsonTreeSetPropertyJavascriptTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..e9557e0d158ce8ab70955b8ae649a298c7738e1b
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/javascript/json/tree/JsonTreeSetPropertyJavascriptTest.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.javascript.json.tree;
+
+import org.camunda.spin.impl.test.ScriptEngine;
+import org.camunda.spin.json.tree.JsonTreeSetPropertyScriptTest;
+
+/**
+ * @author Thorben Lindhauer
+ *
+ */
+@ScriptEngine("graal.js")
+public class JsonTreeSetPropertyJavascriptTest extends JsonTreeSetPropertyScriptTest {
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/javascript/nashorn/json/tree/JsonTreeCreateJavascriptTest.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/javascript/nashorn/json/tree/JsonTreeCreateJavascriptTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..547f837f277563367ae0180a4db31478a18b0ee9
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/javascript/nashorn/json/tree/JsonTreeCreateJavascriptTest.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.javascript.nashorn.json.tree;
+
+import org.camunda.spin.impl.test.ScriptEngine;
+import org.camunda.spin.json.tree.JsonTreeCreateScriptTest;
+
+@ScriptEngine("nashorn")
+public class JsonTreeCreateJavascriptTest extends JsonTreeCreateScriptTest {
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/javascript/nashorn/json/tree/JsonTreeEditListPropertyJavascriptTest.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/javascript/nashorn/json/tree/JsonTreeEditListPropertyJavascriptTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..2f68f5d8087563ea2f289b2c6df0742157695253
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/javascript/nashorn/json/tree/JsonTreeEditListPropertyJavascriptTest.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.javascript.nashorn.json.tree;
+
+import org.camunda.spin.impl.test.ScriptEngine;
+import org.camunda.spin.json.tree.JsonTreeEditListPropertyScriptTest;
+import org.junit.Ignore;
+import org.junit.Test;
+
+@ScriptEngine("nashorn")
+public class JsonTreeEditListPropertyJavascriptTest extends JsonTreeEditListPropertyScriptTest {
+
+ /**
+ * Ignored since javascript implementation changed
+ * see: https://app.camunda.com/jira/browse/CAM-3612
+ */
+ @Test
+ @Ignore
+ public void shouldFailInsertAtWithWrongObject() throws Throwable {
+ }
+
+ /**
+ * Ignored since javascript implementation changed
+ * see: https://app.camunda.com/jira/browse/CAM-3612
+ */
+ @Test
+ @Ignore
+ public void shouldFailInsertWrongObjectAfterSearchObject() throws Throwable {
+ }
+
+ /**
+ * Ignored since javascript implementation changed
+ * see: https://app.camunda.com/jira/browse/CAM-3612
+ */
+ @Test
+ @Ignore
+ public void shouldFailAppendWrongNode() throws Throwable {
+ }
+
+ /**
+ * Ignored since javascript implementation changed
+ * see: https://app.camunda.com/jira/browse/CAM-3612
+ */
+ @Test
+ @Ignore
+ public void shouldFailInsertWrongObjectBeforeSearchObject() throws Throwable {
+ }
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/javascript/nashorn/json/tree/JsonTreeJsonPathJavascriptTest.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/javascript/nashorn/json/tree/JsonTreeJsonPathJavascriptTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..269bf34589551f5f874cff3f9b7ccbb79e4b86d4
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/javascript/nashorn/json/tree/JsonTreeJsonPathJavascriptTest.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.javascript.nashorn.json.tree;
+
+import org.camunda.spin.impl.test.ScriptEngine;
+import org.camunda.spin.json.tree.JsonTreeJsonPathScriptTest;
+
+@ScriptEngine("nashorn")
+public class JsonTreeJsonPathJavascriptTest extends JsonTreeJsonPathScriptTest {
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/javascript/nashorn/json/tree/JsonTreeMapJsonToJavaJavascriptTest.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/javascript/nashorn/json/tree/JsonTreeMapJsonToJavaJavascriptTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..a980e5acf6815976781b4d8f2f80aab25844b614
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/javascript/nashorn/json/tree/JsonTreeMapJsonToJavaJavascriptTest.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.javascript.nashorn.json.tree;
+
+import org.camunda.spin.impl.test.ScriptEngine;
+import org.camunda.spin.json.tree.JsonTreeMapJsonToJavaScriptTest;
+
+@ScriptEngine("nashorn")
+public class JsonTreeMapJsonToJavaJavascriptTest extends JsonTreeMapJsonToJavaScriptTest {
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/javascript/nashorn/json/tree/JsonTreeMapObjectToJsonJavascriptTest.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/javascript/nashorn/json/tree/JsonTreeMapObjectToJsonJavascriptTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..a77db17b8bf0001297d47a0fc69b54d81b58a2d0
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/javascript/nashorn/json/tree/JsonTreeMapObjectToJsonJavascriptTest.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.javascript.nashorn.json.tree;
+
+import org.camunda.spin.impl.test.ScriptEngine;
+import org.camunda.spin.json.tree.JsonTreeMapObjectToJsonScriptTest;
+import org.junit.Ignore;
+
+/**
+ * Note: Jackson is apparently not able to map Nashorn's internal representations
+ * of javascript objects and arrays.
+ */
+@Ignore
+@ScriptEngine("nashorn")
+public class JsonTreeMapObjectToJsonJavascriptTest extends JsonTreeMapObjectToJsonScriptTest {
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/javascript/nashorn/json/tree/JsonTreeReadPropertyJavascriptTest.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/javascript/nashorn/json/tree/JsonTreeReadPropertyJavascriptTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..4ccfe70ae4aef742c0d1e281d7ccb60d995a890d
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/javascript/nashorn/json/tree/JsonTreeReadPropertyJavascriptTest.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.javascript.nashorn.json.tree;
+
+import org.camunda.spin.impl.test.ScriptEngine;
+import org.camunda.spin.json.tree.JsonTreeReadPropertyScriptTest;
+
+@ScriptEngine("nashorn")
+public class JsonTreeReadPropertyJavascriptTest extends JsonTreeReadPropertyScriptTest {
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/javascript/nashorn/json/tree/JsonTreeRemovePropertyJavascriptTest.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/javascript/nashorn/json/tree/JsonTreeRemovePropertyJavascriptTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..287a5a28e357371c27dad46dcee53d414c64f7f9
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/javascript/nashorn/json/tree/JsonTreeRemovePropertyJavascriptTest.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.javascript.nashorn.json.tree;
+
+import org.camunda.spin.impl.test.ScriptEngine;
+import org.camunda.spin.json.tree.JsonTreeRemovePropertyScriptTest;
+
+@ScriptEngine("nashorn")
+public class JsonTreeRemovePropertyJavascriptTest extends JsonTreeRemovePropertyScriptTest {
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/javascript/nashorn/json/tree/JsonTreeSetPropertyJavascriptTest.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/javascript/nashorn/json/tree/JsonTreeSetPropertyJavascriptTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..947e26d121a5704f4ad9a4873bedd75fc93b801e
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/javascript/nashorn/json/tree/JsonTreeSetPropertyJavascriptTest.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.javascript.nashorn.json.tree;
+
+import org.camunda.spin.impl.test.ScriptEngine;
+import org.camunda.spin.json.tree.JsonTreeSetPropertyScriptTest;
+
+@ScriptEngine("nashorn")
+public class JsonTreeSetPropertyJavascriptTest extends JsonTreeSetPropertyScriptTest {
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/JsonSerializationTest.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/JsonSerializationTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..3bdae546aa8d448a9f1cae1848d95efc16d9cd90
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/JsonSerializationTest.java
@@ -0,0 +1,198 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.json;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.camunda.spin.DataFormats.json;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import org.camunda.spin.json.mapping.CustomerList;
+import org.camunda.spin.json.mapping.GenericCustomerList;
+import org.camunda.spin.json.mapping.Order;
+import org.camunda.spin.json.mapping.RegularCustomer;
+import org.camunda.spin.json.mapping.dmn.DmnDecisionResultEntries;
+import org.camunda.spin.json.mapping.dmn.DmnDecisionResultEntriesImpl;
+import org.camunda.spin.json.mapping.dmn.DmnDecisionResultImpl;
+import org.camunda.spin.spi.DataFormatMapper;
+import org.camunda.spin.spi.DataFormatReader;
+import org.camunda.spin.spi.DataFormatWriter;
+import org.junit.Test;
+
+public class JsonSerializationTest {
+
+ @Test
+ public void testNotGenericList() throws Exception {
+ CustomerList customers = new CustomerList<>();
+ customers.add(new RegularCustomer("someCustomer", 5));
+
+ String canonicalTypeString = json().getMapper().getCanonicalTypeName(customers);
+ assertThat(canonicalTypeString).isNotNull();
+
+ final byte[] bytes = serializeToByteArray(customers);
+ assertThat(bytes).isNotEmpty();
+
+ final Object o = deserializeFromByteArray(bytes, canonicalTypeString);
+ assertThat(o).isInstanceOf(CustomerList.class);
+
+ CustomerList> deserializedCustomerList = (CustomerList>) o;
+ assertEquals("someCustomer", deserializedCustomerList.get(0).getName());
+ assertEquals(5, deserializedCustomerList.get(0).getContractStartDate());
+ }
+
+ @Test
+ public void testOrder() throws Exception {
+ Order order = JsonTestConstants.createExampleOrder();
+
+ String canonicalTypeString = json().getMapper().getCanonicalTypeName(order);
+ assertThat(canonicalTypeString).isNotNull();
+
+ final byte[] bytes = serializeToByteArray(order);
+ assertThat(bytes).isNotEmpty();
+
+ final Object o = deserializeFromByteArray(bytes, canonicalTypeString);
+ assertThat(o).isInstanceOf(Order.class);
+
+ Order deserializedOrder = (Order) o;
+ JsonTestConstants.assertIsExampleOrder(deserializedOrder);
+ }
+
+ @Test
+ public void testPlainTypeArray() throws Exception {
+ int[] array = new int[]{5, 10};
+
+ String canonicalTypeString = json().getMapper().getCanonicalTypeName(array);
+ assertThat(canonicalTypeString).isNotNull();
+
+ final byte[] bytes = serializeToByteArray(array);
+ assertThat(bytes).isNotEmpty();
+
+ final Object o = deserializeFromByteArray(bytes, canonicalTypeString);
+ assertThat(o).isInstanceOf(int[].class);
+
+ int[] deserializedArray = (int[]) o;
+ assertEquals(5, deserializedArray[0]);
+ assertEquals(10, deserializedArray[1]);
+ }
+
+ @Test
+ public void testGenericList() throws Exception {
+ GenericCustomerList customers = new GenericCustomerList<>();
+ customers.add(new RegularCustomer("someCustomer", 5));
+
+ String canonicalTypeString = json().getMapper().getCanonicalTypeName(customers);
+ assertThat(canonicalTypeString).isNotNull();
+
+ final byte[] bytes = serializeToByteArray(customers);
+ assertThat(bytes).isNotEmpty();
+
+ final Object o = deserializeFromByteArray(bytes, canonicalTypeString);
+ assertThat(o).isInstanceOf(GenericCustomerList.class);
+
+ GenericCustomerList> deserializedCustomerList = (GenericCustomerList>) o;
+ assertEquals("someCustomer", deserializedCustomerList.get(0).getName());
+ assertEquals(5, deserializedCustomerList.get(0).getContractStartDate());
+
+ }
+
+ @Test
+ public void serializeAndDeserializeGenericCollection() throws Exception {
+ List ruleResults = new ArrayList<>();
+ final DmnDecisionResultEntriesImpl result1 = new DmnDecisionResultEntriesImpl();
+ result1.putValue("key1", "value1");
+ result1.putValue("key2", "value2");
+ ruleResults.add(result1);
+ final DmnDecisionResultEntriesImpl result2 = new DmnDecisionResultEntriesImpl();
+ result2.putValue("key3", "value3");
+ result2.putValue("key4", "value4");
+ ruleResults.add(result2);
+ DmnDecisionResultImpl dmnDecisionResult = new DmnDecisionResultImpl(ruleResults);
+
+ String canonicalTypeString = json().getMapper().getCanonicalTypeName(dmnDecisionResult);
+ assertThat(canonicalTypeString).isNotNull();
+
+ final byte[] bytes = serializeToByteArray(dmnDecisionResult);
+ assertThat(bytes).isNotEmpty();
+
+ //deserialization is not working for this kind of class
+
+ }
+
+ @Test
+ public void deserializeHashMap() throws Exception {
+ final byte[] bytes = new String("{\"foo\": \"bar\"}").getBytes();
+ assertThat(bytes).isNotEmpty();
+
+ final Object o = deserializeFromByteArray(bytes, "java.util.HashMap");
+ assertThat(o).isInstanceOf(HashMap.class);
+ assertTrue(((HashMap, ?>)o).containsKey("foo"));
+ assertEquals("bar", ((HashMap, ?>)o).get("foo"));
+ }
+
+ protected byte[] serializeToByteArray(Object deserializedObject) throws Exception {
+ DataFormatMapper mapper = json().getMapper();
+ DataFormatWriter writer = json().getWriter();
+
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ OutputStreamWriter outWriter = new OutputStreamWriter(out);
+ BufferedWriter bufferedWriter = new BufferedWriter(outWriter);
+
+ try {
+ Object mappedObject = mapper.mapJavaToInternal(deserializedObject);
+ writer.writeToWriter(bufferedWriter, mappedObject);
+ return out.toByteArray();
+ }
+ finally {
+ out.close();
+ outWriter.close();
+ bufferedWriter.close();
+ }
+ }
+
+ protected Object deserializeFromByteArray(byte[] bytes, String objectTypeName) throws Exception {
+ DataFormatMapper mapper = json().getMapper();
+ DataFormatReader reader = json().getReader();
+
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+ InputStreamReader inReader = new InputStreamReader(bais);
+ BufferedReader bufferedReader = new BufferedReader(inReader);
+
+ try {
+ Object mappedObject = reader.readInput(bufferedReader);
+ return doDeserialization(mapper, mappedObject, objectTypeName);
+ } finally {
+ bais.close();
+ inReader.close();
+ bufferedReader.close();
+ }
+ }
+
+ protected Object doDeserialization(DataFormatMapper mapper, Object mappedObject, String objectTypeName) {
+ return mapper.mapInternalToJava(mappedObject, objectTypeName);
+ }
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/JsonSerializationWithValidationTest.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/JsonSerializationWithValidationTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..1ebff659c92cb49ae602f49238c0a1ccd8fc0b7d
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/JsonSerializationWithValidationTest.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.json;
+
+import org.camunda.spin.DeserializationTypeValidator;
+import org.camunda.spin.spi.DataFormatMapper;
+import org.junit.Before;
+import org.mockito.Mockito;
+
+public class JsonSerializationWithValidationTest extends JsonSerializationTest {
+
+ protected DeserializationTypeValidator validator;
+
+ @Before
+ public void setUpValidator() {
+ validator = Mockito.mock(DeserializationTypeValidator.class);
+ Mockito.when(validator.validate(Mockito.anyString())).thenReturn(true);
+ }
+
+ @Override
+ protected Object doDeserialization(DataFormatMapper mapper, Object mappedObject, String objectTypeName) {
+ return mapper.mapInternalToJava(mappedObject, objectTypeName, validator);
+ }
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/JsonTestConstants.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/JsonTestConstants.java
new file mode 100644
index 0000000000000000000000000000000000000000..8ef5941f0ae358a04341b02009faa1fc2ee9076b
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/JsonTestConstants.java
@@ -0,0 +1,132 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.json;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.tuple;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.camunda.spin.impl.util.SpinIoUtil;
+import org.camunda.spin.json.mapping.Customer;
+import org.camunda.spin.json.mapping.Invoice;
+import org.camunda.spin.json.mapping.Order;
+import org.camunda.spin.json.mapping.OrderDetails;
+import org.camunda.spin.json.mapping.RegularCustomer;
+
+public class JsonTestConstants {
+
+ public static final String EXAMPLE_JSON_FILE_NAME = "org/camunda/spin/json/example.json";
+
+ public static final String EXAMPLE_JSON = SpinIoUtil.fileAsString(EXAMPLE_JSON_FILE_NAME);
+
+ public static final String EXAMPLE_JSON_COLLECTION = "[" + EXAMPLE_JSON + "]";
+
+ public static final String EXAMPLE_INVALID_JSON = "{\"invalid\":";
+
+ public static final String EXAMPLE_EMPTY_STRING = "";
+
+ /**
+ * A json file that can only be parsed when configuring Jackson correctly.
+ */
+ public static final String EXAMPLE_JACKSON_READ_CONFIGURATION_JSON_FILE_NAME = "org/camunda/spin/json/example_jackson.json";
+
+ public static final String EXAMPLE_JACKSON_READ_CONFIGURATION_JSON = SpinIoUtil.fileAsString(EXAMPLE_JACKSON_READ_CONFIGURATION_JSON_FILE_NAME);
+
+ public static final String EXAMPLE_JACKSON_TYPE_JSON_FILE_NAME = "org/camunda/spin/json/example_jackson_types.json";
+
+ public static final String EXAMPLE_JACKSON_TYPE_JSON = SpinIoUtil.fileAsString(EXAMPLE_JACKSON_TYPE_JSON_FILE_NAME);
+
+ public static Order createExampleOrder() {
+ Order order = new Order();
+ order.setId(1234567890987654321L);
+ order.setOrder("order1");
+ order.setDueUntil(20150112);
+ order.setActive(true);
+
+ OrderDetails orderDetails = new OrderDetails();
+ orderDetails.setArticle("camundaBPM");
+ orderDetails.setPrice(1234567.13d);
+ orderDetails.setRoundedPrice(1234567L);
+
+ List currencies = new ArrayList();
+ currencies.add("euro");
+ currencies.add("dollar");
+ orderDetails.setCurrencies(currencies);
+
+ order.setOrderDetails(orderDetails);
+
+ List customers = new ArrayList();
+
+ customers.add(new RegularCustomer("Kermit", 1354539722));
+ customers.add(new RegularCustomer("Waldo", 1320325322));
+ customers.add(new RegularCustomer("Johnny", 1286110922));
+
+ order.setCustomers(customers);
+
+ return order;
+
+ }
+
+ public static void assertIsExampleOrder(Order order) {
+ assertThat(order.getId()).isEqualTo(1234567890987654321L);
+ assertThat(order.getOrder()).isEqualTo("order1");
+ assertThat(order.getDueUntil()).isEqualTo(20150112);
+ assertThat(order.isActive()).isTrue();
+
+ OrderDetails orderDetails = order.getOrderDetails();
+ assertThat(orderDetails).isNotNull();
+ assertThat(orderDetails.getArticle()).isEqualTo("camundaBPM");
+ assertThat(orderDetails.getPrice()).isEqualTo(1234567.13d);
+ assertThat(orderDetails.getRoundedPrice()).isEqualTo(1234567L);
+ assertThat(orderDetails.getCurrencies()).containsExactly("euro", "dollar");
+
+ List customers = order.getCustomers();
+ assertThat(customers).isNotNull();
+ assertThat(customers.size()).isEqualTo(3);
+
+ assertThat(customers).extracting("name", "contractStartDate")
+ .contains(
+ tuple("Kermit", 1354539722),
+ tuple("Waldo", 1320325322),
+ tuple("Johnny", 1286110922));
+ }
+
+ public static Invoice createExampleInvoice() {
+ Invoice invoice = new Invoice();
+ invoice.setAmount(2000);
+
+ RegularCustomer customer = new RegularCustomer("Kermit", 20130505);
+ invoice.setCustomer(customer);
+
+ return invoice;
+ }
+
+ public static void assertIsExampleInvoice(Invoice invoice) {
+ assertThat(invoice).isNotNull();
+ assertThat(invoice.getAmount()).isEqualTo(2000);
+
+ assertThat(invoice.getCustomer()).isNotNull();
+
+ Customer customer = invoice.getCustomer();
+ assertThat(customer).isInstanceOf(RegularCustomer.class);
+ assertThat(customer.getName()).isEqualTo("Kermit");
+ assertThat(customer.getContractStartDate()).isEqualTo(20130505);
+ }
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/mapping/Customer.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/mapping/Customer.java
new file mode 100644
index 0000000000000000000000000000000000000000..a2ee599bcd4b781b3811cbd118cbbf6b23dbe45c
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/mapping/Customer.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.json.mapping;
+
+public interface Customer {
+
+ String getName();
+
+ int getContractStartDate();
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/mapping/CustomerList.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/mapping/CustomerList.java
new file mode 100644
index 0000000000000000000000000000000000000000..71108fa75c594b0faa1bff85622f4891c2693ea3
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/mapping/CustomerList.java
@@ -0,0 +1,159 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.json.mapping;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+
+/**
+ * @author Svetlana Dorokhova.
+ */
+@JsonDeserialize(contentAs = RegularCustomer.class)
+public class CustomerList implements List {
+
+ protected List innerList = new ArrayList();
+
+ @Override
+ public int size() {
+ return innerList.size();
+ }
+
+ @Override
+ public boolean isEmpty() {
+ return innerList.isEmpty();
+ }
+
+ @Override
+ public boolean contains(Object o) {
+ return innerList.contains(o);
+ }
+
+ @Override
+ public Iterator iterator() {
+ return innerList.iterator();
+ }
+
+ @Override
+ public Object[] toArray() {
+ return innerList.toArray();
+ }
+
+ @Override
+ public Customer[] toArray(Customer[] a) {
+ return innerList.toArray(a);
+ }
+
+ @Override
+ public boolean add(Customer customer) {
+ return innerList.add(customer);
+ }
+
+ @Override
+ public boolean remove(Object o) {
+ return innerList.remove(o);
+ }
+
+ @Override
+ public boolean containsAll(Collection> c) {
+ return innerList.containsAll(c);
+ }
+
+ @Override
+ public boolean addAll(Collection extends Customer> c) {
+ return innerList.addAll(c);
+ }
+
+ @Override
+ public boolean addAll(int index, Collection extends Customer> c) {
+ return innerList.addAll(index, c);
+ }
+
+ @Override
+ public boolean removeAll(Collection> c) {
+ return innerList.removeAll(c);
+ }
+
+ @Override
+ public boolean retainAll(Collection> c) {
+ return innerList.retainAll(c);
+ }
+
+ @Override
+ public void clear() {
+ innerList.clear();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ return innerList.equals(o);
+ }
+
+ @Override
+ public int hashCode() {
+ return innerList.hashCode();
+ }
+
+ @Override
+ public Customer get(int index) {
+ return innerList.get(index);
+ }
+
+ @Override
+ public Customer set(int index, Customer element) {
+ return innerList.set(index, element);
+ }
+
+ @Override
+ public void add(int index, Customer element) {
+ innerList.add(index, element);
+ }
+
+ @Override
+ public Customer remove(int index) {
+ return innerList.remove(index);
+ }
+
+ @Override
+ public int indexOf(Object o) {
+ return innerList.indexOf(o);
+ }
+
+ @Override
+ public int lastIndexOf(Object o) {
+ return innerList.lastIndexOf(o);
+ }
+
+ @Override
+ public ListIterator listIterator() {
+ return innerList.listIterator();
+ }
+
+ @Override
+ public ListIterator listIterator(int index) {
+ return innerList.listIterator(index);
+ }
+
+ @Override
+ public List subList(int fromIndex, int toIndex) {
+ return innerList.subList(fromIndex, toIndex);
+ }
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/mapping/DateObject.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/mapping/DateObject.java
new file mode 100644
index 0000000000000000000000000000000000000000..20a1eeb615fe0d291b328dfe0200abc41edf5b57
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/mapping/DateObject.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.json.mapping;
+
+import java.util.Date;
+
+public class DateObject {
+
+ private Date date;
+
+ public Date getDate() {
+ return date;
+ }
+
+ public void setDate(Date date) {
+ this.date = date;
+ }
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/mapping/EmptyBean.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/mapping/EmptyBean.java
new file mode 100644
index 0000000000000000000000000000000000000000..8ef22ab250ec339561148cb08ddb1453c2086897
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/mapping/EmptyBean.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.json.mapping;
+
+public class EmptyBean {
+
+ // that is all
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/mapping/GenericCustomerList.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/mapping/GenericCustomerList.java
new file mode 100644
index 0000000000000000000000000000000000000000..9430bdf93ae565a2698142c83c6597248495a9ec
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/mapping/GenericCustomerList.java
@@ -0,0 +1,160 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.json.mapping;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+
+/**
+ * @author Svetlana Dorokhova.
+ */
+
+@JsonDeserialize(contentAs = RegularCustomer.class)
+public class GenericCustomerList implements List {
+
+ protected List innerList = new ArrayList();
+
+ @Override
+ public int size() {
+ return innerList.size();
+ }
+
+ @Override
+ public boolean isEmpty() {
+ return innerList.isEmpty();
+ }
+
+ @Override
+ public boolean contains(Object o) {
+ return innerList.contains(o);
+ }
+
+ @Override
+ public Iterator iterator() {
+ return innerList.iterator();
+ }
+
+ @Override
+ public Object[] toArray() {
+ return innerList.toArray();
+ }
+
+ @Override
+ public T[] toArray(T[] a) {
+ return innerList.toArray(a);
+ }
+
+ @Override
+ public boolean add(T customer) {
+ return innerList.add(customer);
+ }
+
+ @Override
+ public boolean remove(Object o) {
+ return innerList.remove(o);
+ }
+
+ @Override
+ public boolean containsAll(Collection> c) {
+ return innerList.containsAll(c);
+ }
+
+ @Override
+ public boolean addAll(Collection extends T> c) {
+ return innerList.addAll(c);
+ }
+
+ @Override
+ public boolean addAll(int index, Collection extends T> c) {
+ return innerList.addAll(index, c);
+ }
+
+ @Override
+ public boolean removeAll(Collection> c) {
+ return innerList.removeAll(c);
+ }
+
+ @Override
+ public boolean retainAll(Collection> c) {
+ return innerList.retainAll(c);
+ }
+
+ @Override
+ public void clear() {
+ innerList.clear();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ return innerList.equals(o);
+ }
+
+ @Override
+ public int hashCode() {
+ return innerList.hashCode();
+ }
+
+ @Override
+ public T get(int index) {
+ return innerList.get(index);
+ }
+
+ @Override
+ public T set(int index, T element) {
+ return innerList.set(index, element);
+ }
+
+ @Override
+ public void add(int index, T element) {
+ innerList.add(index, element);
+ }
+
+ @Override
+ public T remove(int index) {
+ return innerList.remove(index);
+ }
+
+ @Override
+ public int indexOf(Object o) {
+ return innerList.indexOf(o);
+ }
+
+ @Override
+ public int lastIndexOf(Object o) {
+ return innerList.lastIndexOf(o);
+ }
+
+ @Override
+ public ListIterator listIterator() {
+ return innerList.listIterator();
+ }
+
+ @Override
+ public ListIterator listIterator(int index) {
+ return innerList.listIterator(index);
+ }
+
+ @Override
+ public List subList(int fromIndex, int toIndex) {
+ return innerList.subList(fromIndex, toIndex);
+ }
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/mapping/Invoice.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/mapping/Invoice.java
new file mode 100644
index 0000000000000000000000000000000000000000..1131234ccda6b4567712cb30c21b1e9084f8fd1e
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/mapping/Invoice.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.json.mapping;
+
+public class Invoice {
+
+ private int amount;
+ private Customer customer;
+
+ public int getAmount() {
+ return amount;
+ }
+ public void setAmount(int amount) {
+ this.amount = amount;
+ }
+ public Customer getCustomer() {
+ return customer;
+ }
+ public void setCustomer(Customer customer) {
+ this.customer = customer;
+ }
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/mapping/Order.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/mapping/Order.java
new file mode 100644
index 0000000000000000000000000000000000000000..63ccb3ebec2025ce37d394b65cd7a22a4316248a
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/mapping/Order.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.json.mapping;
+
+import java.util.List;
+
+public class Order {
+
+ private long id;
+ private String order;
+ private Object dueUntil;
+ private boolean active;
+ private List customers;
+ private OrderDetails orderDetails;
+ private Object nullValue;
+
+ public long getId() {
+ return id;
+ }
+ public void setId(long id) {
+ this.id = id;
+ }
+ public String getOrder() {
+ return order;
+ }
+ public void setOrder(String order) {
+ this.order = order;
+ }
+ public Object getDueUntil() {
+ return dueUntil;
+ }
+ public void setDueUntil(Object dueUntil) {
+ this.dueUntil = dueUntil;
+ }
+ public boolean isActive() {
+ return active;
+ }
+ public void setActive(boolean active) {
+ this.active = active;
+ }
+ public List getCustomers() {
+ return customers;
+ }
+ public void setCustomers(List customers) {
+ this.customers = customers;
+ }
+ public OrderDetails getOrderDetails() {
+ return orderDetails;
+ }
+ public void setOrderDetails(OrderDetails orderDetails) {
+ this.orderDetails = orderDetails;
+ }
+ public Object getNullValue() {
+ return nullValue;
+ }
+ public void setNullValue(Object nullValue) {
+ this.nullValue = nullValue;
+ }
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/mapping/OrderDetails.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/mapping/OrderDetails.java
new file mode 100644
index 0000000000000000000000000000000000000000..56ade8c75c246b295a73f76e84b0270849b88ef3
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/mapping/OrderDetails.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.json.mapping;
+
+import java.util.List;
+
+public class OrderDetails {
+
+ private String article;
+ private double price;
+ private long roundedPrice;
+ private List currencies;
+ private boolean paid;
+
+ public String getArticle() {
+ return article;
+ }
+ public void setArticle(String article) {
+ this.article = article;
+ }
+ public double getPrice() {
+ return price;
+ }
+ public void setPrice(double price) {
+ this.price = price;
+ }
+ public long getRoundedPrice() {
+ return roundedPrice;
+ }
+ public void setRoundedPrice(long roundedPrice) {
+ this.roundedPrice = roundedPrice;
+ }
+ public List getCurrencies() {
+ return currencies;
+ }
+ public void setCurrencies(List currencies) {
+ this.currencies = currencies;
+ }
+ public boolean isPaid() {
+ return paid;
+ }
+ public void setPaid(boolean paid) {
+ this.paid = paid;
+ }
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/mapping/RegularCustomer.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/mapping/RegularCustomer.java
new file mode 100644
index 0000000000000000000000000000000000000000..7339151966854755ee09af503026567d8c9c78b9
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/mapping/RegularCustomer.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.json.mapping;
+
+
+public class RegularCustomer implements Customer {
+
+ private String name;
+ private int contractStartDate;
+
+ public RegularCustomer() {
+ }
+
+ public RegularCustomer(String name, int contractStartDate) {
+ this.name = name;
+ this.contractStartDate = contractStartDate;
+ }
+
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+ public int getContractStartDate() {
+ return contractStartDate;
+ }
+ public void setContractStartDate(int contractStartDate) {
+ this.contractStartDate = contractStartDate;
+ }
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/mapping/dmn/DmnDecisionResult.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/mapping/dmn/DmnDecisionResult.java
new file mode 100644
index 0000000000000000000000000000000000000000..d21009628d4e7e3ae02579ccf1787767b84fff9e
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/mapping/dmn/DmnDecisionResult.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.json.mapping.dmn;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * @author Svetlana Dorokhova.
+ */
+public interface DmnDecisionResult extends List, Serializable {
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/mapping/dmn/DmnDecisionResultEntries.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/mapping/dmn/DmnDecisionResultEntries.java
new file mode 100644
index 0000000000000000000000000000000000000000..fbea9e2c4aa685f2ee048ab170d15406dfaed3d5
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/mapping/dmn/DmnDecisionResultEntries.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.json.mapping.dmn;
+
+import java.io.Serializable;
+import java.util.Map;
+
+/**
+ * @author Svetlana Dorokhova.
+ */
+public interface DmnDecisionResultEntries extends Map, Serializable {
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/mapping/dmn/DmnDecisionResultEntriesImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/mapping/dmn/DmnDecisionResultEntriesImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..1db753afda94e6919068744f6eb0a26d8962cfc0
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/mapping/dmn/DmnDecisionResultEntriesImpl.java
@@ -0,0 +1,98 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.json.mapping.dmn;
+
+import java.util.Collection;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author Svetlana Dorokhova.
+ */
+public class DmnDecisionResultEntriesImpl implements DmnDecisionResultEntries {
+
+ protected final Map outputValues = new LinkedHashMap();
+
+ public void putValue(String name, Object value) {
+ outputValues.put(name, value);
+ }
+
+ public void putAllValues(Map values) {
+ outputValues.putAll(values);
+ }
+
+ @Override
+ public int size() {
+ return outputValues.size();
+ }
+
+ @Override
+ public boolean isEmpty() {
+ return outputValues.isEmpty();
+ }
+
+ @Override
+ public boolean containsKey(Object key) {
+ return outputValues.containsKey(key);
+ }
+
+ @Override
+ public boolean containsValue(Object value) {
+ return outputValues.containsValue(value);
+ }
+
+ @Override
+ public Object get(Object key) {
+ return outputValues.get(key);
+ }
+
+ @Override
+ public Object put(String key, Object value) {
+ return outputValues.put(key, value);
+ }
+
+ @Override
+ public Object remove(Object key) {
+ return outputValues.remove(key);
+ }
+
+ @Override
+ public void putAll(Map extends String, ?> m) {
+ outputValues.putAll(m);
+ }
+
+ @Override
+ public void clear() {
+ outputValues.clear();
+ }
+
+ @Override
+ public Set keySet() {
+ return outputValues.keySet();
+ }
+
+ @Override
+ public Collection values() {
+ return outputValues.values();
+ }
+
+ @Override
+ public Set> entrySet() {
+ return outputValues.entrySet();
+ }
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/mapping/dmn/DmnDecisionResultImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/mapping/dmn/DmnDecisionResultImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..aeb03f52246c06beb1f9474e4b46dac8a3ac052f
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/mapping/dmn/DmnDecisionResultImpl.java
@@ -0,0 +1,167 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.json.mapping.dmn;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+
+/**
+ * @author Svetlana Dorokhova.
+ */
+public class DmnDecisionResultImpl implements DmnDecisionResult {
+
+ protected final List ruleResults;
+
+ public DmnDecisionResultImpl() {
+ this.ruleResults = new ArrayList();
+ }
+
+ public DmnDecisionResultImpl(List ruleResults) {
+ this.ruleResults = ruleResults;
+ }
+
+ @Override
+ public Iterator iterator() {
+ return asUnmodifiableList().iterator();
+ }
+
+ @Override
+ public int size() {
+ return ruleResults.size();
+ }
+
+ @Override
+ public boolean isEmpty() {
+ return ruleResults.isEmpty();
+ }
+
+ @Override
+ public DmnDecisionResultEntries get(int index) {
+ return ruleResults.get(index);
+ }
+
+ @Override
+ public boolean contains(Object o) {
+ return ruleResults.contains(o);
+ }
+
+ @Override
+ public Object[] toArray() {
+ return ruleResults.toArray();
+ }
+
+ @Override
+ public T[] toArray(T[] a) {
+ return ruleResults.toArray(a);
+ }
+
+ @Override
+ public boolean add(DmnDecisionResultEntries e) {
+ throw new UnsupportedOperationException("decision result is immutable");
+ }
+
+
+
+ @Override
+ public boolean remove(Object o) {
+ throw new UnsupportedOperationException("decision result is immutable");
+ }
+
+ @Override
+ public boolean containsAll(Collection> c) {
+ return ruleResults.containsAll(c);
+ }
+
+ @Override
+ public boolean addAll(Collection extends DmnDecisionResultEntries> c) {
+ throw new UnsupportedOperationException("decision result is immutable");
+ }
+
+ @Override
+ public boolean addAll(int index, Collection extends DmnDecisionResultEntries> c) {
+ throw new UnsupportedOperationException("decision result is immutable");
+ }
+
+ @Override
+ public boolean removeAll(Collection> c) {
+ throw new UnsupportedOperationException("decision result is immutable");
+ }
+
+ @Override
+ public boolean retainAll(Collection> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void clear() {
+ throw new UnsupportedOperationException("decision result is immutable");
+ }
+
+ @Override
+ public DmnDecisionResultEntries set(int index, DmnDecisionResultEntries element) {
+ throw new UnsupportedOperationException("decision result is immutable");
+ }
+
+ @Override
+ public void add(int index, DmnDecisionResultEntries element) {
+ throw new UnsupportedOperationException("decision result is immutable");
+ }
+
+ @Override
+ public DmnDecisionResultEntries remove(int index) {
+ throw new UnsupportedOperationException("decision result is immutable");
+ }
+
+ @Override
+ public int indexOf(Object o) {
+ return ruleResults.indexOf(o);
+ }
+
+ @Override
+ public int lastIndexOf(Object o) {
+ return ruleResults.lastIndexOf(o);
+ }
+
+ @Override
+ public ListIterator listIterator() {
+ return asUnmodifiableList().listIterator();
+ }
+
+ @Override
+ public ListIterator listIterator(int index) {
+ return asUnmodifiableList().listIterator(index);
+ }
+
+ @Override
+ public List subList(int fromIndex, int toIndex) {
+ return asUnmodifiableList().subList(fromIndex, toIndex);
+ }
+
+ @Override
+ public String toString() {
+ return ruleResults.toString();
+ }
+
+ protected List asUnmodifiableList() {
+ return Collections.unmodifiableList(ruleResults);
+ }
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/tree/JsonJacksonTreeDataFormatReaderTest.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/tree/JsonJacksonTreeDataFormatReaderTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..64315bf2fe55e91a4e008cd54006285d751f6fab
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/tree/JsonJacksonTreeDataFormatReaderTest.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.json.tree;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.camunda.spin.json.JsonTestConstants.EXAMPLE_JSON;
+import static org.camunda.spin.json.JsonTestConstants.EXAMPLE_JSON_COLLECTION;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.io.StringReader;
+
+import org.camunda.spin.DataFormats;
+import org.camunda.spin.impl.json.jackson.format.JacksonJsonDataFormat;
+import org.camunda.spin.impl.json.jackson.format.JacksonJsonDataFormatReader;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class JsonJacksonTreeDataFormatReaderTest {
+
+ private JacksonJsonDataFormatReader reader;
+ private Reader inputReader;
+
+ private static final int REWINDING_LIMIT = 256;
+
+ @Before
+ public void setUp() {
+ reader = new JacksonJsonDataFormatReader(new JacksonJsonDataFormat(DataFormats.JSON_DATAFORMAT_NAME));
+ }
+
+ @Test
+ public void shouldMatchJsonInput() throws IOException {
+ inputReader = stringToReader(EXAMPLE_JSON);
+ assertThat(reader.canRead(inputReader, REWINDING_LIMIT)).isTrue();
+ inputReader.close();
+
+ inputReader = stringToReader(EXAMPLE_JSON_COLLECTION);
+ assertThat(reader.canRead(inputReader, REWINDING_LIMIT)).isTrue();
+ }
+
+ @Test
+ public void shouldMatchJsonInputWithWhitespace() throws IOException {
+ inputReader = stringToReader(" " + EXAMPLE_JSON);
+ assertThat(reader.canRead(inputReader, REWINDING_LIMIT)).isTrue();
+ inputReader.close();
+
+ inputReader = stringToReader("\r\n\t " + EXAMPLE_JSON);
+ assertThat(reader.canRead(inputReader, REWINDING_LIMIT)).isTrue();
+ }
+
+ @Test
+ public void shouldNotMatchInvalidJson() throws IOException {
+ inputReader = stringToReader("prefix " + EXAMPLE_JSON);
+ assertThat(reader.canRead(inputReader, REWINDING_LIMIT)).isFalse();
+ }
+
+ public Reader stringToReader(String input) {
+ return new StringReader(input);
+ }
+
+ @After
+ public void tearDown() throws IOException {
+ if (inputReader != null) {
+ inputReader.close();
+ }
+ }
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/tree/JsonJacksonTreeNodeTest.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/tree/JsonJacksonTreeNodeTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..f83275b9f657c2984f9192d4ca2921199a983289
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/tree/JsonJacksonTreeNodeTest.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.json.tree;
+
+import static net.javacrumbs.jsonunit.fluent.JsonFluentAssert.assertThatJson;
+import static org.camunda.spin.Spin.S;
+import static org.camunda.spin.json.JsonTestConstants.EXAMPLE_JSON;
+
+import java.io.StringWriter;
+
+import org.camunda.spin.impl.json.jackson.JacksonJsonNode;
+import org.junit.Before;
+import org.junit.Test;
+
+public class JsonJacksonTreeNodeTest {
+
+ protected JacksonJsonNode jsonNode;
+
+ @Before
+ public void parseJson() {
+ jsonNode = S(EXAMPLE_JSON);
+ }
+
+ @Test
+ public void canWriteToString() {
+ assertThatJson(jsonNode.toString()).isEqualTo(EXAMPLE_JSON);
+ }
+
+ @Test
+ public void canWriteToWriter() {
+ StringWriter writer = new StringWriter();
+ jsonNode.writeToWriter(writer);
+ String value = writer.toString();
+ assertThatJson(value).isEqualTo(EXAMPLE_JSON);
+ }
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/tree/JsonTreeCreateScriptTest.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/tree/JsonTreeCreateScriptTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..280f2ec96701f52e6c3ff4c49ce4b3a43d3c85b7
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/tree/JsonTreeCreateScriptTest.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.json.tree;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.camunda.spin.json.JsonTestConstants.EXAMPLE_JSON_FILE_NAME;
+
+import org.camunda.spin.impl.json.jackson.JacksonJsonNode;
+import org.camunda.spin.impl.test.Script;
+import org.camunda.spin.impl.test.ScriptTest;
+import org.camunda.spin.impl.test.ScriptVariable;
+import org.junit.Test;
+
+/**
+ * @author Thorben Lindhauer
+ *
+ */
+public abstract class JsonTreeCreateScriptTest extends ScriptTest {
+
+ @Test
+ @Script
+ @ScriptVariable(name="input", value = "{\"root\": 1}")
+ public void shouldCreateForString() {
+
+ JacksonJsonNode json1 = script.getVariable("json1");
+ assertThat(json1).isNotNull();
+
+ JacksonJsonNode json2 = script.getVariable("json2");
+ assertThat(json2).isNotNull();
+
+ JacksonJsonNode json3 = script.getVariable("json3");
+ assertThat(json3).isNotNull();
+
+ }
+
+ @Test
+ @Script(
+ variables = {
+ @ScriptVariable(name="input1", file = EXAMPLE_JSON_FILE_NAME),
+ @ScriptVariable(name="input2", file = EXAMPLE_JSON_FILE_NAME),
+ @ScriptVariable(name="input3", file = EXAMPLE_JSON_FILE_NAME)
+ }
+ )
+ public void shouldCreateForReader() {
+
+ JacksonJsonNode json1 = script.getVariable("json1");
+ assertThat(json1).isNotNull();
+
+ JacksonJsonNode json2 = script.getVariable("json2");
+ assertThat(json2).isNotNull();
+
+ JacksonJsonNode json3 = script.getVariable("json3");
+ assertThat(json3).isNotNull();
+ }
+
+ @Test
+ @Script
+ @ScriptVariable(name="input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldBeIdempotent() {
+
+ JacksonJsonNode json = script.getVariable("json");
+ assertThat(json).isNotNull();
+
+ }
+
+}
+
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/tree/JsonTreeCreateTest.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/tree/JsonTreeCreateTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..938da4afd74b042d143d27e9a7ab7f61b7e3eee0
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/tree/JsonTreeCreateTest.java
@@ -0,0 +1,285 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.json.tree;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.fail;
+import static org.camunda.spin.DataFormats.json;
+import static org.camunda.spin.Spin.JSON;
+import static org.camunda.spin.Spin.S;
+import static org.camunda.spin.impl.util.SpinIoUtil.stringAsReader;
+import static org.camunda.spin.json.JsonTestConstants.EXAMPLE_EMPTY_STRING;
+import static org.camunda.spin.json.JsonTestConstants.EXAMPLE_INVALID_JSON;
+import static org.camunda.spin.json.JsonTestConstants.EXAMPLE_JSON;
+
+import java.io.Reader;
+
+import org.camunda.spin.DataFormats;
+import org.camunda.spin.json.SpinJsonNode;
+import org.camunda.spin.spi.SpinDataFormatException;
+import org.junit.Test;
+
+/**
+ * @author Thorben Lindhauer
+ */
+public class JsonTreeCreateTest {
+
+ @Test
+ public void shouldCreateForString() {
+ SpinJsonNode json = JSON(EXAMPLE_JSON);
+ assertThat(json).isNotNull();
+
+ json = S(EXAMPLE_JSON, json());
+ assertThat(json).isNotNull();
+
+ json = S(EXAMPLE_JSON, DataFormats.JSON_DATAFORMAT_NAME);
+ assertThat(json).isNotNull();
+
+ json = S(EXAMPLE_JSON);
+ assertThat(json).isNotNull();
+ }
+
+ @Test
+ public void shouldCreateObjectDeclaredInput() {
+ Object input = EXAMPLE_JSON;
+ SpinJsonNode jsonNode = JSON(input);
+ assertThat(jsonNode.prop("order")).isNotNull();
+ }
+
+ @Test
+ public void shouldCreateForReader() {
+ SpinJsonNode json = JSON(stringAsReader(EXAMPLE_JSON));
+ assertThat(json).isNotNull();
+
+ json = S(stringAsReader(EXAMPLE_JSON), json());
+ assertThat(json).isNotNull();
+
+ json = S(stringAsReader(EXAMPLE_JSON), DataFormats.JSON_DATAFORMAT_NAME);
+ assertThat(json).isNotNull();
+
+ json = S(stringAsReader(EXAMPLE_JSON));
+ assertThat(json).isNotNull();
+ }
+
+ @Test
+ public void shouldBeIdempotent() {
+ SpinJsonNode json = JSON(EXAMPLE_JSON);
+ assertThat(json).isEqualTo(JSON(json));
+ assertThat(json).isEqualTo(S(json, json()));
+ assertThat(json).isEqualTo(S(json, DataFormats.JSON_DATAFORMAT_NAME));
+ assertThat(json).isEqualTo(S(json));
+ }
+
+ @Test
+ public void shouldFailForNull() {
+ SpinJsonNode jsonNode = null;
+
+ try {
+ JSON(jsonNode);
+ fail("Expected IllegalArgumentException");
+ } catch(IllegalArgumentException e) {
+ // expected
+ }
+
+ try {
+ S(jsonNode, json());
+ fail("Expected IllegalArgumentException");
+ } catch(IllegalArgumentException e) {
+ // expected
+ }
+
+ try {
+ S(jsonNode);
+ fail("Expected IllegalArgumentException");
+ } catch(IllegalArgumentException e) {
+ // expected
+ }
+
+ Reader reader = null;
+
+ try {
+ JSON(reader);
+ fail("Expected IllegalArgumentException");
+ } catch(IllegalArgumentException e) {
+ // expected
+ }
+
+ try {
+ S(reader, json());
+ fail("Expected IllegalArgumentException");
+ } catch(IllegalArgumentException e) {
+ // expected
+ }
+
+ try {
+ S(reader);
+ fail("Expected IllegalArgumentException");
+ } catch(IllegalArgumentException e) {
+ // expected
+ }
+
+ String inputString = null;
+
+ try {
+ JSON(inputString);
+ fail("Expected IllegalArgumentException");
+ } catch(IllegalArgumentException e) {
+ // expected
+ }
+
+ try {
+ S(inputString, json());
+ fail("Expected IllegalArgumentException");
+ } catch(IllegalArgumentException e) {
+ // expected
+ }
+
+ try {
+ S(inputString, DataFormats.JSON_DATAFORMAT_NAME);
+ fail("Expected IllegalArgumentException");
+ } catch(IllegalArgumentException e) {
+ // expected
+ }
+
+ try {
+ S(inputString);
+ fail("Expected IllegalArgumentException");
+ } catch(IllegalArgumentException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void shouldFailForInvalidJson() {
+ try {
+ JSON(EXAMPLE_INVALID_JSON);
+ fail("Expected IllegalArgumentException");
+ } catch(SpinDataFormatException e) {
+ // expected
+ }
+
+ try {
+ S(EXAMPLE_INVALID_JSON, json());
+ fail("Expected IllegalArgumentException");
+ } catch(SpinDataFormatException e) {
+ // expected
+ }
+
+ try {
+ S(EXAMPLE_INVALID_JSON, DataFormats.JSON_DATAFORMAT_NAME);
+ fail("Expected IllegalArgumentException");
+ } catch(SpinDataFormatException e) {
+ // expected
+ }
+
+ try {
+ S(EXAMPLE_INVALID_JSON);
+ fail("Expected IllegalArgumentException");
+ } catch(SpinDataFormatException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void shouldFailForEmptyString() {
+ try {
+ JSON(EXAMPLE_EMPTY_STRING);
+ fail("Expected IllegalArgumentException");
+ } catch(SpinDataFormatException e) {
+ // expected
+ }
+
+ try {
+ S(EXAMPLE_EMPTY_STRING, json());
+ fail("Expected IllegalArgumentException");
+ } catch(SpinDataFormatException e) {
+ // expected
+ }
+
+ try {
+ S(EXAMPLE_EMPTY_STRING, DataFormats.JSON_DATAFORMAT_NAME);
+ fail("Expected IllegalArgumentException");
+ } catch(SpinDataFormatException e) {
+ // expected
+ }
+
+ try {
+ S(EXAMPLE_EMPTY_STRING);
+ fail("Expected IllegalArgumentException");
+ } catch(SpinDataFormatException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void shouldFailForEmptyReader() {
+ try {
+ JSON(stringAsReader(EXAMPLE_EMPTY_STRING));
+ fail("Expected IllegalArgumentException");
+ } catch(SpinDataFormatException e) {
+ // expected
+ }
+
+ try {
+ S(stringAsReader(EXAMPLE_EMPTY_STRING), json());
+ fail("Expected IllegalArgumentException");
+ } catch(SpinDataFormatException e) {
+ // expected
+ }
+
+ try {
+ S(stringAsReader(EXAMPLE_EMPTY_STRING));
+ fail("Expected IllegalArgumentException");
+ } catch(SpinDataFormatException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void shouldCreateForBoolean() {
+ SpinJsonNode node = JSON("false");
+ assertThat(node.isBoolean()).isTrue();
+ assertThat(node.isValue()).isTrue();
+ assertThat(node.boolValue()).isFalse();
+ }
+
+ @Test
+ public void shouldCreateForNumber() {
+ SpinJsonNode node = JSON("42");
+ assertThat(node.isNumber()).isTrue();
+ assertThat(node.isValue()).isTrue();
+ assertThat(node.numberValue()).isEqualTo(42);
+ }
+
+ @Test
+ public void shouldCreateForPrimitiveString() {
+ SpinJsonNode node = JSON("\"a String\"");
+ assertThat(node.isString()).isTrue();
+ assertThat(node.isValue()).isTrue();
+ assertThat(node.stringValue()).isEqualTo("a String");
+ }
+
+ @Test
+ public void shouldFailForUnescapedString() {
+ try {
+ JSON("a String");
+ fail("expected exception");
+ } catch (SpinDataFormatException e) {
+ // expected
+ }
+ }
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/tree/JsonTreeEditListPropertyScriptTest.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/tree/JsonTreeEditListPropertyScriptTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..c7700eaf13c64779da8e878129117de3073f117b
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/tree/JsonTreeEditListPropertyScriptTest.java
@@ -0,0 +1,499 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.json.tree;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.camunda.spin.json.JsonTestConstants.EXAMPLE_JSON_FILE_NAME;
+
+import org.camunda.spin.impl.test.Script;
+import org.camunda.spin.impl.test.ScriptTest;
+import org.camunda.spin.impl.test.ScriptVariable;
+import org.camunda.spin.json.SpinJsonException;
+import org.camunda.spin.json.SpinJsonPropertyException;
+import org.junit.Test;
+
+/**
+ * Index:
+ * 1) indexOf
+ * 2) lastIndexOf
+ * 3) append
+ * 4) insertAt
+ * 5) insertBefore
+ * 6) insertAfter
+ * 7) remove
+ * 8) removeLast
+ * 9) removeAt
+ *
+ * @author Stefan Hentschel
+ *
+ */
+public abstract class JsonTreeEditListPropertyScriptTest extends ScriptTest {
+
+ // ----------------- 1) indexOf ----------------------
+
+ @Test(expected = SpinJsonException.class)
+ @Script(execute = false)
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldFailReadIndexOfNonArray() throws Throwable {
+ failingWithException();
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ @Script(execute = false)
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldFailReadIndexOfWithoutSearchNode() throws Throwable {
+ failingWithException();
+ }
+
+ @Test(expected = SpinJsonException.class)
+ @Script(execute = false)
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldFailReadIndexOfNonExistentValue() throws Throwable {
+ failingWithException();
+ }
+
+ @Test
+ @Script
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldReadIndexOf() {
+ Number i = script.getVariable("value");
+
+ // Casts to int because ruby returns long instead of int values!
+ assertThat(i.intValue()).isEqualTo(1);
+ }
+
+ // ----------------- 2) lastIndexOf ----------------------
+
+ @Test(expected = SpinJsonException.class)
+ @Script(execute = false)
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldFailReadLastIndexOfNonArray() throws Throwable {
+ failingWithException();
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ @Script(execute = false)
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldFailReadLastIndexOfWithoutSearchNode() throws Throwable {
+ failingWithException();
+ }
+
+ @Test(expected = SpinJsonException.class)
+ @Script(execute = false)
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldFailReadLastIndexOfNonExistentValue() throws Throwable {
+ failingWithException();
+ }
+
+ @Test
+ @Script
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldReadLastIndexOf() {
+ Number i = script.getVariable("value");
+
+ // Casts to int because ruby returns long instead of int values!
+ assertThat(i.intValue()).isEqualTo(1);
+ }
+
+ // ----------------- 3) append ----------------------
+
+ @Test(expected = SpinJsonException.class)
+ @Script(execute = false)
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldFailAppendToNonArray() throws Throwable {
+ failingWithException();
+ }
+
+ @Test(expected = SpinJsonException.class)
+ @Script(execute = false)
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldFailAppendWrongNode() throws Throwable {
+ failingWithException();
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ @Script(execute = false)
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldFailAppendNullNode() throws Throwable {
+ failingWithException();
+ }
+
+ @Test
+ @Script
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldAppendNodeToArray() {
+ Number oldSize = script.getVariable("oldSize");
+ Number newSize = script.getVariable("newSize");
+ String value = script.getVariable("value");
+
+ // casts to int because ruby returns long instead of int values!
+ assertThat(oldSize.intValue() + 1).isEqualTo(newSize.intValue());
+ assertThat(value).isEqualTo("Testcustomer");
+ }
+
+ // ----------------- 4) insertAt ----------------------
+
+ @Test(expected = SpinJsonException.class)
+ @Script(execute = false)
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldFailInsertAtNonArray() throws Throwable {
+ failingWithException();
+ }
+
+ @Test(expected = IndexOutOfBoundsException.class)
+ @Script(execute = false)
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldFailInsertAtWithIndexOutOfBounds() throws Throwable {
+ failingWithException();
+ }
+
+ @Test(expected = IndexOutOfBoundsException.class)
+ @Script(execute = false)
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldFailInsertAtWithNegativeIndexOutOfBounds() throws Throwable {
+ failingWithException();
+ }
+
+ @Test(expected = SpinJsonException.class)
+ @Script(execute = false)
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldFailInsertAtWithWrongObject() throws Throwable {
+ failingWithException();
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ @Script(execute = false)
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldFailInsertAtWithNullObject() throws Throwable {
+ failingWithException();
+ }
+
+ @Test
+ @Script
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldInsertAtWithIndex() {
+ Number oldSize = script.getVariable("oldSize");
+ Number oldPosition = script.getVariable("oldPosition");
+ Number newSize = script.getVariable("newSize");
+ Number newPosition = script.getVariable("newPosition");
+ String value = script.getVariable("value");
+
+ // Casts to int because ruby returns long instead of int!
+ assertThat(oldSize.intValue() + 1).isEqualTo(newSize.intValue());
+ assertThat(oldPosition.intValue() + 1).isEqualTo(newPosition.intValue());
+ assertThat(value).isEqualTo("test1");
+ }
+
+ @Test
+ @Script
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldInsertAtWithNegativeIndex() {
+ Number oldSize = script.getVariable("oldSize");
+ Number oldPosition = script.getVariable("oldPosition");
+ Number newSize = script.getVariable("newSize");
+ Number newPosition = script.getVariable("newPosition");
+ String value = script.getVariable("value");
+
+ // Casts to Int because Ruby returns long values instead of int
+ assertThat(oldSize.intValue() + 1).isEqualTo(newSize.intValue());
+ assertThat(oldPosition.intValue() + 1).isEqualTo(newPosition.intValue());
+ assertThat(value).isEqualTo("test1");
+ }
+
+ // ----------------- 5) insertBefore ----------------------
+
+ @Test(expected = SpinJsonException.class)
+ @Script(execute = false)
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldFailInsertBeforeNonExistentSearchObject() throws Throwable {
+ failingWithException();
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ @Script(execute = false)
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldFailInsertBeforeWithNullAsSearchObject() throws Throwable {
+ failingWithException();
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ @Script(execute = false)
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldFailInsertNullObjectBeforeSearchObject() throws Throwable {
+ failingWithException();
+ }
+
+ @Test(expected = SpinJsonPropertyException.class)
+ @Script(execute = false)
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldFailInsertWrongObjectBeforeSearchObject() throws Throwable {
+ failingWithException();
+ }
+
+ @Test(expected = SpinJsonPropertyException.class)
+ @Script(execute = false)
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldFailInsertBeforeWrongSearchObject() throws Throwable {
+ failingWithException();
+ }
+
+ @Test(expected = SpinJsonException.class)
+ @Script(execute = false)
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldFailInsertBeforeOnNonArray() throws Throwable {
+ failingWithException();
+ }
+
+ @Test
+ @Script
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldInsertBeforeSearchObjectOnBeginning() {
+ Number oldSize = script.getVariable("oldSize");
+ Number newSize = script.getVariable("newSize");
+ String oldValue = script.getVariable("oldValue");
+ String newValue = script.getVariable("newValue");
+ String oldValueOnNewPosition = script.getVariable("oldValueOnNewPosition");
+
+ // casts to int because ruby returns long instead of int
+ assertThat(oldSize.intValue() + 1).isEqualTo(newSize.intValue());
+ assertThat(oldValue).isEqualTo("euro");
+ assertThat(oldValue).isEqualTo(oldValueOnNewPosition);
+ assertThat(newValue).isEqualTo("Test");
+ }
+
+ @Test
+ @Script
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldInsertBeforeSearchObject() {
+ Number oldSize = script.getVariable("oldSize");
+ String oldValue = script.getVariable("oldValue");
+ String oldValueOnNewPosition = script.getVariable("oldValueOnNewPosition");
+
+ Number newSize = script.getVariable("newSize");
+ String newValue = script.getVariable("newValue");
+
+ // casts to int because ruby returns long instead of int
+ assertThat(oldSize.intValue() + 1).isEqualTo(newSize.intValue());
+ assertThat(oldValue).isEqualTo("dollar");
+ assertThat(oldValue).isEqualTo(oldValueOnNewPosition);
+ assertThat(newValue).isEqualTo("Test");
+ }
+
+ // ----------------- 6) insertAfter ----------------------
+
+ @Test(expected = SpinJsonException.class)
+ @Script(execute = false)
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldFailInsertAfterNonExistentSearchObject() throws Throwable {
+ failingWithException();
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ @Script(execute = false)
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldFailInsertAfterWithNullAsSearchObject() throws Throwable {
+ failingWithException();
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ @Script(execute = false)
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldFailInsertNullObjectAfterSearchObject() throws Throwable {
+ failingWithException();
+ }
+
+ @Test(expected = SpinJsonException.class)
+ @Script(execute = false)
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldFailInsertWrongObjectAfterSearchObject() throws Throwable {
+ failingWithException();
+ }
+
+ @Test(expected = SpinJsonException.class)
+ @Script(execute = false)
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldFailInsertAfterOnNonArray() throws Throwable {
+ failingWithException();
+ }
+
+ @Test(expected = SpinJsonPropertyException.class)
+ @Script(execute = false)
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldFailInsertAfterWrongSearchObject() throws Throwable {
+ failingWithException();
+ }
+
+ @Test
+ @Script
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldInsertAfterSearchObjectOnEnding() {
+ Number oldSize = script.getVariable("oldSize");
+ Number newSize = script.getVariable("newSize");
+ String oldValue = script.getVariable("oldValue");
+ String newValue = script.getVariable("newValue");
+ String oldValueOnNewPosition = script.getVariable("oldValueOnNewPosition");
+
+ // casts to int because ruby returns long instead of int
+ assertThat(oldSize.intValue() + 1).isEqualTo(newSize.intValue());
+ assertThat(oldValue).isEqualTo("dollar");
+ assertThat(oldValue).isEqualTo(oldValueOnNewPosition);
+ assertThat(newValue).isEqualTo("Test");
+ }
+
+ // ----------------- 7) remove ----------------------
+
+ @Test(expected = SpinJsonPropertyException.class)
+ @Script(execute = false)
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldFailRemoveNonExistentObject() throws Throwable {
+ failingWithException();
+ }
+
+ @Test(expected = SpinJsonException.class)
+ @Script(execute = false)
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldFailRemoveNonArray() throws Throwable {
+ failingWithException();
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ @Script(execute = false)
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldFailRemoveNullObject() throws Throwable {
+ failingWithException();
+ }
+
+ @Test(expected = SpinJsonPropertyException.class)
+ @Script(execute = false)
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldFailRemoveWrongObject() throws Throwable {
+ failingWithException();
+ }
+
+ @Test
+ @Script
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldRemoveObject() {
+ Number oldSize = script.getVariable("oldSize");
+ String oldValue = script.getVariable("oldValue");
+ Number newSize = script.getVariable("newSize");
+ String newValue = script.getVariable("newValue");
+
+ assertThat(oldValue.equals(newValue)).isFalse();
+
+ // Casts to int because ruby returns long instead of int values!
+ assertThat(oldSize.intValue() - 1).isEqualTo(newSize.intValue());
+ }
+
+ // ----------------- 8) removeLast ----------------------
+
+ @Test(expected = IllegalArgumentException.class)
+ @Script(execute = false)
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldFailRemoveLastNullObject() throws Throwable {
+ failingWithException();
+ }
+
+ @Test(expected = SpinJsonPropertyException.class)
+ @Script(execute = false)
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldFailRemoveLastWrongObject() throws Throwable {
+ failingWithException();
+ }
+
+ @Test(expected = SpinJsonException.class)
+ @Script(execute = false)
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldFailRemoveLastNonArray() throws Throwable {
+ failingWithException();
+ }
+
+ @Test(expected = SpinJsonPropertyException.class)
+ @Script(execute = false)
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldFailRemoveLastNonExistentObject() throws Throwable {
+ failingWithException();
+ }
+
+ @Test
+ @Script
+ @ScriptVariable(name = "input", value = "[\"test\",\"test\",\"new value\",\"test\"]")
+ public void shouldRemoveLast() {
+ Number oldSize = script.getVariable("oldSize");
+ Number newSize = script.getVariable("newSize");
+ String oldValue = script.getVariable("oldValue");
+ String value = script.getVariable("newValue");
+
+ // casts to int because ruby returns long instead of int
+ assertThat(oldSize.intValue() - 1).isEqualTo(newSize.intValue());
+ assertThat(oldValue).isEqualTo("test");
+ assertThat(value).isEqualTo("new value");
+ }
+
+ // ----------------- 9) removeAt ----------------------
+
+ @Test(expected = SpinJsonException.class)
+ @Script(execute = false)
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldFailRemoveAtNonArray() throws Throwable {
+ failingWithException();
+ }
+
+ @Test(expected = IndexOutOfBoundsException.class)
+ @Script(execute = false)
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldFailRemoveAtWithIndexOutOfBounds() throws Throwable {
+ failingWithException();
+ }
+
+ @Test(expected = IndexOutOfBoundsException.class)
+ @Script(execute = false)
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldFailRemoveAtWithNegativeIndexOutOfBounds() throws Throwable {
+ failingWithException();
+ }
+
+ @Test
+ @Script
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldRemoveAtWithIndex() {
+ Number oldSize = script.getVariable("oldSize");
+ Number newSize = script.getVariable("newSize");
+ String value = script.getVariable("value");
+
+
+ // casts to int because ruby returns long instead of int
+ assertThat(newSize.intValue()).isEqualTo(1);
+ assertThat(oldSize.intValue() - 1).isEqualTo(newSize.intValue());
+ assertThat(value).isEqualTo("euro");
+ }
+
+ @Test
+ @Script
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldRemoveAtWithNegativeIndex() {
+ Number oldSize = script.getVariable("oldSize");
+ Number newSize = script.getVariable("newSize");
+ String value = script.getVariable("value");
+
+ // casts to int because ruby returns long instead of int
+ assertThat(newSize.intValue()).isEqualTo(1);
+ assertThat(oldSize.intValue() - 1).isEqualTo(newSize.intValue());
+ assertThat(value).isEqualTo("dollar");
+ }
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/tree/JsonTreeEditListPropertyTest.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/tree/JsonTreeEditListPropertyTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..f8dd2b0bd43b714d424bf964d6e15c8de0d47264
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/tree/JsonTreeEditListPropertyTest.java
@@ -0,0 +1,639 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.json.tree;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.fail;
+import static org.camunda.spin.Spin.JSON;
+import static org.camunda.spin.json.JsonTestConstants.EXAMPLE_JSON;
+
+import java.util.Date;
+
+import org.camunda.spin.json.SpinJsonException;
+import org.camunda.spin.json.SpinJsonNode;
+import org.camunda.spin.json.SpinJsonPropertyException;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Index:
+ * 1) indexOf
+ * 2) lastIndexOf
+ * 3) append
+ * 4) insertAt
+ * 5) insertBefore
+ * 6) insertAfter
+ * 7) remove
+ * 8) removeLast
+ * 9) removeAt
+ * 10) contains
+ *
+ * @author Stefan Hentschel
+ */
+public class JsonTreeEditListPropertyTest {
+
+ protected SpinJsonNode jsonNode;
+ protected SpinJsonNode customers;
+ protected SpinJsonNode currencies;
+
+ @Before
+ public void readJson() {
+ jsonNode = JSON(EXAMPLE_JSON);
+ customers = jsonNode.prop("customers");
+ currencies = jsonNode.prop("orderDetails").prop("currencies");
+ }
+
+ // ----------------- 1) indexOf ----------------------
+
+ @Test
+ public void readIndexOfNonArray() {
+ try {
+ jsonNode.indexOf("n");
+ fail("Expected: SpinJsonTreeNodeException");
+ } catch(SpinJsonException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void readIndexOfWithoutSearchNode() {
+ try {
+ jsonNode.indexOf(null);
+ fail("Expected: IllegalArgumentException");
+ } catch(IllegalArgumentException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void readIndexOfNonExistentValue() {
+ try {
+ customers.indexOf("n");
+ fail("Expected: SpinJsonTreeNodeException");
+ } catch(SpinJsonException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void readIndexOfExistentValue() {
+ Integer i = currencies.indexOf("euro");
+
+ assertThat(i).isEqualTo(0);
+ }
+
+ // ----------------- 2) lastIndexOf ----------------------
+
+ @Test
+ public void readLastIndexOfNonArray() {
+ try {
+ jsonNode.lastIndexOf("n");
+ fail("Expected: SpinJsonTreeNodeException");
+ } catch(SpinJsonException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void readLastIndexOfWithoutSearchNode() {
+ try {
+ jsonNode.lastIndexOf(null);
+ fail("Expected: IllegalArgumentException");
+ } catch(IllegalArgumentException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void readLastIndexOfNonExistentValue() {
+ try {
+ customers.lastIndexOf("n");
+ fail("Expected: SpinJsonTreeNodeException");
+ } catch(SpinJsonException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void readLastIndexOfExistentValue() {
+ Integer i = currencies.lastIndexOf("dollar");
+
+ assertThat(i).isEqualTo(1);
+ }
+
+ // ----------------- 3) append ----------------------
+
+ @Test
+ public void appendNodeToArray() {
+ Integer oldSize = customers.elements().size();
+ customers.append("Testcustomer");
+ Integer newSize = customers.elements().size();
+
+ assertThat(oldSize).isNotEqualTo(newSize);
+ assertThat(oldSize + 1).isEqualTo(newSize);
+ assertThat(customers.elements().get(oldSize).isString()).isTrue();
+ assertThat(customers.elements().get(oldSize).stringValue()).isEqualTo("Testcustomer");
+ }
+
+ @Test
+ public void appendNodeToNonArray() {
+ try {
+ jsonNode.append("testcustomer");
+ fail("Expected: SpinJsonTreeNodeException");
+ } catch(SpinJsonException e) {
+ //expected
+ }
+ }
+
+ @Test
+ public void appendWrongNode() {
+ try {
+ jsonNode.append(new Date());
+ fail("Expected: SpinJsonTreeNodeException");
+ } catch(SpinJsonException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void appendNullNode() {
+ try {
+ jsonNode.append(null);
+ fail("Expected: IllegalArgumentException");
+ } catch(IllegalArgumentException e) {
+ // expected
+ }
+ }
+
+ // ----------------- 4) insertAt ----------------------
+
+ @Test
+ public void insertAtWithIndex() {
+ Integer oldSize = currencies.elements().size();
+ Integer oldPosition = currencies.indexOf("dollar");
+ SpinJsonNode oldNode = currencies.elements().get(1);
+
+ currencies.insertAt(1, "test1");
+
+ Integer newSize = currencies.elements().size();
+ Integer newPosition = currencies.indexOf("dollar");
+ SpinJsonNode newNode = currencies.elements().get(1);
+
+ assertThat(oldSize + 1).isEqualTo(newSize);
+ assertThat(newNode.equals(oldNode)).isFalse();
+ assertThat(newNode.stringValue()).isEqualTo("test1");
+ assertThat(oldPosition + 1).isEqualTo(newPosition);
+ }
+
+ @Test
+ public void insertAtNonArray() {
+ try {
+ jsonNode.insertAt(1, "test");
+ fail("Expected: SpinJsonTreeNodeException");
+ } catch(SpinJsonException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void insertAtWithNegativeIndex() {
+ Integer oldSize = currencies.elements().size();
+ Integer oldPosition = currencies.indexOf("dollar");
+ SpinJsonNode oldNode = currencies.elements().get(0);
+
+ currencies.insertAt(-2, "test1");
+
+ Integer newSize = currencies.elements().size();
+ Integer newPosition = currencies.indexOf("dollar");
+ SpinJsonNode newNode = currencies.elements().get(0);
+
+ assertThat(oldSize + 1).isEqualTo(newSize);
+ assertThat(newNode.equals(oldNode)).isFalse();
+ assertThat(newNode.stringValue()).isEqualTo("test1");
+ assertThat(oldPosition + 1).isEqualTo(newPosition);
+ }
+
+ @Test
+ public void insertAtWithIndexOutOfBounds() {
+ try {
+ currencies.insertAt(6, "string");
+ fail("Expected: IndexOutOfBoundsException");
+ } catch(IndexOutOfBoundsException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void insertAtWithNegativeIndexOutOfBounds() {
+ try {
+ currencies.insertAt(-6, "string");
+ fail("Expected: IndexOutOfBoundsException");
+ } catch(IndexOutOfBoundsException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void insertAtWithWrongObject() {
+ try {
+ currencies.insertAt(1, new Date());
+ fail("Expected: SpinJsonTreeNodeException");
+ } catch(SpinJsonException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void insertAtWithNullObject() {
+ try {
+ currencies.insertAt(1, null);
+ fail("Expected: IllegalArgumentException");
+ } catch(IllegalArgumentException e) {
+ // expected
+ }
+ }
+
+ // ----------------- 5) insertBefore ----------------------
+
+ @Test
+ public void insertBeforeNonExistentSearchObject() {
+ try {
+ currencies.insertBefore(1, "test");
+ fail("Expected: SpinJsonTreePropertyException");
+ } catch(SpinJsonPropertyException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void insertBeforeWithNullAsSearchObject() {
+ try {
+ currencies.insertBefore(null, "test");
+ fail("Expected: IllegalArgumentException");
+ } catch(IllegalArgumentException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void insertBeforeSearchObjectOnBeginning() {
+ SpinJsonNode oldNode = currencies.elements().get(0);
+ Integer size = currencies.elements().size();
+
+ currencies.insertBefore("euro", "Test");
+
+ SpinJsonNode newNode = currencies.elements().get(0);
+ SpinJsonNode oldNodeNewPosition = currencies.elements().get(1);
+ Integer newSize = currencies.elements().size();
+
+ assertThat(oldNode.equals(newNode)).isFalse();
+ assertThat(newNode.stringValue()).isEqualTo("Test");
+ assertThat(oldNode.stringValue()).isEqualTo(oldNodeNewPosition.stringValue());
+ assertThat(size).isNotEqualTo(newSize);
+ }
+
+ @Test
+ public void insertBeforeSearchObject() {
+ SpinJsonNode oldNode = currencies.elements().get(1);
+ Integer size = currencies.elements().size();
+
+ currencies.insertBefore("dollar", "Test");
+
+ SpinJsonNode newNode = currencies.elements().get(1);
+ SpinJsonNode oldNodeNewPosition = currencies.elements().get(2);
+ Integer newSize = currencies.elements().size();
+
+ assertThat(oldNode).isNotEqualTo(newNode);
+ assertThat(newNode.stringValue()).isEqualTo("Test");
+ assertThat(oldNode.stringValue()).isEqualTo(oldNodeNewPosition.stringValue());
+ assertThat(size).isNotEqualTo(newSize);
+ }
+
+ @Test
+ public void insertNullObjectBeforeSearchObject() {
+ try {
+ currencies.insertBefore("euro", null);
+ fail("Expected: IllegalArgumentException");
+ } catch(IllegalArgumentException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void insertWrongObjectBeforeSearchObject() {
+ try {
+ currencies.insertBefore("euro", new Date());
+ fail("Expected: SpinJsonTreePropertyException");
+ } catch(SpinJsonPropertyException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void insertObjectBeforeWrongSearchObject() {
+ try {
+ currencies.insertBefore(new Date(), "test");
+ fail("Expected: SpinJsonTreePropertyException");
+ } catch (SpinJsonPropertyException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void insertBeforeOnNonArray() {
+ try {
+ jsonNode.insertBefore("test", "test");
+ fail("Expected: SpinJsonTreeNodeException");
+ } catch (SpinJsonException e) {
+ // expected
+ }
+ }
+
+ // ----------------- 6) insertAfter ----------------------
+
+ @Test
+ public void insertAfterNonExistentSearchObject() {
+ try {
+ currencies.insertBefore("test", "test");
+ fail("Expected: SpinJsonTreeNodeException");
+ } catch (SpinJsonException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void insertAfterSearchObjectOnEnding() {
+ SpinJsonNode oldNode = currencies.elements().get(1);
+ Integer size = currencies.elements().size();
+
+ currencies.insertAfter("dollar", "Test");
+
+ SpinJsonNode newNode = currencies.elements().get(2);
+ SpinJsonNode oldNodeNewPosition = currencies.elements().get(1);
+ Integer newSize = currencies.elements().size();
+
+ assertThat(oldNode.equals(newNode)).isFalse();
+ assertThat(oldNode.stringValue()).isEqualTo(oldNodeNewPosition.stringValue());
+ assertThat(size).isNotEqualTo(newSize);
+ }
+
+ @Test
+ public void insertAfterSearchObject() {
+ SpinJsonNode oldNode = currencies.elements().get(0);
+ Integer size = currencies.elements().size();
+
+ currencies.insertAfter("dollar", "Test");
+
+ SpinJsonNode newNode = currencies.elements().get(1);
+ SpinJsonNode oldNodeNewPosition = currencies.elements().get(0);
+ Integer newSize = currencies.elements().size();
+
+ assertThat(oldNode.equals(newNode)).isFalse();
+ assertThat(oldNode.stringValue()).isEqualTo(oldNodeNewPosition.stringValue());
+ assertThat(size).isNotEqualTo(newSize);
+ }
+
+ @Test
+ public void insertNullObjectAfterSearchObject() {
+ try {
+ currencies.insertBefore("euro", null);
+ fail("Expected: IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void insertWrongObjectAfterSearchObject() {
+ try {
+ currencies.insertBefore("euro", new Date());
+ fail("Expected: SpinJsonTreeNodeException");
+ } catch (SpinJsonException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void insertAfterOnNonArray() {
+ try {
+ jsonNode.insertBefore("euro", "test");
+ fail("Expected: SpinJsonTreeNodeException");
+ } catch (SpinJsonException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void insertObjectAfterWrongSearchObject() {
+ try {
+ currencies.insertAfter(new Date(), "test");
+ fail("Expected: SpinJsonTreePropertyException");
+ } catch (SpinJsonPropertyException e) {
+ // expected
+ }
+ }
+
+ // ----------------- 7) remove ----------------------
+
+ @Test
+ public void removeObject() {
+ Integer oldSize = currencies.elements().size();
+
+ currencies.remove("euro");
+
+ Integer newSize = currencies.elements().size();
+ SpinJsonNode node = currencies.elements().get(0);
+
+ assertThat(oldSize).isNotEqualTo(newSize);
+ assertThat(oldSize - 1).isEqualTo(newSize);
+ assertThat(node.stringValue()).isEqualTo("dollar");
+ }
+
+ @Test
+ public void removeNonExistentObject() {
+ try {
+ currencies.remove("test");
+ fail("Expected: SpinJsonTreePropertyException");
+ } catch(SpinJsonException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void removeObjectInNonExistentArray() {
+ try {
+ jsonNode.remove("test");
+ fail("Expected: SpinJsonTreePropertyException");
+ } catch(SpinJsonException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void removeNullObject() {
+ try {
+ jsonNode.remove(null);
+ fail("Expected: IllegalArgumentException");
+ } catch(IllegalArgumentException e) {
+ // expected
+ }
+ }
+
+ // ----------------- 8) removeLast ----------------------
+
+ @Test
+ public void removeLastNullObject() {
+ try {
+ currencies.removeLast(null);
+ fail("Expected: IllegalArgumentException");
+ } catch(IllegalArgumentException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void removeLastWrongObject() {
+ try {
+ currencies.removeLast(new Date());
+ fail("Expected: SpinJsonTreeNodeException");
+ } catch(SpinJsonException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void removeLast() {
+ String testJson = "[\"test\",\"test\",\"new value\",\"test\"]";
+ SpinJsonNode testNode = JSON(testJson);
+ Integer size = testNode.elements().size();
+
+ testNode.removeLast("test");
+
+ Integer newSize = testNode.elements().size();
+ SpinJsonNode node = testNode.elements().get(newSize - 1);
+
+ assertThat(newSize).isNotEqualTo(size);
+ assertThat(newSize + 1).isEqualTo(size);
+ assertThat(node.stringValue()).isEqualTo("new value");
+ }
+
+ @Test
+ public void removeLastNonExistentArray() {
+ try {
+ jsonNode.removeLast(1);
+ fail("Expected: SpinJsonTreeNodeException ");
+ } catch(SpinJsonException e) {
+ // expected
+ }
+ }
+
+ // ----------------- 9) removeAt ----------------------
+
+ @Test
+ public void removeAtWithIndex() {
+ Integer oldSize = currencies.elements().size();
+
+ currencies.removeAt(1);
+
+ Integer newSize = currencies.elements().size();
+ SpinJsonNode node = currencies.elements().get(newSize - 1);
+
+ assertThat(newSize).isEqualTo(1);
+ assertThat(newSize + 1).isEqualTo(oldSize);
+ assertThat(node.stringValue()).isEqualTo("euro");
+ }
+
+ @Test
+ public void removeAtNonArray() {
+ try {
+ jsonNode.removeAt(1);
+ fail("Expected: SpinJsonTreeNodeException");
+ } catch(SpinJsonException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void removeAtWithNegativeIndex() {
+ Integer oldSize = currencies.elements().size();
+
+ currencies.removeAt(-2);
+
+ Integer newSize = currencies.elements().size();
+ SpinJsonNode node = currencies.elements().get(newSize - 1);
+
+ assertThat(newSize).isEqualTo(1);
+ assertThat(newSize + 1).isEqualTo(oldSize);
+ assertThat(node.stringValue()).isEqualTo("dollar");
+ }
+
+ @Test
+ public void removeAtWithIndexOutOfBounds() {
+ try {
+ currencies.removeAt(6);
+ fail("Expected: IndexOutOfBoundsException");
+ } catch(IndexOutOfBoundsException e){
+ // expected
+ }
+ }
+
+ @Test
+ public void removeAtWithNegativeIndexOutOfBounds() {
+ try {
+ currencies.removeAt(-6);
+ fail("Expected: IndexOutOfBoundsException");
+ } catch(IndexOutOfBoundsException e){
+ // expected
+ }
+ }
+
+ // ----------------- 10) contains ----------------------
+
+ @Test
+ public void containsOfNonArray() {
+ try {
+ jsonNode.contains("n");
+ fail("Expected: SpinJsonTreeNodeException");
+ } catch(SpinJsonException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void containsWithoutSearchNode() {
+ try {
+ jsonNode.contains(null);
+ fail("Expected: IllegalArgumentException");
+ } catch(IllegalArgumentException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void containsNonExistentValue() {
+ boolean res = customers.contains("n");
+
+ assertThat(res).isFalse();
+ }
+
+ @Test
+ public void containsOfExistentValue() {
+ boolean res = currencies.contains("euro");
+
+ assertThat(res).isTrue();
+ }
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/tree/JsonTreeJsonPathScriptTest.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/tree/JsonTreeJsonPathScriptTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..d3b23d610ae69d570ea03ec192d4137fd4a121ae
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/tree/JsonTreeJsonPathScriptTest.java
@@ -0,0 +1,175 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.json.tree;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.camunda.spin.json.JsonTestConstants.EXAMPLE_JSON_FILE_NAME;
+
+import org.camunda.spin.SpinList;
+import org.camunda.spin.impl.test.Script;
+import org.camunda.spin.impl.test.ScriptTest;
+import org.camunda.spin.impl.test.ScriptVariable;
+import org.camunda.spin.json.SpinJsonDataFormatException;
+import org.camunda.spin.json.SpinJsonNode;
+import org.camunda.spin.json.SpinJsonPathException;
+import org.junit.Test;
+
+/**
+ * @author Thorben Lindhauer
+ *
+ */
+public abstract class JsonTreeJsonPathScriptTest extends ScriptTest {
+
+ @Test
+ @Script
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldGetElementFromJsonPath() {
+ SpinJsonNode node = script.getVariable("node");
+
+ assertThat(node.isObject()).isTrue();
+ assertThat(node.prop("article").isString()).isTrue();
+ }
+
+ @Test
+ @Script
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldGetElementListFromJsonPath() {
+ SpinList nodeList = script.getVariable("nodeList");
+
+ assertThat(nodeList).hasSize(3);
+ assertThat(nodeList.get(0).isObject()).isTrue();
+ assertThat(nodeList.get(0).prop("name").isString()).isTrue();
+ }
+
+ @Test
+ @Script
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldGetBooleanFromJsonPath() {
+ Boolean bool = script.getVariable("booleanValue");
+
+ assertThat(bool).isTrue();
+ }
+
+ @Test
+ @Script
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldGetStringFromJsonPath() {
+ String string = script.getVariable("stringValue");
+
+ assertThat(string).isEqualTo("order1");
+ }
+
+ @Test
+ @Script
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldGetNumberFromJsonPath() {
+ Number number = script.getVariable("numberValue");
+
+ assertThat(number.doubleValue()).isEqualTo(1234567.13d);
+ }
+
+ @Test
+ @Script
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldGetSingleArrayEntry() {
+ SpinJsonNode node = script.getVariable("node");
+
+ assertThat(node.isObject());
+ assertThat(node.prop("name").isString());
+ assertThat(node.prop("name").stringValue()).isEqualTo("Kermit");
+ }
+
+ @Test
+ @Script
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldGetMultipleArrayEntries() {
+ SpinList nodeList = script.getVariable("nodeList");
+
+ assertThat(nodeList).hasSize(2);
+ assertThat(nodeList.get(0).prop("name").stringValue()).isEqualTo("Kermit");
+ assertThat(nodeList.get(1).prop("name").stringValue()).isEqualTo("Waldo");
+ }
+
+ @Test
+ @Script
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldGetFilteredResult() {
+ SpinList nodeList = script.getVariable("emptyList");
+
+ assertThat(nodeList.size()).isEqualTo(0);
+
+ SpinList nodeList2 = script.getVariable("nodeList");
+
+ assertThat(nodeList2.size()).isEqualTo(1);
+ assertThat(nodeList2.get(0).prop("name").stringValue()).isEqualTo("Waldo");
+ }
+
+ @Test
+ @Script
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void souldGetMultipleArrayPropertyValues() {
+ SpinList nodeList = script.getVariable("nodeList");
+
+ assertThat(nodeList).hasSize(3);
+ assertThat(nodeList.get(0).stringValue()).isEqualTo("Kermit");
+ assertThat(nodeList.get(1).stringValue()).isEqualTo("Waldo");
+ assertThat(nodeList.get(2).stringValue()).isEqualTo("Johnny");
+ }
+
+ @Test(expected = SpinJsonPathException.class)
+ @Script(execute = false)
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldFailReadingJsonPath() throws Throwable{
+ failingWithException();
+ }
+
+ @Test(expected = SpinJsonPathException.class)
+ @Script(execute = false)
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldFailAccessNonExistentProperty() throws Throwable{
+ failingWithException();
+ }
+
+ @Test(expected = SpinJsonDataFormatException.class)
+ @Script(execute = false)
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldFailReadingElementList() throws Throwable{
+ failingWithException();
+ }
+
+ @Test(expected = SpinJsonDataFormatException.class)
+ @Script(execute = false)
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldFailReadingString() throws Throwable{
+ failingWithException();
+ }
+
+ @Test(expected = SpinJsonDataFormatException.class)
+ @Script(execute = false)
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldFailReadingNumber() throws Throwable{
+ failingWithException();
+ }
+
+ @Test(expected = SpinJsonDataFormatException.class)
+ @Script(execute = false)
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldFailReadingBoolean() throws Throwable{
+ failingWithException();
+ }
+}
+
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/tree/JsonTreeJsonPathTest.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/tree/JsonTreeJsonPathTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..4ec1d9b4eed6acb9d34c45e57aa585f9049d9279
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/tree/JsonTreeJsonPathTest.java
@@ -0,0 +1,284 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.json.tree;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.fail;
+import static org.camunda.spin.Spin.JSON;
+import static org.camunda.spin.json.JsonTestConstants.EXAMPLE_JSON;
+
+import org.camunda.spin.SpinList;
+import org.camunda.spin.json.SpinJsonDataFormatException;
+import org.camunda.spin.json.SpinJsonNode;
+import org.camunda.spin.json.SpinJsonPathException;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @author Stefan Hentschel
+ */
+public class JsonTreeJsonPathTest {
+
+ protected SpinJsonNode jsonNode;
+
+ @Before
+ public void readJson() {
+ jsonNode = JSON(EXAMPLE_JSON);
+ }
+
+ @Test
+ public void shouldGetElementFromJsonPath() {
+ SpinJsonNode node = jsonNode.jsonPath("$.orderDetails").element();
+
+ assertThat(node.isObject()).isTrue();
+ assertThat(node.prop("article").isString()).isTrue();
+ }
+
+ @Test
+ public void shouldGetElementListFromJsonPath() {
+ SpinList node = jsonNode.jsonPath("$.customers").elementList();
+
+ assertThat(node).hasSize(3);
+ assertThat(node.get(0).isObject()).isTrue();
+ assertThat(node.get(0).prop("name").isString()).isTrue();
+ }
+
+ @Test
+ public void shouldGetBooleanFromJsonPath() {
+ Boolean active = jsonNode.jsonPath("$.active").boolValue();
+
+ assertThat(active).isTrue();
+ }
+
+ @Test
+ public void shouldGetStringFromJsonPath() {
+ String order = jsonNode.jsonPath("$.order").stringValue();
+
+ assertThat(order).isEqualTo("order1");
+ }
+
+ @Test
+ public void shouldGetNumberFromJsonPath() {
+ Number order = jsonNode.jsonPath("$.id").numberValue();
+
+ assertThat(order.longValue()).isEqualTo(1234567890987654321L);
+ }
+
+ @Test
+ public void shouldGetNullNode() {
+ SpinJsonNode node = jsonNode.jsonPath("$.nullValue").element();
+ assertThat(node.isNull()).isTrue();
+ }
+
+ @Test
+ public void shouldGetSingleArrayEntry() {
+ SpinJsonNode node = jsonNode.jsonPath("$.customers[0]").element();
+
+ assertThat(node.isObject());
+ assertThat(node.prop("name").isString());
+ assertThat(node.prop("name").stringValue()).isEqualTo("Kermit");
+ }
+
+ @Test
+ public void shouldGetMultipleArrayEntries() {
+ SpinList nodeList = jsonNode.jsonPath("$.customers[0:2]").elementList();
+
+ assertThat(nodeList).hasSize(2);
+ assertThat(nodeList.get(0).prop("name").stringValue()).isEqualTo("Kermit");
+ assertThat(nodeList.get(1).prop("name").stringValue()).isEqualTo("Waldo");
+ }
+
+ @Test
+ public void shouldGetFilteredResult() {
+ SpinList nodeList = jsonNode.jsonPath("$.customers[?(@.name == 'Klo')]").elementList();
+
+ assertThat(nodeList.size()).isEqualTo(0);
+
+ nodeList = jsonNode.jsonPath("$.customers[?(@.name == 'Waldo')]").elementList();
+
+ assertThat(nodeList.size()).isEqualTo(1);
+ assertThat(nodeList.get(0).prop("name").stringValue()).isEqualTo("Waldo");
+ }
+
+ @Test
+ public void shouldGetMultipleArrayPropertyValues() {
+ SpinList nodeList = jsonNode.jsonPath("$.customers[*].name").elementList();
+
+ assertThat(nodeList).hasSize(3);
+ assertThat(nodeList.get(0).stringValue()).isEqualTo("Kermit");
+ assertThat(nodeList.get(1).stringValue()).isEqualTo("Waldo");
+ assertThat(nodeList.get(2).stringValue()).isEqualTo("Johnny");
+ }
+
+ @Test
+ public void failReadingJsonPath() {
+ try {
+ jsonNode.jsonPath("$.....").element();
+ fail("Expected: SpinJsonTreePathException");
+ } catch(SpinJsonPathException ex) {
+ // expected
+ }
+
+ try {
+ jsonNode.jsonPath("").element();
+ fail("Expected: SpinJsonTreePathException");
+ } catch(SpinJsonPathException ex) {
+ // expected
+ }
+ }
+
+ @Test
+ public void failAccessNonExistentProperty() {
+ try {
+ jsonNode.jsonPath("$.order.test").element();
+ fail("Expected: SpinJsonDataFormatException");
+ } catch(SpinJsonPathException ex) {
+ // expected
+ }
+ }
+
+ @Test
+ public void failReadingElementList() {
+ try {
+ jsonNode.jsonPath("$.order").elementList();
+ fail("Expected: SpinJsonDataFormatException");
+ } catch(SpinJsonDataFormatException ex) {
+ // expected
+ }
+
+ try {
+ jsonNode.jsonPath("$.id").elementList();
+ fail("Expected: SpinJsonDataFormatException");
+ } catch(SpinJsonDataFormatException ex) {
+ // expected
+ }
+
+ try {
+ jsonNode.jsonPath("$.active").elementList();
+ fail("Expected: SpinJsonDataFormatException");
+ } catch(SpinJsonDataFormatException ex) {
+ // expected
+ }
+
+ try {
+ jsonNode.jsonPath("$").elementList();
+ fail("Expected: SpinJsonDataFormatException");
+ } catch(SpinJsonDataFormatException ex) {
+ // expected
+ }
+ }
+
+ @Test
+ public void failReadingStringProperty() {
+ try {
+ jsonNode.jsonPath("$.customers").stringValue();
+ fail("Expected: SpinJsonDataFormatException");
+ } catch(SpinJsonDataFormatException ex) {
+ // expected
+ }
+
+ try {
+ jsonNode.jsonPath("$.active").stringValue();
+ fail("Expected: SpinJsonDataFormatException");
+ } catch(SpinJsonDataFormatException ex) {
+ // expected
+ }
+
+ try {
+ jsonNode.jsonPath("$.id").stringValue();
+ fail("Expected: SpinJsonDataFormatException");
+ } catch(SpinJsonDataFormatException ex) {
+ // expected
+ }
+
+ try {
+ jsonNode.jsonPath("$").stringValue();
+ fail("Expected: SpinJsonDataFormatException");
+ } catch(SpinJsonDataFormatException ex) {
+ // expected
+ }
+ }
+
+ @Test
+ public void failReadingNumberProperty() {
+ try {
+ jsonNode.jsonPath("$.customers").numberValue();
+ fail("Expected: SpinJsonDataFormatException");
+ } catch (SpinJsonDataFormatException ex) {
+ // expected
+ }
+
+ try {
+ jsonNode.jsonPath("$.active").numberValue();
+ fail("Expected: SpinJsonDataFormatException");
+ } catch (SpinJsonDataFormatException ex) {
+ // expected
+ }
+
+ try {
+ jsonNode.jsonPath("$.order").numberValue();
+ fail("Expected: SpinJsonDataFormatException");
+ } catch (SpinJsonDataFormatException ex) {
+ // expected
+ }
+
+ try {
+ jsonNode.jsonPath("$").numberValue();
+ fail("Expected: SpinJsonDataFormatException");
+ } catch (SpinJsonDataFormatException ex) {
+ // expected
+ }
+ }
+
+ @Test
+ public void failReadingBooleanProperty() {
+ try {
+ jsonNode.jsonPath("$.customers").boolValue();
+ fail("Expected: SpinJsonDataFormatException");
+ } catch (SpinJsonDataFormatException ex) {
+ // expected
+ }
+
+ try {
+ jsonNode.jsonPath("$.id").boolValue();
+ fail("Expected: SpinJsonDataFormatException");
+ } catch (SpinJsonDataFormatException ex) {
+ // expected
+ }
+
+ try {
+ jsonNode.jsonPath("$.order").boolValue();
+ fail("Expected: SpinJsonDataFormatException");
+ } catch (SpinJsonDataFormatException ex) {
+ // expected
+ }
+
+ try {
+ jsonNode.jsonPath("$").boolValue();
+ fail("Expected: SpinJsonDataFormatException");
+ } catch (SpinJsonDataFormatException ex) {
+ // expected
+ }
+ }
+
+ @Test(expected = SpinJsonPathException.class)
+ public void failOnNonExistingJsonPath() {
+ SpinJsonNode json = JSON("{\"a\": {\"id\": \"a\"}, \"b\": {\"id\": \"b\"}}");
+ json.jsonPath("$.c?(@.id)").element();
+ }
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/tree/JsonTreeMapJavaToJsonTest.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/tree/JsonTreeMapJavaToJsonTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..7b4bd139c3ac3b18b560c56ffea310b3d215f39c
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/tree/JsonTreeMapJavaToJsonTest.java
@@ -0,0 +1,130 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.json.tree;
+
+import static net.javacrumbs.jsonunit.fluent.JsonFluentAssert.assertThatJson;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.fail;
+import static org.camunda.spin.Spin.JSON;
+import static org.camunda.spin.json.JsonTestConstants.EXAMPLE_JSON;
+import static org.camunda.spin.json.JsonTestConstants.createExampleOrder;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.camunda.spin.SpinList;
+import org.camunda.spin.json.SpinJsonNode;
+import org.camunda.spin.json.mapping.Order;
+import org.junit.Test;
+
+public class JsonTreeMapJavaToJsonTest {
+
+ @Test
+ public void shouldMapJavaObjectToJson() {
+ Order exampleOrder = createExampleOrder();
+
+ String json = JSON(exampleOrder).toString();
+
+ assertThatJson(json).isEqualTo(EXAMPLE_JSON);
+ }
+
+ @Test
+ public void shouldMapListToJson() {
+ List names = new ArrayList();
+ names.add("Waldo");
+ names.add("Hugo");
+ names.add("Kermit");
+
+ String json = JSON(names).toString();
+
+ String expectedJson = "[\"Waldo\", \"Hugo\", \"Kermit\"]";
+ assertThatJson(json).isEqualTo(expectedJson);
+ }
+
+ @Test
+ public void shouldMapArrayToJson() {
+ String[] names = new String[] { "Waldo", "Hugo", "Kermit" };
+
+ String json = JSON(names).toString();
+
+ String expectedJson = "[\"Waldo\", \"Hugo\", \"Kermit\"]";
+ assertThatJson(json).isEqualTo(expectedJson);
+ }
+
+ @Test
+ public void shouldMapMapToJson() {
+ Map javaMap = new HashMap();
+ javaMap.put("aKey", "aValue");
+ javaMap.put("anotherKey", 42);
+
+ String json = JSON(javaMap).toString();
+
+ String expectedJson = "{\"aKey\" : \"aValue\", \"anotherKey\" : 42}";
+ assertThatJson(json).isEqualTo(expectedJson);
+ }
+
+ @Test
+ public void shouldFailWithNull() {
+ try {
+ JSON(null).toString();
+ fail("expected exception");
+ } catch (IllegalArgumentException e) {
+ // happy path
+ }
+ }
+
+ @Test
+ public void shouldMapPrimitiveBooleanToJson() {
+ SpinJsonNode node = JSON(true);
+ assertThat(node.isBoolean()).isTrue();
+ assertThat(node.isValue()).isTrue();
+ assertThat(node.boolValue()).isTrue();
+ }
+
+ @Test
+ public void shouldMapPrimitiveNumberToJson() {
+ SpinJsonNode node = JSON(42);
+ assertThat(node.isNumber()).isTrue();
+ assertThat(node.isValue()).isTrue();
+ assertThat(node.numberValue()).isEqualTo(42);
+ }
+
+ @Test
+ public void shouldMapListOfPrimitiveStrings() {
+ List inputList = new ArrayList();
+ inputList.add("Waldo");
+ inputList.add("Hugo");
+ inputList.add("Kermit");
+
+ SpinJsonNode node = JSON(inputList);
+ assertThat(node.isArray()).isTrue();
+
+ SpinList elements = node.elements();
+ assertThat(elements.get(0).stringValue()).isEqualTo("Waldo");
+ assertThat(elements.get(1).stringValue()).isEqualTo("Hugo");
+ assertThat(elements.get(2).stringValue()).isEqualTo("Kermit");
+ }
+
+ protected Map newMap(String key, Object value) {
+ Map result = new HashMap();
+ result.put(key, value);
+
+ return result;
+ }
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/tree/JsonTreeMapJsonToJavaScriptTest.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/tree/JsonTreeMapJsonToJavaScriptTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..1bdaabb5e65fcb061dc5b82b19b5c59070d3d32d
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/tree/JsonTreeMapJsonToJavaScriptTest.java
@@ -0,0 +1,112 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.json.tree;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.camunda.spin.json.JsonTestConstants.EXAMPLE_JSON_COLLECTION;
+import static org.camunda.spin.json.JsonTestConstants.EXAMPLE_JSON_FILE_NAME;
+import static org.camunda.spin.json.JsonTestConstants.assertIsExampleOrder;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.camunda.spin.impl.test.Script;
+import org.camunda.spin.impl.test.ScriptTest;
+import org.camunda.spin.impl.test.ScriptVariable;
+import org.camunda.spin.json.SpinJsonDataFormatException;
+import org.camunda.spin.json.SpinJsonException;
+import org.camunda.spin.json.mapping.Order;
+import org.camunda.spin.json.mapping.RegularCustomer;
+import org.junit.Test;
+
+public abstract class JsonTreeMapJsonToJavaScriptTest extends ScriptTest {
+
+ @Test
+ @Script(
+ name = "JsonTreeMapJsonToJavaScriptTest.mapToType",
+ execute = false
+ )
+ @ScriptVariable(name = "input", file=EXAMPLE_JSON_FILE_NAME)
+ public void shouldMapJsonObjectToJavaObject() throws Throwable {
+ Map variables = newMap("mapToType", Order.class);
+ Order order = script.execute(variables).getVariable("result");
+ assertIsExampleOrder(order);
+ }
+
+ @Test(expected = SpinJsonException.class)
+ @Script(
+ name = "JsonTreeMapJsonToJavaScriptTest.mapToType",
+ execute = false
+ )
+ @ScriptVariable(name = "input", file=EXAMPLE_JSON_FILE_NAME)
+ public void shouldFailMappingToMismatchingClass() throws Throwable {
+ Map variables = newMap("mapToType", RegularCustomer.class);
+ failingWithException(variables);
+ }
+
+ @Test
+ @Script(
+ name = "JsonTreeMapJsonToJavaScriptTest.mapToType",
+ execute = false
+ )
+ @ScriptVariable(name = "input", file=EXAMPLE_JSON_FILE_NAME)
+ public void shouldMapByCanonicalString() throws Throwable {
+ Map variables = newMap("mapToType", Order.class.getCanonicalName());
+ Order order = script.execute(variables).getVariable("result");
+ assertIsExampleOrder(order);
+ }
+
+ @Test
+ @Script(
+ name = "JsonTreeMapJsonToJavaScriptTest.mapToCollection",
+ execute = false
+ )
+ public void shouldMapListByCanonicalString() throws Throwable {
+ Map variables = new HashMap();
+ variables.put("input", EXAMPLE_JSON_COLLECTION);
+ variables.put("collectionType", ArrayList.class);
+ variables.put("mapToType", Order.class);
+
+ List orders = script.execute(variables).getVariable("result");
+
+ assertThat(orders.size()).isEqualTo(1);
+ assertIsExampleOrder(orders.get(0));
+ }
+
+ @Test(expected = SpinJsonDataFormatException.class)
+ @Script(
+ name = "JsonTreeMapJsonToJavaScriptTest.mapToType",
+ variables = {
+ @ScriptVariable(name = "input", file=EXAMPLE_JSON_FILE_NAME),
+ @ScriptVariable(name = "mapToType", value = "rubbish")
+ },
+ execute = false
+ )
+ public void shouldFailForMalformedTypeString() throws Throwable {
+ failingWithException();
+ }
+
+ protected Map newMap(String key, Object value) {
+ Map result = new HashMap();
+ result.put(key, value);
+
+ return result;
+ }
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/tree/JsonTreeMapJsonToJavaTest.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/tree/JsonTreeMapJsonToJavaTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..26a554a7216b2b7ffb34086547c28daf76db2cb3
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/tree/JsonTreeMapJsonToJavaTest.java
@@ -0,0 +1,93 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.json.tree;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.fail;
+import static org.camunda.spin.Spin.JSON;
+import static org.camunda.spin.json.JsonTestConstants.EXAMPLE_JSON;
+import static org.camunda.spin.json.JsonTestConstants.EXAMPLE_JSON_COLLECTION;
+import static org.camunda.spin.json.JsonTestConstants.assertIsExampleOrder;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.camunda.spin.json.SpinJsonDataFormatException;
+import org.camunda.spin.json.SpinJsonException;
+import org.camunda.spin.json.mapping.Order;
+import org.camunda.spin.json.mapping.RegularCustomer;
+import org.junit.Test;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JavaType;
+import com.fasterxml.jackson.databind.type.TypeFactory;
+
+public class JsonTreeMapJsonToJavaTest {
+
+ @Test
+ public void shouldMapJsonObjectToJavaObject() {
+ Order order = JSON(EXAMPLE_JSON).mapTo(Order.class);
+ assertIsExampleOrder(order);
+ }
+
+ @Test
+ public void shouldFailMappingToMismatchingClass() {
+ try {
+ JSON(EXAMPLE_JSON).mapTo(RegularCustomer.class);
+ fail("Expected SpinJsonTreeNodeException");
+ } catch (SpinJsonException e) {
+ // happy path
+ }
+ }
+
+ @Test
+ public void shouldMapByCanonicalString() {
+ Order order = JSON(EXAMPLE_JSON).mapTo(Order.class.getCanonicalName());
+ assertIsExampleOrder(order);
+ }
+
+ @Test
+ public void shouldMapListByCanonicalString() throws JsonProcessingException {
+ JavaType desiredType =
+ TypeFactory.defaultInstance().constructCollectionType(ArrayList.class, Order.class);
+
+ List orders = JSON(EXAMPLE_JSON_COLLECTION).mapTo(desiredType.toCanonical());
+
+ assertThat(orders.size()).isEqualTo(1);
+ assertIsExampleOrder(orders.get(0));
+ }
+
+ @Test
+ public void shouldFailForMalformedTypeString() {
+ try {
+ JSON(EXAMPLE_JSON_COLLECTION).mapTo("rubbish");
+ fail("Expected SpinJsonTreeNodeException");
+ } catch (SpinJsonDataFormatException e) {
+ // happy path
+ }
+ }
+
+ protected Map newMap(String key, Object value) {
+ Map result = new HashMap();
+ result.put(key, value);
+
+ return result;
+ }
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/tree/JsonTreeMapObjectToJsonScriptTest.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/tree/JsonTreeMapObjectToJsonScriptTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..5fe50ada5c3600cd732fa21db9dbdf6d270ea90a
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/tree/JsonTreeMapObjectToJsonScriptTest.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.json.tree;
+
+import static net.javacrumbs.jsonunit.fluent.JsonFluentAssert.assertThatJson;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.camunda.spin.json.JsonTestConstants.EXAMPLE_JSON;
+
+import org.camunda.spin.SpinList;
+import org.camunda.spin.impl.test.Script;
+import org.camunda.spin.impl.test.ScriptTest;
+import org.camunda.spin.json.SpinJsonNode;
+import org.junit.Test;
+
+public abstract class JsonTreeMapObjectToJsonScriptTest extends ScriptTest {
+
+ @Test
+ @Script
+ public void shouldMapDictionary() {
+
+ String json = script.getVariable("json");
+ assertThat(json).isNotNull();
+ assertThatJson(json).isEqualTo(EXAMPLE_JSON);
+ }
+
+ @Test
+ @Script
+ public void shouldMapPrimitives() {
+ SpinJsonNode json = script.getVariable("stringVar");
+
+ assertThat(json.isString()).isTrue();
+ assertThat(json.stringValue()).isEqualTo("a String");
+
+ json = script.getVariable("booleanVar");
+
+ assertThat(json.isBoolean()).isTrue();
+ assertThat(json.boolValue()).isFalse();
+
+ json = script.getVariable("integerVar");
+
+ assertThat(json.isNumber()).isTrue();
+ assertThat(json.numberValue().intValue()).isEqualTo(42);
+
+ SpinJsonNode jsonList = script.getVariable("listVar");
+
+ assertThat(jsonList.isArray()).isTrue();
+ SpinList elements = jsonList.elements();
+ assertThat(elements.get(0).stringValue()).isEqualTo("Waldo");
+ assertThat(elements.get(1).stringValue()).isEqualTo("Hugo");
+ assertThat(elements.get(2).stringValue()).isEqualTo("Kermit");
+ }
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/tree/JsonTreeReadPropertyScriptTest.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/tree/JsonTreeReadPropertyScriptTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..0324af90408d0372fba17860896c4f7b7239998e
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/tree/JsonTreeReadPropertyScriptTest.java
@@ -0,0 +1,330 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.json.tree;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.camunda.spin.json.JsonTestConstants.EXAMPLE_JSON;
+import static org.camunda.spin.json.JsonTestConstants.EXAMPLE_JSON_FILE_NAME;
+
+import org.camunda.spin.Spin;
+import org.camunda.spin.impl.test.Script;
+import org.camunda.spin.impl.test.ScriptTest;
+import org.camunda.spin.impl.test.ScriptVariable;
+import org.camunda.spin.json.SpinJsonDataFormatException;
+import org.camunda.spin.json.SpinJsonNode;
+import org.camunda.spin.json.SpinJsonPropertyException;
+import org.junit.Test;
+
+/**
+ * @author Thorben Lindhauer
+ *
+ */
+public abstract class JsonTreeReadPropertyScriptTest extends ScriptTest {
+
+ @Test
+ @Script
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldReadProperty() {
+ SpinJsonNode property = script.getVariable("property");
+ String value = script.getVariable("value");
+
+ assertThat(property).isNotNull();
+ assertThat(value).isEqualTo("order1");
+ }
+
+ @Test
+ @Script
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldCheckStringValue() {
+ Boolean value1 = script.getVariable("value1");
+ Boolean value2 = script.getVariable("value2");
+ Boolean value3 = script.getVariable("value3");
+ Boolean value4 = script.getVariable("value4");
+ Boolean value5 = script.getVariable("value5");
+
+ assertThat(value1).isTrue();
+ assertThat(value2).isFalse();
+ assertThat(value3).isFalse();
+ assertThat(value4).isFalse();
+ assertThat(value5).isFalse();
+ }
+
+ @Test
+ @Script
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldCheckNumberValue() {
+ Boolean value1 = script.getVariable("value1");
+ Boolean value2 = script.getVariable("value2");
+ Boolean value3 = script.getVariable("value3");
+ Boolean value4 = script.getVariable("value4");
+ Boolean value5 = script.getVariable("value5");
+
+ assertThat(value1).isFalse();
+ assertThat(value2).isTrue();
+ assertThat(value3).isFalse();
+ assertThat(value4).isFalse();
+ assertThat(value5).isFalse();
+ }
+
+ @Test
+ @Script
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldCheckBooleanValue() {
+ Boolean value1 = script.getVariable("value1");
+ Boolean value2 = script.getVariable("value2");
+ Boolean value3 = script.getVariable("value3");
+ Boolean value4 = script.getVariable("value4");
+ Boolean value5 = script.getVariable("value5");
+
+ assertThat(value1).isFalse();
+ assertThat(value2).isFalse();
+ assertThat(value3).isFalse();
+ assertThat(value4).isFalse();
+ assertThat(value5).isTrue();
+ }
+
+ @Test
+ @Script
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldCheckArrayValue() {
+ Boolean value1 = script.getVariable("value1");
+ Boolean value2 = script.getVariable("value2");
+ Boolean value3 = script.getVariable("value3");
+ Boolean value4 = script.getVariable("value4");
+ Boolean value5 = script.getVariable("value5");
+
+ assertThat(value1).isFalse();
+ assertThat(value2).isFalse();
+ assertThat(value3).isTrue();
+ assertThat(value4).isFalse();
+ assertThat(value5).isFalse();
+ }
+
+ @Test
+ @Script
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldCheckValue() {
+ Object orderValue = script.getVariable("value1");
+ Object dueUntilValue = script.getVariable("value2");
+
+ assertThat(orderValue)
+ .isInstanceOf(String.class)
+ .isEqualTo("order1");
+
+ assertThat(dueUntilValue)
+ .isInstanceOf(Number.class);
+
+ assertThat(((Number) dueUntilValue).longValue())
+ .isEqualTo(20150112L);
+ }
+
+ /**
+ * One for array
+ * @throws Throwable
+ */
+ @Test(expected = SpinJsonDataFormatException.class)
+ @Script(execute = false)
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldFailToCheckObject() throws Throwable{
+ failingWithException();
+ }
+
+ /**
+ * One for child node
+ * @throws Throwable
+ */
+ @Test(expected = SpinJsonDataFormatException.class)
+ @Script(execute = false)
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldFailToCheckObject2() throws Throwable{
+ failingWithException();
+ }
+
+ /**
+ * One for not existent property
+ * @throws Throwable
+ */
+ @Test(expected = SpinJsonPropertyException.class)
+ @Script(execute = false)
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldFailToReadProperty() throws Throwable{
+ failingWithException();
+ }
+
+ /**
+ * One for property argument equals null
+ * @throws Throwable
+ */
+ @Test(expected = IllegalArgumentException.class)
+ @Script(execute = false)
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldFailToReadProperty2() throws Throwable{
+ failingWithException();
+ }
+
+
+ @Test
+ @Script
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldReadTextValue() {
+ String value1 = script.getVariable("value1");
+ String value2 = script.getVariable("value2");
+ String value3 = script.getVariable("value3");
+
+ assertThat(value1).isEqualTo("order1");
+ assertThat(value2).isEqualTo("Kermit");
+ assertThat(value3).isEqualTo("camundaBPM");
+ }
+
+ @Test
+ @Script
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldReadNumberValue() {
+ Number value1 = script.getVariable("value1");
+ Number value2 = script.getVariable("value2");
+ Number value3 = script.getVariable("value3");
+
+ assertThat(value1.longValue()).isEqualTo(20150112L);
+
+ // python returns bigInt instead of Long
+ assertThat(value2.longValue()).isEqualTo(1234567890987654321L);
+ assertThat(value3).isEqualTo(1234567.13);
+ }
+
+ @Test(expected = SpinJsonDataFormatException.class)
+ @Script(execute = false)
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldFailToReadNumberValue() throws Throwable {
+ failingWithException();
+ }
+
+ @Test(expected = SpinJsonDataFormatException.class)
+ @Script(execute = false)
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldFailToReadBooleanValue() throws Throwable {
+ failingWithException();
+ }
+
+ @Test(expected = SpinJsonDataFormatException.class)
+ @Script(execute = false)
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldFailToReadStringValue() throws Throwable {
+ failingWithException();
+ }
+
+ @Test
+ @Script
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldReadBooleanValue() {
+ Boolean value1 = script.getVariable("value1");
+
+ assertThat(value1).isEqualTo(true);
+ }
+
+ @Test
+ @Script
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldReadChildNode() {
+ SpinJsonNode childNode = script.getVariable("childNode");
+ String value = script.getVariable("value");
+
+ assertThat(childNode).isNotNull();
+ assertThat(value).isEqualTo("camundaBPM");
+ }
+
+ @Test
+ @Script
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldReadChildNodeProperty() {
+ SpinJsonNode property1 = script.getVariable("property1");
+ SpinJsonNode property2 = script.getVariable("property2");
+
+ Number value1 = script.getVariable("value1");
+ String value2 = script.getVariable("value2");
+
+ assertThat(property1).isNotNull();
+ assertThat(property2).isNotNull();
+
+ // Ruby casts this to long instead int
+ assertThat(value1.longValue()).isEqualTo(1234567L);
+ assertThat(value2).isEqualTo("dollar");
+ }
+
+ @Test
+ @Script
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldReadObjectInArrayChildNode() {
+ SpinJsonNode property1 = script.getVariable("property1");
+ SpinJsonNode property2 = script.getVariable("property2");
+
+ String value1 = script.getVariable("value1");
+ String value2 = script.getVariable("value2");
+
+ assertThat(property1).isNotNull();
+ assertThat(property2).isNotNull();
+
+ assertThat(value1).isEqualTo("Kermit");
+ assertThat(value2).isEqualTo("Waldo");
+ }
+
+ @Test
+ @Script
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldReadListOfNodes() {
+ String value1 = script.getVariable("value1");
+ String value2 = script.getVariable("value2");
+ String value3 = script.getVariable("value3");
+
+ assertThat(value1).isEqualTo("order");
+ assertThat(value2).isEqualTo("dueUntil");
+ assertThat(value3).isEqualTo("orderDetails");
+ }
+
+ @Test(expected = SpinJsonDataFormatException.class)
+ @Script(execute = false)
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldFailToReadObjectInNonArray() throws Throwable{
+ failingWithException();
+ }
+
+ @Test
+ @Script
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldBeSameAsJavaValue() {
+
+ SpinJsonNode node = Spin.JSON(EXAMPLE_JSON);
+ SpinJsonNode childNode = node.prop("orderDetails");
+
+ SpinJsonNode property1 = node.prop("order");
+ SpinJsonNode property2 = childNode.prop("price");
+ SpinJsonNode property3 = node.prop("active");
+
+ String javaVariable1 = property1.stringValue();
+ Number javaVariable2 = property2.numberValue();
+ Boolean javaVariable3 = property3.boolValue();
+
+ String scriptVariable1 = script.getVariable("stringValue");
+ Number scriptVariable2 = script.getVariable("numberValue");
+ Boolean scriptVariable3 = script.getVariable("boolValue");
+
+ assertThat(javaVariable1).isEqualTo(scriptVariable1);
+ assertThat(javaVariable2).isEqualTo(scriptVariable2);
+ assertThat(javaVariable3).isEqualTo(scriptVariable3);
+ }
+
+}
+
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/tree/JsonTreeReadPropertyTest.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/tree/JsonTreeReadPropertyTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..1bf5f85d5400b7c1b8a558eaf71490cbbbf9f2e7
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/tree/JsonTreeReadPropertyTest.java
@@ -0,0 +1,446 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.json.tree;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.fail;
+import static org.camunda.spin.Spin.JSON;
+import static org.camunda.spin.json.JsonTestConstants.EXAMPLE_JSON;
+
+import org.camunda.spin.SpinList;
+import org.camunda.spin.impl.util.SpinIoUtil;
+import org.camunda.spin.json.SpinJsonDataFormatException;
+import org.camunda.spin.json.SpinJsonNode;
+import org.camunda.spin.json.SpinJsonPropertyException;
+import org.camunda.spin.spi.SpinDataFormatException;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @author Stefan Hentschel
+ */
+public class JsonTreeReadPropertyTest {
+
+ protected SpinJsonNode jsonNode;
+ protected SpinJsonNode order;
+ protected SpinJsonNode dueUntil;
+ protected SpinJsonNode id;
+ protected SpinJsonNode customers;
+ protected SpinJsonNode orderDetails;
+ protected SpinJsonNode active;
+ protected SpinJsonNode nullValue;
+
+ @Before
+ public void readJson() {
+ jsonNode = JSON(EXAMPLE_JSON);
+ order = jsonNode.prop("order");
+ dueUntil = jsonNode.prop("dueUntil");
+ id = jsonNode.prop("id");
+ customers = jsonNode.prop("customers");
+ orderDetails = jsonNode.prop("orderDetails");
+ active = jsonNode.prop("active");
+ nullValue = jsonNode.prop("nullValue");
+ }
+
+ @Test
+ public void checkForProperty() {
+ assertThat(jsonNode.hasProp("order")).isTrue();
+ assertThat(order.hasProp("order")).isFalse();
+ assertThat(dueUntil.hasProp("order")).isFalse();
+ assertThat(id.hasProp("order")).isFalse();
+ assertThat(customers.hasProp("order")).isFalse();
+ assertThat(orderDetails.hasProp("price")).isTrue();
+ assertThat(active.hasProp("order")).isFalse();
+ assertThat(jsonNode.hasProp("nullValue")).isTrue();
+ }
+
+ @Test
+ public void shouldReadProperty() {
+ assertThat(jsonNode).isNotNull();
+
+ SpinJsonNode property = jsonNode.prop("order");
+ assertThat(property).isNotNull();
+ }
+
+ @Test
+ public void shouldFailToReadNonProperty() {
+ try {
+ jsonNode.prop("nonExisting");
+ fail("Expected SpinJsonTreePropertyException");
+ } catch(SpinJsonPropertyException e) {
+ // expected
+ }
+
+ try {
+ order.prop("nonExisting");
+ fail("Expected SpinJsonTreePropertyException");
+ } catch(SpinJsonPropertyException e) {
+ // expected
+ }
+
+ try {
+ customers.prop("nonExisting");
+ fail("Expected SpinJsonTreePropertyException");
+ } catch(SpinJsonPropertyException e) {
+ // expected
+ }
+
+ try {
+ jsonNode.prop(null);
+ fail("Expected IllegalArgumentException");
+ } catch(IllegalArgumentException e) {
+ // expected
+ }
+
+ try {
+ order.prop("null");
+ fail("Expected SpinJsonTreePropertyException");
+ } catch(SpinJsonPropertyException e) {
+ // expected
+ }
+
+ try {
+ customers.prop("null");
+ fail("Expected SpinJsonTreePropertyException");
+ } catch(SpinJsonPropertyException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void checkForObjectValue() {
+ assertThat(jsonNode.isObject()).isTrue();
+ assertThat(order.isObject()).isFalse();
+ assertThat(dueUntil.isObject()).isFalse();
+ assertThat(id.isObject()).isFalse();
+ assertThat(customers.isObject()).isFalse();
+ assertThat(orderDetails.isObject()).isTrue();
+ assertThat(active.isObject()).isFalse();
+ }
+
+ @Test
+ public void shouldReadObjectProperty() {
+ assertThat(jsonNode.prop("order")).isNotNull();
+ assertThat(orderDetails.prop("article")).isNotNull();
+ }
+
+ @Test
+ public void shouldFailToReadNonObject() {
+ try {
+ jsonNode.prop("order").prop("nonExisting");
+ fail("Expected SpinJsonTreePropertyException");
+ } catch(SpinJsonPropertyException e) {
+ // expected
+ }
+
+ try {
+ orderDetails.prop("roundedPrice").prop("nonExisting");
+ fail("Expected SpinJsonTreePropertyException");
+ } catch(SpinJsonPropertyException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void checkForStringValue() {
+ assertThat(jsonNode.isString()).isFalse();
+ assertThat(order.isString()).isTrue();
+ assertThat(dueUntil.isString()).isFalse();
+ assertThat(id.isString()).isFalse();
+ assertThat(customers.isString()).isFalse();
+ assertThat(orderDetails.isString()).isFalse();
+ assertThat(active.isString()).isFalse();
+ }
+
+ @Test
+ public void shouldReadStringValue() {
+ assertThat(order.stringValue()).isEqualTo("order1");
+ assertThat(orderDetails.prop("article").stringValue()).isEqualTo("camundaBPM");
+ assertThat(customers.elements().get(0).prop("name").stringValue()).isEqualTo("Kermit");
+ }
+
+ @Test
+ public void shouldFailToReadNonStringValue() {
+ try {
+ jsonNode.stringValue();
+ fail("Expected SpinJsonDataFormatException");
+ } catch(SpinJsonDataFormatException e) {
+ // expected
+ }
+
+ try {
+ dueUntil.stringValue();
+ fail("Expected SpinJsonDataFormatException");
+ } catch(SpinJsonDataFormatException e) {
+ // expected
+ }
+
+ try {
+ orderDetails.prop("currencies").stringValue();
+ fail("Expected SpinJsonDataFormatException");
+ } catch(SpinDataFormatException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void checkForNumberValue() {
+ assertThat(jsonNode.isNumber()).isFalse();
+ assertThat(order.isNumber()).isFalse();
+ assertThat(dueUntil.isNumber()).isTrue();
+ assertThat(id.isNumber()).isTrue();
+ assertThat(customers.isNumber()).isFalse();
+ assertThat(orderDetails.isNumber()).isFalse();
+ assertThat(active.isNumber()).isFalse();
+ }
+
+ @Test
+ public void shouldReadNumberValue() {
+ assertThat(dueUntil.numberValue()).isEqualTo(20150112);
+ assertThat(id.numberValue()).isEqualTo(1234567890987654321L);
+ }
+
+ @Test
+ public void shouldFailToReadNonNumberValue() {
+ try {
+ jsonNode.numberValue();
+ fail("Expected SpinJsonDataFormatException");
+ } catch(SpinJsonDataFormatException e) {
+ // expected
+ }
+
+ try {
+ order.numberValue();
+ fail("Expected SpinJsonDataFormatException");
+ } catch(SpinJsonDataFormatException e) {
+ // expected
+ }
+
+ try {
+ customers.numberValue();
+ fail("Expected SpinJsonDataFormatException");
+ } catch(SpinDataFormatException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void checkForBooleanValue() {
+ assertThat(jsonNode.isBoolean()).isFalse();
+ assertThat(order.isBoolean()).isFalse();
+ assertThat(dueUntil.isBoolean()).isFalse();
+ assertThat(id.isBoolean()).isFalse();
+ assertThat(customers.isBoolean()).isFalse();
+ assertThat(orderDetails.isBoolean()).isFalse();
+ assertThat(active.isBoolean()).isTrue();
+ }
+
+ @Test
+ public void shouldReadBooleanValue() {
+ assertThat(active.boolValue()).isTrue();
+ assertThat(orderDetails.prop("paid").boolValue()).isFalse();
+ }
+
+ @Test
+ public void shouldFailToReadNonBooleanValue() {
+ try {
+ jsonNode.boolValue();
+ fail("Expected SpinJsonDataFormatException");
+ } catch(SpinJsonDataFormatException e) {
+ // expected
+ }
+
+ try {
+ order.boolValue();
+ fail("Expected SpinJsonDataFormatException");
+ } catch(SpinJsonDataFormatException e) {
+ // expected
+ }
+
+ try {
+ customers.boolValue();
+ fail("Expected SpinJsonDataFormatException");
+ } catch(SpinDataFormatException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void checkForValue() {
+ assertThat(jsonNode.isValue()).isFalse();
+ assertThat(order.isValue()).isTrue();
+ assertThat(dueUntil.isValue()).isTrue();
+ assertThat(id.isValue()).isTrue();
+ assertThat(customers.isValue()).isFalse();
+ assertThat(orderDetails.isValue()).isFalse();
+ assertThat(active.isValue()).isTrue();
+ }
+
+ @Test
+ public void shouldReadValue() {
+ assertThat(order.value())
+ .isInstanceOf(String.class)
+ .isEqualTo("order1");
+
+ assertThat(dueUntil.value())
+ .isInstanceOf(Number.class)
+ .isEqualTo(20150112);
+
+ assertThat(active.value())
+ .isInstanceOf(Boolean.class)
+ .isEqualTo(true);
+ }
+
+ @Test
+ public void shouldFailToReadNonValue() {
+ try {
+ jsonNode.value();
+ fail("Expected SpinJsonDataFormatException");
+ } catch(SpinJsonDataFormatException e) {
+ // expected
+ }
+
+ try {
+ customers.value();
+ fail("Expected SpinJsonDataFormatException");
+ } catch(SpinJsonDataFormatException e) {
+ // expected
+ }
+
+ try {
+ orderDetails.value();
+ fail("Expected SpinJsonDataFormatException");
+ } catch(SpinDataFormatException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void checkForArrayValue() {
+ assertThat(jsonNode.isArray()).isFalse();
+ assertThat(order.isArray()).isFalse();
+ assertThat(dueUntil.isArray()).isFalse();
+ assertThat(id.isArray()).isFalse();
+ assertThat(customers.isArray()).isTrue();
+ assertThat(orderDetails.isArray()).isFalse();
+ assertThat(active.isArray()).isFalse();
+ }
+
+ @Test
+ public void shouldReadArrayValue() {
+ SpinList customerElements = customers.elements();
+ SpinList currenciesElements = orderDetails.prop("currencies").elements();
+
+ assertThat(customerElements).hasSize(3);
+ assertThat(currenciesElements).hasSize(2);
+
+ assertThat(customerElements.get(0).prop("name").stringValue()).isEqualTo("Kermit");
+ assertThat(currenciesElements.get(0).stringValue()).isEqualTo("euro");
+ }
+
+ @Test
+ public void shouldFailToReadNonArrayValue() {
+ try {
+ jsonNode.elements();
+ fail("Expected SpinJsonDataFormatException");
+ } catch(SpinJsonDataFormatException e) {
+ // expected
+ }
+
+ try {
+ order.elements();
+ fail("Expected SpinJsonDataFormatException");
+ } catch(SpinJsonDataFormatException e) {
+ // expected
+ }
+
+ try {
+ id.elements();
+ fail("Expected SpinJsonDataFormatException");
+ } catch(SpinDataFormatException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void checkForNullValue() {
+ assertThat(nullValue.isNull()).isTrue();
+ assertThat(jsonNode.isNull()).isFalse();
+ assertThat(order.isNull()).isFalse();
+ assertThat(dueUntil.isNull()).isFalse();
+ assertThat(id.isNull()).isFalse();
+ assertThat(customers.isNull()).isFalse();
+ assertThat(orderDetails.isNull()).isFalse();
+ assertThat(active.isNull()).isFalse();
+ }
+
+ @Test
+ public void shouldReadNullValue() {
+ assertThat(nullValue.isValue()).isTrue();
+ assertThat(nullValue.value()).isNull();
+ }
+
+ @Test
+ public void shouldReadFieldNames() {
+ assertThat(jsonNode.fieldNames()).contains("order", "dueUntil", "id", "customers", "orderDetails", "active");
+ assertThat(customers.fieldNames()).isEmpty();
+ assertThat(orderDetails.fieldNames()).contains("article", "price", "roundedPrice", "currencies", "paid");
+ }
+
+ @Test
+ public void shouldFailToReadNonFieldNames() {
+ try {
+ order.fieldNames();
+ fail("Expected SpinJsonDataFormatException");
+ } catch(SpinJsonDataFormatException e) {
+ // expected
+ }
+
+ try {
+ dueUntil.fieldNames();
+ fail("Expected SpinJsonDataFormatException");
+ } catch(SpinJsonDataFormatException e) {
+ // expected
+ }
+
+ try {
+ active.fieldNames();
+ fail("Expected SpinJsonDataFormatException");
+ } catch(SpinDataFormatException e) {
+ // expected
+ }
+ }
+
+
+ /**
+ * Tests an issue with Jackson 2.4.1
+ *
+ * The test contains a negative float at character position 8000 which is important
+ * to provoke Jackson bug #146.
+ * See also the Jackson bug report .
+ */
+ @Test
+ public void shouldNotFailWithJackson146Bug() {
+ // this should not fail
+ SpinJsonNode node = JSON(SpinIoUtil.fileAsString("org/camunda/spin/json/jackson146.json"));
+
+ // file has 4000 characters in length a
+ // 20 characters per repeated JSON object
+ assertThat(node.prop("abcdef").elements()).hasSize(200);
+ }
+
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/tree/JsonTreeRemovePropertyScriptTest.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/tree/JsonTreeRemovePropertyScriptTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..024a3fa13ff54ed505155e7f38427a25ea6b4efc
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/tree/JsonTreeRemovePropertyScriptTest.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.json.tree;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.camunda.spin.json.JsonTestConstants.EXAMPLE_JSON_FILE_NAME;
+
+import org.camunda.spin.impl.test.Script;
+import org.camunda.spin.impl.test.ScriptTest;
+import org.camunda.spin.impl.test.ScriptVariable;
+import org.camunda.spin.json.SpinJsonPropertyException;
+import org.junit.Test;
+
+/**
+ * @author Thorben Lindhauer
+ *
+ */
+public abstract class JsonTreeRemovePropertyScriptTest extends ScriptTest {
+
+ @Test
+ @Script
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldRemovePropertyByName() {
+ Boolean value = script.getVariable("value");
+
+ assertThat(value).isFalse();
+ }
+
+ @Test
+ @Script
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldRemovePropertyByList() {
+ Boolean value1 = script.getVariable("value1");
+ Boolean value2 = script.getVariable("value2");
+
+ assertThat(value1).isFalse();
+ assertThat(value2).isFalse();
+ }
+
+ @Test(expected = SpinJsonPropertyException.class)
+ @Script(execute = false)
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldFailWhileRemovingPropertyByName() throws Throwable{
+ failingWithException();
+ }
+
+ @Test(expected = SpinJsonPropertyException.class)
+ @Script(execute = false)
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldFailWhileRemovingPropertyByList() throws Throwable{
+ failingWithException();
+ }
+
+}
+
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/tree/JsonTreeRemovePropertyTest.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/tree/JsonTreeRemovePropertyTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..d271eef96e57c5e0419e4cf8784272979b226d27
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/tree/JsonTreeRemovePropertyTest.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.json.tree;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.fail;
+import static org.camunda.spin.Spin.JSON;
+import static org.camunda.spin.json.JsonTestConstants.EXAMPLE_JSON;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.camunda.spin.json.SpinJsonNode;
+import org.camunda.spin.json.SpinJsonPropertyException;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @author Stefan Hentschel
+ */
+public class JsonTreeRemovePropertyTest {
+
+ protected SpinJsonNode jsonNode;
+ protected String order;
+ protected String active;
+
+ @Before
+ public void readJson() {
+ jsonNode = JSON(EXAMPLE_JSON);
+ order = "order";
+ active = "active";
+ }
+
+ @Test
+ public void removePropertyByName() {
+ assertThat(jsonNode.hasProp(order)).isTrue();
+
+ jsonNode.deleteProp(order);
+ assertThat(jsonNode.hasProp(order)).isFalse();
+
+ }
+
+ @Test
+ public void removePropertyByList() {
+ List names = new ArrayList();
+ names.add(order);
+ names.add(active);
+
+ assertThat(jsonNode.hasProp(names.get(0))).isTrue();
+ assertThat(jsonNode.hasProp(names.get(1))).isTrue();
+
+ jsonNode.deleteProp(names);
+
+ assertThat(jsonNode.hasProp(names.get(0))).isFalse();
+ assertThat(jsonNode.hasProp(names.get(1))).isFalse();
+ }
+
+ @Test
+ public void failWhileRemovePropertyByName() {
+ try {
+ jsonNode.deleteProp("waldo");
+ fail("Expected SpinJsonTreePropertyException");
+ } catch(SpinJsonPropertyException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void failWhileRemovePropertyByList() {
+ List names = new ArrayList();
+ names.add(active);
+ names.add("waldo");
+ try {
+ jsonNode.deleteProp(names);
+ fail("Expected SpinJsonTreePropertyException");
+ } catch(SpinJsonPropertyException e) {
+ // expected
+ }
+ }
+}
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/tree/JsonTreeSetPropertyScriptTest.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/tree/JsonTreeSetPropertyScriptTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..ba4d05eb5da77d63063d6a341ba518397a6a71bc
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/tree/JsonTreeSetPropertyScriptTest.java
@@ -0,0 +1,259 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.json.tree;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.camunda.spin.json.JsonTestConstants.EXAMPLE_JSON_FILE_NAME;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.camunda.spin.impl.test.Script;
+import org.camunda.spin.impl.test.ScriptTest;
+import org.camunda.spin.impl.test.ScriptVariable;
+import org.camunda.spin.json.SpinJsonNode;
+import org.camunda.spin.json.SpinJsonPropertyException;
+import org.junit.Test;
+
+/**
+ * @author Thorben Lindhauer
+ *
+ */
+public abstract class JsonTreeSetPropertyScriptTest extends ScriptTest {
+
+ @Test
+ @Script
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldSetStringProperty() {
+ SpinJsonNode propertyNode = script.getVariable("propertyNode");
+ String value = script.getVariable("value");
+
+ assertThat(propertyNode).isNotNull();
+ assertThat(value).isEqualTo("42!");
+ }
+
+ @Test
+ @Script
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldReplaceStringProperty() {
+ String oldValue = script.getVariable("oldValue");
+ String newValue = script.getVariable("newValue");
+
+ assertThat(newValue).isNotEqualTo(oldValue);
+ assertThat(newValue).isEqualTo("new Order");
+ }
+
+ @Test
+ @Script
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldSetIntegerProperty() {
+ SpinJsonNode propertyNode = script.getVariable("propertyNode");
+ Number value = script.getVariable("value");
+
+ assertThat(propertyNode).isNotNull();
+ // Ruby casts Number to long
+ assertThat(value.intValue()).isEqualTo(42);
+ }
+
+ @Test
+ @Script
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldReplaceIntegerProperty() {
+ String oldValue = script.getVariable("oldValue");
+ Number newValue = script.getVariable("newValue");
+
+ assertThat(newValue).isNotEqualTo(oldValue);
+ // Ruby casts Number to long
+ assertThat(newValue.intValue()).isEqualTo(42);
+ }
+
+ @Test
+ @Script
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldSetFloatProperty() {
+ SpinJsonNode propertyNode = script.getVariable("propertyNode");
+ Number value = script.getVariable("value");
+
+ assertThat(propertyNode).isNotNull();
+
+ // python returns Double, needs to cast to Float
+ assertThat(value.floatValue()).isEqualTo(42.00F);
+ }
+
+ @Test
+ @Script
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldReplaceFloatProperty() {
+ String oldValue = script.getVariable("oldValue");
+ Number newValue = script.getVariable("newValue");
+
+ assertThat(newValue).isNotEqualTo(oldValue);
+ // Python returns a double instead a float
+ assertThat(newValue.floatValue()).isEqualTo(42.00F);
+ }
+
+ @Test
+ @Script
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldSetLongProperty() {
+ SpinJsonNode propertyNode = script.getVariable("propertyNode");
+ Number value = script.getVariable("value");
+
+ assertThat(propertyNode).isNotNull();
+
+ // python returns BigInt, needs to cast to Long
+ assertThat(value.floatValue()).isEqualTo(4200000000L);
+ }
+
+ @Test
+ @Script
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldReplaceLongProperty() {
+ String oldValue = script.getVariable("oldValue");
+ Number newValue = script.getVariable("newValue");
+
+ assertThat(newValue).isNotEqualTo(oldValue);
+ // python returns a BigInt, needs to cast it
+ assertThat(newValue.longValue()).isEqualTo(4200000000L);
+ }
+
+ /**
+ * Please note: in jython there is a known issue that Boolean
+ * and boolean values are casted to long if a matching method
+ * is found first. See script source code for workaround.
+ */
+ @Test
+ @Script
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldSetBooleanProperty() {
+ SpinJsonNode propertyNode = script.getVariable("propertyNode");
+ Boolean value = script.getVariable("value");
+
+ assertThat(propertyNode).isNotNull();
+ assertThat(value).isFalse();
+ }
+
+ /**
+ * Please note: in jython there is a known issue that Boolean
+ * and boolean values are casted to long if a matching method
+ * is found first. See script source code for workaround.
+ */
+ @Test
+ @Script
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldReplaceBooleanProperty() {
+ String oldValue = script.getVariable("oldValue");
+ Boolean newValue = script.getVariable("newValue");
+
+ assertThat(newValue).isNotEqualTo(oldValue);
+ assertThat(newValue).isFalse();
+ }
+
+ @Test
+ @Script
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldSetArrayProperty() {
+ SpinJsonNode propertyNode = script.getVariable("propertyNode");
+ String value = script.getVariable("value");
+
+ assertThat(propertyNode).isNotNull();
+ assertThat(propertyNode.isArray()).isTrue();
+ assertThat(value).isEqualTo("test2");
+ }
+
+ @Test
+ @Script
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldReplaceArrayProperty() {
+ SpinJsonNode oldValue = script.getVariable("oldValue");
+ SpinJsonNode newValue = script.getVariable("newValue");
+
+ assertThat(oldValue.isString()).isTrue();
+ assertThat(newValue).isNotEqualTo(oldValue);
+ assertThat(newValue.isArray()).isTrue();
+ }
+
+ @Test
+ @Script
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldSetObjectProperty() {
+ SpinJsonNode propertyNode = script.getVariable("propertyNode");
+ String value = script.getVariable("value");
+
+ assertThat(propertyNode).isNotNull();
+ assertThat(propertyNode.isObject()).isTrue();
+ assertThat(value).isEqualTo("42!");
+ }
+
+ @Test
+ @Script
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldReplaceObjectProperty() {
+
+ SpinJsonNode oldValue = script.getVariable("oldValue");
+ SpinJsonNode newValue = script.getVariable("newValue");
+
+ assertThat(oldValue.isString()).isTrue();
+ assertThat(newValue).isNotEqualTo(oldValue);
+ assertThat(newValue.isObject()).isTrue();
+ }
+
+ @Test
+ @Script
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldSetNullProperty() {
+ SpinJsonNode propertyNode = script.getVariable("propertyNode");
+ Object value = script.getVariable("value");
+
+ assertThat(propertyNode).isNotNull();
+ assertThat(propertyNode.isNull()).isTrue();
+ assertThat(value).isNull();
+ }
+
+ @Test
+ @Script
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldReplaceNullProperty() {
+ SpinJsonNode propertyNode = script.getVariable("propertyNode");
+ Object newValue = script.getVariable("newValue");
+
+ assertThat(propertyNode).isNotNull();
+ assertThat(propertyNode.isNull()).isTrue();
+ assertThat(newValue).isNull();
+ }
+
+ @Test(expected = SpinJsonPropertyException.class)
+ @Script(execute = false)
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldFailWhileSettingObject() throws Throwable{
+ Map variables = new HashMap();
+ variables.put("date", new Date());
+ failingWithException(variables);
+ }
+
+ @Test(expected = SpinJsonPropertyException.class)
+ @Script(execute = false)
+ @ScriptVariable(name = "input", file = EXAMPLE_JSON_FILE_NAME)
+ public void shouldFailWhileSettingArray() throws Throwable{
+ Map variables = new HashMap();
+ variables.put("date", new Date());
+ failingWithException(variables);
+ }
+
+}
+
diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/tree/JsonTreeSetPropertyTest.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/tree/JsonTreeSetPropertyTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..83ee5475bfd0832b4c08efe9ff488822f12b7cdf
--- /dev/null
+++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/spin/dataformat-json-jackson/src/test/java/org/camunda/spin/json/tree/JsonTreeSetPropertyTest.java
@@ -0,0 +1,449 @@
+/*
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
+ * under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright
+ * ownership. Camunda licenses this file to you under the Apache License,
+ * Version 2.0; you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.camunda.spin.json.tree;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.fail;
+import static org.camunda.spin.Spin.JSON;
+import static org.camunda.spin.json.JsonTestConstants.EXAMPLE_JSON;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.camunda.spin.json.SpinJsonNode;
+import org.camunda.spin.json.SpinJsonPropertyException;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @author Stefan Hentschel
+ */
+public class JsonTreeSetPropertyTest {
+
+ protected SpinJsonNode jsonNode;
+ protected SpinJsonNode order;
+ protected SpinJsonNode dueUntil;
+ protected SpinJsonNode id;
+ protected SpinJsonNode customers;
+ protected SpinJsonNode orderDetails;
+ protected SpinJsonNode active;
+ protected SpinJsonNode nullValue;
+
+ @Before
+ public void readJson() {
+ jsonNode = JSON(EXAMPLE_JSON);
+ order = jsonNode.prop("order");
+ dueUntil = jsonNode.prop("dueUntil");
+ id = jsonNode.prop("id");
+ customers = jsonNode.prop("customers");
+ orderDetails = jsonNode.prop("orderDetails");
+ active = jsonNode.prop("active");
+ nullValue = jsonNode.prop("nullValue");
+ }
+
+ @Test
+ public void setStringProperty() {
+ String newComment = "42!";
+
+ jsonNode.prop("comment", newComment);
+ SpinJsonNode comment = jsonNode.prop("comment");
+
+ assertThat(comment.isString()).isTrue();
+ assertThat(comment.stringValue()).isEqualTo(newComment);
+ }
+
+ @Test
+ public void replaceStringProperty() {
+ String value = "new Order";
+ String oldValue = order.stringValue();
+
+ assertThat(order.isString()).isTrue();
+ assertThat(customers.isArray()).isTrue();
+
+ // set new values
+ jsonNode.prop("order", value);
+ jsonNode.prop("customers", value);
+ SpinJsonNode newValue1 = jsonNode.prop("order");
+ SpinJsonNode newValue2 = jsonNode.prop("customers");
+
+ assertThat(newValue1.stringValue()).isNotEqualTo(oldValue);
+ assertThat(newValue1.stringValue()).isEqualTo(value);
+
+ assertThat(newValue2.isArray()).isFalse();
+ assertThat(newValue2.stringValue()).isEqualTo(value);
+ }
+
+ @Test
+ public void setIntegerProperty() {
+ Integer newComment = 42;
+ jsonNode.prop("comment", newComment);
+ SpinJsonNode comment = jsonNode.prop("comment");
+
+ assertThat(comment.isNumber()).isTrue();
+ assertThat(comment.numberValue()).isEqualTo(newComment);
+ }
+
+ @Test
+ public void replaceIntegerProperty() {
+ Integer value = 42;
+ Integer oldValue = dueUntil.numberValue().intValue();
+
+ assertThat(customers.isArray()).isTrue();
+ assertThat(dueUntil.isNumber());
+
+ // set new values
+ jsonNode.prop("dueUntil", value);
+ jsonNode.prop("customers", value);
+ SpinJsonNode newValue1 = jsonNode.prop("dueUntil");
+ SpinJsonNode newValue2 = jsonNode.prop("customers");
+
+ assertThat(newValue1.numberValue()).isNotEqualTo(oldValue);
+ assertThat(newValue1.numberValue()).isEqualTo(value);
+
+ assertThat(newValue2.isArray()).isFalse();
+ assertThat(newValue2.isNumber()).isTrue();
+ assertThat(newValue2.numberValue()).isEqualTo(value);
+ }
+
+ @Test
+ public void setFloatProperty() {
+ Float floatValue = 42.00F;
+ jsonNode.prop("comment", floatValue);
+ SpinJsonNode comment = jsonNode.prop("comment");
+
+ assertThat(comment.isNumber()).isTrue();
+ assertThat(comment.numberValue()).isEqualTo(floatValue);
+ }
+
+ @Test
+ public void replaceFloatProperty() {
+ SpinJsonNode price = orderDetails.prop("price");
+ Float value = 42.00F;
+
+ Float oldValue = price.numberValue().floatValue();
+
+ assertThat(customers.isArray()).isTrue();
+ assertThat(price.isNumber());
+
+ // set new values
+ orderDetails.prop("price", value);
+ jsonNode.prop("customers", value);
+ SpinJsonNode newValue1 = orderDetails.prop("price");
+ SpinJsonNode newValue2 = jsonNode.prop("customers");
+
+ assertThat(newValue1.numberValue()).isNotEqualTo(oldValue);
+ assertThat(newValue1.numberValue()).isEqualTo(value);
+
+ assertThat(newValue2.isArray()).isFalse();
+ assertThat(newValue2.isNumber()).isTrue();
+ assertThat(newValue2.numberValue()).isEqualTo(value);
+ }
+
+ @Test
+ public void setLongProperty() {
+ Long longValue = 4200000000L;
+ jsonNode.prop("comment", longValue);
+ SpinJsonNode comment = jsonNode.prop("comment");
+
+ assertThat(comment.isNumber()).isTrue();
+ assertThat(comment.numberValue().longValue()).isEqualTo(longValue);
+ }
+
+ @Test
+ public void replaceLongProperty() {
+ Long value = 4200000000L;
+
+ Long oldValue = id.numberValue().longValue();
+
+ assertThat(customers.isArray()).isTrue();
+ assertThat(id.isNumber());
+
+ // set new values
+ jsonNode.prop("id", value);
+ jsonNode.prop("customers", value);
+ SpinJsonNode newValue1 = jsonNode.prop("id");
+ SpinJsonNode newValue2 = jsonNode.prop("customers");
+
+ assertThat(newValue1.numberValue()).isNotEqualTo(oldValue);
+ assertThat(newValue1.numberValue()).isEqualTo(value);
+
+ assertThat(newValue2.isArray()).isFalse();
+ assertThat(newValue2.isNumber()).isTrue();
+ assertThat(newValue2.numberValue()).isEqualTo(value);
+ }
+
+ @Test
+ public void setBooleanProperty() {
+ jsonNode.prop("comment", true);
+ SpinJsonNode comment = jsonNode.prop("comment");
+
+ assertThat(comment.isBoolean()).isTrue();
+ assertThat(comment.boolValue()).isTrue();
+ }
+
+ @Test
+ public void replaceBooleanProperty() {
+ SpinJsonNode active = jsonNode.prop("active");
+
+ Boolean oldValue = active.boolValue();
+ Boolean value = !oldValue;
+
+ assertThat(customers.isArray()).isTrue();
+ assertThat(active.isBoolean());
+
+ // set new values
+ jsonNode.prop("active", value);
+ jsonNode.prop("customers", value);
+ SpinJsonNode newValue1 = jsonNode.prop("active");
+ SpinJsonNode newValue2 = jsonNode.prop("customers");
+
+ assertThat(newValue1.boolValue()).isNotEqualTo(oldValue);
+ assertThat(newValue1.boolValue()).isEqualTo(value);
+
+ assertThat(newValue2.isArray()).isFalse();
+ assertThat(newValue2.isBoolean()).isTrue();
+ assertThat(newValue2.boolValue()).isEqualTo(value);
+ }
+
+ @Test
+ public void setArrayProperty() {
+ ArrayList