diff --git a/docs/pom.xml b/docs/pom.xml index 8c63eaf3..88ed4288 100644 --- a/docs/pom.xml +++ b/docs/pom.xml @@ -6,7 +6,7 @@ io.holunda.data camunda-bpm-data-parent - 1.2.2 + 1.2.3 camunda-bpm-data-docs diff --git a/example/coverage-report-aggregator/pom.xml b/example/coverage-report-aggregator/pom.xml index 7bfef642..008a6baa 100644 --- a/example/coverage-report-aggregator/pom.xml +++ b/example/coverage-report-aggregator/pom.xml @@ -6,7 +6,7 @@ io.holunda.data.example camunda-bpm-data-example-parent - 1.2.2 + 1.2.3 camunda-bpm-data-coverage-report diff --git a/example/example-java/pom.xml b/example/example-java/pom.xml index 40462e51..fe91facd 100644 --- a/example/example-java/pom.xml +++ b/example/example-java/pom.xml @@ -6,7 +6,7 @@ io.holunda.data.example camunda-bpm-data-example-parent - 1.2.2 + 1.2.3 camunda-bpm-data-example-java diff --git a/example/example-kotlin/pom.xml b/example/example-kotlin/pom.xml index 4d5e0aa1..8067539b 100644 --- a/example/example-kotlin/pom.xml +++ b/example/example-kotlin/pom.xml @@ -6,7 +6,7 @@ io.holunda.data.example camunda-bpm-data-example-parent - 1.2.2 + 1.2.3 camunda-bpm-data-example-kotlin diff --git a/example/itest/pom.xml b/example/itest/pom.xml index 8f0602a8..1d5c646a 100644 --- a/example/itest/pom.xml +++ b/example/itest/pom.xml @@ -6,7 +6,7 @@ io.holunda.data.example camunda-bpm-data-example-parent - 1.2.2 + 1.2.3 camunda-bpm-data-integration-test diff --git a/example/pom.xml b/example/pom.xml index 269dc38c..54459a57 100644 --- a/example/pom.xml +++ b/example/pom.xml @@ -6,7 +6,7 @@ io.holunda.data camunda-bpm-data-parent - 1.2.2 + 1.2.3 io.holunda.data.example @@ -59,7 +59,7 @@ io.holunda.testing camunda-bpm-jgiven - 0.0.5 + 0.0.7 test diff --git a/example/spin-type-detector/pom.xml b/example/spin-type-detector/pom.xml index 1f05241b..cde809ba 100644 --- a/example/spin-type-detector/pom.xml +++ b/example/spin-type-detector/pom.xml @@ -6,7 +6,7 @@ io.holunda.data.example camunda-bpm-data-example-parent - 1.2.2 + 1.2.3 camunda-bpm-data-spin-type-detector diff --git a/extension/core/pom.xml b/extension/core/pom.xml index ef3980b2..018a029e 100644 --- a/extension/core/pom.xml +++ b/extension/core/pom.xml @@ -6,7 +6,7 @@ io.holunda.data camunda-bpm-data-parent - 1.2.2 + 1.2.3 ../../pom.xml diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/list/ListReadAdapterLockedExternalTask.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/list/ListReadAdapterLockedExternalTask.java index d47412eb..efee4f18 100644 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/list/ListReadAdapterLockedExternalTask.java +++ b/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/list/ListReadAdapterLockedExternalTask.java @@ -3,6 +3,7 @@ import io.holunda.camunda.bpm.data.adapter.ReadAdapter; import io.holunda.camunda.bpm.data.adapter.WrongVariableTypeException; import org.camunda.bpm.engine.externaltask.LockedExternalTask; +import org.camunda.bpm.engine.variable.Variables; import java.util.Collections; import java.util.List; @@ -28,7 +29,7 @@ public ListReadAdapterLockedExternalTask(LockedExternalTask lockedExternalTask, @Override public List get() { - return null; + return getOptional().get(); } @Override @@ -90,6 +91,8 @@ private List getOrNull(T value) { } private T getValue() { - return (T) Optional.ofNullable(lockedExternalTask.getVariables()).map(it -> it.get(variableName)).get(); + return (T) Optional.ofNullable(lockedExternalTask.getVariables()) + .orElse(Variables.createVariables()) + .get(variableName); } } diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/map/MapReadAdapterLockedExternalTask.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/map/MapReadAdapterLockedExternalTask.java index f1011ae2..8bca8fd3 100644 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/map/MapReadAdapterLockedExternalTask.java +++ b/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/map/MapReadAdapterLockedExternalTask.java @@ -3,6 +3,7 @@ import io.holunda.camunda.bpm.data.adapter.ReadAdapter; import io.holunda.camunda.bpm.data.adapter.WrongVariableTypeException; import org.camunda.bpm.engine.externaltask.LockedExternalTask; +import org.camunda.bpm.engine.variable.Variables; import java.util.Collections; import java.util.Map; @@ -31,47 +32,47 @@ public MapReadAdapterLockedExternalTask(LockedExternalTask lockedExternalTask, S @Override public Map get() { - return null; + return getOptional().get(); } @Override @SuppressWarnings("java:S3655") - public Optional> getOptional() { + public Optional> getOptional() { return Optional.ofNullable(getOrNull(getValue())); } @Override - public Map getLocal() { + public Map getLocal() { throw new UnsupportedOperationException("Can't get a local variable on an external task"); } @Override - public Optional> getLocalOptional() { + public Optional> getLocalOptional() { throw new UnsupportedOperationException("Can't get a local variable on an external task"); } @Override - public Map getOrDefault(Map defaultValue) { + public Map getOrDefault(Map defaultValue) { return getOptional().orElse(defaultValue); } @Override - public Map getLocalOrDefault(Map defaultValue) { + public Map getLocalOrDefault(Map defaultValue) { throw new UnsupportedOperationException("Can't get a local variable on an external task"); } @Override - public Map getOrNull() { + public Map getOrNull() { return getOrNull(getValue()); } @Override - public Map getLocalOrNull() { + public Map getLocalOrNull() { throw new UnsupportedOperationException("Can't get a local variable on an external task"); } @SuppressWarnings("Duplicates") - private Map getOrNull(Object value) { + private Map getOrNull(Object value) { if (value == null) { return null; } @@ -96,6 +97,8 @@ private Map getOrNull(Object value) { } private Object getValue() { - return Optional.ofNullable(lockedExternalTask.getVariables()).map(it -> it.get(variableName)).get(); + return Optional.ofNullable(lockedExternalTask.getVariables()) + .orElse(Variables.createVariables()) + .get(variableName); } } diff --git a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/set/SetReadAdapterLockedExternalTask.java b/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/set/SetReadAdapterLockedExternalTask.java index 21b25a63..574b9ae8 100644 --- a/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/set/SetReadAdapterLockedExternalTask.java +++ b/extension/core/src/main/java/io/holunda/camunda/bpm/data/adapter/set/SetReadAdapterLockedExternalTask.java @@ -3,9 +3,9 @@ import io.holunda.camunda.bpm.data.adapter.ReadAdapter; import io.holunda.camunda.bpm.data.adapter.WrongVariableTypeException; import org.camunda.bpm.engine.externaltask.LockedExternalTask; +import org.camunda.bpm.engine.variable.Variables; import java.util.Collections; -import java.util.List; import java.util.Optional; import java.util.Set; @@ -29,7 +29,7 @@ public SetReadAdapterLockedExternalTask(LockedExternalTask lockedExternalTask, S @Override public Set get() { - return null; + return getOptional().get(); } @Override @@ -74,8 +74,8 @@ private Set getOrNull(T value) { return null; } - if (List.class.isAssignableFrom(value.getClass())) { - List valueAsSet = (List) value; + if (Set.class.isAssignableFrom(value.getClass())) { + Set valueAsSet = (Set) value; if (valueAsSet.isEmpty()) { return Collections.emptySet(); } else { @@ -91,6 +91,8 @@ private Set getOrNull(T value) { } private T getValue() { - return (T) Optional.ofNullable(lockedExternalTask.getVariables()).map(it -> it.get(variableName)).get(); + return (T) Optional.ofNullable(lockedExternalTask.getVariables()) + .orElse(Variables.createVariables()) + .get(variableName); } } diff --git a/extension/core/src/test/java/io/holunda/camunda/bpm/data/reader/LockedExternalTaskReaderTest.java b/extension/core/src/test/java/io/holunda/camunda/bpm/data/reader/LockedExternalTaskReaderTest.java index 94b512bb..e9d1b039 100644 --- a/extension/core/src/test/java/io/holunda/camunda/bpm/data/reader/LockedExternalTaskReaderTest.java +++ b/extension/core/src/test/java/io/holunda/camunda/bpm/data/reader/LockedExternalTaskReaderTest.java @@ -7,17 +7,32 @@ import org.junit.Before; import org.junit.Test; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import static io.holunda.camunda.bpm.data.CamundaBpmData.listVariable; +import static io.holunda.camunda.bpm.data.CamundaBpmData.mapVariable; +import static io.holunda.camunda.bpm.data.CamundaBpmData.setVariable; import static io.holunda.camunda.bpm.data.CamundaBpmData.stringVariable; +import static java.util.Arrays.asList; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.camunda.bpm.engine.impl.util.CollectionUtil.asHashSet; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; public class LockedExternalTaskReaderTest { private static final VariableFactory STRING = stringVariable("myString"); + private static final VariableFactory> LIST = listVariable("myList", String.class); + private static final VariableFactory> SET = setVariable("mySet", String.class); + private static final VariableFactory> MAP = mapVariable("myMap", String.class, String.class); - private final String value = "value"; + private final String stringValue = "value"; + private final List listValue = asList("foo", "bar"); + private final Set setValue = asHashSet("foo", "bar"); + private final Map mapValue = Map.of("a", "b", "c", "d"); LockedExternalTask externalTask = mock(LockedExternalTask.class); private VariableReader reader = CamundaBpmData.reader(externalTask); @@ -25,17 +40,29 @@ public class LockedExternalTaskReaderTest { @Before public void setUp() { - when(externalTask.getVariables()).thenReturn(Variables.putValue(STRING.getName(), value)); + when(externalTask.getVariables()).thenReturn( + Variables + .putValue(STRING.getName(), stringValue) + .putValue(LIST.getName(), listValue) + .putValue(SET.getName(), setValue) + .putValue(MAP.getName(), mapValue) + ); } @Test public void shouldDelegateGet() { - assertThat(reader.get(STRING)).isEqualTo(value); + assertThat(reader.get(STRING)).isEqualTo(stringValue); + assertThat(reader.get(LIST)).isEqualTo(listValue); + assertThat(reader.get(SET)).isEqualTo(setValue); + assertThat(reader.get(MAP)).isEqualTo(mapValue); } @Test public void shouldDelegateGetOptional() { - assertThat(reader.getOptional(STRING)).hasValue(value); + assertThat(reader.getOptional(STRING)).hasValue(stringValue); + assertThat(reader.getOptional(LIST)).hasValue(listValue); + assertThat(reader.getOptional(SET)).hasValue(setValue); + assertThat(reader.getOptional(MAP)).hasValue(mapValue); assertThat(reader.getOptional(stringVariable("xxx"))).isEmpty(); } @@ -55,7 +82,10 @@ public void shouldDelegateGetLocal() { @Test public void shouldDelegateGetOrNull() { - assertThat(reader.getOrNull(STRING)).isEqualTo(value); + assertThat(reader.getOrNull(STRING)).isEqualTo(stringValue); + assertThat(reader.getOrNull(LIST)).isEqualTo(listValue); + assertThat(reader.getOrNull(SET)).isEqualTo(setValue); + assertThat(reader.getOrNull(MAP)).isEqualTo(mapValue); assertThat(reader.getOrNull(stringVariable("xxx"))).isNull(); } @@ -68,14 +98,20 @@ public void shouldDelegateGetLocalOrNull() { @Test public void shouldDelegateGetOrDefault() { - assertThat(reader.getOrDefault(STRING, "default")).isEqualTo(value); - assertThat(reader.getOrDefault(stringVariable("xxx"), "default")).isEqualTo("default"); + assertThat(reader.getOrDefault(STRING, "default")).isEqualTo(stringValue); + assertThat(reader.getOrDefault(LIST, asList("a", "b"))).isEqualTo(listValue); + assertThat(reader.getOrDefault(SET, asHashSet("a", "b"))).isEqualTo(setValue); + assertThat(reader.getOrDefault(MAP, Map.of("a", "b", "c", "d"))).isEqualTo(mapValue); + assertThat(reader.getOrDefault(stringVariable("xxx"), "default")).isEqualTo("default"); + assertThat(reader.getOrDefault(listVariable("xxx", String.class), asList("a", "b"))).isEqualTo(asList("a", "b")); + assertThat(reader.getOrDefault(setVariable("xxx", String.class), asHashSet("a", "b"))).isEqualTo(asHashSet("a", "b")); + assertThat(reader.getOrDefault(mapVariable("xxx", String.class, String.class), Map.of("a", "b", "c", "d"))).isEqualTo(Map.of("a", "b", "c", "d")); } @Test public void shouldDelegateGetLocalOrDefault() { - assertThatThrownBy(() -> reader.getLocalOrDefault(STRING, value)) + assertThatThrownBy(() -> reader.getLocalOrDefault(STRING, stringValue)) .isInstanceOf(UnsupportedOperationException.class) .hasMessage("Can't get a local variable on an external task"); } diff --git a/extension/test/pom.xml b/extension/test/pom.xml index 6a561126..6525f180 100644 --- a/extension/test/pom.xml +++ b/extension/test/pom.xml @@ -6,7 +6,7 @@ io.holunda.data camunda-bpm-data-parent - 1.2.2 + 1.2.3 ../../pom.xml diff --git a/pom.xml b/pom.xml index 5a18502f..f8d31737 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ io.holunda.data camunda-bpm-data-parent - 1.2.2 + 1.2.3 ${project.artifactId} Camunda BPM Data https://github.com/holunda-io/camunda-bpm-data/ @@ -21,19 +21,19 @@ 7.15.0 7.15.0-ee - 2.4.4 - 2.4.5 + 2.4.5 + 2.4.21 1.10.1 10.0.0 0.18.2 - 1.4.21 + 1.4.32 true - 2.0.2 + 2.0.6 2.2.0 - 4.12.0 - 2.23.4 + 5.15.0 + 3.9.0 **/*ITest.* **/itest/**/*.* @@ -125,7 +125,7 @@ org.jetbrains annotations - 18.0.0 + 20.1.0 @@ -309,7 +309,7 @@ org.apache.maven.plugins maven-resources-plugin - 3.1.0 + 3.2.0 ${project.build.sourceEncoding} @@ -347,7 +347,7 @@ org.jetbrains.dokka dokka-maven-plugin - 1.4.10.2 + 1.4.32 attach-javadocs @@ -381,7 +381,7 @@ org.codehaus.mojo build-helper-maven-plugin - 3.0.0 + 3.2.0 generate-sources @@ -401,7 +401,7 @@ org.apache.maven.plugins maven-source-plugin - 3.2.0 + 3.2.1 attach-sources @@ -421,7 +421,7 @@ com.amashchenko.maven.plugin gitflow-maven-plugin - 1.14.0 + 1.16.0 master