Skip to content

Commit

Permalink
Fix checkProcessInstanceHasVariableValue contains exactly list of val…
Browse files Browse the repository at this point in the history
…ues in any order
  • Loading branch information
igdianov committed Nov 16, 2024
1 parent 75dc504 commit 6bf785a
Showing 1 changed file with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@
import static org.activiti.cloud.services.common.util.ImageUtils.svgToPng;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.catchThrowable;
import static org.assertj.core.api.Assertions.tuple;
import static org.awaitility.Awaitility.await;

import java.time.Duration;
import java.util.Collection;
import java.util.List;
import net.thucydides.core.annotations.Step;
import org.activiti.api.model.shared.model.VariableInstance;
import org.activiti.api.process.model.ProcessDefinition;
Expand Down Expand Up @@ -113,7 +112,6 @@ public void checkProcessInstanceHasVariableValue(
Object variableValue
) {
await()
.atMost(Duration.ofSeconds(30))
.untilAsserted(() -> {
assertThat(variableName).isNotNull();
final Collection<CloudVariableInstance> variableInstances = processQueryService
Expand All @@ -122,9 +120,19 @@ public void checkProcessInstanceHasVariableValue(
assertThat(variableInstances).isNotNull();
assertThat(variableInstances).isNotEmpty();
//one of the variables should have name matching variableName and value
assertThat(variableInstances)
.extracting(VariableInstance::getName, VariableInstance::getValue)
.contains(tuple(variableName, variableValue));

assertThat(variableInstances).extracting(VariableInstance::getName).contains(variableName);

assertThat(
variableInstances
.stream()
.filter(it -> it.getName().equals(variableName))
.map(CloudVariableInstance::getValue)
.toList()
)
.containsExactlyInAnyOrderElementsOf(
variableValue instanceof List<?> variableValues ? variableValues : List.of(variableValue)
);
});
}

Expand Down

0 comments on commit 6bf785a

Please sign in to comment.