Skip to content

Commit

Permalink
Merge branch 'release/1.2.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
zambrovski committed Apr 27, 2021
2 parents d848781 + 36d92cf commit 4827ac2
Show file tree
Hide file tree
Showing 14 changed files with 92 additions and 48 deletions.
2 changes: 1 addition & 1 deletion docs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.holunda.data</groupId>
<artifactId>camunda-bpm-data-parent</artifactId>
<version>1.2.2</version>
<version>1.2.3</version>
</parent>

<artifactId>camunda-bpm-data-docs</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion example/coverage-report-aggregator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.holunda.data.example</groupId>
<artifactId>camunda-bpm-data-example-parent</artifactId>
<version>1.2.2</version>
<version>1.2.3</version>
</parent>

<artifactId>camunda-bpm-data-coverage-report</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion example/example-java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.holunda.data.example</groupId>
<artifactId>camunda-bpm-data-example-parent</artifactId>
<version>1.2.2</version>
<version>1.2.3</version>
</parent>

<artifactId>camunda-bpm-data-example-java</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion example/example-kotlin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.holunda.data.example</groupId>
<artifactId>camunda-bpm-data-example-parent</artifactId>
<version>1.2.2</version>
<version>1.2.3</version>
</parent>

<artifactId>camunda-bpm-data-example-kotlin</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion example/itest/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.holunda.data.example</groupId>
<artifactId>camunda-bpm-data-example-parent</artifactId>
<version>1.2.2</version>
<version>1.2.3</version>
</parent>

<artifactId>camunda-bpm-data-integration-test</artifactId>
Expand Down
4 changes: 2 additions & 2 deletions example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.holunda.data</groupId>
<artifactId>camunda-bpm-data-parent</artifactId>
<version>1.2.2</version>
<version>1.2.3</version>
</parent>

<groupId>io.holunda.data.example</groupId>
Expand Down Expand Up @@ -59,7 +59,7 @@
<dependency>
<groupId>io.holunda.testing</groupId>
<artifactId>camunda-bpm-jgiven</artifactId>
<version>0.0.5</version>
<version>0.0.7</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion example/spin-type-detector/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.holunda.data.example</groupId>
<artifactId>camunda-bpm-data-example-parent</artifactId>
<version>1.2.2</version>
<version>1.2.3</version>
</parent>

<artifactId>camunda-bpm-data-spin-type-detector</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion extension/core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.holunda.data</groupId>
<artifactId>camunda-bpm-data-parent</artifactId>
<version>1.2.2</version>
<version>1.2.3</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -28,7 +29,7 @@ public ListReadAdapterLockedExternalTask(LockedExternalTask lockedExternalTask,

@Override
public List<T> get() {
return null;
return getOptional().get();
}

@Override
Expand Down Expand Up @@ -90,6 +91,8 @@ private List<T> 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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -31,47 +32,47 @@ public MapReadAdapterLockedExternalTask(LockedExternalTask lockedExternalTask, S

@Override
public Map<K, V> get() {
return null;
return getOptional().get();
}

@Override
@SuppressWarnings("java:S3655")
public Optional<Map<K,V>> getOptional() {
public Optional<Map<K, V>> getOptional() {
return Optional.ofNullable(getOrNull(getValue()));
}

@Override
public Map<K,V> getLocal() {
public Map<K, V> getLocal() {
throw new UnsupportedOperationException("Can't get a local variable on an external task");
}

@Override
public Optional<Map<K,V>> getLocalOptional() {
public Optional<Map<K, V>> getLocalOptional() {
throw new UnsupportedOperationException("Can't get a local variable on an external task");
}

@Override
public Map<K,V> getOrDefault(Map<K,V> defaultValue) {
public Map<K, V> getOrDefault(Map<K, V> defaultValue) {
return getOptional().orElse(defaultValue);
}

@Override
public Map<K,V> getLocalOrDefault(Map<K,V> defaultValue) {
public Map<K, V> getLocalOrDefault(Map<K, V> defaultValue) {
throw new UnsupportedOperationException("Can't get a local variable on an external task");
}

@Override
public Map<K,V> getOrNull() {
public Map<K, V> getOrNull() {
return getOrNull(getValue());
}

@Override
public Map<K,V> getLocalOrNull() {
public Map<K, V> getLocalOrNull() {
throw new UnsupportedOperationException("Can't get a local variable on an external task");
}

@SuppressWarnings("Duplicates")
private Map<K,V> getOrNull(Object value) {
private Map<K, V> getOrNull(Object value) {
if (value == null) {
return null;
}
Expand All @@ -96,6 +97,8 @@ private Map<K,V> 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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -29,7 +29,7 @@ public SetReadAdapterLockedExternalTask(LockedExternalTask lockedExternalTask, S

@Override
public Set<T> get() {
return null;
return getOptional().get();
}

@Override
Expand Down Expand Up @@ -74,8 +74,8 @@ private Set<T> 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 {
Expand All @@ -91,6 +91,8 @@ private Set<T> 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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,62 @@
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> STRING = stringVariable("myString");
private static final VariableFactory<List<String>> LIST = listVariable("myList", String.class);
private static final VariableFactory<Set<String>> SET = setVariable("mySet", String.class);
private static final VariableFactory<Map<String, String>> MAP = mapVariable("myMap", String.class, String.class);

private final String value = "value";
private final String stringValue = "value";
private final List<String> listValue = asList("foo", "bar");
private final Set<String> setValue = asHashSet("foo", "bar");
private final Map<String, String> mapValue = Map.of("a", "b", "c", "d");

LockedExternalTask externalTask = mock(LockedExternalTask.class);
private VariableReader reader = CamundaBpmData.reader(externalTask);


@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();
}

Expand All @@ -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();
}

Expand All @@ -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");
}
Expand Down
2 changes: 1 addition & 1 deletion extension/test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.holunda.data</groupId>
<artifactId>camunda-bpm-data-parent</artifactId>
<version>1.2.2</version>
<version>1.2.3</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
Loading

0 comments on commit 4827ac2

Please sign in to comment.