From b8fcb1c3040932dda13343da37672c4fe5cbbe48 Mon Sep 17 00:00:00 2001 From: Paul Daulby Date: Wed, 24 Jul 2019 13:46:13 +0100 Subject: [PATCH 01/14] feat(#1441): Create DecisionBasedSolver --- .../decisionbased/DecisionBasedSolver.java | 84 +++++++++++++++++++ .../walker/decisionbased/OptionPicker.java | 11 +++ .../generator/walker/reductive/Merged.java | 6 ++ 3 files changed, 101 insertions(+) create mode 100644 generator/src/main/java/com/scottlogic/deg/generator/walker/decisionbased/DecisionBasedSolver.java create mode 100644 generator/src/main/java/com/scottlogic/deg/generator/walker/decisionbased/OptionPicker.java diff --git a/generator/src/main/java/com/scottlogic/deg/generator/walker/decisionbased/DecisionBasedSolver.java b/generator/src/main/java/com/scottlogic/deg/generator/walker/decisionbased/DecisionBasedSolver.java new file mode 100644 index 000000000..15e89c698 --- /dev/null +++ b/generator/src/main/java/com/scottlogic/deg/generator/walker/decisionbased/DecisionBasedSolver.java @@ -0,0 +1,84 @@ +package com.scottlogic.deg.generator.walker.decisionbased; + +import com.google.inject.Inject; +import com.scottlogic.deg.common.profile.Field; +import com.scottlogic.deg.common.profile.ProfileFields; +import com.scottlogic.deg.common.profile.constraints.atomic.AtomicConstraint; +import com.scottlogic.deg.common.util.FlatMappingSpliterator; +import com.scottlogic.deg.generator.decisiontree.ConstraintNode; +import com.scottlogic.deg.generator.decisiontree.DecisionNode; +import com.scottlogic.deg.generator.decisiontree.DecisionTree; +import com.scottlogic.deg.generator.fieldspecs.FieldSpec; +import com.scottlogic.deg.generator.fieldspecs.RowSpec; +import com.scottlogic.deg.generator.reducer.ConstraintReducer; +import com.scottlogic.deg.generator.walker.reductive.Merged; +import com.scottlogic.deg.generator.walker.reductive.ReductiveTreePruner; +import com.scottlogic.deg.generator.walker.rowspec.RowSpecTreeSolver; + +import java.util.Collections; +import java.util.Map; +import java.util.function.Function; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +public class DecisionBasedSolver implements RowSpecTreeSolver { + + private final ConstraintReducer constraintReducer; + private final ReductiveTreePruner reductiveTreePruner; + private final OptionPicker optionPicker; + + @Inject + public DecisionBasedSolver(ConstraintReducer constraintReducer, ReductiveTreePruner reductiveTreePruner, OptionPicker optionPicker) { + this.constraintReducer = constraintReducer; + this.reductiveTreePruner = reductiveTreePruner; + this.optionPicker = optionPicker; + } + + @Override + public Stream createRowSpecs(DecisionTree tree) { + return reduceToRowNodes(tree.rootNode) + .map(rootNode -> toRowspec(tree.fields, rootNode)); + } + + private RowSpec toRowspec(ProfileFields fields, ConstraintNode rootNode){ + return constraintReducer + .reduceConstraintsToRowSpec(fields, rootNode.getAtomicConstraints()) + .get();//todo + } + + private Stream reduceToRowNodes(ConstraintNode rootNode){ + if (rootNode.getDecisions().isEmpty()){ + return Stream.of(rootNode); + } + + DecisionNode decisionNode = optionPicker.pickDecision(rootNode); + ConstraintNode rootWithoutDecision = rootNode.removeDecisions(Collections.singleton(decisionNode)); + + Stream rootOnlyConstraintNodes = optionPicker.streamOptions(decisionNode) + .map(option -> combineWithRootNode(rootWithoutDecision, option)) + .filter(Merged::notContradictory) + .map(Merged::get); + + return FlatMappingSpliterator.flatMap( + rootOnlyConstraintNodes, + this::reduceToRowNodes); + } + + private Merged combineWithRootNode(ConstraintNode rootNode, ConstraintNode option) { + ConstraintNode constraintNode = rootNode + .addDecisions(option.getDecisions()) + .addAtomicConstraints(option.getAtomicConstraints()); + + return reductiveTreePruner.pruneConstraintNode(constraintNode, getFields(option)); + } + + private Map getFields(ConstraintNode option) { + return option.getAtomicConstraints().stream() + .map(AtomicConstraint::getField) + .distinct() + .collect(Collectors.toMap( + Function.identity(), + field-> FieldSpec.Empty)); + } + +} diff --git a/generator/src/main/java/com/scottlogic/deg/generator/walker/decisionbased/OptionPicker.java b/generator/src/main/java/com/scottlogic/deg/generator/walker/decisionbased/OptionPicker.java new file mode 100644 index 000000000..d77920aa5 --- /dev/null +++ b/generator/src/main/java/com/scottlogic/deg/generator/walker/decisionbased/OptionPicker.java @@ -0,0 +1,11 @@ +package com.scottlogic.deg.generator.walker.decisionbased; + +import com.scottlogic.deg.generator.decisiontree.ConstraintNode; +import com.scottlogic.deg.generator.decisiontree.DecisionNode; + +import java.util.stream.Stream; + +public interface OptionPicker { + DecisionNode pickDecision (ConstraintNode constraintNode); + Stream streamOptions(DecisionNode decisionNode); +} diff --git a/generator/src/main/java/com/scottlogic/deg/generator/walker/reductive/Merged.java b/generator/src/main/java/com/scottlogic/deg/generator/walker/reductive/Merged.java index 06cd82eee..827f0f4ec 100644 --- a/generator/src/main/java/com/scottlogic/deg/generator/walker/reductive/Merged.java +++ b/generator/src/main/java/com/scottlogic/deg/generator/walker/reductive/Merged.java @@ -16,6 +16,8 @@ package com.scottlogic.deg.generator.walker.reductive; +import com.scottlogic.deg.generator.decisiontree.ConstraintNode; + import java.util.NoSuchElementException; import java.util.Objects; import java.util.function.Consumer; @@ -51,6 +53,10 @@ public boolean isContradictory() { return value == null; } + public boolean notContradictory() { + return !isContradictory(); + } + /** * If a value not Contradictory in this {@code Merged}, returns the value, * otherwise throws {@code NoSuchElementException}. From e3382b60bfb1df78c0499832d1ec682a4353bcb7 Mon Sep 17 00:00:00 2001 From: Paul Daulby Date: Wed, 24 Jul 2019 13:46:32 +0100 Subject: [PATCH 02/14] Implement OptionPicker --- .../decisionbased/RandomOptionPicker.java | 32 +++++++++++++++++++ .../decisionbased/SequentialOptionPicker.java | 18 +++++++++++ 2 files changed, 50 insertions(+) create mode 100644 generator/src/main/java/com/scottlogic/deg/generator/walker/decisionbased/RandomOptionPicker.java create mode 100644 generator/src/main/java/com/scottlogic/deg/generator/walker/decisionbased/SequentialOptionPicker.java diff --git a/generator/src/main/java/com/scottlogic/deg/generator/walker/decisionbased/RandomOptionPicker.java b/generator/src/main/java/com/scottlogic/deg/generator/walker/decisionbased/RandomOptionPicker.java new file mode 100644 index 000000000..86322a42a --- /dev/null +++ b/generator/src/main/java/com/scottlogic/deg/generator/walker/decisionbased/RandomOptionPicker.java @@ -0,0 +1,32 @@ +package com.scottlogic.deg.generator.walker.decisionbased; + +import com.google.inject.Inject; +import com.scottlogic.deg.generator.decisiontree.ConstraintNode; +import com.scottlogic.deg.generator.decisiontree.DecisionNode; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Random; +import java.util.stream.Stream; + +public class RandomOptionPicker implements OptionPicker { + private final Random random; + + public RandomOptionPicker() { + this.random = new Random(); + } + + @Override + public DecisionNode pickDecision(ConstraintNode constraintNode) { + return constraintNode.getDecisions().stream() + .skip(random.nextInt(constraintNode.getDecisions().size())) + .findFirst().get(); + } + + @Override + public Stream streamOptions(DecisionNode decisionNode) { + ArrayList options = new ArrayList(decisionNode.getOptions()); + Collections.shuffle(options); + return options.stream(); + } +} diff --git a/generator/src/main/java/com/scottlogic/deg/generator/walker/decisionbased/SequentialOptionPicker.java b/generator/src/main/java/com/scottlogic/deg/generator/walker/decisionbased/SequentialOptionPicker.java new file mode 100644 index 000000000..7ee374a58 --- /dev/null +++ b/generator/src/main/java/com/scottlogic/deg/generator/walker/decisionbased/SequentialOptionPicker.java @@ -0,0 +1,18 @@ +package com.scottlogic.deg.generator.walker.decisionbased; + +import com.scottlogic.deg.generator.decisiontree.ConstraintNode; +import com.scottlogic.deg.generator.decisiontree.DecisionNode; + +import java.util.stream.Stream; + +public class SequentialOptionPicker implements OptionPicker { + @Override + public DecisionNode pickDecision(ConstraintNode constraintNode) { + return constraintNode.getDecisions().iterator().next(); + } + + @Override + public Stream streamOptions(DecisionNode decisionNode) { + return decisionNode.getOptions().stream(); + } +} From a519665597c0d3346a3f1f006e0a34e623181b72 Mon Sep 17 00:00:00 2001 From: Paul Daulby Date: Wed, 24 Jul 2019 13:47:00 +0100 Subject: [PATCH 03/14] Add Decision Based tree walker to config --- .../config/detail/TreeWalkerType.java | 3 +- .../guice/DecisionTreeWalkerProvider.java | 1 + .../deg/generator/guice/GeneratorModule.java | 4 +- .../generator/guice/OptionPickerProvider.java | 32 ++++++++++++++++ .../guice/RowSpecTreeSolverProvider.java | 37 +++++++++++++++++++ 5 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 generator/src/main/java/com/scottlogic/deg/generator/guice/OptionPickerProvider.java create mode 100644 generator/src/main/java/com/scottlogic/deg/generator/guice/RowSpecTreeSolverProvider.java diff --git a/generator/src/main/java/com/scottlogic/deg/generator/config/detail/TreeWalkerType.java b/generator/src/main/java/com/scottlogic/deg/generator/config/detail/TreeWalkerType.java index 8bc11e82b..f6cbbf5c4 100644 --- a/generator/src/main/java/com/scottlogic/deg/generator/config/detail/TreeWalkerType.java +++ b/generator/src/main/java/com/scottlogic/deg/generator/config/detail/TreeWalkerType.java @@ -18,5 +18,6 @@ public enum TreeWalkerType { CARTESIAN_PRODUCT, - REDUCTIVE + REDUCTIVE, + DECISION_BASED } diff --git a/generator/src/main/java/com/scottlogic/deg/generator/guice/DecisionTreeWalkerProvider.java b/generator/src/main/java/com/scottlogic/deg/generator/guice/DecisionTreeWalkerProvider.java index 39b1133f5..3d550fdf8 100644 --- a/generator/src/main/java/com/scottlogic/deg/generator/guice/DecisionTreeWalkerProvider.java +++ b/generator/src/main/java/com/scottlogic/deg/generator/guice/DecisionTreeWalkerProvider.java @@ -45,6 +45,7 @@ public DecisionTreeWalkerProvider( public DecisionTreeWalker get() { switch(configSource.getWalkerType()) { case CARTESIAN_PRODUCT: + case DECISION_BASED: return rowSpecDecisionTreeWalker; case REDUCTIVE: diff --git a/generator/src/main/java/com/scottlogic/deg/generator/guice/GeneratorModule.java b/generator/src/main/java/com/scottlogic/deg/generator/guice/GeneratorModule.java index 51d1fbf3e..d007efc2f 100644 --- a/generator/src/main/java/com/scottlogic/deg/generator/guice/GeneratorModule.java +++ b/generator/src/main/java/com/scottlogic/deg/generator/guice/GeneratorModule.java @@ -28,6 +28,7 @@ import com.scottlogic.deg.generator.generation.combinationstrategies.CombinationStrategy; import com.scottlogic.deg.generator.inputs.validation.ProfileValidator; import com.scottlogic.deg.generator.utils.JavaUtilRandomNumberGenerator; +import com.scottlogic.deg.generator.walker.decisionbased.OptionPicker; import com.scottlogic.deg.generator.walker.rowspec.CartesianProductRowSpecTreeSolver; import com.scottlogic.deg.generator.walker.DecisionTreeWalker; import com.scottlogic.deg.generator.walker.ReductiveWalkerRetryChecker; @@ -60,6 +61,8 @@ protected void configure() { bind(ReductiveDataGeneratorMonitor.class).toProvider(MonitorProvider.class).in(Singleton.class); bind(IterationVisualiser.class).toProvider(IterationVisualiserProvider.class); bind(CombinationStrategy.class).toProvider(CombinationStrategyProvider.class); + bind(OptionPicker.class).toProvider(OptionPickerProvider.class); + bind(RowSpecTreeSolver.class).toProvider(RowSpecTreeSolverProvider.class); // bind config directly bind(DataGenerationType.class).toInstance(generationConfigSource.getGenerationType()); @@ -73,7 +76,6 @@ protected void configure() { bind(DataGenerator.class).to(DecisionTreeDataGenerator.class); bind(DecisionTreeFactory.class).to(MaxStringLengthInjectingDecisionTreeFactory.class); bind(FieldValueSourceEvaluator.class).to(StandardFieldValueSourceEvaluator.class); - bind(RowSpecTreeSolver.class).to(CartesianProductRowSpecTreeSolver.class); bind(ReductiveWalkerRetryChecker.class).toInstance(new ReductiveWalkerRetryChecker(10000)); bind(JavaUtilRandomNumberGenerator.class) diff --git a/generator/src/main/java/com/scottlogic/deg/generator/guice/OptionPickerProvider.java b/generator/src/main/java/com/scottlogic/deg/generator/guice/OptionPickerProvider.java new file mode 100644 index 000000000..24f25eafa --- /dev/null +++ b/generator/src/main/java/com/scottlogic/deg/generator/guice/OptionPickerProvider.java @@ -0,0 +1,32 @@ +package com.scottlogic.deg.generator.guice; + +import com.google.inject.Inject; +import com.google.inject.Provider; +import com.scottlogic.deg.generator.config.detail.DataGenerationType; +import com.scottlogic.deg.generator.generation.GenerationConfigSource; +import com.scottlogic.deg.generator.walker.decisionbased.OptionPicker; +import com.scottlogic.deg.generator.walker.decisionbased.RandomOptionPicker; +import com.scottlogic.deg.generator.walker.decisionbased.SequentialOptionPicker; + +public class OptionPickerProvider implements Provider { + + private final GenerationConfigSource config; + private final RandomOptionPicker randomOptionPicker; + private final SequentialOptionPicker sequentialOptionPicker; + + @Inject + public OptionPickerProvider(GenerationConfigSource config, RandomOptionPicker randomOptionPicker, SequentialOptionPicker sequentialOptionPicker){ + this.config = config; + this.randomOptionPicker = randomOptionPicker; + this.sequentialOptionPicker = sequentialOptionPicker; + } + + @Override + public OptionPicker get() { + if (config.getGenerationType() == DataGenerationType.RANDOM){ + return randomOptionPicker; + } + + return sequentialOptionPicker; + } +} diff --git a/generator/src/main/java/com/scottlogic/deg/generator/guice/RowSpecTreeSolverProvider.java b/generator/src/main/java/com/scottlogic/deg/generator/guice/RowSpecTreeSolverProvider.java new file mode 100644 index 000000000..d26912b6b --- /dev/null +++ b/generator/src/main/java/com/scottlogic/deg/generator/guice/RowSpecTreeSolverProvider.java @@ -0,0 +1,37 @@ +package com.scottlogic.deg.generator.guice; + +import com.google.inject.Inject; +import com.google.inject.Provider; +import com.scottlogic.deg.common.ValidationException; +import com.scottlogic.deg.generator.generation.GenerationConfigSource; +import com.scottlogic.deg.generator.walker.decisionbased.DecisionBasedSolver; +import com.scottlogic.deg.generator.walker.rowspec.CartesianProductRowSpecTreeSolver; +import com.scottlogic.deg.generator.walker.rowspec.RowSpecTreeSolver; + +public class RowSpecTreeSolverProvider implements Provider { + + private final GenerationConfigSource config; + private final CartesianProductRowSpecTreeSolver cartesianProductRowSpecTreeSolver; + private final DecisionBasedSolver decisionBasedSolver; + + @Inject + public RowSpecTreeSolverProvider(GenerationConfigSource config, CartesianProductRowSpecTreeSolver cartesianProductRowSpecTreeSolver, DecisionBasedSolver decisionBasedSolver) { + this.config = config; + this.cartesianProductRowSpecTreeSolver = cartesianProductRowSpecTreeSolver; + this.decisionBasedSolver = decisionBasedSolver; + } + + @Override + public RowSpecTreeSolver get() { + switch (config.getWalkerType()) { + case DECISION_BASED: + return decisionBasedSolver; + case CARTESIAN_PRODUCT: + return cartesianProductRowSpecTreeSolver; + case REDUCTIVE: + return decisionBasedSolver; + default: + throw new ValidationException("no WalkerType selected"); + } + } +} From 5fb6e1fe3ceaaa5fbba8c007db3fe1625dbb818a Mon Sep 17 00:00:00 2001 From: Paul Daulby Date: Wed, 24 Jul 2019 17:31:22 +0100 Subject: [PATCH 04/14] Create RandomRowSpecDecisionTreeWalker --- .../guice/DecisionTreeWalkerProvider.java | 8 ++- .../RandomRowSpecDecisionTreeWalker.java | 60 +++++++++++++++++++ 2 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 generator/src/main/java/com/scottlogic/deg/generator/walker/rowspec/RandomRowSpecDecisionTreeWalker.java diff --git a/generator/src/main/java/com/scottlogic/deg/generator/guice/DecisionTreeWalkerProvider.java b/generator/src/main/java/com/scottlogic/deg/generator/guice/DecisionTreeWalkerProvider.java index 3d550fdf8..fa143f4f9 100644 --- a/generator/src/main/java/com/scottlogic/deg/generator/guice/DecisionTreeWalkerProvider.java +++ b/generator/src/main/java/com/scottlogic/deg/generator/guice/DecisionTreeWalkerProvider.java @@ -21,12 +21,14 @@ import com.scottlogic.deg.generator.config.detail.DataGenerationType; import com.scottlogic.deg.generator.generation.GenerationConfigSource; import com.scottlogic.deg.generator.walker.*; +import com.scottlogic.deg.generator.walker.rowspec.RandomRowSpecDecisionTreeWalker; import com.scottlogic.deg.generator.walker.rowspec.RowSpecDecisionTreeWalker; public class DecisionTreeWalkerProvider implements Provider { private final ReductiveDecisionTreeWalker reductiveDecisionTreeWalker; - private final RowSpecDecisionTreeWalker rowSpecDecisionTreeWalker; private final RandomReductiveDecisionTreeWalker randomReductiveDecisionTreeWalker; + private final RowSpecDecisionTreeWalker rowSpecDecisionTreeWalker; + private final RandomRowSpecDecisionTreeWalker randomRowSpecDecisionTreeWalker; private final GenerationConfigSource configSource; @Inject @@ -34,10 +36,12 @@ public DecisionTreeWalkerProvider( ReductiveDecisionTreeWalker reductiveDecisionTreeWalker, RowSpecDecisionTreeWalker rowSpecDecisionTreeWalker, RandomReductiveDecisionTreeWalker randomReductiveDecisionTreeWalker, + RandomRowSpecDecisionTreeWalker randomRowSpecDecisionTreeWalker, GenerationConfigSource configSource) { this.reductiveDecisionTreeWalker = reductiveDecisionTreeWalker; this.rowSpecDecisionTreeWalker = rowSpecDecisionTreeWalker; this.randomReductiveDecisionTreeWalker = randomReductiveDecisionTreeWalker; + this.randomRowSpecDecisionTreeWalker = randomRowSpecDecisionTreeWalker; this.configSource = configSource; } @@ -46,6 +50,8 @@ public DecisionTreeWalker get() { switch(configSource.getWalkerType()) { case CARTESIAN_PRODUCT: case DECISION_BASED: + if (configSource.getGenerationType() == DataGenerationType.RANDOM) + return randomRowSpecDecisionTreeWalker; return rowSpecDecisionTreeWalker; case REDUCTIVE: diff --git a/generator/src/main/java/com/scottlogic/deg/generator/walker/rowspec/RandomRowSpecDecisionTreeWalker.java b/generator/src/main/java/com/scottlogic/deg/generator/walker/rowspec/RandomRowSpecDecisionTreeWalker.java new file mode 100644 index 000000000..9c59aa38f --- /dev/null +++ b/generator/src/main/java/com/scottlogic/deg/generator/walker/rowspec/RandomRowSpecDecisionTreeWalker.java @@ -0,0 +1,60 @@ +package com.scottlogic.deg.generator.walker.rowspec; + +import com.google.inject.Inject; +import com.scottlogic.deg.common.util.FlatMappingSpliterator; +import com.scottlogic.deg.generator.decisiontree.DecisionTree; +import com.scottlogic.deg.generator.fieldspecs.RowSpec; +import com.scottlogic.deg.generator.generation.databags.DataBag; +import com.scottlogic.deg.generator.generation.databags.RowSpecDataBagGenerator; +import com.scottlogic.deg.generator.walker.DecisionTreeWalker; + +import java.util.Optional; +import java.util.stream.Stream; + +public class RandomRowSpecDecisionTreeWalker implements DecisionTreeWalker { + private final RowSpecTreeSolver rowSpecTreeSolver; + private final RowSpecDataBagGenerator rowSpecDataBagGenerator; + + @Inject + public RandomRowSpecDecisionTreeWalker(RowSpecTreeSolver rowSpecTreeSolver, RowSpecDataBagGenerator rowSpecDataBagGenerator) { + this.rowSpecTreeSolver = rowSpecTreeSolver; + this.rowSpecDataBagGenerator = rowSpecDataBagGenerator; + } + + @Override + public Stream walk(DecisionTree tree) { + + if (tree.rootNode.getDecisions().isEmpty()){ + return generateWithoutRestarting(tree); + } + + return FlatMappingSpliterator.flatMap( + getRowSpecAndRestart(tree), + this::createDataBags); + } + + private Stream generateWithoutRestarting(DecisionTree tree) { + return FlatMappingSpliterator.flatMap( + rowSpecTreeSolver.createRowSpecs(tree), + rowSpecDataBagGenerator::createDataBags); + } + + private Stream getRowSpecAndRestart(DecisionTree tree) { + Optional firstRowSpecOpt = getFirstRowSpec(tree); + if (!firstRowSpecOpt.isPresent()) { + return Stream.empty(); + } + + return Stream.generate(() -> getFirstRowSpec(tree)) + .map(Optional::get); + } + + private Optional getFirstRowSpec(DecisionTree tree) { + return rowSpecTreeSolver.createRowSpecs(tree).findFirst(); + } + + private Stream createDataBags(RowSpec rowSpec) { + return rowSpecDataBagGenerator.createDataBags(rowSpec) + .limit(1); + } +} From cea264ea7c445e626ff226d9fd907e27be5c7d90 Mon Sep 17 00:00:00 2001 From: Paul Daulby Date: Wed, 24 Jul 2019 17:37:09 +0100 Subject: [PATCH 05/14] Make Copy of if feature for decisionBasedSolver --- .../grammatical/IfDecisionBased.feature | 3900 +++++++++++++++++ 1 file changed, 3900 insertions(+) create mode 100644 orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/features/operators/grammatical/IfDecisionBased.feature diff --git a/orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/features/operators/grammatical/IfDecisionBased.feature b/orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/features/operators/grammatical/IfDecisionBased.feature new file mode 100644 index 000000000..a96cd7c09 --- /dev/null +++ b/orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/features/operators/grammatical/IfDecisionBased.feature @@ -0,0 +1,3900 @@ +Feature: Values can be specified by using if, then and else constraints + + Background: + Given the generation strategy is full + And the combination strategy is exhaustive + And the walker type is DECISION_BASED + And the following fields exist: + | foo | + | bar | + + Scenario: Running an 'if' constraint for then condition only should be successful + Given foo is in set: + | "a" | + | "b" | + And foo is anything but null + And bar is in set: + | 10 | + | 20 | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": "a" }, + "then": { "field": "bar", "is": "equalTo", "value": 10 } + } + """ + Then the following data should be generated: + | foo | bar | + | "a" | 10 | + | "b" | 10 | + | "b" | 20 | + + Scenario: Running an 'if' constraint for then and else conditions should be successful + Given foo is in set: + | "a" | + | "b" | + And foo is anything but null + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": "a" }, + "then": { "field": "bar", "is": "equalTo", "value": 3 }, + "else": { "field": "bar", "is": "equalTo", "value": 5 } + } + """ + Then the following data should be generated: + | foo | bar | + | "a" | 3 | + | "b" | 5 | + + Scenario: Running an 'if' request that contains a valid anyOf statement should be successful + Given foo is in set: + | 1 | + | 2 | + | 3 | + | 4 | + And foo is anything but null + And bar is in set: + | "a" | + | "b" | + And bar is anything but null + And there is a constraint: + """ + { + "if": + { "anyOf": [ + { "field": "foo", "is": "equalTo", "value": 1 }, + { "field": "foo", "is": "equalTo", "value": 2 } + ]}, + "then": { "field": "bar", "is": "equalTo", "value": "a" }, + "else": { "field": "bar", "is": "equalTo", "value": "b" } + } + """ + Then the following data should be generated: + | foo | bar | + | 1 | "a" | + | 2 | "a" | + | 3 | "b" | + | 4 | "b" | + + Scenario: Running an 'if' request that contains a valid allOf statement should be successful + Given foo is in set: + | 1 | + | 2 | + | 3 | + | 4 | + And foo is anything but null + And bar is in set: + | "a" | + | "b" | + And bar is anything but null + And there is a constraint: + """ + { + "if": { + "allOf": [ + { "field": "foo", "is": "greaterThan", "value": 1 }, + { "field": "foo", "is": "lessThan", "value": 4 } + ]}, + "then": { "field": "bar", "is": "equalTo", "value": "a" }, + "else": { "field": "bar", "is": "equalTo", "value": "b" } + } + """ + Then the following data should be generated: + | foo | bar | + | 1 | "b" | + | 2 | "a" | + | 3 | "a" | + | 4 | "b" | + + Scenario: Running an 'if' request that contains a valid not statement should be successful + Given foo is in set: + | 1 | + | 2 | + | 3 | + | 4 | + And foo is anything but null + And bar is in set: + | "a" | + | "b" | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "not": { "field": "foo", "is": "equalTo", "value": 1 } }, + "then": { "field": "bar", "is": "equalTo", "value": "a" }, + "else": { "field": "bar", "is": "equalTo", "value": "b" } + } + """ + Then the following data should be generated: + | foo | bar | + | 1 | "b" | + | 2 | "a" | + | 3 | "a" | + | 4 | "a" | + + Scenario: Running an 'if' request that contains a valid nested if statement should be successful + Given foo is in set: + | 1 | + | 2 | + | 3 | + | 4 | + And foo is anything but null + And bar is in set: + | "a" | + | "b" | + | "c" | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "greaterThan", "value": 1 }, + "then": { + "if": { "field": "foo", "is": "greaterThan", "value": 3 }, + "then": { "field": "bar", "is": "equalTo", "value": "a" }, + "else": { "field": "bar", "is": "equalTo", "value": "b" } + }, + "else": { "field": "bar", "is": "equalTo", "value": "c" } + } + """ + Then the following data should be generated: + | foo | bar | + | 1 | "c" | + | 2 | "b" | + | 3 | "b" | + | 4 | "a" | + + Scenario: Running an 'if' request that is invalidly formatted (missing a then statement) should be successful + Given foo is in set: + | 1 | + | 2 | + | 3 | + | 4 | + And foo is anything but null + And bar is in set: + | "a" | + | "b" | + | "c" | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": "1" }, + "else": { "field": "bar", "is": "equalTo", "value": 10 } + } + """ + Then the profile is invalid because "Constraint is null" + And no data is created + + Scenario: Running a 'if' request that includes an invalid if value (not in field set) should be successful + Given foo is in set: + | 1 | + | 2 | + | 3 | + | 4 | + And foo is anything but null + And bar is in set: + | "a" | + | "b" | + | "c" | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": "a" }, + "then": { "field": "bar", "is": "equalTo", "value": "a" }, + "else": { "field": "bar", "is": "equalTo", "value": "b" } + } + """ + Then the following data should be generated: + | foo | bar | + | 1 | "b" | + | 2 | "b" | + | 3 | "b" | + | 4 | "b" | + + Scenario: Running a 'if' request that includes an invalid then value (not in field set) should be successful + Given foo is in set: + | 1 | + | 2 | + | 3 | + | 4 | + And foo is anything but null + And bar is in set: + | "a" | + | "b" | + | "c" | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": 1 }, + "then": { "field": "bar", "is": "equalTo", "value": "X" }, + "else": { "field": "bar", "is": "equalTo", "value": "b" } + } + """ + Then the following data should be generated: + | foo | bar | + | 2 | "b" | + | 3 | "b" | + | 4 | "b" | + + Scenario: Running a 'if' request that includes an invalid else value (not in field set) should be successful + Given foo is in set: + | 1 | + | 2 | + | 3 | + | 4 | + And foo is anything but null + And bar is in set: + | "a" | + | "b" | + | "c" | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": 1 }, + "then": { "field": "bar", "is": "equalTo", "value": "a" }, + "else": { "field": "bar", "is": "equalTo", "value": "X" } + } + """ + Then the following data should be generated: + | foo | bar | + | 1 | "a" | + + Scenario: Running an if request that contains a non contradictory inSet constraint within its if statement should be successful + Given foo is in set: + | 1 | + | 2 | + | 3 | + | 4 | + And foo is anything but null + And bar is in set: + | "a" | + | "b" | + | "c" | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "inSet", "values": [1, 2] }, + "then": { "field": "bar", "is": "equalTo", "value": "a" }, + "else": { "field": "bar", "is": "equalTo", "value": "b" } + } + """ + Then the following data should be generated: + | foo | bar | + | 1 | "a" | + | 2 | "a" | + | 3 | "b" | + | 4 | "b" | + + Scenario: Running an if request that contains a non contradictory inSet constraint within its then statement should be successful + Given foo is in set: + | 1 | + | 2 | + | 3 | + | 4 | + And foo is anything but null + And bar is in set: + | "a" | + | "b" | + | "c" | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": 1 }, + "then": { "field": "bar", "is": "inSet", "values": [ "a", "b" ] }, + "else": { "field": "bar", "is": "equalTo", "value": "c" } + } + """ + Then the following data should be generated: + | foo | bar | + | 1 | "a" | + | 1 | "b" | + | 2 | "c" | + | 3 | "c" | + | 4 | "c" | + + Scenario: Running an if request that contains a non contradictory inSet constraint within its else statement should be successful + Given foo is in set: + | 1 | + | 2 | + | 3 | + | 4 | + And foo is anything but null + And bar is in set: + | "a" | + | "b" | + | "c" | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": 1 }, + "then": { "field": "bar", "is": "equalTo", "value": "b" }, + "else": { "field": "bar", "is": "inSet", "values": [ "a", "c" ] } + } + """ + Then the following data should be generated: + | foo | bar | + | 1 | "b" | + | 2 | "a" | + | 2 | "c" | + | 3 | "a" | + | 3 | "c" | + | 4 | "a" | + | 4 | "c" | + + Scenario: Running an if request that contains a contradictory inSet constraint within its if statement should be successful + Given foo is in set: + | 1 | + | 2 | + | 3 | + | 4 | + And foo is anything but null + And bar is in set: + | "a" | + | "b" | + | "c" | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "inSet", "values": [ "X", "Y" ] }, + "then": { "field": "bar", "is": "equalTo", "value": "a" }, + "else": { "field": "bar", "is": "equalTo", "value": "b" } + } + """ + Then the following data should be generated: + | foo | bar | + | 1 | "b" | + | 2 | "b" | + | 3 | "b" | + | 4 | "b" | + + Scenario: Running an if request that contains a contradictory inSet constraint within its then statement should be successful + Given foo is in set: + | 1 | + | 2 | + | 3 | + | 4 | + And foo is anything but null + And bar is in set: + | "a" | + | "b" | + | "c" | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": 1 }, + "then": { "field": "bar", "is": "inSet", "value": [ "X", "Y" ] }, + "else": { "field": "bar", "is": "equalTo", "value": "c" } + } + """ + Then the profile is invalid because "Field \[bar\]: Couldn't recognise 'values' property, it must not contain 'null'" + And no data is created + + Scenario: Running an if request that contains a contradictory inSet constraint within its else statement should be successful + Given foo is in set: + | 1 | + | 2 | + | 3 | + | 4 | + And foo is anything but null + And bar is in set: + | "a" | + | "b" | + | "c" | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": 1 }, + "then": { "field": "bar", "is": "equalTo", "value": "a" }, + "else": { "field": "bar", "is": "inSet", "values": [ "X", "Y" ] } + } + """ + Then the following data should be generated: + | foo | bar | + | 1 | "a" | + + Scenario: Running an if request that contains a non contradictory null constraint within its if statement should be successful + Given foo is in set: + | 2 | + | 3 | + | 4 | + And bar is in set: + | "b" | + | "c" | + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "null" }, + "then": { "field": "bar", "is": "equalTo", "value": "b" }, + "else": { "field": "bar", "is": "equalTo", "value": "c" } + } + """ + Then the following data should be generated: + | foo | bar | + | null | "b" | + | 2 | "c" | + | 3 | "c" | + | 4 | "c" | + + Scenario: Running an if request that contains a non contradictory null constraint within its then statement should be successful + Given foo is in set: + | 2 | + | 3 | + | 4 | + And bar is in set: + | "b" | + | "c" | + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": 2 }, + "then": { "field": "bar", "is": "null" }, + "else": { "field": "bar", "is": "equalTo", "value": "c" } + } + """ + Then the following data should be generated: + | foo | bar | + | null | "c" | + | 2 | null | + | 3 | "c" | + | 4 | "c" | + + Scenario: Running an if request that contains a non contradictory null constraint within its else statement should be successful + Given foo is in set: + | 2 | + | 3 | + | 4 | + And bar is in set: + | "b" | + | "c" | + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": 2 }, + "then": { "field": "bar", "is": "equalTo", "value": "b" }, + "else": { "field": "bar", "is": "null" } + } + """ + Then the following data should be generated: + | foo | bar | + | null | null | + | 2 | "b" | + | 3 | null | + | 4 | null | + + Scenario: Running an if request that contains a contradictory null constraint within its if statement should be successful + Given foo is in set: + | 1 | + | 2 | + | 3 | + | 4 | + And foo is anything but null + And bar is in set: + | "a" | + | "b" | + | "c" | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "null" }, + "then": { "field": "bar", "is": "equalTo", "value": "a" }, + "else": { "field": "bar", "is": "equalTo", "value": "b" } + } + """ + Then the following data should be generated: + | foo | bar | + | 1 | "b" | + | 2 | "b" | + | 3 | "b" | + | 4 | "b" | + + Scenario: Running an if request that contains a contradictory null constraint within its then statement should be successful + Given foo is in set: + | 1 | + | 2 | + | 3 | + | 4 | + And foo is anything but null + And bar is in set: + | "a" | + | "b" | + | "c" | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": 1}, + "then": { "field": "bar", "is": "null" }, + "else": { "field": "bar", "is": "equalTo", "value": "a" } + } + """ + Then the following data should be generated: + | foo | bar | + | 2 | "a" | + | 3 | "a" | + | 4 | "a" | + + Scenario: Running an if request that contains a contradictory null constraint within its else statement should be successful + Given foo is in set: + | 1 | + | 2 | + | 3 | + | 4 | + And foo is anything but null + And bar is in set: + | "a" | + | "b" | + | "c" | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": 1}, + "then": { "field": "bar", "is": "equalTo", "value": "a" }, + "else": { "field": "bar", "is": "null" } + } + """ + Then the following data should be generated: + | foo | bar | + | 1 | "a" | + + Scenario: Running an if request that contains a non contradictory ofType constraint within its if statement should be successful + Given foo is in set: + | 1 | + | 2 | + | "a" | + | "b" | + And foo is anything but null + And bar is in set: + | 10 | + | 20 | + | "AA" | + | "BB" | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "ofType", "value": "string" }, + "then": { "field": "bar", "is": "equalTo", "value": "AA" }, + "else": { "field": "bar", "is": "equalTo", "value": 10 } + } + """ + Then the following data should be generated: + | foo | bar | + | 1 | 10 | + | 2 | 10 | + | "a" | "AA" | + | "b" | "AA" | + + Scenario: Running an if request that contains a non contradictory ofType constraint within its then statement should be successful + Given foo is in set: + | 1 | + | 2 | + | "a" | + | "b" | + And foo is anything but null + And bar is in set: + | 10 | + | 20 | + | "AA" | + | "BB" | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": "a" }, + "then": { "field": "bar", "is": "ofType", "value": "string" }, + "else": { "field": "bar", "is": "equalTo", "value": 10 } + } + """ + Then the following data should be generated: + | foo | bar | + | 1 | 10 | + | 2 | 10 | + | "a" | "AA" | + | "a" | "BB" | + | "b" | 10 | + + Scenario: Running an if request that contains a non contradictory ofType constraint within its else statement should be successful + Given foo is in set: + | 1 | + | 2 | + | "a" | + | "b" | + And foo is anything but null + And bar is in set: + | 10 | + | 20 | + | "AA" | + | "BB" | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": "a" }, + "then": { "field": "bar", "is": "equalTo", "value": "AA" }, + "else": { "field": "bar", "is": "ofType", "value": "integer" } + } + """ + Then the following data should be generated: + | foo | bar | + | 1 | 10 | + | 1 | 20 | + | 2 | 10 | + | 2 | 20 | + | "a" | "AA" | + | "b" | 10 | + | "b" | 20 | + + Scenario: Running an if request that contains a contradictory ofType constraint within its if statement should be successful + Given foo is in set: + | 1 | + | 2 | + | 3 | + | 4 | + And foo is anything but null + And bar is in set: + | "a" | + | "b" | + | "c" | + | "d" | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "ofType", "value": "string" }, + "then": { "field": "bar", "is": "equalTo", "value": "a" }, + "else": { "field": "bar", "is": "equalTo", "value": "c" } + } + """ + Then the following data should be generated: + | foo | bar | + | 1 | "c" | + | 2 | "c" | + | 3 | "c" | + | 4 | "c" | + + Scenario: Running an if request that contains a contradictory ofType constraint within its then statement should be successful + Given foo is in set: + | 1 | + | 2 | + | 3 | + | 4 | + And foo is anything but null + And bar is in set: + | "a" | + | "b" | + | "c" | + | "d" | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": 1 }, + "then": { "field": "bar", "is": "ofType", "value": "integer" }, + "else": { "field": "bar", "is": "equalTo", "value": "c" } + } + """ + Then the following data should be generated: + | foo | bar | + | 2 | "c" | + | 3 | "c" | + | 4 | "c" | + + Scenario: Running an if request that contains a contradictory ofType constraint within its else statement should be successful + Given foo is in set: + | 1 | + | 2 | + | 3 | + | 4 | + And foo is anything but null + And bar is in set: + | "a" | + | "b" | + | "c" | + | "d" | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": 1 }, + "then": { "field": "bar", "is": "equalTo", "value": "a" }, + "else": { "field": "bar", "is": "ofType", "value": "integer" } + } + """ + Then the following data should be generated: + | foo | bar | + | 1 | "a" | + + Scenario: Running an if request that contains a non contradictory matchingRegex constraint within its if statement should be successful + Given foo is in set: + | "1" | + | "2" | + | "a" | + | "b" | + And foo is anything but null + And bar is in set: + | "10" | + | "20" | + | "AA" | + | "BB" | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "matchingRegex", "value": "[a-z]{1}" }, + "then": { "field": "bar", "is": "equalTo", "value": "AA" }, + "else": { "field": "bar", "is": "equalTo", "value": "10" } + } + """ + Then the following data should be generated: + | foo | bar | + | "1" | "10" | + | "2" | "10" | + | "a" | "AA" | + | "b" | "AA" | + + Scenario: Running an if request that contains a non contradictory matchingRegex constraint within its then statement should be successful + Given foo is in set: + | "1" | + | "2" | + | "a" | + | "b" | + And foo is anything but null + And bar is in set: + | "10" | + | "20" | + | "AA" | + | "BB" | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": "1" }, + "then": { "field": "bar", "is": "matchingRegex", "value": "[A-Z]{2}" }, + "else": { "field": "bar", "is": "equalTo", "value": "10" } + } + """ + Then the following data should be generated: + | foo | bar | + | "1" | "AA" | + | "1" | "BB" | + | "2" | "10" | + | "a" | "10" | + | "b" | "10" | + + Scenario: Running an if request that contains a non contradictory matchingRegex constraint within its else statement should be successful + Given foo is in set: + | "1" | + | "2" | + | "a" | + | "b" | + And foo is anything but null + And bar is in set: + | "10" | + | "20" | + | "AA" | + | "BB" | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": "1" }, + "then": { "field": "bar", "is": "equalTo", "value": "AA" }, + "else": { "field": "bar", "is": "matchingRegex", "value": "[0-9]{2}" } + } + """ + Then the following data should be generated: + | foo | bar | + | "1" | "AA" | + | "2" | "10" | + | "2" | "20" | + | "a" | "10" | + | "a" | "20" | + | "b" | "10" | + | "b" | "20" | + + Scenario: Running an if request that contains a contradictory matchingRegex constraint within its if statement should be successful + Given foo is in set: + | "1" | + | "2" | + | "a" | + | "b" | + And foo is anything but null + And bar is in set: + | "10" | + | "20" | + | "AA" | + | "BB" | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "matchingRegex", "value": "[0-9]{10}" }, + "then": { "field": "bar", "is": "equalTo", "value": "AA" }, + "else": { "field": "bar", "is": "equalTo", "value": "10" } + } + """ + Then the following data should be generated: + | foo | bar | + | "1" | "10" | + | "2" | "10" | + | "a" | "10" | + | "b" | "10" | + + Scenario: Running an if request that contains a contradictory matchingRegex constraint within its then statement should be successful + Given foo is in set: + | "1" | + | "2" | + | "a" | + | "b" | + And foo is anything but null + And bar is in set: + | "10" | + | "20" | + | "AA" | + | "BB" | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": "a" }, + "then": { "field": "bar", "is": "matchingRegex", "value": "[😁-😡]{1}"}, + "else": { "field": "bar", "is": "equalTo", "value": "10" } + } + """ + Then the following data should be generated: + | foo | bar | + | "1" | "10" | + | "2" | "10" | + | "b" | "10" | + + Scenario: Running an if request that contains a contradictory matchingRegex constraint within its else statement should be successful + Given foo is in set: + | "1" | + | "2" | + | "a" | + | "b" | + And foo is anything but null + And bar is in set: + | "10" | + | "20" | + | "AA" | + | "BB" | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": "a" }, + "then": { "field": "bar", "is": "equalTo", "value": "BB"}, + "else": { "field": "bar", "is": "matchingRegex", "value": "[😁-😡]{1}"} + } + """ + Then the following data should be generated: + | foo | bar | + | "a" | "BB" | + + Scenario: Running an if request that contains a non contradictory containingRegex constraint within its if statement should be successful + Given foo is in set: + | "1" | + | "2" | + | "a1" | + | "b2" | + And foo is anything but null + And bar is in set: + | "10" | + | "20" | + | "AA" | + | "BB" | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "containingRegex", "value": "[1]{1}" }, + "then": { "field": "bar", "is": "equalTo", "value": "AA" }, + "else": { "field": "bar", "is": "equalTo", "value": "10" } + } + """ + Then the following data should be generated: + | foo | bar | + | "1" | "AA" | + | "2" | "10" | + | "a1" | "AA" | + | "b2" | "10" | + + Scenario: Running an if request that contains a non contradictory containingRegex constraint within its then statement should be successful + Given foo is in set: + | "1" | + | "2" | + | "a1" | + | "b2" | + And foo is anything but null + And bar is in set: + | "10" | + | "20" | + | "AA" | + | "BB" | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": "1" }, + "then": { "field": "bar", "is": "containingRegex", "value": "[0]{1}" }, + "else": { "field": "bar", "is": "equalTo", "value": "AA" } + } + """ + Then the following data should be generated: + | foo | bar | + | "1" | "10" | + | "1" | "20" | + | "2" | "AA" | + | "a1" | "AA" | + | "b2" | "AA" | + + Scenario: Running an if request that contains a non contradictory containingRegex constraint within its else statement should be successful + Given foo is in set: + | "1" | + | "2" | + | "a1" | + | "b2" | + And foo is anything but null + And bar is in set: + | "10" | + | "20" | + | "AA" | + | "BB" | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": "1" }, + "then": { "field": "bar", "is": "equalTo", "value": "BB" }, + "else": { "field": "bar", "is": "containingRegex", "value": "[0]{1}" } + } + """ + Then the following data should be generated: + | foo | bar | + | "1" | "BB" | + | "2" | "10" | + | "2" | "20" | + | "a1" | "10" | + | "a1" | "20" | + | "b2" | "10" | + | "b2" | "20" | + + Scenario: Running an if request that contains a contradictory containingRegex constraint within its if statement should be successful + Given foo is in set: + | "1" | + | "2" | + | "a1" | + | "b2" | + And foo is anything but null + And bar is in set: + | "10" | + | "20" | + | "AA" | + | "BB" | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "containingRegex", "value": "[🚫]{1}" }, + "then": { "field": "bar", "is": "equalTo", "value": "AA" }, + "else": { "field": "bar", "is": "equalTo", "value": "10" } + } + """ + Then the following data should be generated: + | foo | bar | + | "1" | "10" | + | "2" | "10" | + | "a1" | "10" | + | "b2" | "10" | + + Scenario: Running an if request that contains a contradictory containingRegex constraint within its then statement should be successful + Given foo is in set: + | "1" | + | "2" | + | "a1" | + | "b2" | + And foo is anything but null + And bar is in set: + | "10" | + | "20" | + | "AA" | + | "BB" | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": "1" }, + "then": { "field": "bar", "is": "containingRegex", "value": "[🚫]{1}" }, + "else": { "field": "bar", "is": "equalTo", "value": "10" } + } + """ + Then the following data should be generated: + | foo | bar | + | "2" | "10" | + | "a1" | "10" | + | "b2" | "10" | + + Scenario: Running an if request that contains a contradictory containingRegex constraint within its then statement should be successful + Given foo is in set: + | "1" | + | "2" | + | "a1" | + | "b2" | + And foo is anything but null + And bar is in set: + | "10" | + | "20" | + | "AA" | + | "BB" | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": "1" }, + "then": { "field": "bar", "is": "equalTo", "value": "10" }, + "else": { "field": "bar", "is": "containingRegex", "value": "[🚫]{1}" } + } + """ + Then the following data should be generated: + | foo | bar | + | "1" | "10" | + + Scenario: Running an if request that contains a non contradictory ofLength constraint within its if statement should be successful + Given foo is in set: + | "a" | + | "bb" | + | "ccc" | + | "dddd" | + And foo is anything but null + And bar is in set: + | "1" | + | "22" | + | "333" | + | "4444" | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "ofLength", "value": 2 }, + "then": { "field": "bar", "is": "equalTo", "value": "1" }, + "else": { "field": "bar", "is": "equalTo", "value": "4444" } + } + """ + Then the following data should be generated: + | foo | bar | + | "a" | "4444" | + | "bb" | "1" | + | "ccc" | "4444" | + | "dddd" | "4444" | + + Scenario: Running an if request that contains a non contradictory ofLength constraint within its then statement should be successful + Given foo is in set: + | "a" | + | "bb" | + | "ccc" | + | "dddd" | + And foo is anything but null + And bar is in set: + | "1" | + | "22" | + | "333" | + | "4444" | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": "bb" }, + "then": { "field": "bar", "is": "ofLength", "value": 3 }, + "else": { "field": "bar", "is": "equalTo", "value": "1" } + } + """ + Then the following data should be generated: + | foo | bar | + | "a" | "1" | + | "bb" | "333" | + | "ccc" | "1" | + | "dddd" | "1" | + + Scenario: Running an if request that contains a non contradictory ofLength constraint within its else statement should be successful + Given foo is in set: + | "a" | + | "bb" | + | "ccc" | + | "dddd" | + And foo is anything but null + And bar is in set: + | "1" | + | "22" | + | "333" | + | "4444" | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": "a" }, + "then": { "field": "bar", "is": "equalTo", "value": "1" }, + "else": { "field": "bar", "is": "ofLength", "value": 4 } + } + """ + Then the following data should be generated: + | foo | bar | + | "a" | "1" | + | "bb" | "4444" | + | "ccc" | "4444" | + | "dddd" | "4444" | + + Scenario: Running an if request that contains a contradictory ofLength constraint within its if statement should be successful + Given foo is in set: + | "a" | + | "bb" | + | "ccc" | + | "dddd" | + And foo is anything but null + And bar is in set: + | "1" | + | "22" | + | "333" | + | "4444" | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "ofLength", "value": 7 }, + "then": { "field": "bar", "is": "equalTo", "value": "1" }, + "else": { "field": "bar", "is": "equalTo", "value": "4444" } + } + """ + Then the following data should be generated: + | foo | bar | + | "a" | "4444" | + | "bb" | "4444" | + | "ccc" | "4444" | + | "dddd" | "4444" | + + Scenario: Running an if request that contains a contradictory ofLength constraint within its then statement should be successful + Given foo is in set: + | "a" | + | "bb" | + | "ccc" | + | "dddd" | + And foo is anything but null + And bar is in set: + | "1" | + | "22" | + | "333" | + | "4444" | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": "a" }, + "then": { "field": "bar", "is": "ofLength", "value": 10 }, + "else": { "field": "bar", "is": "equalTo", "value": "4444" } + } + """ + Then the following data should be generated: + | foo | bar | + | "bb" | "4444" | + | "ccc" | "4444" | + | "dddd" | "4444" | + + Scenario: Running an if request that contains a contradictory ofLength constraint within its else statement should be successful + Given foo is in set: + | "a" | + | "bb" | + | "ccc" | + | "dddd" | + And foo is anything but null + And bar is in set: + | "1" | + | "22" | + | "333" | + | "4444" | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": "a" }, + "then": { "field": "bar", "is": "equalTo", "value": "1" }, + "else": { "field": "bar", "is": "ofLength", "value": 10 } + } + """ + Then the following data should be generated: + | foo | bar | + | "a" | "1" | + + Scenario: Running an if request that contains a non contradictory longerThan constraint within its if statement should be successful + Given foo is in set: + | "a" | + | "bb" | + | "ccc" | + | "dddd" | + And foo is anything but null + And bar is in set: + | "1" | + | "22" | + | "333" | + | "4444" | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "longerThan", "value": 2 }, + "then": { "field": "bar", "is": "equalTo", "value": "1" }, + "else": { "field": "bar", "is": "equalTo", "value": "4444" } + } + """ + Then the following data should be generated: + | foo | bar | + | "a" | "4444" | + | "bb" | "4444" | + | "ccc" | "1" | + | "dddd" | "1" | + + Scenario: Running an if request that contains a non contradictory longerThan constraint within its then statement should be successful + Given foo is in set: + | "a" | + | "bb" | + | "ccc" | + | "dddd" | + And foo is anything but null + And bar is in set: + | "1" | + | "22" | + | "333" | + | "4444" | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": "bb" }, + "then": { "field": "bar", "is": "longerThan", "value": 2 }, + "else": { "field": "bar", "is": "equalTo", "value": "1" } + } + """ + Then the following data should be generated: + | foo | bar | + | "a" | "1" | + | "bb" | "333" | + | "bb" | "4444" | + | "ccc" | "1" | + | "dddd" | "1" | + + Scenario: Running an if request that contains a non contradictory longerThan constraint within its else statement should be successful + Given foo is in set: + | "a" | + | "bb" | + | "ccc" | + | "dddd" | + And foo is anything but null + And bar is in set: + | "1" | + | "22" | + | "333" | + | "4444" | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": "dddd" }, + "then": { "field": "bar", "is": "equalTo", "value": "1" }, + "else": { "field": "bar", "is": "longerThan", "value": 2 } + } + """ + Then the following data should be generated: + | foo | bar | + | "a" | "333" | + | "a" | "4444" | + | "bb" | "333" | + | "bb" | "4444" | + | "ccc" | "333" | + | "ccc" | "4444" | + | "dddd" | "1" | + + Scenario: Running an if request that contains a contradictory longerThan constraint within its if statement should be successful + Given foo is in set: + | "a" | + | "bb" | + | "ccc" | + | "dddd" | + And foo is anything but null + And bar is in set: + | "1" | + | "22" | + | "333" | + | "4444" | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "longerThan", "value": 25 }, + "then": { "field": "bar", "is": "equalTo", "value": "1" }, + "else": { "field": "bar", "is": "equalTo", "value": "4444" } + } + """ + Then the following data should be generated: + | foo | bar | + | "a" | "4444" | + | "bb" | "4444" | + | "ccc" | "4444" | + | "dddd" | "4444" | + + Scenario: Running an if request that contains a contradictory longerThan constraint within its then statement should be successful + Given foo is in set: + | "a" | + | "bb" | + | "ccc" | + | "dddd" | + And foo is anything but null + And bar is in set: + | "1" | + | "22" | + | "333" | + | "4444" | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": "a" }, + "then": { "field": "bar", "is": "longerThan", "value": 100 }, + "else": { "field": "bar", "is": "equalTo", "value": "4444" } + } + """ + Then the following data should be generated: + | foo | bar | + | "bb" | "4444" | + | "ccc" | "4444" | + | "dddd" | "4444" | + + Scenario: Running an if request that contains a contradictory longerThan constraint within its else statement should be successful + Given foo is in set: + | "a" | + | "bb" | + | "ccc" | + | "dddd" | + And foo is anything but null + And bar is in set: + | "1" | + | "22" | + | "333" | + | "4444" | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": "a" }, + "then": { "field": "bar", "is": "equalTo", "value": "1" }, + "else": { "field": "bar", "is": "longerThan", "value": 100 } + } + """ + Then the following data should be generated: + | foo | bar | + | "a" | "1" | + + Scenario: Running an if request that contains a non contradictory shorterThan constraint within its if statement should be successful + Given foo is in set: + | "a" | + | "bb" | + | "ccc" | + | "dddd" | + And foo is anything but null + And bar is in set: + | "1" | + | "22" | + | "333" | + | "4444" | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "shorterThan", "value": 3 }, + "then": { "field": "bar", "is": "equalTo", "value": "1" }, + "else": { "field": "bar", "is": "equalTo", "value": "4444" } + } + """ + Then the following data should be generated: + | foo | bar | + | "a" | "1" | + | "bb" | "1" | + | "ccc" | "4444" | + | "dddd" | "4444" | + + Scenario: Running an if request that contains a non contradictory shorterThan constraint within its then statement should be successful + Given foo is in set: + | "a" | + | "bb" | + | "ccc" | + | "dddd" | + And foo is anything but null + And bar is in set: + | "1" | + | "22" | + | "333" | + | "4444" | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": "ccc" }, + "then": { "field": "bar", "is": "shorterThan", "value": 3 }, + "else": { "field": "bar", "is": "equalTo", "value": "333" } + } + """ + Then the following data should be generated: + | foo | bar | + | "a" | "333" | + | "bb" | "333" | + | "ccc" | "1" | + | "ccc" | "22" | + | "dddd" | "333" | + + Scenario: Running an if request that contains a non contradictory shorterThan constraint within its else statement should be successful + Given foo is in set: + | "a" | + | "bb" | + | "ccc" | + | "dddd" | + And foo is anything but null + And bar is in set: + | "1" | + | "22" | + | "333" | + | "4444" | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": "dddd" }, + "then": { "field": "bar", "is": "equalTo", "value": "4444" }, + "else": { "field": "bar", "is": "shorterThan", "value": 4 } + } + """ + Then the following data should be generated: + | foo | bar | + | "a" | "1" | + | "a" | "22" | + | "a" | "333" | + | "bb" | "1" | + | "bb" | "22" | + | "bb" | "333" | + | "ccc" | "1" | + | "ccc" | "22" | + | "ccc" | "333" | + | "dddd" | "4444" | + + Scenario: Running an if request that contains a contradictory shorterThan constraint within its if statement should be successful + Given foo is in set: + | "a" | + | "bb" | + | "ccc" | + | "dddd" | + And foo is anything but null + And bar is in set: + | "1" | + | "22" | + | "333" | + | "4444" | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "shorterThan", "value": 1 }, + "then": { "field": "bar", "is": "equalTo", "value": "1" }, + "else": { "field": "bar", "is": "equalTo", "value": "4444" } + } + """ + Then the following data should be generated: + | foo | bar | + | "a" | "4444" | + | "bb" | "4444" | + | "ccc" | "4444" | + | "dddd" | "4444" | + + Scenario: Running an if request that contains a contradictory shorterThan constraint within its then statement should be successful + Given foo is in set: + | "a" | + | "bb" | + | "ccc" | + | "dddd" | + And foo is anything but null + And bar is in set: + | "1" | + | "22" | + | "333" | + | "4444" | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": "dddd" }, + "then": { "field": "bar", "is": "shorterThan", "value": 1 }, + "else": { "field": "bar", "is": "equalTo", "value": "4444" } + } + """ + Then the following data should be generated: + | foo | bar | + | "a" | "4444" | + | "bb" | "4444" | + | "ccc" | "4444" | + + Scenario: Running an if request that contains a contradictory shorterThan constraint within its else statement should be successful + Given foo is in set: + | "a" | + | "bb" | + | "ccc" | + | "dddd" | + And foo is anything but null + And bar is in set: + | "1" | + | "22" | + | "333" | + | "4444" | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": "dddd" }, + "then": { "field": "bar", "is": "equalTo", "value": "4444" }, + "else": { "field": "bar", "is": "shorterThan", "value": 1 } + } + """ + Then the following data should be generated: + | foo | bar | + | "dddd" | "4444" | + + Scenario: An if constraint that contains an ISIN constraint in the if clause generates the expected output + Given foo is in set: + | "GB0002634946" | + | "bb" | + | "ccc" | + | "dddd" | + And foo is anything but null + And bar is in set: + | "GB0002634946" | + | "22" | + | "333" | + | "4444" | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "ofType", "value": "ISIN" }, + "then": { "field": "bar", "is": "equalTo", "value": "22" }, + "else": { "field": "bar", "is": "equalTo", "value": "4444" } + } + """ + Then the following data should be generated: + | foo | bar | + | "GB0002634946" | "22" | + | "bb" | "4444" | + | "ccc" | "4444" | + | "dddd" | "4444" | + + Scenario: An if constraint that contains an ISIN constraint in the then clause generates valid ISINs when the if clause applies + Given foo is in set: + | "GB0002634946" | + | "bb" | + | "ccc" | + | "dddd" | + And foo is anything but null + And bar is in set: + | "GB0002634946" | + | "22" | + | "333" | + | "4444" | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": "bb" }, + "then": { "field": "bar", "is": "ofType", "value": "ISIN" }, + "else": { "field": "bar", "is": "equalTo", "value": "333" } + } + """ + Then the following data should be generated: + | foo | bar | + | "GB0002634946" | "333" | + | "bb" | "GB0002634946" | + | "ccc" | "333" | + | "dddd" | "333" | + + Scenario: An if constraint that contains an ISIN constraint in the else clause generates valid ISINs when the if clause does not apply + Given foo is in set: + | "GB0002634946" | + | "bb" | + | "ccc" | + | "dddd" | + And foo is anything but null + And bar is in set: + | "GB0002634946" | + | "22" | + | "333" | + | "4444" | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": "bb" }, + "then": { "field": "bar", "is": "equalTo", "value": "22" }, + "else": { "field": "bar", "is": "ofType", "value": "ISIN" } + } + """ + Then the following data should be generated: + | foo | bar | + | "GB0002634946" | "GB0002634946" | + | "bb" | "22" | + | "ccc" | "GB0002634946" | + | "dddd" | "GB0002634946" | + + Scenario: An if constraint that contains an ISIN constraint in the if clause and is combined with an in set constraint that does not contain any valid ISINs only generates data that matches the else clause + Given foo is in set: + | "aa" | + | "bb" | + | "ccc" | + | "dddd" | + And foo is anything but null + And bar is in set: + | "11" | + | "22" | + | "333" | + | "4444" | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "ofType", "value": "ISIN" }, + "then": { "field": "bar", "is": "equalTo", "value": "22" }, + "else": { "field": "bar", "is": "equalTo", "value": "333" } + } + """ + Then the following data should be generated: + | foo | bar | + | "aa" | "333" | + | "bb" | "333" | + | "ccc" | "333" | + | "dddd" | "333" | + + + Scenario: An if constraint that contains an ISIN constraint in the then clause combined with an in set constraint that does not contain any valid ISINs only generates data that matches the else clause + Given foo is in set: + | "aa" | + | "bb" | + | "ccc" | + | "dddd" | + And foo is anything but null + And bar is in set: + | "11" | + | "22" | + | "333" | + | "4444" | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": "ccc" }, + "then": { "field": "bar", "is": "ofType", "value": "ISIN" }, + "else": { "field": "bar", "is": "equalTo", "value": "333" } + } + """ + Then the following data should be generated: + | foo | bar | + | "aa" | "333" | + | "bb" | "333" | + | "dddd" | "333" | + + Scenario: An if constraint with an else clause containing an ISIN constraint which contradicts an in set constraint generates data that only matches the then clause + Given foo is in set: + | "aa" | + | "bb" | + | "ccc" | + | "dddd" | + And foo is anything but null + And bar is in set: + | "11" | + | "22" | + | "333" | + | "4444" | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": "ccc" }, + "then": { "field": "bar", "is": "equalTo", "value": "333" }, + "else": { "field": "bar", "is": "ofType", "value": "ISIN" } + } + """ + Then the following data should be generated: + | foo | bar | + | "ccc" | "333" | + + Scenario: Running an if request that contains a non contradictory greaterThan constraint within its if statement should be successful + Given foo is in set: + | 10 | + | 20 | + | 30 | + | 40 | + And foo is anything but null + And bar is in set: + | 1 | + | 22 | + | 333 | + | 4444 | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "greaterThan", "value": 29 }, + "then": { "field": "bar", "is": "equalTo", "value": 22 }, + "else": { "field": "bar", "is": "equalTo", "value": 1 } + } + """ + Then the following data should be generated: + | foo | bar | + | 10 | 1 | + | 20 | 1 | + | 30 | 22 | + | 40 | 22 | + + Scenario: Running an if request that contains a non contradictory greaterThan constraint within its then statement should be successful + Given foo is in set: + | 10 | + | 20 | + | 30 | + | 40 | + And foo is anything but null + And bar is in set: + | 1 | + | 22 | + | 333 | + | 4444 | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": 40 }, + "then": { "field": "bar", "is": "greaterThan", "value": 20 }, + "else": { "field": "bar", "is": "equalTo", "value": 1 } + } + """ + Then the following data should be generated: + | foo | bar | + | 10 | 1 | + | 20 | 1 | + | 30 | 1 | + | 40 | 22 | + | 40 | 333 | + | 40 | 4444 | + + Scenario: Running an if request that contains a non contradictory greaterThan constraint within its else statement should be successful + Given foo is in set: + | 10 | + | 20 | + | 30 | + | 40 | + And foo is anything but null + And bar is in set: + | 1 | + | 22 | + | 333 | + | 4444 | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": 40 }, + "then": { "field": "bar", "is": "equalTo", "value": 1 }, + "else": { "field": "bar", "is": "greaterThan", "value": 300 } + } + """ + Then the following data should be generated: + | foo | bar | + | 10 | 333 | + | 10 | 4444 | + | 20 | 333 | + | 20 | 4444 | + | 30 | 333 | + | 30 | 4444 | + | 40 | 1 | + + Scenario: Running an if request that contains a contradictory greaterThan constraint within its if statement should be successful + Given foo is in set: + | 10 | + | 20 | + | 30 | + | 40 | + And foo is anything but null + And bar is in set: + | 1 | + | 22 | + | 333 | + | 4444 | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "greaterThan", "value": 8000 }, + "then": { "field": "bar", "is": "equalTo", "value": 22 }, + "else": { "field": "bar", "is": "equalTo", "value": 1 } + } + """ + Then the following data should be generated: + | foo | bar | + | 10 | 1 | + | 20 | 1 | + | 30 | 1 | + | 40 | 1 | + + Scenario: Running an if request that contains a contradictory greaterThan constraint within its then statement should be successful + Given foo is in set: + | 10 | + | 20 | + | 30 | + | 40 | + And foo is anything but null + And bar is in set: + | 1 | + | 22 | + | 333 | + | 4444 | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": 40 }, + "then": { "field": "bar", "is": "greaterThan", "value": 8000 }, + "else": { "field": "bar", "is": "equalTo", "value": 1 } + } + """ + Then the following data should be generated: + | foo | bar | + | 10 | 1 | + | 20 | 1 | + | 30 | 1 | + + Scenario: Running an if request that contains a contradictory greaterThan constraint within its else statement should be successful + Given foo is in set: + | 10 | + | 20 | + | 30 | + | 40 | + And foo is anything but null + And bar is in set: + | 1 | + | 22 | + | 333 | + | 4444 | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": 40 }, + "then": { "field": "bar", "is": "equalTo", "value": 1 }, + "else": { "field": "bar", "is": "greaterThan", "value": 8000 } + } + """ + Then the following data should be generated: + | foo | bar | + | 40 | 1 | + + Scenario: Running an if request that contains a non contradictory greaterThanOrEqualTo constraint within its if statement should be successful + Given foo is in set: + | 10 | + | 20 | + | 30 | + | 40 | + And foo is anything but null + And bar is in set: + | 1 | + | 22 | + | 333 | + | 4444 | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "greaterThanOrEqualTo", "value": 20 }, + "then": { "field": "bar", "is": "equalTo", "value": 22 }, + "else": { "field": "bar", "is": "equalTo", "value": 1 } + } + """ + Then the following data should be generated: + | foo | bar | + | 10 | 1 | + | 20 | 22 | + | 30 | 22 | + | 40 | 22 | + + Scenario: Running an if request that contains a non contradictory greaterThanOrEqualTo constraint within its then statement should be successful + Given foo is in set: + | 10 | + | 20 | + | 30 | + | 40 | + And foo is anything but null + And bar is in set: + | 1 | + | 22 | + | 333 | + | 4444 | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": 20 }, + "then": { "field": "bar", "is": "greaterThanOrEqualTo", "value": 22 }, + "else": { "field": "bar", "is": "equalTo", "value": 1 } + } + """ + Then the following data should be generated: + | foo | bar | + | 10 | 1 | + | 20 | 22 | + | 20 | 333 | + | 20 | 4444 | + | 30 | 1 | + | 40 | 1 | + + Scenario: Running an if request that contains a non contradictory greaterThanOrEqualTo constraint within its else statement should be successful + Given foo is in set: + | 10 | + | 20 | + | 30 | + | 40 | + And foo is anything but null + And bar is in set: + | 1 | + | 22 | + | 333 | + | 4444 | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": 20 }, + "then": { "field": "bar", "is": "equalTo", "value": 1 }, + "else": { "field": "bar", "is": "greaterThanOrEqualTo", "value": 22 } + } + """ + Then the following data should be generated: + | foo | bar | + | 10 | 22 | + | 10 | 333 | + | 10 | 4444 | + | 20 | 1 | + | 30 | 22 | + | 30 | 333 | + | 30 | 4444 | + | 40 | 22 | + | 40 | 333 | + | 40 | 4444 | + + Scenario: Running an if request that contains a contradictory greaterThanOrEqualTo constraint within its if statement should be successful + Given foo is in set: + | 10 | + | 20 | + | 30 | + | 40 | + And foo is anything but null + And bar is in set: + | 1 | + | 22 | + | 333 | + | 4444 | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "greaterThanOrEqualTo", "value": 8000 }, + "then": { "field": "bar", "is": "equalTo", "value": 22 }, + "else": { "field": "bar", "is": "equalTo", "value": 1 } + } + """ + Then the following data should be generated: + | foo | bar | + | 10 | 1 | + | 20 | 1 | + | 30 | 1 | + | 40 | 1 | + + Scenario: Running an if request that contains a contradictory greaterThanOrEqualTo constraint within its then statement should be successful + Given foo is in set: + | 10 | + | 20 | + | 30 | + | 40 | + And foo is anything but null + And bar is in set: + | 1 | + | 22 | + | 333 | + | 4444 | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": 10 }, + "then": { "field": "bar", "is": "greaterThanOrEqualTo", "value": 8000 }, + "else": { "field": "bar", "is": "equalTo", "value": 333 } + } + """ + Then the following data should be generated: + | foo | bar | + | 20 | 333 | + | 30 | 333 | + | 40 | 333 | + + Scenario: Running an if request that contains a contradictory greaterThanOrEqualTo constraint within its else statement should be successful + Given foo is in set: + | 10 | + | 20 | + | 30 | + | 40 | + And foo is anything but null + And bar is in set: + | 1 | + | 22 | + | 333 | + | 4444 | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": 10 }, + "then": { "field": "bar", "is": "equalTo", "value": 4444 }, + "else": { "field": "bar", "is": "greaterThanOrEqualTo", "value": 8000 } + } + """ + Then the following data should be generated: + | foo | bar | + | 10 | 4444 | + + Scenario: Running an if request that contains a non contradictory lessThan constraint within its if statement should be successful + Given foo is in set: + | 10 | + | 20 | + | 30 | + | 40 | + And foo is anything but null + And bar is in set: + | 1 | + | 22 | + | 333 | + | 4444 | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "lessThan", "value": 20 }, + "then": { "field": "bar", "is": "equalTo", "value": 4444 }, + "else": { "field": "bar", "is": "equalTo", "value": 1 } + } + """ + Then the following data should be generated: + | foo | bar | + | 10 | 4444 | + | 20 | 1 | + | 30 | 1 | + | 40 | 1 | + + Scenario: Running an if request that contains a non contradictory lessThan constraint within its then statement should be successful + Given foo is in set: + | 10 | + | 20 | + | 30 | + | 40 | + And foo is anything but null + And bar is in set: + | 1 | + | 22 | + | 333 | + | 4444 | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": 40 }, + "then": { "field": "bar", "is": "lessThan", "value": 4400 }, + "else": { "field": "bar", "is": "equalTo", "value": 1 } + } + """ + Then the following data should be generated: + | foo | bar | + | 10 | 1 | + | 20 | 1 | + | 30 | 1 | + | 40 | 1 | + | 40 | 22 | + | 40 | 333 | + + Scenario: Running an if request that contains a non contradictory lessThan constraint within its else statement should be successful + Given foo is in set: + | 10 | + | 20 | + | 30 | + | 40 | + And foo is anything but null + And bar is in set: + | 1 | + | 22 | + | 333 | + | 4444 | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": 40 }, + "then": { "field": "bar", "is": "equalTo", "value": 333 }, + "else": { "field": "bar", "is": "lessThan", "value": 300 } + } + """ + Then the following data should be generated: + | foo | bar | + | 10 | 1 | + | 10 | 22 | + | 20 | 1 | + | 20 | 22 | + | 30 | 1 | + | 30 | 22 | + | 40 | 333 | + + Scenario: Running an if request that contains a contradictory lessThan constraint within its if statement should be successful + Given foo is in set: + | 10 | + | 20 | + | 30 | + | 40 | + And foo is anything but null + And bar is in set: + | 1 | + | 22 | + | 333 | + | 4444 | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "lessThan", "value": 1 }, + "then": { "field": "bar", "is": "equalTo", "value": 333 }, + "else": { "field": "bar", "is": "equalTo", "value": 22 } + } + """ + Then the following data should be generated: + | foo | bar | + | 10 | 22 | + | 20 | 22 | + | 30 | 22 | + | 40 | 22 | + + Scenario: Running an if request that contains a contradictory lessThan constraint within its then statement should be successful + Given foo is in set: + | 10 | + | 20 | + | 30 | + | 40 | + And foo is anything but null + And bar is in set: + | 1 | + | 22 | + | 333 | + | 4444 | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": 10 }, + "then": { "field": "bar", "is": "lessThan", "value": 1 }, + "else": { "field": "bar", "is": "equalTo", "value": 333 } + } + """ + Then the following data should be generated: + | foo | bar | + | 20 | 333 | + | 30 | 333 | + | 40 | 333 | + + Scenario: Running an if request that contains a contradictory lessThan constraint within its else statement should be successful + Given foo is in set: + | 10 | + | 20 | + | 30 | + | 40 | + And foo is anything but null + And bar is in set: + | 1 | + | 22 | + | 333 | + | 4444 | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": 30 }, + "then": { "field": "bar", "is": "equalTo", "value": 1 }, + "else": { "field": "bar", "is": "lessThan", "value": 1 } + } + """ + Then the following data should be generated: + | foo | bar | + | 30 | 1 | + + Scenario: Running an if request that contains a non contradictory lessThanOrEqualTo constraint within its if statement should be successful + Given foo is in set: + | 10 | + | 20 | + | 30 | + | 40 | + And foo is anything but null + And bar is in set: + | 1 | + | 22 | + | 333 | + | 4444 | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "lessThanOrEqualTo", "value": 20 }, + "then": { "field": "bar", "is": "equalTo", "value": 1 }, + "else": { "field": "bar", "is": "equalTo", "value": 4444 } + } + """ + Then the following data should be generated: + | foo | bar | + | 10 | 1 | + | 20 | 1 | + | 30 | 4444 | + | 40 | 4444 | + + Scenario: Running an if request that contains a non contradictory lessThanOrEqualTo constraint within its then statement should be successful + Given foo is in set: + | 10 | + | 20 | + | 30 | + | 40 | + And foo is anything but null + And bar is in set: + | 1 | + | 22 | + | 333 | + | 4444 | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": 20 }, + "then": { "field": "bar", "is": "lessThanOrEqualTo", "value": 333 }, + "else": { "field": "bar", "is": "equalTo", "value": 4444 } + } + """ + Then the following data should be generated: + | foo | bar | + | 10 | 4444 | + | 20 | 1 | + | 20 | 22 | + | 20 | 333 | + | 30 | 4444 | + | 40 | 4444 | + + Scenario: Running an if request that contains a non contradictory lessThanOrEqualTo constraint within its else statement should be successful + Given foo is in set: + | 10 | + | 20 | + | 30 | + | 40 | + And foo is anything but null + And bar is in set: + | 1 | + | 22 | + | 333 | + | 4444 | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": 20 }, + "then": { "field": "bar", "is": "equalTo", "value": 333 }, + "else": { "field": "bar", "is": "lessThanOrEqualTo", "value": 4444 } + } + """ + Then the following data should be generated: + | foo | bar | + | 10 | 1 | + | 10 | 22 | + | 10 | 333 | + | 10 | 4444 | + | 20 | 333 | + | 30 | 1 | + | 30 | 22 | + | 30 | 333 | + | 30 | 4444 | + | 40 | 1 | + | 40 | 22 | + | 40 | 333 | + | 40 | 4444 | + + Scenario: Running an if request that contains a contradictory lessThanOrEqualTo constraint within its if statement should be successful + Given foo is in set: + | 10 | + | 20 | + | 30 | + | 40 | + And foo is anything but null + And bar is in set: + | 1 | + | 22 | + | 333 | + | 4444 | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "lessThanOrEqualTo", "value": 1 }, + "then": { "field": "bar", "is": "equalTo", "value": 333 }, + "else": { "field": "bar", "is": "equalTo", "value": 4444 } + } + """ + Then the following data should be generated: + | foo | bar | + | 10 | 4444 | + | 20 | 4444 | + | 30 | 4444 | + | 40 | 4444 | + + Scenario: Running an if request that contains a contradictory lessThanOrEqualTo constraint within its then statement should be successful + Given foo is in set: + | 10 | + | 20 | + | 30 | + | 40 | + And foo is anything but null + And bar is in set: + | 1 | + | 22 | + | 333 | + | 4444 | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": 10 }, + "then": { "field": "bar", "is": "lessThanOrEqualTo", "value": 0 }, + "else": { "field": "bar", "is": "equalTo", "value": 4444 } + } + """ + Then the following data should be generated: + | foo | bar | + | 20 | 4444 | + | 30 | 4444 | + | 40 | 4444 | + + Scenario: Running an if request that contains a contradictory lessThanOrEqualTo constraint within its else statement should be successful + Given foo is in set: + | 10 | + | 20 | + | 30 | + | 40 | + And foo is anything but null + And bar is in set: + | 1 | + | 22 | + | 333 | + | 4444 | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": 10 }, + "then": { "field": "bar", "is": "equalTo", "value": 1 }, + "else": { "field": "bar", "is": "lessThanOrEqualTo", "value": 0 } + } + """ + Then the following data should be generated: + | foo | bar | + | 10 | 1 | + +@ignore #769 Violation of numeric and temporal granularity + Scenario: Running an if request that contains a non contradictory granularTo constraint within its if statement should be successful + Given foo is in set: + | 1 | + | 1.1 | + | 1.11 | + | 1.111 | + And foo is anything but null + And bar is in set: + | 1 | + | 2.2 | + | 3.33 | + | 4.444 | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "granularTo", "value": 1 }, + "then": { "field": "bar", "is": "equalTo", "value": 1 }, + "else": { "field": "bar", "is": "equalTo", "value": 2.2 } + } + """ + Then the following data should be generated: + | foo | bar | + | 1 | 1 | + | 1.1 | 2.2 | + | 1.11 | 2.2 | + | 1.111 | 2.2 | + + Scenario: Running an if request that contains a non contradictory granularTo constraint within its else statement should be successful + Given foo is in set: + | 1 | + | 1.1 | + | 1.11 | + | 1.111 | + And foo is anything but null + And bar is in set: + | 2.2 | + | 3.33 | + | 4.444 | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": 1 }, + "then": { "field": "bar", "is": "equalTo", "value": 3.33 }, + "else": { "field": "bar", "is": "granularTo", "value": 0.1 } + } + """ + Then the following data should be generated: + | foo | bar | + | 1 | 3.33 | + | 1.1 | 2.2 | + | 1.11 | 2.2 | + | 1.111 | 2.2 | + + Scenario: Running an if request that contains a contradictory granularTo constraint within its if statement should be successful + Given foo is in set: + | 1.1 | + | 1.11 | + | 1.111 | + And foo is anything but null + And bar is in set: + | 1 | + | 2.2 | + | 3.33 | + | 4.444 | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "granularTo", "value": 1 }, + "then": { "field": "bar", "is": "equalTo", "value": 1 }, + "else": { "field": "bar", "is": "equalTo", "value": 2.2 } + } + """ + Then the following data should be generated: + | foo | bar | + | 1.1 | 2.2 | + | 1.11 | 2.2 | + | 1.111 | 2.2 | + + Scenario: Running an if request that contains a contradictory granularTo constraint within its then statement should be successful + Given foo is in set: + | 1 | + | 1.1 | + | 1.11 | + | 1.111 | + And foo is anything but null + And bar is in set: + | 2.2 | + | 3.33 | + | 4.444 | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": 1 }, + "then": { "field": "bar", "is": "granularTo", "value": 1 }, + "else": { "field": "bar", "is": "equalTo", "value": 2.2 } + } + """ + Then the following data should be generated: + | foo | bar | + | 1.1 | 2.2 | + | 1.11 | 2.2 | + | 1.111 | 2.2 | + + Scenario: Running an if request that contains a contradictory granularTo constraint within its else statement should be successful + Given foo is in set: + | 1 | + | 1.1 | + | 1.11 | + | 1.111 | + And foo is anything but null + And bar is in set: + | 2.2 | + | 3.33 | + | 4.444 | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": 1 }, + "then": { "field": "bar", "is": "equalTo", "value": 3.33 }, + "else": { "field": "bar", "is": "granularTo", "value": 1 } + } + """ + Then the following data should be generated: + | foo | bar | + | 1 | 3.33 | + + Scenario: Running an if request that contains a non contradictory after constraint within its if statement should be successful + Given foo is in set: + | 2018-01-01T00:00:00.000Z | + | 2018-02-01T00:00:00.000Z | + | 2018-03-01T00:00:00.000Z | + | 2018-04-01T00:00:00.000Z | + | 2018-05-01T00:00:00.000Z | + | 2018-06-01T00:00:00.000Z | + And foo is anything but null + And bar is in set: + | 2010-01-01T00:00:00.000Z | + | 2010-01-02T00:00:00.000Z | + | 2010-01-03T00:00:00.000Z | + | 2010-01-04T00:00:00.000Z | + | 2010-01-05T00:00:00.000Z | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "after", "value": { "date": "2018-01-02T00:00:00.000Z" } }, + "then": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-01T00:00:00.000Z" } }, + "else": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-05T00:00:00.000Z" } } + } + """ + Then the following data should be generated: + | foo | bar | + | 2018-01-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | + | 2018-02-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | + | 2018-03-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | + | 2018-04-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | + | 2018-05-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | + | 2018-06-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | + + Scenario: Running an if request that contains a non contradictory after constraint within its then statement should be successful + Given foo is in set: + | 2018-01-01T00:00:00.000Z | + | 2018-02-01T00:00:00.000Z | + | 2018-03-01T00:00:00.000Z | + | 2018-04-01T00:00:00.000Z | + | 2018-05-01T00:00:00.000Z | + | 2018-06-01T00:00:00.000Z | + And foo is anything but null + And bar is in set: + | 2010-01-01T00:00:00.000Z | + | 2010-01-02T00:00:00.000Z | + | 2010-01-03T00:00:00.000Z | + | 2010-01-04T00:00:00.000Z | + | 2010-01-05T00:00:00.000Z | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": { "date": "2018-02-01T00:00:00.000Z" } }, + "then": { "field": "bar", "is": "after", "value": { "date": "2010-01-04T00:00:00.000Z" } }, + "else": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-01T00:00:00.000Z" } } + } + """ + Then the following data should be generated: + | foo | bar | + | 2018-01-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | + | 2018-02-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | + | 2018-03-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | + | 2018-04-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | + | 2018-05-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | + | 2018-06-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | + + Scenario: Running an if request that contains a non contradictory after constraint within its else statement should be successful + Given foo is in set: + | 2018-01-01T00:00:00.000Z | + | 2018-02-01T00:00:00.000Z | + | 2018-03-01T00:00:00.000Z | + | 2018-04-01T00:00:00.000Z | + | 2018-05-01T00:00:00.000Z | + | 2018-06-01T00:00:00.000Z | + And foo is anything but null + And bar is in set: + | 2010-01-01T00:00:00.000Z | + | 2010-01-02T00:00:00.000Z | + | 2010-01-03T00:00:00.000Z | + | 2010-01-04T00:00:00.000Z | + | 2010-01-05T00:00:00.000Z | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": { "date": "2018-01-01T00:00:00.000Z" } }, + "then": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-01T00:00:00.000Z" } }, + "else": { "field": "bar", "is": "after", "value": { "date": "2010-01-04T00:00:00.000Z" } } + } + """ + Then the following data should be generated: + | foo | bar | + | 2018-01-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | + | 2018-02-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | + | 2018-03-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | + | 2018-04-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | + | 2018-05-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | + | 2018-06-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | + + Scenario: Running an if request that contains a contradictory after constraint within its if statement should be successful + Given foo is in set: + | 2018-01-01T00:00:00.000Z | + | 2018-02-01T00:00:00.000Z | + | 2018-03-01T00:00:00.000Z | + | 2018-04-01T00:00:00.000Z | + | 2018-05-01T00:00:00.000Z | + | 2018-06-01T00:00:00.000Z | + And foo is anything but null + And bar is in set: + | 2010-01-01T00:00:00.000Z | + | 2010-01-02T00:00:00.000Z | + | 2010-01-03T00:00:00.000Z | + | 2010-01-04T00:00:00.000Z | + | 2010-01-05T00:00:00.000Z | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "after", "value": { "date": "2020-01-01T00:00:00.000Z" } }, + "then": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-01T00:00:00.000Z" } }, + "else": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-04T00:00:00.000Z" } } + } + """ + Then the following data should be generated: + | foo | bar | + | 2018-01-01T00:00:00.000Z | 2010-01-04T00:00:00.000Z | + | 2018-02-01T00:00:00.000Z | 2010-01-04T00:00:00.000Z | + | 2018-03-01T00:00:00.000Z | 2010-01-04T00:00:00.000Z | + | 2018-04-01T00:00:00.000Z | 2010-01-04T00:00:00.000Z | + | 2018-05-01T00:00:00.000Z | 2010-01-04T00:00:00.000Z | + | 2018-06-01T00:00:00.000Z | 2010-01-04T00:00:00.000Z | + + Scenario: Running an if request that contains a contradictory after constraint within its then statement should be successful + Given foo is in set: + | 2018-01-01T00:00:00.000Z | + | 2018-02-01T00:00:00.000Z | + | 2018-03-01T00:00:00.000Z | + | 2018-04-01T00:00:00.000Z | + | 2018-05-01T00:00:00.000Z | + | 2018-06-01T00:00:00.000Z | + And foo is anything but null + And bar is in set: + | 2010-01-01T00:00:00.000Z | + | 2010-01-02T00:00:00.000Z | + | 2010-01-03T00:00:00.000Z | + | 2010-01-04T00:00:00.000Z | + | 2010-01-05T00:00:00.000Z | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": { "date": "2018-01-01T00:00:00.000Z" } }, + "then": { "field": "bar", "is": "after", "value": { "date": "2020-01-01T00:00:00.000Z" } }, + "else": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-04T00:00:00.000Z" } } + } + """ + Then the following data should be generated: + | foo | bar | + | 2018-02-01T00:00:00.000Z | 2010-01-04T00:00:00.000Z | + | 2018-03-01T00:00:00.000Z | 2010-01-04T00:00:00.000Z | + | 2018-04-01T00:00:00.000Z | 2010-01-04T00:00:00.000Z | + | 2018-05-01T00:00:00.000Z | 2010-01-04T00:00:00.000Z | + | 2018-06-01T00:00:00.000Z | 2010-01-04T00:00:00.000Z | + + Scenario: Running an if request that contains a contradictory after constraint within its else statement should be successful + Given foo is in set: + | 2018-01-01T00:00:00.000Z | + | 2018-02-01T00:00:00.000Z | + | 2018-03-01T00:00:00.000Z | + | 2018-04-01T00:00:00.000Z | + | 2018-05-01T00:00:00.000Z | + | 2018-06-01T00:00:00.000Z | + And foo is anything but null + And bar is in set: + | 2010-01-01T00:00:00.000Z | + | 2010-01-02T00:00:00.000Z | + | 2010-01-03T00:00:00.000Z | + | 2010-01-04T00:00:00.000Z | + | 2010-01-05T00:00:00.000Z | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": { "date": "2018-01-01T00:00:00.000Z" } }, + "then": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-01T00:00:00.000Z" } }, + "else": { "field": "bar", "is": "after", "value": { "date": "2020-01-01T00:00:00.000Z" } } + } + """ + Then the following data should be generated: + | foo | bar | + | 2018-01-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | + + Scenario: Running an if request that contains a non contradictory afterOrAt constraint within its if statement should be successful + Given foo is in set: + | 2018-01-01T00:00:00.000Z | + | 2018-02-01T00:00:00.000Z | + | 2018-03-01T00:00:00.000Z | + | 2018-04-01T00:00:00.000Z | + | 2018-05-01T00:00:00.000Z | + | 2018-06-01T00:00:00.000Z | + And foo is anything but null + And bar is in set: + | 2010-01-01T00:00:00.000Z | + | 2010-01-02T00:00:00.000Z | + | 2010-01-03T00:00:00.000Z | + | 2010-01-04T00:00:00.000Z | + | 2010-01-05T00:00:00.000Z | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "afterOrAt", "value": { "date": "2018-05-01T00:00:00.000Z" } }, + "then": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-05T00:00:00.000Z" } }, + "else": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-01T00:00:00.000Z" } } + } + """ + Then the following data should be generated: + | foo | bar | + | 2018-01-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | + | 2018-02-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | + | 2018-03-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | + | 2018-04-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | + | 2018-05-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | + | 2018-06-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | + + Scenario: Running an if request that contains a non contradictory afterOrAt constraint within its then statement should be successful + Given foo is in set: + | 2018-01-01T00:00:00.000Z | + | 2018-02-01T00:00:00.000Z | + | 2018-03-01T00:00:00.000Z | + | 2018-04-01T00:00:00.000Z | + | 2018-05-01T00:00:00.000Z | + | 2018-06-01T00:00:00.000Z | + And foo is anything but null + And bar is in set: + | 2010-01-01T00:00:00.000Z | + | 2010-01-02T00:00:00.000Z | + | 2010-01-03T00:00:00.000Z | + | 2010-01-04T00:00:00.000Z | + | 2010-01-05T00:00:00.000Z | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": { "date": "2018-05-01T00:00:00.000Z" } }, + "then": { "field": "bar", "is": "afterOrAt", "value": { "date": "2010-01-04T00:00:00.000Z" } }, + "else": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-01T00:00:00.000Z" } } + } + """ + Then the following data should be generated: + | foo | bar | + | 2018-01-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | + | 2018-02-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | + | 2018-03-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | + | 2018-04-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | + | 2018-05-01T00:00:00.000Z | 2010-01-04T00:00:00.000Z | + | 2018-05-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | + | 2018-06-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | + + Scenario: Running an if request that contains a non contradictory afterOrAt constraint within its else statement should be successful + Given foo is in set: + | 2018-01-01T00:00:00.000Z | + | 2018-02-01T00:00:00.000Z | + | 2018-03-01T00:00:00.000Z | + | 2018-04-01T00:00:00.000Z | + | 2018-05-01T00:00:00.000Z | + | 2018-06-01T00:00:00.000Z | + And foo is anything but null + And bar is in set: + | 2010-01-01T00:00:00.000Z | + | 2010-01-02T00:00:00.000Z | + | 2010-01-03T00:00:00.000Z | + | 2010-01-04T00:00:00.000Z | + | 2010-01-05T00:00:00.000Z | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": { "date": "2018-06-01T00:00:00.000Z" } }, + "then": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-01T00:00:00.000Z" } }, + "else": { "field": "bar", "is": "afterOrAt", "value": { "date": "2010-01-04T00:00:00.000Z" } } + } + """ + Then the following data should be generated: + | foo | bar | + | 2018-01-01T00:00:00.000Z | 2010-01-04T00:00:00.000Z | + | 2018-01-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | + | 2018-02-01T00:00:00.000Z | 2010-01-04T00:00:00.000Z | + | 2018-02-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | + | 2018-03-01T00:00:00.000Z | 2010-01-04T00:00:00.000Z | + | 2018-03-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | + | 2018-04-01T00:00:00.000Z | 2010-01-04T00:00:00.000Z | + | 2018-04-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | + | 2018-05-01T00:00:00.000Z | 2010-01-04T00:00:00.000Z | + | 2018-05-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | + | 2018-06-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | + + Scenario: Running an if request that contains a contradictory afterOrAt constraint within its if statement should be successful + Given foo is in set: + | 2018-01-01T00:00:00.000Z | + | 2018-02-01T00:00:00.000Z | + | 2018-03-01T00:00:00.000Z | + | 2018-04-01T00:00:00.000Z | + | 2018-05-01T00:00:00.000Z | + | 2018-06-01T00:00:00.000Z | + And foo is anything but null + And bar is in set: + | 2010-01-01T00:00:00.000Z | + | 2010-01-02T00:00:00.000Z | + | 2010-01-03T00:00:00.000Z | + | 2010-01-04T00:00:00.000Z | + | 2010-01-05T00:00:00.000Z | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "afterOrAt", "value": { "date": "2020-01-01T00:00:00.000Z" } }, + "then": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-01T00:00:00.000Z" } }, + "else": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-05T00:00:00.000Z" } } + } + """ + Then the following data should be generated: + | foo | bar | + | 2018-01-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | + | 2018-02-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | + | 2018-03-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | + | 2018-04-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | + | 2018-05-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | + | 2018-06-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | + + Scenario: Running an if request that contains a contradictory afterOrAt constraint within its then statement should be successful + Given foo is in set: + | 2018-01-01T00:00:00.000Z | + | 2018-02-01T00:00:00.000Z | + | 2018-03-01T00:00:00.000Z | + | 2018-04-01T00:00:00.000Z | + | 2018-05-01T00:00:00.000Z | + | 2018-06-01T00:00:00.000Z | + And foo is anything but null + And bar is in set: + | 2010-01-01T00:00:00.000Z | + | 2010-01-02T00:00:00.000Z | + | 2010-01-03T00:00:00.000Z | + | 2010-01-04T00:00:00.000Z | + | 2010-01-05T00:00:00.000Z | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": { "date": "2018-01-01T00:00:00.000Z" } }, + "then": { "field": "bar", "is": "afterOrAt", "value": { "date": "2020-01-01T00:00:00.000Z" } }, + "else": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-05T00:00:00.000Z" } } + } + """ + Then the following data should be generated: + | foo | bar | + | 2018-02-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | + | 2018-03-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | + | 2018-04-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | + | 2018-05-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | + | 2018-06-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | + + Scenario: Running an if request that contains a contradictory afterOrAt constraint within its else statement should be successful + Given foo is in set: + | 2018-01-01T00:00:00.000Z | + | 2018-02-01T00:00:00.000Z | + | 2018-03-01T00:00:00.000Z | + | 2018-04-01T00:00:00.000Z | + | 2018-05-01T00:00:00.000Z | + | 2018-06-01T00:00:00.000Z | + And foo is anything but null + And bar is in set: + | 2010-01-01T00:00:00.000Z | + | 2010-01-02T00:00:00.000Z | + | 2010-01-03T00:00:00.000Z | + | 2010-01-04T00:00:00.000Z | + | 2010-01-05T00:00:00.000Z | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": { "date": "2018-01-01T00:00:00.000Z" } }, + "then": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-01T00:00:00.000Z" } }, + "else": { "field": "bar", "is": "afterOrAt", "value": { "date": "2020-01-05T00:00:00.000Z" } } + } + """ + Then the following data should be generated: + | foo | bar | + | 2018-01-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | + + Scenario: Running an if request that contains a non contradictory before constraint within its if statement should be successful + Given foo is in set: + | 2018-01-01T00:00:00.000Z | + | 2018-02-01T00:00:00.000Z | + | 2018-03-01T00:00:00.000Z | + | 2018-04-01T00:00:00.000Z | + | 2018-05-01T00:00:00.000Z | + | 2018-06-01T00:00:00.000Z | + And foo is anything but null + And bar is in set: + | 2010-01-01T00:00:00.000Z | + | 2010-01-02T00:00:00.000Z | + | 2010-01-03T00:00:00.000Z | + | 2010-01-04T00:00:00.000Z | + | 2010-01-05T00:00:00.000Z | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "before", "value": { "date": "2018-02-01T00:00:00.000Z" } }, + "then": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-01T00:00:00.000Z" } }, + "else": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-05T00:00:00.000Z" } } + } + """ + Then the following data should be generated: + | foo | bar | + | 2018-01-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | + | 2018-02-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | + | 2018-03-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | + | 2018-04-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | + | 2018-05-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | + | 2018-06-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | + + Scenario: Running an if request that contains a non contradictory before constraint within its then statement should be successful + Given foo is in set: + | 2018-01-01T00:00:00.000Z | + | 2018-02-01T00:00:00.000Z | + | 2018-03-01T00:00:00.000Z | + | 2018-04-01T00:00:00.000Z | + | 2018-05-01T00:00:00.000Z | + | 2018-06-01T00:00:00.000Z | + And foo is anything but null + And bar is in set: + | 2010-01-01T00:00:00.000Z | + | 2010-01-02T00:00:00.000Z | + | 2010-01-03T00:00:00.000Z | + | 2010-01-04T00:00:00.000Z | + | 2010-01-05T00:00:00.000Z | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": { "date": "2018-01-01T00:00:00.000Z" } }, + "then": { "field": "bar", "is": "before", "value": { "date": "2010-01-03T00:00:00.000Z" } }, + "else": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-05T00:00:00.000Z" } } + } + """ + Then the following data should be generated: + | foo | bar | + | 2018-01-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | + | 2018-01-01T00:00:00.000Z | 2010-01-02T00:00:00.000Z | + | 2018-02-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | + | 2018-03-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | + | 2018-04-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | + | 2018-05-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | + | 2018-06-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | + + Scenario: Running an if request that contains a non contradictory before constraint within its else statement should be successful + Given foo is in set: + | 2018-01-01T00:00:00.000Z | + | 2018-02-01T00:00:00.000Z | + | 2018-03-01T00:00:00.000Z | + | 2018-04-01T00:00:00.000Z | + | 2018-05-01T00:00:00.000Z | + | 2018-06-01T00:00:00.000Z | + And foo is anything but null + And bar is in set: + | 2010-01-01T00:00:00.000Z | + | 2010-01-02T00:00:00.000Z | + | 2010-01-03T00:00:00.000Z | + | 2010-01-04T00:00:00.000Z | + | 2010-01-05T00:00:00.000Z | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": { "date": "2018-01-01T00:00:00.000Z" } }, + "then": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-05T00:00:00.000Z" } }, + "else": { "field": "bar", "is": "before", "value": { "date": "2010-01-03T00:00:00.000Z" } } + } + """ + Then the following data should be generated: + | foo | bar | + | 2018-01-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | + | 2018-02-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | + | 2018-02-01T00:00:00.000Z | 2010-01-02T00:00:00.000Z | + | 2018-03-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | + | 2018-03-01T00:00:00.000Z | 2010-01-02T00:00:00.000Z | + | 2018-04-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | + | 2018-04-01T00:00:00.000Z | 2010-01-02T00:00:00.000Z | + | 2018-05-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | + | 2018-05-01T00:00:00.000Z | 2010-01-02T00:00:00.000Z | + | 2018-06-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | + | 2018-06-01T00:00:00.000Z | 2010-01-02T00:00:00.000Z | + + Scenario: Running an if request that contains a contradictory before constraint within its if statement should be successful + Given foo is in set: + | 2018-01-01T00:00:00.000Z | + | 2018-02-01T00:00:00.000Z | + | 2018-03-01T00:00:00.000Z | + | 2018-04-01T00:00:00.000Z | + | 2018-05-01T00:00:00.000Z | + | 2018-06-01T00:00:00.000Z | + And foo is anything but null + And bar is in set: + | 2010-01-01T00:00:00.000Z | + | 2010-01-02T00:00:00.000Z | + | 2010-01-03T00:00:00.000Z | + | 2010-01-04T00:00:00.000Z | + | 2010-01-05T00:00:00.000Z | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "before", "value": { "date": "2010-01-01T00:00:00.000Z" } }, + "then": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-05T00:00:00.000Z" } }, + "else": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-03T00:00:00.000Z" } } + } + """ + Then the following data should be generated: + | foo | bar | + | 2018-01-01T00:00:00.000Z | 2010-01-03T00:00:00.000Z | + | 2018-02-01T00:00:00.000Z | 2010-01-03T00:00:00.000Z | + | 2018-03-01T00:00:00.000Z | 2010-01-03T00:00:00.000Z | + | 2018-04-01T00:00:00.000Z | 2010-01-03T00:00:00.000Z | + | 2018-05-01T00:00:00.000Z | 2010-01-03T00:00:00.000Z | + | 2018-06-01T00:00:00.000Z | 2010-01-03T00:00:00.000Z | + + Scenario: Running an if request that contains a contradictory before constraint within its then statement should be successful + Given foo is in set: + | 2018-01-01T00:00:00.000Z | + | 2018-02-01T00:00:00.000Z | + | 2018-03-01T00:00:00.000Z | + | 2018-04-01T00:00:00.000Z | + | 2018-05-01T00:00:00.000Z | + | 2018-06-01T00:00:00.000Z | + And foo is anything but null + And bar is in set: + | 2010-01-01T00:00:00.000Z | + | 2010-01-02T00:00:00.000Z | + | 2010-01-03T00:00:00.000Z | + | 2010-01-04T00:00:00.000Z | + | 2010-01-05T00:00:00.000Z | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": { "date": "2018-01-01T00:00:00.000Z" } }, + "then": { "field": "bar", "is": "before", "value": { "date": "2010-01-01T00:00:00.000Z" } }, + "else": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-03T00:00:00.000Z" } } + } + """ + Then the following data should be generated: + | foo | bar | + | 2018-02-01T00:00:00.000Z | 2010-01-03T00:00:00.000Z | + | 2018-03-01T00:00:00.000Z | 2010-01-03T00:00:00.000Z | + | 2018-04-01T00:00:00.000Z | 2010-01-03T00:00:00.000Z | + | 2018-05-01T00:00:00.000Z | 2010-01-03T00:00:00.000Z | + | 2018-06-01T00:00:00.000Z | 2010-01-03T00:00:00.000Z | + + Scenario: Running an if request that contains a contradictory before constraint within its else statement should be successful + Given foo is in set: + | 2018-01-01T00:00:00.000Z | + | 2018-02-01T00:00:00.000Z | + | 2018-03-01T00:00:00.000Z | + | 2018-04-01T00:00:00.000Z | + | 2018-05-01T00:00:00.000Z | + | 2018-06-01T00:00:00.000Z | + And foo is anything but null + And bar is in set: + | 2010-01-01T00:00:00.000Z | + | 2010-01-02T00:00:00.000Z | + | 2010-01-03T00:00:00.000Z | + | 2010-01-04T00:00:00.000Z | + | 2010-01-05T00:00:00.000Z | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": { "date": "2018-01-01T00:00:00.000Z" } }, + "then": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-01T00:00:00.000Z" } }, + "else": { "field": "bar", "is": "before", "value": { "date": "2010-01-01T00:00:00.000Z" } } + } + """ + Then the following data should be generated: + | foo | bar | + | 2018-01-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | + + Scenario: Running an if request that contains a non contradictory beforeOrAt constraint within its if statement should be successful + Given foo is in set: + | 2018-01-01T00:00:00.000Z | + | 2018-02-01T00:00:00.000Z | + | 2018-03-01T00:00:00.000Z | + | 2018-04-01T00:00:00.000Z | + | 2018-05-01T00:00:00.000Z | + | 2018-06-01T00:00:00.000Z | + And foo is anything but null + And bar is in set: + | 2010-01-01T00:00:00.000Z | + | 2010-01-02T00:00:00.000Z | + | 2010-01-03T00:00:00.000Z | + | 2010-01-04T00:00:00.000Z | + | 2010-01-05T00:00:00.000Z | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "beforeOrAt", "value": { "date": "2018-02-01T00:00:00.000Z" } }, + "then": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-01T00:00:00.000Z" } }, + "else": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-05T00:00:00.000Z" } } + } + """ + Then the following data should be generated: + | foo | bar | + | 2018-01-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | + | 2018-02-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | + | 2018-03-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | + | 2018-04-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | + | 2018-05-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | + | 2018-06-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | + + Scenario: Running an if request that contains a non contradictory beforeOrAt constraint within its then statement should be successful + Given foo is in set: + | 2018-01-01T00:00:00.000Z | + | 2018-02-01T00:00:00.000Z | + | 2018-03-01T00:00:00.000Z | + | 2018-04-01T00:00:00.000Z | + | 2018-05-01T00:00:00.000Z | + | 2018-06-01T00:00:00.000Z | + And foo is anything but null + And bar is in set: + | 2010-01-01T00:00:00.000Z | + | 2010-01-02T00:00:00.000Z | + | 2010-01-03T00:00:00.000Z | + | 2010-01-04T00:00:00.000Z | + | 2010-01-05T00:00:00.000Z | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": { "date": "2018-01-01T00:00:00.000Z" } }, + "then": { "field": "bar", "is": "beforeOrAt", "value": { "date": "2010-01-03T00:00:00.000Z" } }, + "else": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-05T00:00:00.000Z" } } + } + """ + Then the following data should be generated: + | foo | bar | + | 2018-01-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | + | 2018-01-01T00:00:00.000Z | 2010-01-02T00:00:00.000Z | + | 2018-01-01T00:00:00.000Z | 2010-01-03T00:00:00.000Z | + | 2018-02-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | + | 2018-03-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | + | 2018-04-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | + | 2018-05-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | + | 2018-06-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | + + Scenario: Running an if request that contains a non contradictory beforeOrAt constraint within its else statement should be successful + Given foo is in set: + | 2018-01-01T00:00:00.000Z | + | 2018-02-01T00:00:00.000Z | + | 2018-03-01T00:00:00.000Z | + | 2018-04-01T00:00:00.000Z | + | 2018-05-01T00:00:00.000Z | + | 2018-06-01T00:00:00.000Z | + And foo is anything but null + And bar is in set: + | 2010-01-01T00:00:00.000Z | + | 2010-01-02T00:00:00.000Z | + | 2010-01-03T00:00:00.000Z | + | 2010-01-04T00:00:00.000Z | + | 2010-01-05T00:00:00.000Z | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": { "date": "2018-01-01T00:00:00.000Z" } }, + "then": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-05T00:00:00.000Z" } }, + "else": { "field": "bar", "is": "beforeOrAt", "value": { "date": "2010-01-03T00:00:00.000Z" } } + } + """ + Then the following data should be generated: + | foo | bar | + | 2018-01-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | + | 2018-02-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | + | 2018-02-01T00:00:00.000Z | 2010-01-02T00:00:00.000Z | + | 2018-02-01T00:00:00.000Z | 2010-01-03T00:00:00.000Z | + | 2018-03-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | + | 2018-03-01T00:00:00.000Z | 2010-01-02T00:00:00.000Z | + | 2018-03-01T00:00:00.000Z | 2010-01-03T00:00:00.000Z | + | 2018-04-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | + | 2018-04-01T00:00:00.000Z | 2010-01-02T00:00:00.000Z | + | 2018-04-01T00:00:00.000Z | 2010-01-03T00:00:00.000Z | + | 2018-05-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | + | 2018-05-01T00:00:00.000Z | 2010-01-02T00:00:00.000Z | + | 2018-05-01T00:00:00.000Z | 2010-01-03T00:00:00.000Z | + | 2018-06-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | + | 2018-06-01T00:00:00.000Z | 2010-01-02T00:00:00.000Z | + | 2018-06-01T00:00:00.000Z | 2010-01-03T00:00:00.000Z | + + Scenario: Running an if request that contains a contradictory beforeOrAt constraint within its if statement should be successful + Given foo is in set: + | 2018-01-01T00:00:00.000Z | + | 2018-02-01T00:00:00.000Z | + | 2018-03-01T00:00:00.000Z | + | 2018-04-01T00:00:00.000Z | + | 2018-05-01T00:00:00.000Z | + | 2018-06-01T00:00:00.000Z | + And foo is anything but null + And bar is in set: + | 2010-01-01T00:00:00.000Z | + | 2010-01-02T00:00:00.000Z | + | 2010-01-03T00:00:00.000Z | + | 2010-01-04T00:00:00.000Z | + | 2010-01-05T00:00:00.000Z | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "beforeOrAt", "value": { "date": "2009-01-01T00:00:00.000Z" } }, + "then": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-05T00:00:00.000Z" } }, + "else": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-03T00:00:00.000Z" } } + } + """ + Then the following data should be generated: + | foo | bar | + | 2018-01-01T00:00:00.000Z | 2010-01-03T00:00:00.000Z | + | 2018-02-01T00:00:00.000Z | 2010-01-03T00:00:00.000Z | + | 2018-03-01T00:00:00.000Z | 2010-01-03T00:00:00.000Z | + | 2018-04-01T00:00:00.000Z | 2010-01-03T00:00:00.000Z | + | 2018-05-01T00:00:00.000Z | 2010-01-03T00:00:00.000Z | + | 2018-06-01T00:00:00.000Z | 2010-01-03T00:00:00.000Z | + + Scenario: Running an if request that contains a contradictory beforeOrAt constraint within its then statement should be successful + Given foo is in set: + | 2018-01-01T00:00:00.000Z | + | 2018-02-01T00:00:00.000Z | + | 2018-03-01T00:00:00.000Z | + | 2018-04-01T00:00:00.000Z | + | 2018-05-01T00:00:00.000Z | + | 2018-06-01T00:00:00.000Z | + And foo is anything but null + And bar is in set: + | 2010-01-01T00:00:00.000Z | + | 2010-01-02T00:00:00.000Z | + | 2010-01-03T00:00:00.000Z | + | 2010-01-04T00:00:00.000Z | + | 2010-01-05T00:00:00.000Z | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": { "date": "2018-01-01T00:00:00.000Z" } }, + "then": { "field": "bar", "is": "beforeOrAt", "value": { "date": "2009-01-01T00:00:00.000Z" } }, + "else": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-03T00:00:00.000Z" } } + } + """ + Then the following data should be generated: + | foo | bar | + | 2018-02-01T00:00:00.000Z | 2010-01-03T00:00:00.000Z | + | 2018-03-01T00:00:00.000Z | 2010-01-03T00:00:00.000Z | + | 2018-04-01T00:00:00.000Z | 2010-01-03T00:00:00.000Z | + | 2018-05-01T00:00:00.000Z | 2010-01-03T00:00:00.000Z | + | 2018-06-01T00:00:00.000Z | 2010-01-03T00:00:00.000Z | + + Scenario: Running an if request that contains a contradictory beforeOrAt constraint within its else statement should be successful + Given foo is in set: + | 2018-01-01T00:00:00.000Z | + | 2018-02-01T00:00:00.000Z | + | 2018-03-01T00:00:00.000Z | + | 2018-04-01T00:00:00.000Z | + | 2018-05-01T00:00:00.000Z | + | 2018-06-01T00:00:00.000Z | + And foo is anything but null + And bar is in set: + | 2010-01-01T00:00:00.000Z | + | 2010-01-02T00:00:00.000Z | + | 2010-01-03T00:00:00.000Z | + | 2010-01-04T00:00:00.000Z | + | 2010-01-05T00:00:00.000Z | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": { "date": "2018-01-01T00:00:00.000Z" } }, + "then": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-01T00:00:00.000Z" } }, + "else": { "field": "bar", "is": "beforeOrAt", "value": { "date": "2009-01-01T00:00:00.000Z" } } + } + """ + Then the following data should be generated: + | foo | bar | + | 2018-01-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | + + Scenario: Running an if request that contains a non contradictory not constraint within its if statement should be successful + Given foo is in set: + | "a" | + | "b" | + And foo is anything but null + And bar is in set: + | 10 | + | 20 | + | 30 | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "not": { "field": "foo", "is": "equalTo", "value": "a" } }, + "then": { "field": "bar", "is": "equalTo", "value": 10 } + } + """ + Then the following data should be generated: + | foo | bar | + | "a" | 10 | + | "a" | 20 | + | "a" | 30 | + | "b" | 10 | + + Scenario: Running an if request that contains a non contradictory not constraint within its then statement should be successful + Given foo is in set: + | "a" | + | "b" | + And foo is anything but null + And bar is in set: + | 10 | + | 20 | + | 30 | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": "a" }, + "then": { "not": { "field": "bar", "is": "equalTo", "value": 10 } }, + "else": { "field": "bar", "is": "equalTo", "value": 10 } + } + """ + Then the following data should be generated: + | foo | bar | + | "a" | 20 | + | "a" | 30 | + | "b" | 10 | + + Scenario: Running an if request that contains a non contradictory not constraint within its else statement should be successful + Given foo is in set: + | "a" | + | "b" | + And foo is anything but null + And bar is in set: + | 10 | + | 20 | + | 30 | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": "a" }, + "then": { "field": "bar", "is": "equalTo", "value": 10 }, + "else": { "not": { "field": "bar", "is": "equalTo", "value": 10 } } + } + """ + Then the following data should be generated: + | foo | bar | + | "a" | 10 | + | "b" | 20 | + | "b" | 30 | + + Scenario: Running an if request that contains a contradictory not constraint within its if statement should be successful + Given foo is in set: + | "a" | + And foo is anything but null + And bar is in set: + | 10 | + | 20 | + | 30 | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "not": { "field": "foo", "is": "equalTo", "value": "a" } }, + "then": { "field": "bar", "is": "equalTo", "value": 10 }, + "else": { "field": "bar", "is": "equalTo", "value": 30 } + } + """ + Then the following data should be generated: + | foo | bar | + | "a" | 30 | + + Scenario: Running an if request that contains a contradictory not constraint within its then statement should be successful + Given foo is in set: + | "a" | + | "b" | + And foo is anything but null + And bar is in set: + | 10 | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": "a" }, + "then": { "not": { "field": "bar", "is": "equalTo", "value": 10 } } + } + """ + Then the following data should be generated: + | foo | bar | + | "b" | 10 | + + Scenario: Running an if request that contains a contradictory not constraint within its else statement should be successful + Given foo is in set: + | "a" | + | "b" | + And foo is anything but null + And bar is in set: + | 10 | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": "a" }, + "then": { "field": "bar", "is": "equalTo", "value": 10 }, + "else": { "not": { "field": "bar", "is": "equalTo", "value": 10 } } + } + """ + Then the following data should be generated: + | foo | bar | + | "a" | 10 | + + Scenario: Running an if request that contains a non contradictory anyOf constraint within its if statement should be successful + Given foo is in set: + | "a" | + | "b" | + | "c" | + | "d" | + | "e" | + And foo is anything but null + And bar is in set: + | 10 | + | 20 | + | 30 | + | 40 | + | 50 | + And bar is anything but null + And there is a constraint: + """ + { + "if": + { "anyOf": [ + { "field": "foo", "is": "equalTo", "value": "a" }, + { "field": "foo", "is": "equalTo", "value": "e" } + ]}, + "then": { "field": "bar", "is": "equalTo", "value": 10 }, + "else": { "field": "bar", "is": "equalTo", "value": 50 } + } + """ + Then the following data should be generated: + | foo | bar | + | "a" | 10 | + | "b" | 50 | + | "c" | 50 | + | "d" | 50 | + | "e" | 10 | + + Scenario: Running an if request that contains a non contradictory anyOf constraint within its then statement should be successful + Given foo is in set: + | "a" | + | "b" | + | "c" | + | "d" | + | "e" | + And foo is anything but null + And bar is in set: + | 10 | + | 20 | + | 30 | + | 40 | + | 50 | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": "a" }, + "then": + { "anyOf": [ + { "field": "bar", "is": "equalTo", "value": 20 }, + { "field": "bar", "is": "equalTo", "value": 40 } + ]}, + "else": { "field": "bar", "is": "equalTo", "value": 50 } + } + """ + Then the following data should be generated: + | foo | bar | + | "a" | 20 | + | "a" | 40 | + | "b" | 50 | + | "c" | 50 | + | "d" | 50 | + | "e" | 50 | + + Scenario: Running an if request that contains a non contradictory anyOf constraint within its then statement should be successful + Given foo is in set: + | "a" | + | "b" | + | "c" | + | "d" | + | "e" | + And foo is anything but null + And bar is in set: + | 10 | + | 20 | + | 30 | + | 40 | + | 50 | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": "a" }, + "then": { "field": "bar", "is": "equalTo", "value": 10 }, + "else": + { "anyOf": [ + { "field": "bar", "is": "equalTo", "value": 20 }, + { "field": "bar", "is": "equalTo", "value": 40 } + ]} + } + """ + Then the following data should be generated: + | foo | bar | + | "a" | 10 | + | "b" | 20 | + | "b" | 40 | + | "c" | 20 | + | "c" | 40 | + | "d" | 20 | + | "d" | 40 | + | "e" | 20 | + | "e" | 40 | + + Scenario: Running an if request that contains a contradictory anyOf constraint within its if statement should be successful + Given foo is in set: + | "a" | + | "b" | + | "c" | + | "d" | + | "e" | + And foo is anything but null + And bar is in set: + | 10 | + | 20 | + | 30 | + | 40 | + | 50 | + And bar is anything but null + And there is a constraint: + """ + { + "if": + { "anyOf": [ + { "field": "foo", "is": "equalTo", "value": "Test1" }, + { "field": "foo", "is": "equalTo", "value": "Test2" } + ]}, + "then": { "field": "bar", "is": "equalTo", "value": 10 }, + "else": { "field": "bar", "is": "equalTo", "value": 50 } + } + """ + Then the following data should be generated: + | foo | bar | + | "a" | 50 | + | "b" | 50 | + | "c" | 50 | + | "d" | 50 | + | "e" | 50 | + + + Scenario: Running an if request that contains a contradictory anyOf constraint within its then statement should be successful + Given foo is in set: + | "a" | + | "b" | + | "c" | + | "d" | + | "e" | + And foo is anything but null + And bar is in set: + | 10 | + | 20 | + | 30 | + | 40 | + | 50 | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": "a" }, + "then": + { "anyOf": [ + { "field": "bar", "is": "equalTo", "value": "Test1" }, + { "field": "bar", "is": "equalTo", "value": "Test2" } + ]}, + "else": { "field": "bar", "is": "equalTo", "value": 50 } + } + """ + Then the following data should be generated: + | foo | bar | + | "b" | 50 | + | "c" | 50 | + | "d" | 50 | + | "e" | 50 | + + Scenario: Running an if request that contains a contradictory anyOf constraint within its else statement should be successful + Given foo is in set: + | "a" | + | "b" | + | "c" | + | "d" | + | "e" | + And foo is anything but null + And bar is in set: + | 10 | + | 20 | + | 30 | + | 40 | + | 50 | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": "a" }, + "then": { "field": "bar", "is": "equalTo", "value": 10 }, + "else": { + "anyOf": [ + { "field": "bar", "is": "equalTo", "value": "Test1" }, + { "field": "bar", "is": "equalTo", "value": "Test2" } + ]} + } + """ + Then the following data should be generated: + | foo | bar | + | "a" | 10 | + + Scenario: Running an if request that contains a non contradictory allOf constraint within its if statement should be successful + Given foo is in set: + | "a" | + | "bb" | + | "ccc" | + | "dddd" | + | "eeeee" | + And foo is anything but null + And bar is in set: + | 1 | + | 22 | + | 333 | + | 4444 | + | 55555 | + And bar is anything but null + And there is a constraint: + """ + { + "if": + { "allOf": [ + { "field": "foo", "is": "longerThan", "value": 0 }, + { "field": "foo", "is": "shorterThan", "value": 2 } + ]}, + "then": { "field": "bar", "is": "equalTo", "value": 1 }, + "else": { "field": "bar", "is": "equalTo", "value": 55555 } + } + """ + Then the following data should be generated: + | foo | bar | + | "a" | 1 | + | "bb" | 55555 | + | "ccc" | 55555 | + | "dddd" | 55555 | + | "eeeee" | 55555 | + + Scenario: Running an if request that contains a non contradictory allOf constraint within its then statement should be successful + Given foo is in set: + | "a" | + | "bb" | + | "ccc" | + | "dddd" | + | "eeeee" | + And foo is anything but null + And bar is in set: + | 1 | + | 22 | + | 333 | + | 4444 | + | 55555 | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": "a" }, + "then": + { "allOf": [ + { "field": "bar", "is": "greaterThan", "value": 20 }, + { "field": "bar", "is": "lessThan", "value": 30 } + ]}, + "else": { "field": "bar", "is": "equalTo", "value": 55555 } + } + """ + Then the following data should be generated: + | foo | bar | + | "a" | 22 | + | "bb" | 55555 | + | "ccc" | 55555 | + | "dddd" | 55555 | + | "eeeee" | 55555 | + + Scenario: Running an if request that contains a non contradictory allOf constraint within its else statement should be successful + Given foo is in set: + | "a" | + | "bb" | + | "ccc" | + | "dddd" | + | "eeeee" | + And foo is anything but null + And bar is in set: + | 1 | + | 22 | + | 333 | + | 4444 | + | 55555 | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": "a" }, + "then": { "field": "bar", "is": "equalTo", "value": 1 }, + "else": + { "allOf": [ + { "field": "bar", "is": "greaterThan", "value": 20 }, + { "field": "bar", "is": "lessThan", "value": 30 } + ]} + } + """ + Then the following data should be generated: + | foo | bar | + | "a" | 1 | + | "bb" | 22 | + | "ccc" | 22 | + | "dddd" | 22 | + | "eeeee" | 22 | + + Scenario: Running an if request that contains a contradictory allOf constraint within its if statement should be successful + Given foo is in set: + | "a" | + | "bb" | + | "ccc" | + | "dddd" | + | "eeeee" | + And foo is anything but null + And bar is in set: + | 1 | + | 22 | + | 333 | + | 4444 | + | 55555 | + And bar is anything but null + And there is a constraint: + """ + { + "if": + { "allOf": [ + { "field": "foo", "is": "longerThan", "value": 88 }, + { "field": "foo", "is": "shorterThan", "value": 90 } + ]}, + "then": { "field": "bar", "is": "equalTo", "value": 1 }, + "else": { "field": "bar", "is": "equalTo", "value": 55555 } + } + """ + Then the following data should be generated: + | foo | bar | + | "a" | 55555 | + | "bb" | 55555 | + | "ccc" | 55555 | + | "dddd" | 55555 | + | "eeeee" | 55555 | + + Scenario: Running an if request that contains a non contradictory allOf constraint within its then statement should be successful + Given foo is in set: + | "a" | + | "bb" | + | "ccc" | + | "dddd" | + | "eeeee" | + And foo is anything but null + And bar is in set: + | 1 | + | 22 | + | 333 | + | 4444 | + | 55555 | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": "a" }, + "then": + { "allOf": [ + { "field": "bar", "is": "greaterThan", "value": 200 }, + { "field": "bar", "is": "lessThan", "value": 300 } + ]}, + "else": { "field": "bar", "is": "equalTo", "value": 55555 } + } + """ + Then the following data should be generated: + | foo | bar | + | "bb" | 55555 | + | "ccc" | 55555 | + | "dddd" | 55555 | + | "eeeee" | 55555 | + + Scenario: Running an if request that contains a non contradictory allOf constraint within its else statement should be successful + Given foo is in set: + | "a" | + | "bb" | + | "ccc" | + | "dddd" | + | "eeeee" | + And foo is anything but null + And bar is in set: + | 1 | + | 22 | + | 333 | + | 4444 | + | 55555 | + And bar is anything but null + And there is a constraint: + """ + { + "if": { "field": "foo", "is": "equalTo", "value": "a" }, + "then": { "field": "bar", "is": "equalTo", "value": 1 }, + "else": + { "allOf": [ + { "field": "bar", "is": "greaterThan", "value": 200 }, + { "field": "bar", "is": "lessThan", "value": 300 } + ]} + } + """ + Then the following data should be generated: + | foo | bar | + | "a" | 1 | From 1adb424d50baba79ebf6195d96d16886c5519763 Mon Sep 17 00:00:00 2001 From: Paul Daulby Date: Thu, 25 Jul 2019 13:58:46 +0100 Subject: [PATCH 06/14] Remove FlatMappingSpliterator from random row spec decision tree walker --- .../RandomRowSpecDecisionTreeWalker.java | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/generator/src/main/java/com/scottlogic/deg/generator/walker/rowspec/RandomRowSpecDecisionTreeWalker.java b/generator/src/main/java/com/scottlogic/deg/generator/walker/rowspec/RandomRowSpecDecisionTreeWalker.java index 9c59aa38f..1cecb7bbb 100644 --- a/generator/src/main/java/com/scottlogic/deg/generator/walker/rowspec/RandomRowSpecDecisionTreeWalker.java +++ b/generator/src/main/java/com/scottlogic/deg/generator/walker/rowspec/RandomRowSpecDecisionTreeWalker.java @@ -1,7 +1,6 @@ package com.scottlogic.deg.generator.walker.rowspec; import com.google.inject.Inject; -import com.scottlogic.deg.common.util.FlatMappingSpliterator; import com.scottlogic.deg.generator.decisiontree.DecisionTree; import com.scottlogic.deg.generator.fieldspecs.RowSpec; import com.scottlogic.deg.generator.generation.databags.DataBag; @@ -23,20 +22,17 @@ public RandomRowSpecDecisionTreeWalker(RowSpecTreeSolver rowSpecTreeSolver, RowS @Override public Stream walk(DecisionTree tree) { - if (tree.rootNode.getDecisions().isEmpty()){ return generateWithoutRestarting(tree); } - return FlatMappingSpliterator.flatMap( - getRowSpecAndRestart(tree), - this::createDataBags); + return getRowSpecAndRestart(tree) + .map(this::createDataBag); } private Stream generateWithoutRestarting(DecisionTree tree) { - return FlatMappingSpliterator.flatMap( - rowSpecTreeSolver.createRowSpecs(tree), - rowSpecDataBagGenerator::createDataBags); + RowSpec rowSpec = getFirstRowSpec(tree).get(); + return rowSpecDataBagGenerator.createDataBags(rowSpec); } private Stream getRowSpecAndRestart(DecisionTree tree) { @@ -53,8 +49,7 @@ private Optional getFirstRowSpec(DecisionTree tree) { return rowSpecTreeSolver.createRowSpecs(tree).findFirst(); } - private Stream createDataBags(RowSpec rowSpec) { - return rowSpecDataBagGenerator.createDataBags(rowSpec) - .limit(1); + private DataBag createDataBag(RowSpec rowSpec) { + return rowSpecDataBagGenerator.createDataBags(rowSpec).findFirst().get(); } } From 01edfede646cdf4b1bef26b0676bc5711f85c597 Mon Sep 17 00:00:00 2001 From: Paul Daulby Date: Thu, 25 Jul 2019 15:43:46 +0100 Subject: [PATCH 07/14] update to PR comments --- .../generator/walker/decisionbased/DecisionBasedSolver.java | 5 ++--- .../generator/walker/decisionbased/RandomOptionPicker.java | 3 ++- .../scottlogic/deg/generator/walker/reductive/Merged.java | 4 ---- .../cucumber/features/operators/grammatical/If.feature | 2 ++ .../features/operators/grammatical/IfDecisionBased.feature | 2 ++ 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/generator/src/main/java/com/scottlogic/deg/generator/walker/decisionbased/DecisionBasedSolver.java b/generator/src/main/java/com/scottlogic/deg/generator/walker/decisionbased/DecisionBasedSolver.java index 15e89c698..a5e76df8a 100644 --- a/generator/src/main/java/com/scottlogic/deg/generator/walker/decisionbased/DecisionBasedSolver.java +++ b/generator/src/main/java/com/scottlogic/deg/generator/walker/decisionbased/DecisionBasedSolver.java @@ -42,8 +42,7 @@ public Stream createRowSpecs(DecisionTree tree) { private RowSpec toRowspec(ProfileFields fields, ConstraintNode rootNode){ return constraintReducer - .reduceConstraintsToRowSpec(fields, rootNode.getAtomicConstraints()) - .get();//todo + .reduceConstraintsToRowSpec(fields, rootNode.getAtomicConstraints()).get(); } private Stream reduceToRowNodes(ConstraintNode rootNode){ @@ -56,7 +55,7 @@ private Stream reduceToRowNodes(ConstraintNode rootNode){ Stream rootOnlyConstraintNodes = optionPicker.streamOptions(decisionNode) .map(option -> combineWithRootNode(rootWithoutDecision, option)) - .filter(Merged::notContradictory) + .filter(newNode -> !newNode.isContradictory()) .map(Merged::get); return FlatMappingSpliterator.flatMap( diff --git a/generator/src/main/java/com/scottlogic/deg/generator/walker/decisionbased/RandomOptionPicker.java b/generator/src/main/java/com/scottlogic/deg/generator/walker/decisionbased/RandomOptionPicker.java index 86322a42a..fd55511cd 100644 --- a/generator/src/main/java/com/scottlogic/deg/generator/walker/decisionbased/RandomOptionPicker.java +++ b/generator/src/main/java/com/scottlogic/deg/generator/walker/decisionbased/RandomOptionPicker.java @@ -6,6 +6,7 @@ import java.util.ArrayList; import java.util.Collections; +import java.util.List; import java.util.Random; import java.util.stream.Stream; @@ -25,7 +26,7 @@ public DecisionNode pickDecision(ConstraintNode constraintNode) { @Override public Stream streamOptions(DecisionNode decisionNode) { - ArrayList options = new ArrayList(decisionNode.getOptions()); + List options = new ArrayList<>(decisionNode.getOptions()); Collections.shuffle(options); return options.stream(); } diff --git a/generator/src/main/java/com/scottlogic/deg/generator/walker/reductive/Merged.java b/generator/src/main/java/com/scottlogic/deg/generator/walker/reductive/Merged.java index 827f0f4ec..67b89242b 100644 --- a/generator/src/main/java/com/scottlogic/deg/generator/walker/reductive/Merged.java +++ b/generator/src/main/java/com/scottlogic/deg/generator/walker/reductive/Merged.java @@ -53,10 +53,6 @@ public boolean isContradictory() { return value == null; } - public boolean notContradictory() { - return !isContradictory(); - } - /** * If a value not Contradictory in this {@code Merged}, returns the value, * otherwise throws {@code NoSuchElementException}. diff --git a/orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/features/operators/grammatical/If.feature b/orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/features/operators/grammatical/If.feature index fbe279adc..4268fb4a6 100644 --- a/orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/features/operators/grammatical/If.feature +++ b/orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/features/operators/grammatical/If.feature @@ -1,5 +1,7 @@ Feature: Values can be specified by using if, then and else constraints + # this feature is a duplicated in IfDecisionBased.feature. this one tests the reductive walker + Background: Given the generation strategy is full And the combination strategy is exhaustive diff --git a/orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/features/operators/grammatical/IfDecisionBased.feature b/orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/features/operators/grammatical/IfDecisionBased.feature index a96cd7c09..a3e1b1a4a 100644 --- a/orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/features/operators/grammatical/IfDecisionBased.feature +++ b/orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/features/operators/grammatical/IfDecisionBased.feature @@ -1,5 +1,7 @@ Feature: Values can be specified by using if, then and else constraints + # this feature is a duplicate of If.feature. except it tests the Decision Based walker instead of reductive + Background: Given the generation strategy is full And the combination strategy is exhaustive From 8e9e7ebb5b0ccc4efa977457798c6ec33a2b94f1 Mon Sep 17 00:00:00 2001 From: Paul Daulby Date: Fri, 26 Jul 2019 12:27:15 +0100 Subject: [PATCH 08/14] Run cucumber tests with decision based walker --- .../features/operators/general/InSet.feature | 59 +- .../features/operators/general/Null.feature | 3 + .../general/OfTypeFinancialCodes.feature | 21 +- .../grammatical/IfDecisionBased.feature | 3902 ----------------- .../operators/string/LongerThan.feature | 12 +- .../utils/CucumberTestState.java | 2 +- 6 files changed, 32 insertions(+), 3967 deletions(-) delete mode 100644 orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/features/operators/grammatical/IfDecisionBased.feature diff --git a/orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/features/operators/general/InSet.feature b/orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/features/operators/general/InSet.feature index f516bc375..ff7c20d51 100644 --- a/orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/features/operators/general/InSet.feature +++ b/orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/features/operators/general/InSet.feature @@ -996,24 +996,14 @@ Feature: User can specify that a field value belongs to a set of predetermined o ### Financial data types ### - Scenario: In set of valid ISINs combined with an ISIN constraint returns members of the set - Given there is a field foo - And foo is in set: - | "GB00YG2XYC52" | - And foo is of type "ISIN" - Then the following data should be generated: - | foo | - | null | - | "GB00YG2XYC52" | - Scenario: In set of things that are not valid ISINs combined with a non-ISIN constraint returns members of the set Given there is a field foo + And foo is anything but null And foo is in set: | "a" | And foo is anything but of type "ISIN" Then the following data should be generated: | foo | - | null | | "a" | Scenario: Not in set of things that are not valid ISINs combined with an ISIN constraint generates valid ISINs @@ -1038,33 +1028,22 @@ Feature: User can specify that a field value belongs to a set of predetermined o | foo | | null | - Scenario: In set of valid ISINs combined with a non-ISIN constraint only generates nulls + Scenario: In set of valid ISINs combined with a non-ISIN constraint generates no data Given there is a field foo + And foo is anything but null And foo is in set: | "GB00YG2XYC52" | And foo is anything but of type "ISIN" - Then the following data should be generated: - | foo | - | null | - - Scenario: In set of valid SEDOLs combined with a SEDOL constraint returns members of the set - Given there is a field foo - And foo is in set: - | "0263494" | - And foo is of type "SEDOL" - Then the following data should be generated: - | foo | - | null | - | "0263494" | + Then no data is created Scenario: In set of things that are not valid SEDOLs combined with a non-SEDOL constraint returns members of the set Given there is a field foo + And foo is anything but null And foo is in set: | "a" | And foo is anything but of type "SEDOL" Then the following data should be generated: | foo | - | null | | "a" | Scenario: Not in set of things that are not valid SEDOLs combined with a SEDOL constraint generates valid SEDOLs @@ -1089,33 +1068,22 @@ Feature: User can specify that a field value belongs to a set of predetermined o | foo | | null | - Scenario: In set of valid SEDOLs combined with a non-SEDOL constraint only generates null + Scenario: In set of valid SEDOLs combined with a non-SEDOL constraint generates no data Given there is a field foo + And foo is anything but null And foo is in set: | "0263494" | And foo is anything but of type "SEDOL" - Then the following data should be generated: - | foo | - | null | - - Scenario: In set of valid CUSIPs combined with a CUSIP constraint returns members of the set - Given there is a field foo - And foo is in set: - | "38259P508" | - And foo is of type "CUSIP" - Then the following data should be generated: - | foo | - | null | - | "38259P508" | + Then no data is created Scenario: In set of things that are not valid CUSIPs combined with a non-CUSIP constraint returns members of the set Given there is a field foo + And foo is anything but null And foo is in set: | "a" | And foo is anything but of type "CUSIP" Then the following data should be generated: | foo | - | null | | "a" | Scenario: Not in set of things that are not valid CUSIPs combined with a CUSIP constraint generates valid CUSIPs @@ -1140,14 +1108,13 @@ Feature: User can specify that a field value belongs to a set of predetermined o | foo | | null | - Scenario: In set of things that are valid CUSIPs combined with a non-CUSIP constraint only generates null + Scenario: In set of things that are valid CUSIPs combined with a non-CUSIP constraint generates no data Given there is a field foo + And foo is anything but null And foo is in set: | "38259P508" | And foo is anything but of type "CUSIP" - Then the following data should be generated: - | foo | - | null | + Then no data is created ### greaterThan ### @@ -2182,6 +2149,7 @@ Feature: User can specify that a field value belongs to a set of predetermined o Scenario: Running a 'inSet' request as part of a non-contradicting anyOf constraint should be successful Given there is a field foo + And foo is anything but null And there is a constraint: """ { "anyOf": [ @@ -2191,7 +2159,6 @@ Feature: User can specify that a field value belongs to a set of predetermined o """ Then the following data should be generated: | foo | - | null | | "Test 1" | | "Test 2" | | "Test 3" | diff --git a/orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/features/operators/general/Null.feature b/orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/features/operators/general/Null.feature index fd7155352..f5a39f0a5 100644 --- a/orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/features/operators/general/Null.feature +++ b/orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/features/operators/general/Null.feature @@ -238,6 +238,7 @@ Feature: User can specify that a field is null or absent Then the following data should be generated: | foo | | null | + | null | Scenario: Not null combined with a SEDOL constraint generates valid SEDOLs Given foo is anything but null @@ -261,6 +262,7 @@ Feature: User can specify that a field is null or absent Then the following data should be generated: | foo | | null | + | null | Scenario: Not null combined with a CUSIP constraint generates valid CUSIPs Given foo is anything but null @@ -284,6 +286,7 @@ Feature: User can specify that a field is null or absent Then the following data should be generated: | foo | | null | + | null | ### greaterThan ### diff --git a/orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/features/operators/general/OfTypeFinancialCodes.feature b/orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/features/operators/general/OfTypeFinancialCodes.feature index b7f5c3c54..c8ba591b5 100644 --- a/orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/features/operators/general/OfTypeFinancialCodes.feature +++ b/orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/features/operators/general/OfTypeFinancialCodes.feature @@ -71,12 +71,11 @@ Feature: User can specify that a field must be a financial code type | null | | "GB0002634946" | - Scenario: An ISIN constraint combined with a non-ISIN constraint only generates null + Scenario: An ISIN constraint combined with a non-ISIN constraint generates no data Given foo is of type "ISIN" + And foo is anything but null And foo is anything but of type "ISIN" - Then the following data should be generated: - | foo | - | null | + Then no data is created Scenario: An ISIN constraint combined with a greater than constraint generates valid ISINs Given foo is of type "ISIN" @@ -344,12 +343,11 @@ Feature: User can specify that a field must be a financial code type | null | | "0263494" | - Scenario: A SEDOL constraint combined with a non-SEDOL constraint only generates null + Scenario: A SEDOL constraint combined with a non-SEDOL constraint generates no data Given foo is of type "SEDOL" + And foo is anything but null And foo is anything but of type "SEDOL" - Then the following data should be generated: - | foo | - | null | + Then no data is created Scenario: A SEDOL constraint combined with a greater than constraint generates valid SEDOLs Given foo is of type "SEDOL" @@ -624,12 +622,11 @@ Feature: User can specify that a field must be a financial code type | null | | "38259P508" | - Scenario: A CUSIP constraint combined with a non-CUSIP constraint only generates null + Scenario: A CUSIP constraint combined with a non-CUSIP constraint generates no data Given foo is of type "CUSIP" + And foo is anything but null And foo is anything but of type "CUSIP" - Then the following data should be generated: - | foo | - | null | + Then no data is created Scenario: A CUSIP constraint combined with a greater than constraint generates valid CUSIPs Given foo is of type "CUSIP" diff --git a/orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/features/operators/grammatical/IfDecisionBased.feature b/orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/features/operators/grammatical/IfDecisionBased.feature deleted file mode 100644 index a3e1b1a4a..000000000 --- a/orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/features/operators/grammatical/IfDecisionBased.feature +++ /dev/null @@ -1,3902 +0,0 @@ -Feature: Values can be specified by using if, then and else constraints - - # this feature is a duplicate of If.feature. except it tests the Decision Based walker instead of reductive - - Background: - Given the generation strategy is full - And the combination strategy is exhaustive - And the walker type is DECISION_BASED - And the following fields exist: - | foo | - | bar | - - Scenario: Running an 'if' constraint for then condition only should be successful - Given foo is in set: - | "a" | - | "b" | - And foo is anything but null - And bar is in set: - | 10 | - | 20 | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": "a" }, - "then": { "field": "bar", "is": "equalTo", "value": 10 } - } - """ - Then the following data should be generated: - | foo | bar | - | "a" | 10 | - | "b" | 10 | - | "b" | 20 | - - Scenario: Running an 'if' constraint for then and else conditions should be successful - Given foo is in set: - | "a" | - | "b" | - And foo is anything but null - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": "a" }, - "then": { "field": "bar", "is": "equalTo", "value": 3 }, - "else": { "field": "bar", "is": "equalTo", "value": 5 } - } - """ - Then the following data should be generated: - | foo | bar | - | "a" | 3 | - | "b" | 5 | - - Scenario: Running an 'if' request that contains a valid anyOf statement should be successful - Given foo is in set: - | 1 | - | 2 | - | 3 | - | 4 | - And foo is anything but null - And bar is in set: - | "a" | - | "b" | - And bar is anything but null - And there is a constraint: - """ - { - "if": - { "anyOf": [ - { "field": "foo", "is": "equalTo", "value": 1 }, - { "field": "foo", "is": "equalTo", "value": 2 } - ]}, - "then": { "field": "bar", "is": "equalTo", "value": "a" }, - "else": { "field": "bar", "is": "equalTo", "value": "b" } - } - """ - Then the following data should be generated: - | foo | bar | - | 1 | "a" | - | 2 | "a" | - | 3 | "b" | - | 4 | "b" | - - Scenario: Running an 'if' request that contains a valid allOf statement should be successful - Given foo is in set: - | 1 | - | 2 | - | 3 | - | 4 | - And foo is anything but null - And bar is in set: - | "a" | - | "b" | - And bar is anything but null - And there is a constraint: - """ - { - "if": { - "allOf": [ - { "field": "foo", "is": "greaterThan", "value": 1 }, - { "field": "foo", "is": "lessThan", "value": 4 } - ]}, - "then": { "field": "bar", "is": "equalTo", "value": "a" }, - "else": { "field": "bar", "is": "equalTo", "value": "b" } - } - """ - Then the following data should be generated: - | foo | bar | - | 1 | "b" | - | 2 | "a" | - | 3 | "a" | - | 4 | "b" | - - Scenario: Running an 'if' request that contains a valid not statement should be successful - Given foo is in set: - | 1 | - | 2 | - | 3 | - | 4 | - And foo is anything but null - And bar is in set: - | "a" | - | "b" | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "not": { "field": "foo", "is": "equalTo", "value": 1 } }, - "then": { "field": "bar", "is": "equalTo", "value": "a" }, - "else": { "field": "bar", "is": "equalTo", "value": "b" } - } - """ - Then the following data should be generated: - | foo | bar | - | 1 | "b" | - | 2 | "a" | - | 3 | "a" | - | 4 | "a" | - - Scenario: Running an 'if' request that contains a valid nested if statement should be successful - Given foo is in set: - | 1 | - | 2 | - | 3 | - | 4 | - And foo is anything but null - And bar is in set: - | "a" | - | "b" | - | "c" | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "greaterThan", "value": 1 }, - "then": { - "if": { "field": "foo", "is": "greaterThan", "value": 3 }, - "then": { "field": "bar", "is": "equalTo", "value": "a" }, - "else": { "field": "bar", "is": "equalTo", "value": "b" } - }, - "else": { "field": "bar", "is": "equalTo", "value": "c" } - } - """ - Then the following data should be generated: - | foo | bar | - | 1 | "c" | - | 2 | "b" | - | 3 | "b" | - | 4 | "a" | - - Scenario: Running an 'if' request that is invalidly formatted (missing a then statement) should be successful - Given foo is in set: - | 1 | - | 2 | - | 3 | - | 4 | - And foo is anything but null - And bar is in set: - | "a" | - | "b" | - | "c" | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": "1" }, - "else": { "field": "bar", "is": "equalTo", "value": 10 } - } - """ - Then the profile is invalid because "Constraint is null" - And no data is created - - Scenario: Running a 'if' request that includes an invalid if value (not in field set) should be successful - Given foo is in set: - | 1 | - | 2 | - | 3 | - | 4 | - And foo is anything but null - And bar is in set: - | "a" | - | "b" | - | "c" | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": "a" }, - "then": { "field": "bar", "is": "equalTo", "value": "a" }, - "else": { "field": "bar", "is": "equalTo", "value": "b" } - } - """ - Then the following data should be generated: - | foo | bar | - | 1 | "b" | - | 2 | "b" | - | 3 | "b" | - | 4 | "b" | - - Scenario: Running a 'if' request that includes an invalid then value (not in field set) should be successful - Given foo is in set: - | 1 | - | 2 | - | 3 | - | 4 | - And foo is anything but null - And bar is in set: - | "a" | - | "b" | - | "c" | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": 1 }, - "then": { "field": "bar", "is": "equalTo", "value": "X" }, - "else": { "field": "bar", "is": "equalTo", "value": "b" } - } - """ - Then the following data should be generated: - | foo | bar | - | 2 | "b" | - | 3 | "b" | - | 4 | "b" | - - Scenario: Running a 'if' request that includes an invalid else value (not in field set) should be successful - Given foo is in set: - | 1 | - | 2 | - | 3 | - | 4 | - And foo is anything but null - And bar is in set: - | "a" | - | "b" | - | "c" | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": 1 }, - "then": { "field": "bar", "is": "equalTo", "value": "a" }, - "else": { "field": "bar", "is": "equalTo", "value": "X" } - } - """ - Then the following data should be generated: - | foo | bar | - | 1 | "a" | - - Scenario: Running an if request that contains a non contradictory inSet constraint within its if statement should be successful - Given foo is in set: - | 1 | - | 2 | - | 3 | - | 4 | - And foo is anything but null - And bar is in set: - | "a" | - | "b" | - | "c" | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "inSet", "values": [1, 2] }, - "then": { "field": "bar", "is": "equalTo", "value": "a" }, - "else": { "field": "bar", "is": "equalTo", "value": "b" } - } - """ - Then the following data should be generated: - | foo | bar | - | 1 | "a" | - | 2 | "a" | - | 3 | "b" | - | 4 | "b" | - - Scenario: Running an if request that contains a non contradictory inSet constraint within its then statement should be successful - Given foo is in set: - | 1 | - | 2 | - | 3 | - | 4 | - And foo is anything but null - And bar is in set: - | "a" | - | "b" | - | "c" | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": 1 }, - "then": { "field": "bar", "is": "inSet", "values": [ "a", "b" ] }, - "else": { "field": "bar", "is": "equalTo", "value": "c" } - } - """ - Then the following data should be generated: - | foo | bar | - | 1 | "a" | - | 1 | "b" | - | 2 | "c" | - | 3 | "c" | - | 4 | "c" | - - Scenario: Running an if request that contains a non contradictory inSet constraint within its else statement should be successful - Given foo is in set: - | 1 | - | 2 | - | 3 | - | 4 | - And foo is anything but null - And bar is in set: - | "a" | - | "b" | - | "c" | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": 1 }, - "then": { "field": "bar", "is": "equalTo", "value": "b" }, - "else": { "field": "bar", "is": "inSet", "values": [ "a", "c" ] } - } - """ - Then the following data should be generated: - | foo | bar | - | 1 | "b" | - | 2 | "a" | - | 2 | "c" | - | 3 | "a" | - | 3 | "c" | - | 4 | "a" | - | 4 | "c" | - - Scenario: Running an if request that contains a contradictory inSet constraint within its if statement should be successful - Given foo is in set: - | 1 | - | 2 | - | 3 | - | 4 | - And foo is anything but null - And bar is in set: - | "a" | - | "b" | - | "c" | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "inSet", "values": [ "X", "Y" ] }, - "then": { "field": "bar", "is": "equalTo", "value": "a" }, - "else": { "field": "bar", "is": "equalTo", "value": "b" } - } - """ - Then the following data should be generated: - | foo | bar | - | 1 | "b" | - | 2 | "b" | - | 3 | "b" | - | 4 | "b" | - - Scenario: Running an if request that contains a contradictory inSet constraint within its then statement should be successful - Given foo is in set: - | 1 | - | 2 | - | 3 | - | 4 | - And foo is anything but null - And bar is in set: - | "a" | - | "b" | - | "c" | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": 1 }, - "then": { "field": "bar", "is": "inSet", "value": [ "X", "Y" ] }, - "else": { "field": "bar", "is": "equalTo", "value": "c" } - } - """ - Then the profile is invalid because "Field \[bar\]: Couldn't recognise 'values' property, it must not contain 'null'" - And no data is created - - Scenario: Running an if request that contains a contradictory inSet constraint within its else statement should be successful - Given foo is in set: - | 1 | - | 2 | - | 3 | - | 4 | - And foo is anything but null - And bar is in set: - | "a" | - | "b" | - | "c" | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": 1 }, - "then": { "field": "bar", "is": "equalTo", "value": "a" }, - "else": { "field": "bar", "is": "inSet", "values": [ "X", "Y" ] } - } - """ - Then the following data should be generated: - | foo | bar | - | 1 | "a" | - - Scenario: Running an if request that contains a non contradictory null constraint within its if statement should be successful - Given foo is in set: - | 2 | - | 3 | - | 4 | - And bar is in set: - | "b" | - | "c" | - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "null" }, - "then": { "field": "bar", "is": "equalTo", "value": "b" }, - "else": { "field": "bar", "is": "equalTo", "value": "c" } - } - """ - Then the following data should be generated: - | foo | bar | - | null | "b" | - | 2 | "c" | - | 3 | "c" | - | 4 | "c" | - - Scenario: Running an if request that contains a non contradictory null constraint within its then statement should be successful - Given foo is in set: - | 2 | - | 3 | - | 4 | - And bar is in set: - | "b" | - | "c" | - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": 2 }, - "then": { "field": "bar", "is": "null" }, - "else": { "field": "bar", "is": "equalTo", "value": "c" } - } - """ - Then the following data should be generated: - | foo | bar | - | null | "c" | - | 2 | null | - | 3 | "c" | - | 4 | "c" | - - Scenario: Running an if request that contains a non contradictory null constraint within its else statement should be successful - Given foo is in set: - | 2 | - | 3 | - | 4 | - And bar is in set: - | "b" | - | "c" | - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": 2 }, - "then": { "field": "bar", "is": "equalTo", "value": "b" }, - "else": { "field": "bar", "is": "null" } - } - """ - Then the following data should be generated: - | foo | bar | - | null | null | - | 2 | "b" | - | 3 | null | - | 4 | null | - - Scenario: Running an if request that contains a contradictory null constraint within its if statement should be successful - Given foo is in set: - | 1 | - | 2 | - | 3 | - | 4 | - And foo is anything but null - And bar is in set: - | "a" | - | "b" | - | "c" | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "null" }, - "then": { "field": "bar", "is": "equalTo", "value": "a" }, - "else": { "field": "bar", "is": "equalTo", "value": "b" } - } - """ - Then the following data should be generated: - | foo | bar | - | 1 | "b" | - | 2 | "b" | - | 3 | "b" | - | 4 | "b" | - - Scenario: Running an if request that contains a contradictory null constraint within its then statement should be successful - Given foo is in set: - | 1 | - | 2 | - | 3 | - | 4 | - And foo is anything but null - And bar is in set: - | "a" | - | "b" | - | "c" | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": 1}, - "then": { "field": "bar", "is": "null" }, - "else": { "field": "bar", "is": "equalTo", "value": "a" } - } - """ - Then the following data should be generated: - | foo | bar | - | 2 | "a" | - | 3 | "a" | - | 4 | "a" | - - Scenario: Running an if request that contains a contradictory null constraint within its else statement should be successful - Given foo is in set: - | 1 | - | 2 | - | 3 | - | 4 | - And foo is anything but null - And bar is in set: - | "a" | - | "b" | - | "c" | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": 1}, - "then": { "field": "bar", "is": "equalTo", "value": "a" }, - "else": { "field": "bar", "is": "null" } - } - """ - Then the following data should be generated: - | foo | bar | - | 1 | "a" | - - Scenario: Running an if request that contains a non contradictory ofType constraint within its if statement should be successful - Given foo is in set: - | 1 | - | 2 | - | "a" | - | "b" | - And foo is anything but null - And bar is in set: - | 10 | - | 20 | - | "AA" | - | "BB" | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "ofType", "value": "string" }, - "then": { "field": "bar", "is": "equalTo", "value": "AA" }, - "else": { "field": "bar", "is": "equalTo", "value": 10 } - } - """ - Then the following data should be generated: - | foo | bar | - | 1 | 10 | - | 2 | 10 | - | "a" | "AA" | - | "b" | "AA" | - - Scenario: Running an if request that contains a non contradictory ofType constraint within its then statement should be successful - Given foo is in set: - | 1 | - | 2 | - | "a" | - | "b" | - And foo is anything but null - And bar is in set: - | 10 | - | 20 | - | "AA" | - | "BB" | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": "a" }, - "then": { "field": "bar", "is": "ofType", "value": "string" }, - "else": { "field": "bar", "is": "equalTo", "value": 10 } - } - """ - Then the following data should be generated: - | foo | bar | - | 1 | 10 | - | 2 | 10 | - | "a" | "AA" | - | "a" | "BB" | - | "b" | 10 | - - Scenario: Running an if request that contains a non contradictory ofType constraint within its else statement should be successful - Given foo is in set: - | 1 | - | 2 | - | "a" | - | "b" | - And foo is anything but null - And bar is in set: - | 10 | - | 20 | - | "AA" | - | "BB" | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": "a" }, - "then": { "field": "bar", "is": "equalTo", "value": "AA" }, - "else": { "field": "bar", "is": "ofType", "value": "integer" } - } - """ - Then the following data should be generated: - | foo | bar | - | 1 | 10 | - | 1 | 20 | - | 2 | 10 | - | 2 | 20 | - | "a" | "AA" | - | "b" | 10 | - | "b" | 20 | - - Scenario: Running an if request that contains a contradictory ofType constraint within its if statement should be successful - Given foo is in set: - | 1 | - | 2 | - | 3 | - | 4 | - And foo is anything but null - And bar is in set: - | "a" | - | "b" | - | "c" | - | "d" | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "ofType", "value": "string" }, - "then": { "field": "bar", "is": "equalTo", "value": "a" }, - "else": { "field": "bar", "is": "equalTo", "value": "c" } - } - """ - Then the following data should be generated: - | foo | bar | - | 1 | "c" | - | 2 | "c" | - | 3 | "c" | - | 4 | "c" | - - Scenario: Running an if request that contains a contradictory ofType constraint within its then statement should be successful - Given foo is in set: - | 1 | - | 2 | - | 3 | - | 4 | - And foo is anything but null - And bar is in set: - | "a" | - | "b" | - | "c" | - | "d" | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": 1 }, - "then": { "field": "bar", "is": "ofType", "value": "integer" }, - "else": { "field": "bar", "is": "equalTo", "value": "c" } - } - """ - Then the following data should be generated: - | foo | bar | - | 2 | "c" | - | 3 | "c" | - | 4 | "c" | - - Scenario: Running an if request that contains a contradictory ofType constraint within its else statement should be successful - Given foo is in set: - | 1 | - | 2 | - | 3 | - | 4 | - And foo is anything but null - And bar is in set: - | "a" | - | "b" | - | "c" | - | "d" | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": 1 }, - "then": { "field": "bar", "is": "equalTo", "value": "a" }, - "else": { "field": "bar", "is": "ofType", "value": "integer" } - } - """ - Then the following data should be generated: - | foo | bar | - | 1 | "a" | - - Scenario: Running an if request that contains a non contradictory matchingRegex constraint within its if statement should be successful - Given foo is in set: - | "1" | - | "2" | - | "a" | - | "b" | - And foo is anything but null - And bar is in set: - | "10" | - | "20" | - | "AA" | - | "BB" | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "matchingRegex", "value": "[a-z]{1}" }, - "then": { "field": "bar", "is": "equalTo", "value": "AA" }, - "else": { "field": "bar", "is": "equalTo", "value": "10" } - } - """ - Then the following data should be generated: - | foo | bar | - | "1" | "10" | - | "2" | "10" | - | "a" | "AA" | - | "b" | "AA" | - - Scenario: Running an if request that contains a non contradictory matchingRegex constraint within its then statement should be successful - Given foo is in set: - | "1" | - | "2" | - | "a" | - | "b" | - And foo is anything but null - And bar is in set: - | "10" | - | "20" | - | "AA" | - | "BB" | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": "1" }, - "then": { "field": "bar", "is": "matchingRegex", "value": "[A-Z]{2}" }, - "else": { "field": "bar", "is": "equalTo", "value": "10" } - } - """ - Then the following data should be generated: - | foo | bar | - | "1" | "AA" | - | "1" | "BB" | - | "2" | "10" | - | "a" | "10" | - | "b" | "10" | - - Scenario: Running an if request that contains a non contradictory matchingRegex constraint within its else statement should be successful - Given foo is in set: - | "1" | - | "2" | - | "a" | - | "b" | - And foo is anything but null - And bar is in set: - | "10" | - | "20" | - | "AA" | - | "BB" | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": "1" }, - "then": { "field": "bar", "is": "equalTo", "value": "AA" }, - "else": { "field": "bar", "is": "matchingRegex", "value": "[0-9]{2}" } - } - """ - Then the following data should be generated: - | foo | bar | - | "1" | "AA" | - | "2" | "10" | - | "2" | "20" | - | "a" | "10" | - | "a" | "20" | - | "b" | "10" | - | "b" | "20" | - - Scenario: Running an if request that contains a contradictory matchingRegex constraint within its if statement should be successful - Given foo is in set: - | "1" | - | "2" | - | "a" | - | "b" | - And foo is anything but null - And bar is in set: - | "10" | - | "20" | - | "AA" | - | "BB" | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "matchingRegex", "value": "[0-9]{10}" }, - "then": { "field": "bar", "is": "equalTo", "value": "AA" }, - "else": { "field": "bar", "is": "equalTo", "value": "10" } - } - """ - Then the following data should be generated: - | foo | bar | - | "1" | "10" | - | "2" | "10" | - | "a" | "10" | - | "b" | "10" | - - Scenario: Running an if request that contains a contradictory matchingRegex constraint within its then statement should be successful - Given foo is in set: - | "1" | - | "2" | - | "a" | - | "b" | - And foo is anything but null - And bar is in set: - | "10" | - | "20" | - | "AA" | - | "BB" | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": "a" }, - "then": { "field": "bar", "is": "matchingRegex", "value": "[😁-😡]{1}"}, - "else": { "field": "bar", "is": "equalTo", "value": "10" } - } - """ - Then the following data should be generated: - | foo | bar | - | "1" | "10" | - | "2" | "10" | - | "b" | "10" | - - Scenario: Running an if request that contains a contradictory matchingRegex constraint within its else statement should be successful - Given foo is in set: - | "1" | - | "2" | - | "a" | - | "b" | - And foo is anything but null - And bar is in set: - | "10" | - | "20" | - | "AA" | - | "BB" | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": "a" }, - "then": { "field": "bar", "is": "equalTo", "value": "BB"}, - "else": { "field": "bar", "is": "matchingRegex", "value": "[😁-😡]{1}"} - } - """ - Then the following data should be generated: - | foo | bar | - | "a" | "BB" | - - Scenario: Running an if request that contains a non contradictory containingRegex constraint within its if statement should be successful - Given foo is in set: - | "1" | - | "2" | - | "a1" | - | "b2" | - And foo is anything but null - And bar is in set: - | "10" | - | "20" | - | "AA" | - | "BB" | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "containingRegex", "value": "[1]{1}" }, - "then": { "field": "bar", "is": "equalTo", "value": "AA" }, - "else": { "field": "bar", "is": "equalTo", "value": "10" } - } - """ - Then the following data should be generated: - | foo | bar | - | "1" | "AA" | - | "2" | "10" | - | "a1" | "AA" | - | "b2" | "10" | - - Scenario: Running an if request that contains a non contradictory containingRegex constraint within its then statement should be successful - Given foo is in set: - | "1" | - | "2" | - | "a1" | - | "b2" | - And foo is anything but null - And bar is in set: - | "10" | - | "20" | - | "AA" | - | "BB" | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": "1" }, - "then": { "field": "bar", "is": "containingRegex", "value": "[0]{1}" }, - "else": { "field": "bar", "is": "equalTo", "value": "AA" } - } - """ - Then the following data should be generated: - | foo | bar | - | "1" | "10" | - | "1" | "20" | - | "2" | "AA" | - | "a1" | "AA" | - | "b2" | "AA" | - - Scenario: Running an if request that contains a non contradictory containingRegex constraint within its else statement should be successful - Given foo is in set: - | "1" | - | "2" | - | "a1" | - | "b2" | - And foo is anything but null - And bar is in set: - | "10" | - | "20" | - | "AA" | - | "BB" | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": "1" }, - "then": { "field": "bar", "is": "equalTo", "value": "BB" }, - "else": { "field": "bar", "is": "containingRegex", "value": "[0]{1}" } - } - """ - Then the following data should be generated: - | foo | bar | - | "1" | "BB" | - | "2" | "10" | - | "2" | "20" | - | "a1" | "10" | - | "a1" | "20" | - | "b2" | "10" | - | "b2" | "20" | - - Scenario: Running an if request that contains a contradictory containingRegex constraint within its if statement should be successful - Given foo is in set: - | "1" | - | "2" | - | "a1" | - | "b2" | - And foo is anything but null - And bar is in set: - | "10" | - | "20" | - | "AA" | - | "BB" | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "containingRegex", "value": "[🚫]{1}" }, - "then": { "field": "bar", "is": "equalTo", "value": "AA" }, - "else": { "field": "bar", "is": "equalTo", "value": "10" } - } - """ - Then the following data should be generated: - | foo | bar | - | "1" | "10" | - | "2" | "10" | - | "a1" | "10" | - | "b2" | "10" | - - Scenario: Running an if request that contains a contradictory containingRegex constraint within its then statement should be successful - Given foo is in set: - | "1" | - | "2" | - | "a1" | - | "b2" | - And foo is anything but null - And bar is in set: - | "10" | - | "20" | - | "AA" | - | "BB" | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": "1" }, - "then": { "field": "bar", "is": "containingRegex", "value": "[🚫]{1}" }, - "else": { "field": "bar", "is": "equalTo", "value": "10" } - } - """ - Then the following data should be generated: - | foo | bar | - | "2" | "10" | - | "a1" | "10" | - | "b2" | "10" | - - Scenario: Running an if request that contains a contradictory containingRegex constraint within its then statement should be successful - Given foo is in set: - | "1" | - | "2" | - | "a1" | - | "b2" | - And foo is anything but null - And bar is in set: - | "10" | - | "20" | - | "AA" | - | "BB" | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": "1" }, - "then": { "field": "bar", "is": "equalTo", "value": "10" }, - "else": { "field": "bar", "is": "containingRegex", "value": "[🚫]{1}" } - } - """ - Then the following data should be generated: - | foo | bar | - | "1" | "10" | - - Scenario: Running an if request that contains a non contradictory ofLength constraint within its if statement should be successful - Given foo is in set: - | "a" | - | "bb" | - | "ccc" | - | "dddd" | - And foo is anything but null - And bar is in set: - | "1" | - | "22" | - | "333" | - | "4444" | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "ofLength", "value": 2 }, - "then": { "field": "bar", "is": "equalTo", "value": "1" }, - "else": { "field": "bar", "is": "equalTo", "value": "4444" } - } - """ - Then the following data should be generated: - | foo | bar | - | "a" | "4444" | - | "bb" | "1" | - | "ccc" | "4444" | - | "dddd" | "4444" | - - Scenario: Running an if request that contains a non contradictory ofLength constraint within its then statement should be successful - Given foo is in set: - | "a" | - | "bb" | - | "ccc" | - | "dddd" | - And foo is anything but null - And bar is in set: - | "1" | - | "22" | - | "333" | - | "4444" | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": "bb" }, - "then": { "field": "bar", "is": "ofLength", "value": 3 }, - "else": { "field": "bar", "is": "equalTo", "value": "1" } - } - """ - Then the following data should be generated: - | foo | bar | - | "a" | "1" | - | "bb" | "333" | - | "ccc" | "1" | - | "dddd" | "1" | - - Scenario: Running an if request that contains a non contradictory ofLength constraint within its else statement should be successful - Given foo is in set: - | "a" | - | "bb" | - | "ccc" | - | "dddd" | - And foo is anything but null - And bar is in set: - | "1" | - | "22" | - | "333" | - | "4444" | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": "a" }, - "then": { "field": "bar", "is": "equalTo", "value": "1" }, - "else": { "field": "bar", "is": "ofLength", "value": 4 } - } - """ - Then the following data should be generated: - | foo | bar | - | "a" | "1" | - | "bb" | "4444" | - | "ccc" | "4444" | - | "dddd" | "4444" | - - Scenario: Running an if request that contains a contradictory ofLength constraint within its if statement should be successful - Given foo is in set: - | "a" | - | "bb" | - | "ccc" | - | "dddd" | - And foo is anything but null - And bar is in set: - | "1" | - | "22" | - | "333" | - | "4444" | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "ofLength", "value": 7 }, - "then": { "field": "bar", "is": "equalTo", "value": "1" }, - "else": { "field": "bar", "is": "equalTo", "value": "4444" } - } - """ - Then the following data should be generated: - | foo | bar | - | "a" | "4444" | - | "bb" | "4444" | - | "ccc" | "4444" | - | "dddd" | "4444" | - - Scenario: Running an if request that contains a contradictory ofLength constraint within its then statement should be successful - Given foo is in set: - | "a" | - | "bb" | - | "ccc" | - | "dddd" | - And foo is anything but null - And bar is in set: - | "1" | - | "22" | - | "333" | - | "4444" | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": "a" }, - "then": { "field": "bar", "is": "ofLength", "value": 10 }, - "else": { "field": "bar", "is": "equalTo", "value": "4444" } - } - """ - Then the following data should be generated: - | foo | bar | - | "bb" | "4444" | - | "ccc" | "4444" | - | "dddd" | "4444" | - - Scenario: Running an if request that contains a contradictory ofLength constraint within its else statement should be successful - Given foo is in set: - | "a" | - | "bb" | - | "ccc" | - | "dddd" | - And foo is anything but null - And bar is in set: - | "1" | - | "22" | - | "333" | - | "4444" | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": "a" }, - "then": { "field": "bar", "is": "equalTo", "value": "1" }, - "else": { "field": "bar", "is": "ofLength", "value": 10 } - } - """ - Then the following data should be generated: - | foo | bar | - | "a" | "1" | - - Scenario: Running an if request that contains a non contradictory longerThan constraint within its if statement should be successful - Given foo is in set: - | "a" | - | "bb" | - | "ccc" | - | "dddd" | - And foo is anything but null - And bar is in set: - | "1" | - | "22" | - | "333" | - | "4444" | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "longerThan", "value": 2 }, - "then": { "field": "bar", "is": "equalTo", "value": "1" }, - "else": { "field": "bar", "is": "equalTo", "value": "4444" } - } - """ - Then the following data should be generated: - | foo | bar | - | "a" | "4444" | - | "bb" | "4444" | - | "ccc" | "1" | - | "dddd" | "1" | - - Scenario: Running an if request that contains a non contradictory longerThan constraint within its then statement should be successful - Given foo is in set: - | "a" | - | "bb" | - | "ccc" | - | "dddd" | - And foo is anything but null - And bar is in set: - | "1" | - | "22" | - | "333" | - | "4444" | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": "bb" }, - "then": { "field": "bar", "is": "longerThan", "value": 2 }, - "else": { "field": "bar", "is": "equalTo", "value": "1" } - } - """ - Then the following data should be generated: - | foo | bar | - | "a" | "1" | - | "bb" | "333" | - | "bb" | "4444" | - | "ccc" | "1" | - | "dddd" | "1" | - - Scenario: Running an if request that contains a non contradictory longerThan constraint within its else statement should be successful - Given foo is in set: - | "a" | - | "bb" | - | "ccc" | - | "dddd" | - And foo is anything but null - And bar is in set: - | "1" | - | "22" | - | "333" | - | "4444" | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": "dddd" }, - "then": { "field": "bar", "is": "equalTo", "value": "1" }, - "else": { "field": "bar", "is": "longerThan", "value": 2 } - } - """ - Then the following data should be generated: - | foo | bar | - | "a" | "333" | - | "a" | "4444" | - | "bb" | "333" | - | "bb" | "4444" | - | "ccc" | "333" | - | "ccc" | "4444" | - | "dddd" | "1" | - - Scenario: Running an if request that contains a contradictory longerThan constraint within its if statement should be successful - Given foo is in set: - | "a" | - | "bb" | - | "ccc" | - | "dddd" | - And foo is anything but null - And bar is in set: - | "1" | - | "22" | - | "333" | - | "4444" | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "longerThan", "value": 25 }, - "then": { "field": "bar", "is": "equalTo", "value": "1" }, - "else": { "field": "bar", "is": "equalTo", "value": "4444" } - } - """ - Then the following data should be generated: - | foo | bar | - | "a" | "4444" | - | "bb" | "4444" | - | "ccc" | "4444" | - | "dddd" | "4444" | - - Scenario: Running an if request that contains a contradictory longerThan constraint within its then statement should be successful - Given foo is in set: - | "a" | - | "bb" | - | "ccc" | - | "dddd" | - And foo is anything but null - And bar is in set: - | "1" | - | "22" | - | "333" | - | "4444" | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": "a" }, - "then": { "field": "bar", "is": "longerThan", "value": 100 }, - "else": { "field": "bar", "is": "equalTo", "value": "4444" } - } - """ - Then the following data should be generated: - | foo | bar | - | "bb" | "4444" | - | "ccc" | "4444" | - | "dddd" | "4444" | - - Scenario: Running an if request that contains a contradictory longerThan constraint within its else statement should be successful - Given foo is in set: - | "a" | - | "bb" | - | "ccc" | - | "dddd" | - And foo is anything but null - And bar is in set: - | "1" | - | "22" | - | "333" | - | "4444" | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": "a" }, - "then": { "field": "bar", "is": "equalTo", "value": "1" }, - "else": { "field": "bar", "is": "longerThan", "value": 100 } - } - """ - Then the following data should be generated: - | foo | bar | - | "a" | "1" | - - Scenario: Running an if request that contains a non contradictory shorterThan constraint within its if statement should be successful - Given foo is in set: - | "a" | - | "bb" | - | "ccc" | - | "dddd" | - And foo is anything but null - And bar is in set: - | "1" | - | "22" | - | "333" | - | "4444" | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "shorterThan", "value": 3 }, - "then": { "field": "bar", "is": "equalTo", "value": "1" }, - "else": { "field": "bar", "is": "equalTo", "value": "4444" } - } - """ - Then the following data should be generated: - | foo | bar | - | "a" | "1" | - | "bb" | "1" | - | "ccc" | "4444" | - | "dddd" | "4444" | - - Scenario: Running an if request that contains a non contradictory shorterThan constraint within its then statement should be successful - Given foo is in set: - | "a" | - | "bb" | - | "ccc" | - | "dddd" | - And foo is anything but null - And bar is in set: - | "1" | - | "22" | - | "333" | - | "4444" | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": "ccc" }, - "then": { "field": "bar", "is": "shorterThan", "value": 3 }, - "else": { "field": "bar", "is": "equalTo", "value": "333" } - } - """ - Then the following data should be generated: - | foo | bar | - | "a" | "333" | - | "bb" | "333" | - | "ccc" | "1" | - | "ccc" | "22" | - | "dddd" | "333" | - - Scenario: Running an if request that contains a non contradictory shorterThan constraint within its else statement should be successful - Given foo is in set: - | "a" | - | "bb" | - | "ccc" | - | "dddd" | - And foo is anything but null - And bar is in set: - | "1" | - | "22" | - | "333" | - | "4444" | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": "dddd" }, - "then": { "field": "bar", "is": "equalTo", "value": "4444" }, - "else": { "field": "bar", "is": "shorterThan", "value": 4 } - } - """ - Then the following data should be generated: - | foo | bar | - | "a" | "1" | - | "a" | "22" | - | "a" | "333" | - | "bb" | "1" | - | "bb" | "22" | - | "bb" | "333" | - | "ccc" | "1" | - | "ccc" | "22" | - | "ccc" | "333" | - | "dddd" | "4444" | - - Scenario: Running an if request that contains a contradictory shorterThan constraint within its if statement should be successful - Given foo is in set: - | "a" | - | "bb" | - | "ccc" | - | "dddd" | - And foo is anything but null - And bar is in set: - | "1" | - | "22" | - | "333" | - | "4444" | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "shorterThan", "value": 1 }, - "then": { "field": "bar", "is": "equalTo", "value": "1" }, - "else": { "field": "bar", "is": "equalTo", "value": "4444" } - } - """ - Then the following data should be generated: - | foo | bar | - | "a" | "4444" | - | "bb" | "4444" | - | "ccc" | "4444" | - | "dddd" | "4444" | - - Scenario: Running an if request that contains a contradictory shorterThan constraint within its then statement should be successful - Given foo is in set: - | "a" | - | "bb" | - | "ccc" | - | "dddd" | - And foo is anything but null - And bar is in set: - | "1" | - | "22" | - | "333" | - | "4444" | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": "dddd" }, - "then": { "field": "bar", "is": "shorterThan", "value": 1 }, - "else": { "field": "bar", "is": "equalTo", "value": "4444" } - } - """ - Then the following data should be generated: - | foo | bar | - | "a" | "4444" | - | "bb" | "4444" | - | "ccc" | "4444" | - - Scenario: Running an if request that contains a contradictory shorterThan constraint within its else statement should be successful - Given foo is in set: - | "a" | - | "bb" | - | "ccc" | - | "dddd" | - And foo is anything but null - And bar is in set: - | "1" | - | "22" | - | "333" | - | "4444" | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": "dddd" }, - "then": { "field": "bar", "is": "equalTo", "value": "4444" }, - "else": { "field": "bar", "is": "shorterThan", "value": 1 } - } - """ - Then the following data should be generated: - | foo | bar | - | "dddd" | "4444" | - - Scenario: An if constraint that contains an ISIN constraint in the if clause generates the expected output - Given foo is in set: - | "GB0002634946" | - | "bb" | - | "ccc" | - | "dddd" | - And foo is anything but null - And bar is in set: - | "GB0002634946" | - | "22" | - | "333" | - | "4444" | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "ofType", "value": "ISIN" }, - "then": { "field": "bar", "is": "equalTo", "value": "22" }, - "else": { "field": "bar", "is": "equalTo", "value": "4444" } - } - """ - Then the following data should be generated: - | foo | bar | - | "GB0002634946" | "22" | - | "bb" | "4444" | - | "ccc" | "4444" | - | "dddd" | "4444" | - - Scenario: An if constraint that contains an ISIN constraint in the then clause generates valid ISINs when the if clause applies - Given foo is in set: - | "GB0002634946" | - | "bb" | - | "ccc" | - | "dddd" | - And foo is anything but null - And bar is in set: - | "GB0002634946" | - | "22" | - | "333" | - | "4444" | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": "bb" }, - "then": { "field": "bar", "is": "ofType", "value": "ISIN" }, - "else": { "field": "bar", "is": "equalTo", "value": "333" } - } - """ - Then the following data should be generated: - | foo | bar | - | "GB0002634946" | "333" | - | "bb" | "GB0002634946" | - | "ccc" | "333" | - | "dddd" | "333" | - - Scenario: An if constraint that contains an ISIN constraint in the else clause generates valid ISINs when the if clause does not apply - Given foo is in set: - | "GB0002634946" | - | "bb" | - | "ccc" | - | "dddd" | - And foo is anything but null - And bar is in set: - | "GB0002634946" | - | "22" | - | "333" | - | "4444" | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": "bb" }, - "then": { "field": "bar", "is": "equalTo", "value": "22" }, - "else": { "field": "bar", "is": "ofType", "value": "ISIN" } - } - """ - Then the following data should be generated: - | foo | bar | - | "GB0002634946" | "GB0002634946" | - | "bb" | "22" | - | "ccc" | "GB0002634946" | - | "dddd" | "GB0002634946" | - - Scenario: An if constraint that contains an ISIN constraint in the if clause and is combined with an in set constraint that does not contain any valid ISINs only generates data that matches the else clause - Given foo is in set: - | "aa" | - | "bb" | - | "ccc" | - | "dddd" | - And foo is anything but null - And bar is in set: - | "11" | - | "22" | - | "333" | - | "4444" | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "ofType", "value": "ISIN" }, - "then": { "field": "bar", "is": "equalTo", "value": "22" }, - "else": { "field": "bar", "is": "equalTo", "value": "333" } - } - """ - Then the following data should be generated: - | foo | bar | - | "aa" | "333" | - | "bb" | "333" | - | "ccc" | "333" | - | "dddd" | "333" | - - - Scenario: An if constraint that contains an ISIN constraint in the then clause combined with an in set constraint that does not contain any valid ISINs only generates data that matches the else clause - Given foo is in set: - | "aa" | - | "bb" | - | "ccc" | - | "dddd" | - And foo is anything but null - And bar is in set: - | "11" | - | "22" | - | "333" | - | "4444" | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": "ccc" }, - "then": { "field": "bar", "is": "ofType", "value": "ISIN" }, - "else": { "field": "bar", "is": "equalTo", "value": "333" } - } - """ - Then the following data should be generated: - | foo | bar | - | "aa" | "333" | - | "bb" | "333" | - | "dddd" | "333" | - - Scenario: An if constraint with an else clause containing an ISIN constraint which contradicts an in set constraint generates data that only matches the then clause - Given foo is in set: - | "aa" | - | "bb" | - | "ccc" | - | "dddd" | - And foo is anything but null - And bar is in set: - | "11" | - | "22" | - | "333" | - | "4444" | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": "ccc" }, - "then": { "field": "bar", "is": "equalTo", "value": "333" }, - "else": { "field": "bar", "is": "ofType", "value": "ISIN" } - } - """ - Then the following data should be generated: - | foo | bar | - | "ccc" | "333" | - - Scenario: Running an if request that contains a non contradictory greaterThan constraint within its if statement should be successful - Given foo is in set: - | 10 | - | 20 | - | 30 | - | 40 | - And foo is anything but null - And bar is in set: - | 1 | - | 22 | - | 333 | - | 4444 | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "greaterThan", "value": 29 }, - "then": { "field": "bar", "is": "equalTo", "value": 22 }, - "else": { "field": "bar", "is": "equalTo", "value": 1 } - } - """ - Then the following data should be generated: - | foo | bar | - | 10 | 1 | - | 20 | 1 | - | 30 | 22 | - | 40 | 22 | - - Scenario: Running an if request that contains a non contradictory greaterThan constraint within its then statement should be successful - Given foo is in set: - | 10 | - | 20 | - | 30 | - | 40 | - And foo is anything but null - And bar is in set: - | 1 | - | 22 | - | 333 | - | 4444 | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": 40 }, - "then": { "field": "bar", "is": "greaterThan", "value": 20 }, - "else": { "field": "bar", "is": "equalTo", "value": 1 } - } - """ - Then the following data should be generated: - | foo | bar | - | 10 | 1 | - | 20 | 1 | - | 30 | 1 | - | 40 | 22 | - | 40 | 333 | - | 40 | 4444 | - - Scenario: Running an if request that contains a non contradictory greaterThan constraint within its else statement should be successful - Given foo is in set: - | 10 | - | 20 | - | 30 | - | 40 | - And foo is anything but null - And bar is in set: - | 1 | - | 22 | - | 333 | - | 4444 | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": 40 }, - "then": { "field": "bar", "is": "equalTo", "value": 1 }, - "else": { "field": "bar", "is": "greaterThan", "value": 300 } - } - """ - Then the following data should be generated: - | foo | bar | - | 10 | 333 | - | 10 | 4444 | - | 20 | 333 | - | 20 | 4444 | - | 30 | 333 | - | 30 | 4444 | - | 40 | 1 | - - Scenario: Running an if request that contains a contradictory greaterThan constraint within its if statement should be successful - Given foo is in set: - | 10 | - | 20 | - | 30 | - | 40 | - And foo is anything but null - And bar is in set: - | 1 | - | 22 | - | 333 | - | 4444 | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "greaterThan", "value": 8000 }, - "then": { "field": "bar", "is": "equalTo", "value": 22 }, - "else": { "field": "bar", "is": "equalTo", "value": 1 } - } - """ - Then the following data should be generated: - | foo | bar | - | 10 | 1 | - | 20 | 1 | - | 30 | 1 | - | 40 | 1 | - - Scenario: Running an if request that contains a contradictory greaterThan constraint within its then statement should be successful - Given foo is in set: - | 10 | - | 20 | - | 30 | - | 40 | - And foo is anything but null - And bar is in set: - | 1 | - | 22 | - | 333 | - | 4444 | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": 40 }, - "then": { "field": "bar", "is": "greaterThan", "value": 8000 }, - "else": { "field": "bar", "is": "equalTo", "value": 1 } - } - """ - Then the following data should be generated: - | foo | bar | - | 10 | 1 | - | 20 | 1 | - | 30 | 1 | - - Scenario: Running an if request that contains a contradictory greaterThan constraint within its else statement should be successful - Given foo is in set: - | 10 | - | 20 | - | 30 | - | 40 | - And foo is anything but null - And bar is in set: - | 1 | - | 22 | - | 333 | - | 4444 | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": 40 }, - "then": { "field": "bar", "is": "equalTo", "value": 1 }, - "else": { "field": "bar", "is": "greaterThan", "value": 8000 } - } - """ - Then the following data should be generated: - | foo | bar | - | 40 | 1 | - - Scenario: Running an if request that contains a non contradictory greaterThanOrEqualTo constraint within its if statement should be successful - Given foo is in set: - | 10 | - | 20 | - | 30 | - | 40 | - And foo is anything but null - And bar is in set: - | 1 | - | 22 | - | 333 | - | 4444 | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "greaterThanOrEqualTo", "value": 20 }, - "then": { "field": "bar", "is": "equalTo", "value": 22 }, - "else": { "field": "bar", "is": "equalTo", "value": 1 } - } - """ - Then the following data should be generated: - | foo | bar | - | 10 | 1 | - | 20 | 22 | - | 30 | 22 | - | 40 | 22 | - - Scenario: Running an if request that contains a non contradictory greaterThanOrEqualTo constraint within its then statement should be successful - Given foo is in set: - | 10 | - | 20 | - | 30 | - | 40 | - And foo is anything but null - And bar is in set: - | 1 | - | 22 | - | 333 | - | 4444 | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": 20 }, - "then": { "field": "bar", "is": "greaterThanOrEqualTo", "value": 22 }, - "else": { "field": "bar", "is": "equalTo", "value": 1 } - } - """ - Then the following data should be generated: - | foo | bar | - | 10 | 1 | - | 20 | 22 | - | 20 | 333 | - | 20 | 4444 | - | 30 | 1 | - | 40 | 1 | - - Scenario: Running an if request that contains a non contradictory greaterThanOrEqualTo constraint within its else statement should be successful - Given foo is in set: - | 10 | - | 20 | - | 30 | - | 40 | - And foo is anything but null - And bar is in set: - | 1 | - | 22 | - | 333 | - | 4444 | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": 20 }, - "then": { "field": "bar", "is": "equalTo", "value": 1 }, - "else": { "field": "bar", "is": "greaterThanOrEqualTo", "value": 22 } - } - """ - Then the following data should be generated: - | foo | bar | - | 10 | 22 | - | 10 | 333 | - | 10 | 4444 | - | 20 | 1 | - | 30 | 22 | - | 30 | 333 | - | 30 | 4444 | - | 40 | 22 | - | 40 | 333 | - | 40 | 4444 | - - Scenario: Running an if request that contains a contradictory greaterThanOrEqualTo constraint within its if statement should be successful - Given foo is in set: - | 10 | - | 20 | - | 30 | - | 40 | - And foo is anything but null - And bar is in set: - | 1 | - | 22 | - | 333 | - | 4444 | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "greaterThanOrEqualTo", "value": 8000 }, - "then": { "field": "bar", "is": "equalTo", "value": 22 }, - "else": { "field": "bar", "is": "equalTo", "value": 1 } - } - """ - Then the following data should be generated: - | foo | bar | - | 10 | 1 | - | 20 | 1 | - | 30 | 1 | - | 40 | 1 | - - Scenario: Running an if request that contains a contradictory greaterThanOrEqualTo constraint within its then statement should be successful - Given foo is in set: - | 10 | - | 20 | - | 30 | - | 40 | - And foo is anything but null - And bar is in set: - | 1 | - | 22 | - | 333 | - | 4444 | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": 10 }, - "then": { "field": "bar", "is": "greaterThanOrEqualTo", "value": 8000 }, - "else": { "field": "bar", "is": "equalTo", "value": 333 } - } - """ - Then the following data should be generated: - | foo | bar | - | 20 | 333 | - | 30 | 333 | - | 40 | 333 | - - Scenario: Running an if request that contains a contradictory greaterThanOrEqualTo constraint within its else statement should be successful - Given foo is in set: - | 10 | - | 20 | - | 30 | - | 40 | - And foo is anything but null - And bar is in set: - | 1 | - | 22 | - | 333 | - | 4444 | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": 10 }, - "then": { "field": "bar", "is": "equalTo", "value": 4444 }, - "else": { "field": "bar", "is": "greaterThanOrEqualTo", "value": 8000 } - } - """ - Then the following data should be generated: - | foo | bar | - | 10 | 4444 | - - Scenario: Running an if request that contains a non contradictory lessThan constraint within its if statement should be successful - Given foo is in set: - | 10 | - | 20 | - | 30 | - | 40 | - And foo is anything but null - And bar is in set: - | 1 | - | 22 | - | 333 | - | 4444 | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "lessThan", "value": 20 }, - "then": { "field": "bar", "is": "equalTo", "value": 4444 }, - "else": { "field": "bar", "is": "equalTo", "value": 1 } - } - """ - Then the following data should be generated: - | foo | bar | - | 10 | 4444 | - | 20 | 1 | - | 30 | 1 | - | 40 | 1 | - - Scenario: Running an if request that contains a non contradictory lessThan constraint within its then statement should be successful - Given foo is in set: - | 10 | - | 20 | - | 30 | - | 40 | - And foo is anything but null - And bar is in set: - | 1 | - | 22 | - | 333 | - | 4444 | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": 40 }, - "then": { "field": "bar", "is": "lessThan", "value": 4400 }, - "else": { "field": "bar", "is": "equalTo", "value": 1 } - } - """ - Then the following data should be generated: - | foo | bar | - | 10 | 1 | - | 20 | 1 | - | 30 | 1 | - | 40 | 1 | - | 40 | 22 | - | 40 | 333 | - - Scenario: Running an if request that contains a non contradictory lessThan constraint within its else statement should be successful - Given foo is in set: - | 10 | - | 20 | - | 30 | - | 40 | - And foo is anything but null - And bar is in set: - | 1 | - | 22 | - | 333 | - | 4444 | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": 40 }, - "then": { "field": "bar", "is": "equalTo", "value": 333 }, - "else": { "field": "bar", "is": "lessThan", "value": 300 } - } - """ - Then the following data should be generated: - | foo | bar | - | 10 | 1 | - | 10 | 22 | - | 20 | 1 | - | 20 | 22 | - | 30 | 1 | - | 30 | 22 | - | 40 | 333 | - - Scenario: Running an if request that contains a contradictory lessThan constraint within its if statement should be successful - Given foo is in set: - | 10 | - | 20 | - | 30 | - | 40 | - And foo is anything but null - And bar is in set: - | 1 | - | 22 | - | 333 | - | 4444 | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "lessThan", "value": 1 }, - "then": { "field": "bar", "is": "equalTo", "value": 333 }, - "else": { "field": "bar", "is": "equalTo", "value": 22 } - } - """ - Then the following data should be generated: - | foo | bar | - | 10 | 22 | - | 20 | 22 | - | 30 | 22 | - | 40 | 22 | - - Scenario: Running an if request that contains a contradictory lessThan constraint within its then statement should be successful - Given foo is in set: - | 10 | - | 20 | - | 30 | - | 40 | - And foo is anything but null - And bar is in set: - | 1 | - | 22 | - | 333 | - | 4444 | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": 10 }, - "then": { "field": "bar", "is": "lessThan", "value": 1 }, - "else": { "field": "bar", "is": "equalTo", "value": 333 } - } - """ - Then the following data should be generated: - | foo | bar | - | 20 | 333 | - | 30 | 333 | - | 40 | 333 | - - Scenario: Running an if request that contains a contradictory lessThan constraint within its else statement should be successful - Given foo is in set: - | 10 | - | 20 | - | 30 | - | 40 | - And foo is anything but null - And bar is in set: - | 1 | - | 22 | - | 333 | - | 4444 | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": 30 }, - "then": { "field": "bar", "is": "equalTo", "value": 1 }, - "else": { "field": "bar", "is": "lessThan", "value": 1 } - } - """ - Then the following data should be generated: - | foo | bar | - | 30 | 1 | - - Scenario: Running an if request that contains a non contradictory lessThanOrEqualTo constraint within its if statement should be successful - Given foo is in set: - | 10 | - | 20 | - | 30 | - | 40 | - And foo is anything but null - And bar is in set: - | 1 | - | 22 | - | 333 | - | 4444 | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "lessThanOrEqualTo", "value": 20 }, - "then": { "field": "bar", "is": "equalTo", "value": 1 }, - "else": { "field": "bar", "is": "equalTo", "value": 4444 } - } - """ - Then the following data should be generated: - | foo | bar | - | 10 | 1 | - | 20 | 1 | - | 30 | 4444 | - | 40 | 4444 | - - Scenario: Running an if request that contains a non contradictory lessThanOrEqualTo constraint within its then statement should be successful - Given foo is in set: - | 10 | - | 20 | - | 30 | - | 40 | - And foo is anything but null - And bar is in set: - | 1 | - | 22 | - | 333 | - | 4444 | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": 20 }, - "then": { "field": "bar", "is": "lessThanOrEqualTo", "value": 333 }, - "else": { "field": "bar", "is": "equalTo", "value": 4444 } - } - """ - Then the following data should be generated: - | foo | bar | - | 10 | 4444 | - | 20 | 1 | - | 20 | 22 | - | 20 | 333 | - | 30 | 4444 | - | 40 | 4444 | - - Scenario: Running an if request that contains a non contradictory lessThanOrEqualTo constraint within its else statement should be successful - Given foo is in set: - | 10 | - | 20 | - | 30 | - | 40 | - And foo is anything but null - And bar is in set: - | 1 | - | 22 | - | 333 | - | 4444 | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": 20 }, - "then": { "field": "bar", "is": "equalTo", "value": 333 }, - "else": { "field": "bar", "is": "lessThanOrEqualTo", "value": 4444 } - } - """ - Then the following data should be generated: - | foo | bar | - | 10 | 1 | - | 10 | 22 | - | 10 | 333 | - | 10 | 4444 | - | 20 | 333 | - | 30 | 1 | - | 30 | 22 | - | 30 | 333 | - | 30 | 4444 | - | 40 | 1 | - | 40 | 22 | - | 40 | 333 | - | 40 | 4444 | - - Scenario: Running an if request that contains a contradictory lessThanOrEqualTo constraint within its if statement should be successful - Given foo is in set: - | 10 | - | 20 | - | 30 | - | 40 | - And foo is anything but null - And bar is in set: - | 1 | - | 22 | - | 333 | - | 4444 | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "lessThanOrEqualTo", "value": 1 }, - "then": { "field": "bar", "is": "equalTo", "value": 333 }, - "else": { "field": "bar", "is": "equalTo", "value": 4444 } - } - """ - Then the following data should be generated: - | foo | bar | - | 10 | 4444 | - | 20 | 4444 | - | 30 | 4444 | - | 40 | 4444 | - - Scenario: Running an if request that contains a contradictory lessThanOrEqualTo constraint within its then statement should be successful - Given foo is in set: - | 10 | - | 20 | - | 30 | - | 40 | - And foo is anything but null - And bar is in set: - | 1 | - | 22 | - | 333 | - | 4444 | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": 10 }, - "then": { "field": "bar", "is": "lessThanOrEqualTo", "value": 0 }, - "else": { "field": "bar", "is": "equalTo", "value": 4444 } - } - """ - Then the following data should be generated: - | foo | bar | - | 20 | 4444 | - | 30 | 4444 | - | 40 | 4444 | - - Scenario: Running an if request that contains a contradictory lessThanOrEqualTo constraint within its else statement should be successful - Given foo is in set: - | 10 | - | 20 | - | 30 | - | 40 | - And foo is anything but null - And bar is in set: - | 1 | - | 22 | - | 333 | - | 4444 | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": 10 }, - "then": { "field": "bar", "is": "equalTo", "value": 1 }, - "else": { "field": "bar", "is": "lessThanOrEqualTo", "value": 0 } - } - """ - Then the following data should be generated: - | foo | bar | - | 10 | 1 | - -@ignore #769 Violation of numeric and temporal granularity - Scenario: Running an if request that contains a non contradictory granularTo constraint within its if statement should be successful - Given foo is in set: - | 1 | - | 1.1 | - | 1.11 | - | 1.111 | - And foo is anything but null - And bar is in set: - | 1 | - | 2.2 | - | 3.33 | - | 4.444 | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "granularTo", "value": 1 }, - "then": { "field": "bar", "is": "equalTo", "value": 1 }, - "else": { "field": "bar", "is": "equalTo", "value": 2.2 } - } - """ - Then the following data should be generated: - | foo | bar | - | 1 | 1 | - | 1.1 | 2.2 | - | 1.11 | 2.2 | - | 1.111 | 2.2 | - - Scenario: Running an if request that contains a non contradictory granularTo constraint within its else statement should be successful - Given foo is in set: - | 1 | - | 1.1 | - | 1.11 | - | 1.111 | - And foo is anything but null - And bar is in set: - | 2.2 | - | 3.33 | - | 4.444 | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": 1 }, - "then": { "field": "bar", "is": "equalTo", "value": 3.33 }, - "else": { "field": "bar", "is": "granularTo", "value": 0.1 } - } - """ - Then the following data should be generated: - | foo | bar | - | 1 | 3.33 | - | 1.1 | 2.2 | - | 1.11 | 2.2 | - | 1.111 | 2.2 | - - Scenario: Running an if request that contains a contradictory granularTo constraint within its if statement should be successful - Given foo is in set: - | 1.1 | - | 1.11 | - | 1.111 | - And foo is anything but null - And bar is in set: - | 1 | - | 2.2 | - | 3.33 | - | 4.444 | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "granularTo", "value": 1 }, - "then": { "field": "bar", "is": "equalTo", "value": 1 }, - "else": { "field": "bar", "is": "equalTo", "value": 2.2 } - } - """ - Then the following data should be generated: - | foo | bar | - | 1.1 | 2.2 | - | 1.11 | 2.2 | - | 1.111 | 2.2 | - - Scenario: Running an if request that contains a contradictory granularTo constraint within its then statement should be successful - Given foo is in set: - | 1 | - | 1.1 | - | 1.11 | - | 1.111 | - And foo is anything but null - And bar is in set: - | 2.2 | - | 3.33 | - | 4.444 | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": 1 }, - "then": { "field": "bar", "is": "granularTo", "value": 1 }, - "else": { "field": "bar", "is": "equalTo", "value": 2.2 } - } - """ - Then the following data should be generated: - | foo | bar | - | 1.1 | 2.2 | - | 1.11 | 2.2 | - | 1.111 | 2.2 | - - Scenario: Running an if request that contains a contradictory granularTo constraint within its else statement should be successful - Given foo is in set: - | 1 | - | 1.1 | - | 1.11 | - | 1.111 | - And foo is anything but null - And bar is in set: - | 2.2 | - | 3.33 | - | 4.444 | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": 1 }, - "then": { "field": "bar", "is": "equalTo", "value": 3.33 }, - "else": { "field": "bar", "is": "granularTo", "value": 1 } - } - """ - Then the following data should be generated: - | foo | bar | - | 1 | 3.33 | - - Scenario: Running an if request that contains a non contradictory after constraint within its if statement should be successful - Given foo is in set: - | 2018-01-01T00:00:00.000Z | - | 2018-02-01T00:00:00.000Z | - | 2018-03-01T00:00:00.000Z | - | 2018-04-01T00:00:00.000Z | - | 2018-05-01T00:00:00.000Z | - | 2018-06-01T00:00:00.000Z | - And foo is anything but null - And bar is in set: - | 2010-01-01T00:00:00.000Z | - | 2010-01-02T00:00:00.000Z | - | 2010-01-03T00:00:00.000Z | - | 2010-01-04T00:00:00.000Z | - | 2010-01-05T00:00:00.000Z | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "after", "value": { "date": "2018-01-02T00:00:00.000Z" } }, - "then": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-01T00:00:00.000Z" } }, - "else": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-05T00:00:00.000Z" } } - } - """ - Then the following data should be generated: - | foo | bar | - | 2018-01-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | - | 2018-02-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | - | 2018-03-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | - | 2018-04-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | - | 2018-05-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | - | 2018-06-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | - - Scenario: Running an if request that contains a non contradictory after constraint within its then statement should be successful - Given foo is in set: - | 2018-01-01T00:00:00.000Z | - | 2018-02-01T00:00:00.000Z | - | 2018-03-01T00:00:00.000Z | - | 2018-04-01T00:00:00.000Z | - | 2018-05-01T00:00:00.000Z | - | 2018-06-01T00:00:00.000Z | - And foo is anything but null - And bar is in set: - | 2010-01-01T00:00:00.000Z | - | 2010-01-02T00:00:00.000Z | - | 2010-01-03T00:00:00.000Z | - | 2010-01-04T00:00:00.000Z | - | 2010-01-05T00:00:00.000Z | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": { "date": "2018-02-01T00:00:00.000Z" } }, - "then": { "field": "bar", "is": "after", "value": { "date": "2010-01-04T00:00:00.000Z" } }, - "else": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-01T00:00:00.000Z" } } - } - """ - Then the following data should be generated: - | foo | bar | - | 2018-01-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | - | 2018-02-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | - | 2018-03-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | - | 2018-04-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | - | 2018-05-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | - | 2018-06-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | - - Scenario: Running an if request that contains a non contradictory after constraint within its else statement should be successful - Given foo is in set: - | 2018-01-01T00:00:00.000Z | - | 2018-02-01T00:00:00.000Z | - | 2018-03-01T00:00:00.000Z | - | 2018-04-01T00:00:00.000Z | - | 2018-05-01T00:00:00.000Z | - | 2018-06-01T00:00:00.000Z | - And foo is anything but null - And bar is in set: - | 2010-01-01T00:00:00.000Z | - | 2010-01-02T00:00:00.000Z | - | 2010-01-03T00:00:00.000Z | - | 2010-01-04T00:00:00.000Z | - | 2010-01-05T00:00:00.000Z | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": { "date": "2018-01-01T00:00:00.000Z" } }, - "then": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-01T00:00:00.000Z" } }, - "else": { "field": "bar", "is": "after", "value": { "date": "2010-01-04T00:00:00.000Z" } } - } - """ - Then the following data should be generated: - | foo | bar | - | 2018-01-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | - | 2018-02-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | - | 2018-03-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | - | 2018-04-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | - | 2018-05-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | - | 2018-06-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | - - Scenario: Running an if request that contains a contradictory after constraint within its if statement should be successful - Given foo is in set: - | 2018-01-01T00:00:00.000Z | - | 2018-02-01T00:00:00.000Z | - | 2018-03-01T00:00:00.000Z | - | 2018-04-01T00:00:00.000Z | - | 2018-05-01T00:00:00.000Z | - | 2018-06-01T00:00:00.000Z | - And foo is anything but null - And bar is in set: - | 2010-01-01T00:00:00.000Z | - | 2010-01-02T00:00:00.000Z | - | 2010-01-03T00:00:00.000Z | - | 2010-01-04T00:00:00.000Z | - | 2010-01-05T00:00:00.000Z | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "after", "value": { "date": "2020-01-01T00:00:00.000Z" } }, - "then": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-01T00:00:00.000Z" } }, - "else": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-04T00:00:00.000Z" } } - } - """ - Then the following data should be generated: - | foo | bar | - | 2018-01-01T00:00:00.000Z | 2010-01-04T00:00:00.000Z | - | 2018-02-01T00:00:00.000Z | 2010-01-04T00:00:00.000Z | - | 2018-03-01T00:00:00.000Z | 2010-01-04T00:00:00.000Z | - | 2018-04-01T00:00:00.000Z | 2010-01-04T00:00:00.000Z | - | 2018-05-01T00:00:00.000Z | 2010-01-04T00:00:00.000Z | - | 2018-06-01T00:00:00.000Z | 2010-01-04T00:00:00.000Z | - - Scenario: Running an if request that contains a contradictory after constraint within its then statement should be successful - Given foo is in set: - | 2018-01-01T00:00:00.000Z | - | 2018-02-01T00:00:00.000Z | - | 2018-03-01T00:00:00.000Z | - | 2018-04-01T00:00:00.000Z | - | 2018-05-01T00:00:00.000Z | - | 2018-06-01T00:00:00.000Z | - And foo is anything but null - And bar is in set: - | 2010-01-01T00:00:00.000Z | - | 2010-01-02T00:00:00.000Z | - | 2010-01-03T00:00:00.000Z | - | 2010-01-04T00:00:00.000Z | - | 2010-01-05T00:00:00.000Z | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": { "date": "2018-01-01T00:00:00.000Z" } }, - "then": { "field": "bar", "is": "after", "value": { "date": "2020-01-01T00:00:00.000Z" } }, - "else": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-04T00:00:00.000Z" } } - } - """ - Then the following data should be generated: - | foo | bar | - | 2018-02-01T00:00:00.000Z | 2010-01-04T00:00:00.000Z | - | 2018-03-01T00:00:00.000Z | 2010-01-04T00:00:00.000Z | - | 2018-04-01T00:00:00.000Z | 2010-01-04T00:00:00.000Z | - | 2018-05-01T00:00:00.000Z | 2010-01-04T00:00:00.000Z | - | 2018-06-01T00:00:00.000Z | 2010-01-04T00:00:00.000Z | - - Scenario: Running an if request that contains a contradictory after constraint within its else statement should be successful - Given foo is in set: - | 2018-01-01T00:00:00.000Z | - | 2018-02-01T00:00:00.000Z | - | 2018-03-01T00:00:00.000Z | - | 2018-04-01T00:00:00.000Z | - | 2018-05-01T00:00:00.000Z | - | 2018-06-01T00:00:00.000Z | - And foo is anything but null - And bar is in set: - | 2010-01-01T00:00:00.000Z | - | 2010-01-02T00:00:00.000Z | - | 2010-01-03T00:00:00.000Z | - | 2010-01-04T00:00:00.000Z | - | 2010-01-05T00:00:00.000Z | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": { "date": "2018-01-01T00:00:00.000Z" } }, - "then": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-01T00:00:00.000Z" } }, - "else": { "field": "bar", "is": "after", "value": { "date": "2020-01-01T00:00:00.000Z" } } - } - """ - Then the following data should be generated: - | foo | bar | - | 2018-01-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | - - Scenario: Running an if request that contains a non contradictory afterOrAt constraint within its if statement should be successful - Given foo is in set: - | 2018-01-01T00:00:00.000Z | - | 2018-02-01T00:00:00.000Z | - | 2018-03-01T00:00:00.000Z | - | 2018-04-01T00:00:00.000Z | - | 2018-05-01T00:00:00.000Z | - | 2018-06-01T00:00:00.000Z | - And foo is anything but null - And bar is in set: - | 2010-01-01T00:00:00.000Z | - | 2010-01-02T00:00:00.000Z | - | 2010-01-03T00:00:00.000Z | - | 2010-01-04T00:00:00.000Z | - | 2010-01-05T00:00:00.000Z | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "afterOrAt", "value": { "date": "2018-05-01T00:00:00.000Z" } }, - "then": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-05T00:00:00.000Z" } }, - "else": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-01T00:00:00.000Z" } } - } - """ - Then the following data should be generated: - | foo | bar | - | 2018-01-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | - | 2018-02-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | - | 2018-03-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | - | 2018-04-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | - | 2018-05-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | - | 2018-06-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | - - Scenario: Running an if request that contains a non contradictory afterOrAt constraint within its then statement should be successful - Given foo is in set: - | 2018-01-01T00:00:00.000Z | - | 2018-02-01T00:00:00.000Z | - | 2018-03-01T00:00:00.000Z | - | 2018-04-01T00:00:00.000Z | - | 2018-05-01T00:00:00.000Z | - | 2018-06-01T00:00:00.000Z | - And foo is anything but null - And bar is in set: - | 2010-01-01T00:00:00.000Z | - | 2010-01-02T00:00:00.000Z | - | 2010-01-03T00:00:00.000Z | - | 2010-01-04T00:00:00.000Z | - | 2010-01-05T00:00:00.000Z | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": { "date": "2018-05-01T00:00:00.000Z" } }, - "then": { "field": "bar", "is": "afterOrAt", "value": { "date": "2010-01-04T00:00:00.000Z" } }, - "else": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-01T00:00:00.000Z" } } - } - """ - Then the following data should be generated: - | foo | bar | - | 2018-01-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | - | 2018-02-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | - | 2018-03-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | - | 2018-04-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | - | 2018-05-01T00:00:00.000Z | 2010-01-04T00:00:00.000Z | - | 2018-05-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | - | 2018-06-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | - - Scenario: Running an if request that contains a non contradictory afterOrAt constraint within its else statement should be successful - Given foo is in set: - | 2018-01-01T00:00:00.000Z | - | 2018-02-01T00:00:00.000Z | - | 2018-03-01T00:00:00.000Z | - | 2018-04-01T00:00:00.000Z | - | 2018-05-01T00:00:00.000Z | - | 2018-06-01T00:00:00.000Z | - And foo is anything but null - And bar is in set: - | 2010-01-01T00:00:00.000Z | - | 2010-01-02T00:00:00.000Z | - | 2010-01-03T00:00:00.000Z | - | 2010-01-04T00:00:00.000Z | - | 2010-01-05T00:00:00.000Z | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": { "date": "2018-06-01T00:00:00.000Z" } }, - "then": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-01T00:00:00.000Z" } }, - "else": { "field": "bar", "is": "afterOrAt", "value": { "date": "2010-01-04T00:00:00.000Z" } } - } - """ - Then the following data should be generated: - | foo | bar | - | 2018-01-01T00:00:00.000Z | 2010-01-04T00:00:00.000Z | - | 2018-01-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | - | 2018-02-01T00:00:00.000Z | 2010-01-04T00:00:00.000Z | - | 2018-02-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | - | 2018-03-01T00:00:00.000Z | 2010-01-04T00:00:00.000Z | - | 2018-03-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | - | 2018-04-01T00:00:00.000Z | 2010-01-04T00:00:00.000Z | - | 2018-04-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | - | 2018-05-01T00:00:00.000Z | 2010-01-04T00:00:00.000Z | - | 2018-05-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | - | 2018-06-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | - - Scenario: Running an if request that contains a contradictory afterOrAt constraint within its if statement should be successful - Given foo is in set: - | 2018-01-01T00:00:00.000Z | - | 2018-02-01T00:00:00.000Z | - | 2018-03-01T00:00:00.000Z | - | 2018-04-01T00:00:00.000Z | - | 2018-05-01T00:00:00.000Z | - | 2018-06-01T00:00:00.000Z | - And foo is anything but null - And bar is in set: - | 2010-01-01T00:00:00.000Z | - | 2010-01-02T00:00:00.000Z | - | 2010-01-03T00:00:00.000Z | - | 2010-01-04T00:00:00.000Z | - | 2010-01-05T00:00:00.000Z | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "afterOrAt", "value": { "date": "2020-01-01T00:00:00.000Z" } }, - "then": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-01T00:00:00.000Z" } }, - "else": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-05T00:00:00.000Z" } } - } - """ - Then the following data should be generated: - | foo | bar | - | 2018-01-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | - | 2018-02-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | - | 2018-03-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | - | 2018-04-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | - | 2018-05-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | - | 2018-06-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | - - Scenario: Running an if request that contains a contradictory afterOrAt constraint within its then statement should be successful - Given foo is in set: - | 2018-01-01T00:00:00.000Z | - | 2018-02-01T00:00:00.000Z | - | 2018-03-01T00:00:00.000Z | - | 2018-04-01T00:00:00.000Z | - | 2018-05-01T00:00:00.000Z | - | 2018-06-01T00:00:00.000Z | - And foo is anything but null - And bar is in set: - | 2010-01-01T00:00:00.000Z | - | 2010-01-02T00:00:00.000Z | - | 2010-01-03T00:00:00.000Z | - | 2010-01-04T00:00:00.000Z | - | 2010-01-05T00:00:00.000Z | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": { "date": "2018-01-01T00:00:00.000Z" } }, - "then": { "field": "bar", "is": "afterOrAt", "value": { "date": "2020-01-01T00:00:00.000Z" } }, - "else": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-05T00:00:00.000Z" } } - } - """ - Then the following data should be generated: - | foo | bar | - | 2018-02-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | - | 2018-03-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | - | 2018-04-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | - | 2018-05-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | - | 2018-06-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | - - Scenario: Running an if request that contains a contradictory afterOrAt constraint within its else statement should be successful - Given foo is in set: - | 2018-01-01T00:00:00.000Z | - | 2018-02-01T00:00:00.000Z | - | 2018-03-01T00:00:00.000Z | - | 2018-04-01T00:00:00.000Z | - | 2018-05-01T00:00:00.000Z | - | 2018-06-01T00:00:00.000Z | - And foo is anything but null - And bar is in set: - | 2010-01-01T00:00:00.000Z | - | 2010-01-02T00:00:00.000Z | - | 2010-01-03T00:00:00.000Z | - | 2010-01-04T00:00:00.000Z | - | 2010-01-05T00:00:00.000Z | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": { "date": "2018-01-01T00:00:00.000Z" } }, - "then": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-01T00:00:00.000Z" } }, - "else": { "field": "bar", "is": "afterOrAt", "value": { "date": "2020-01-05T00:00:00.000Z" } } - } - """ - Then the following data should be generated: - | foo | bar | - | 2018-01-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | - - Scenario: Running an if request that contains a non contradictory before constraint within its if statement should be successful - Given foo is in set: - | 2018-01-01T00:00:00.000Z | - | 2018-02-01T00:00:00.000Z | - | 2018-03-01T00:00:00.000Z | - | 2018-04-01T00:00:00.000Z | - | 2018-05-01T00:00:00.000Z | - | 2018-06-01T00:00:00.000Z | - And foo is anything but null - And bar is in set: - | 2010-01-01T00:00:00.000Z | - | 2010-01-02T00:00:00.000Z | - | 2010-01-03T00:00:00.000Z | - | 2010-01-04T00:00:00.000Z | - | 2010-01-05T00:00:00.000Z | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "before", "value": { "date": "2018-02-01T00:00:00.000Z" } }, - "then": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-01T00:00:00.000Z" } }, - "else": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-05T00:00:00.000Z" } } - } - """ - Then the following data should be generated: - | foo | bar | - | 2018-01-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | - | 2018-02-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | - | 2018-03-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | - | 2018-04-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | - | 2018-05-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | - | 2018-06-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | - - Scenario: Running an if request that contains a non contradictory before constraint within its then statement should be successful - Given foo is in set: - | 2018-01-01T00:00:00.000Z | - | 2018-02-01T00:00:00.000Z | - | 2018-03-01T00:00:00.000Z | - | 2018-04-01T00:00:00.000Z | - | 2018-05-01T00:00:00.000Z | - | 2018-06-01T00:00:00.000Z | - And foo is anything but null - And bar is in set: - | 2010-01-01T00:00:00.000Z | - | 2010-01-02T00:00:00.000Z | - | 2010-01-03T00:00:00.000Z | - | 2010-01-04T00:00:00.000Z | - | 2010-01-05T00:00:00.000Z | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": { "date": "2018-01-01T00:00:00.000Z" } }, - "then": { "field": "bar", "is": "before", "value": { "date": "2010-01-03T00:00:00.000Z" } }, - "else": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-05T00:00:00.000Z" } } - } - """ - Then the following data should be generated: - | foo | bar | - | 2018-01-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | - | 2018-01-01T00:00:00.000Z | 2010-01-02T00:00:00.000Z | - | 2018-02-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | - | 2018-03-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | - | 2018-04-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | - | 2018-05-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | - | 2018-06-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | - - Scenario: Running an if request that contains a non contradictory before constraint within its else statement should be successful - Given foo is in set: - | 2018-01-01T00:00:00.000Z | - | 2018-02-01T00:00:00.000Z | - | 2018-03-01T00:00:00.000Z | - | 2018-04-01T00:00:00.000Z | - | 2018-05-01T00:00:00.000Z | - | 2018-06-01T00:00:00.000Z | - And foo is anything but null - And bar is in set: - | 2010-01-01T00:00:00.000Z | - | 2010-01-02T00:00:00.000Z | - | 2010-01-03T00:00:00.000Z | - | 2010-01-04T00:00:00.000Z | - | 2010-01-05T00:00:00.000Z | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": { "date": "2018-01-01T00:00:00.000Z" } }, - "then": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-05T00:00:00.000Z" } }, - "else": { "field": "bar", "is": "before", "value": { "date": "2010-01-03T00:00:00.000Z" } } - } - """ - Then the following data should be generated: - | foo | bar | - | 2018-01-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | - | 2018-02-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | - | 2018-02-01T00:00:00.000Z | 2010-01-02T00:00:00.000Z | - | 2018-03-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | - | 2018-03-01T00:00:00.000Z | 2010-01-02T00:00:00.000Z | - | 2018-04-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | - | 2018-04-01T00:00:00.000Z | 2010-01-02T00:00:00.000Z | - | 2018-05-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | - | 2018-05-01T00:00:00.000Z | 2010-01-02T00:00:00.000Z | - | 2018-06-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | - | 2018-06-01T00:00:00.000Z | 2010-01-02T00:00:00.000Z | - - Scenario: Running an if request that contains a contradictory before constraint within its if statement should be successful - Given foo is in set: - | 2018-01-01T00:00:00.000Z | - | 2018-02-01T00:00:00.000Z | - | 2018-03-01T00:00:00.000Z | - | 2018-04-01T00:00:00.000Z | - | 2018-05-01T00:00:00.000Z | - | 2018-06-01T00:00:00.000Z | - And foo is anything but null - And bar is in set: - | 2010-01-01T00:00:00.000Z | - | 2010-01-02T00:00:00.000Z | - | 2010-01-03T00:00:00.000Z | - | 2010-01-04T00:00:00.000Z | - | 2010-01-05T00:00:00.000Z | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "before", "value": { "date": "2010-01-01T00:00:00.000Z" } }, - "then": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-05T00:00:00.000Z" } }, - "else": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-03T00:00:00.000Z" } } - } - """ - Then the following data should be generated: - | foo | bar | - | 2018-01-01T00:00:00.000Z | 2010-01-03T00:00:00.000Z | - | 2018-02-01T00:00:00.000Z | 2010-01-03T00:00:00.000Z | - | 2018-03-01T00:00:00.000Z | 2010-01-03T00:00:00.000Z | - | 2018-04-01T00:00:00.000Z | 2010-01-03T00:00:00.000Z | - | 2018-05-01T00:00:00.000Z | 2010-01-03T00:00:00.000Z | - | 2018-06-01T00:00:00.000Z | 2010-01-03T00:00:00.000Z | - - Scenario: Running an if request that contains a contradictory before constraint within its then statement should be successful - Given foo is in set: - | 2018-01-01T00:00:00.000Z | - | 2018-02-01T00:00:00.000Z | - | 2018-03-01T00:00:00.000Z | - | 2018-04-01T00:00:00.000Z | - | 2018-05-01T00:00:00.000Z | - | 2018-06-01T00:00:00.000Z | - And foo is anything but null - And bar is in set: - | 2010-01-01T00:00:00.000Z | - | 2010-01-02T00:00:00.000Z | - | 2010-01-03T00:00:00.000Z | - | 2010-01-04T00:00:00.000Z | - | 2010-01-05T00:00:00.000Z | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": { "date": "2018-01-01T00:00:00.000Z" } }, - "then": { "field": "bar", "is": "before", "value": { "date": "2010-01-01T00:00:00.000Z" } }, - "else": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-03T00:00:00.000Z" } } - } - """ - Then the following data should be generated: - | foo | bar | - | 2018-02-01T00:00:00.000Z | 2010-01-03T00:00:00.000Z | - | 2018-03-01T00:00:00.000Z | 2010-01-03T00:00:00.000Z | - | 2018-04-01T00:00:00.000Z | 2010-01-03T00:00:00.000Z | - | 2018-05-01T00:00:00.000Z | 2010-01-03T00:00:00.000Z | - | 2018-06-01T00:00:00.000Z | 2010-01-03T00:00:00.000Z | - - Scenario: Running an if request that contains a contradictory before constraint within its else statement should be successful - Given foo is in set: - | 2018-01-01T00:00:00.000Z | - | 2018-02-01T00:00:00.000Z | - | 2018-03-01T00:00:00.000Z | - | 2018-04-01T00:00:00.000Z | - | 2018-05-01T00:00:00.000Z | - | 2018-06-01T00:00:00.000Z | - And foo is anything but null - And bar is in set: - | 2010-01-01T00:00:00.000Z | - | 2010-01-02T00:00:00.000Z | - | 2010-01-03T00:00:00.000Z | - | 2010-01-04T00:00:00.000Z | - | 2010-01-05T00:00:00.000Z | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": { "date": "2018-01-01T00:00:00.000Z" } }, - "then": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-01T00:00:00.000Z" } }, - "else": { "field": "bar", "is": "before", "value": { "date": "2010-01-01T00:00:00.000Z" } } - } - """ - Then the following data should be generated: - | foo | bar | - | 2018-01-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | - - Scenario: Running an if request that contains a non contradictory beforeOrAt constraint within its if statement should be successful - Given foo is in set: - | 2018-01-01T00:00:00.000Z | - | 2018-02-01T00:00:00.000Z | - | 2018-03-01T00:00:00.000Z | - | 2018-04-01T00:00:00.000Z | - | 2018-05-01T00:00:00.000Z | - | 2018-06-01T00:00:00.000Z | - And foo is anything but null - And bar is in set: - | 2010-01-01T00:00:00.000Z | - | 2010-01-02T00:00:00.000Z | - | 2010-01-03T00:00:00.000Z | - | 2010-01-04T00:00:00.000Z | - | 2010-01-05T00:00:00.000Z | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "beforeOrAt", "value": { "date": "2018-02-01T00:00:00.000Z" } }, - "then": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-01T00:00:00.000Z" } }, - "else": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-05T00:00:00.000Z" } } - } - """ - Then the following data should be generated: - | foo | bar | - | 2018-01-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | - | 2018-02-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | - | 2018-03-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | - | 2018-04-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | - | 2018-05-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | - | 2018-06-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | - - Scenario: Running an if request that contains a non contradictory beforeOrAt constraint within its then statement should be successful - Given foo is in set: - | 2018-01-01T00:00:00.000Z | - | 2018-02-01T00:00:00.000Z | - | 2018-03-01T00:00:00.000Z | - | 2018-04-01T00:00:00.000Z | - | 2018-05-01T00:00:00.000Z | - | 2018-06-01T00:00:00.000Z | - And foo is anything but null - And bar is in set: - | 2010-01-01T00:00:00.000Z | - | 2010-01-02T00:00:00.000Z | - | 2010-01-03T00:00:00.000Z | - | 2010-01-04T00:00:00.000Z | - | 2010-01-05T00:00:00.000Z | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": { "date": "2018-01-01T00:00:00.000Z" } }, - "then": { "field": "bar", "is": "beforeOrAt", "value": { "date": "2010-01-03T00:00:00.000Z" } }, - "else": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-05T00:00:00.000Z" } } - } - """ - Then the following data should be generated: - | foo | bar | - | 2018-01-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | - | 2018-01-01T00:00:00.000Z | 2010-01-02T00:00:00.000Z | - | 2018-01-01T00:00:00.000Z | 2010-01-03T00:00:00.000Z | - | 2018-02-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | - | 2018-03-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | - | 2018-04-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | - | 2018-05-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | - | 2018-06-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | - - Scenario: Running an if request that contains a non contradictory beforeOrAt constraint within its else statement should be successful - Given foo is in set: - | 2018-01-01T00:00:00.000Z | - | 2018-02-01T00:00:00.000Z | - | 2018-03-01T00:00:00.000Z | - | 2018-04-01T00:00:00.000Z | - | 2018-05-01T00:00:00.000Z | - | 2018-06-01T00:00:00.000Z | - And foo is anything but null - And bar is in set: - | 2010-01-01T00:00:00.000Z | - | 2010-01-02T00:00:00.000Z | - | 2010-01-03T00:00:00.000Z | - | 2010-01-04T00:00:00.000Z | - | 2010-01-05T00:00:00.000Z | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": { "date": "2018-01-01T00:00:00.000Z" } }, - "then": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-05T00:00:00.000Z" } }, - "else": { "field": "bar", "is": "beforeOrAt", "value": { "date": "2010-01-03T00:00:00.000Z" } } - } - """ - Then the following data should be generated: - | foo | bar | - | 2018-01-01T00:00:00.000Z | 2010-01-05T00:00:00.000Z | - | 2018-02-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | - | 2018-02-01T00:00:00.000Z | 2010-01-02T00:00:00.000Z | - | 2018-02-01T00:00:00.000Z | 2010-01-03T00:00:00.000Z | - | 2018-03-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | - | 2018-03-01T00:00:00.000Z | 2010-01-02T00:00:00.000Z | - | 2018-03-01T00:00:00.000Z | 2010-01-03T00:00:00.000Z | - | 2018-04-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | - | 2018-04-01T00:00:00.000Z | 2010-01-02T00:00:00.000Z | - | 2018-04-01T00:00:00.000Z | 2010-01-03T00:00:00.000Z | - | 2018-05-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | - | 2018-05-01T00:00:00.000Z | 2010-01-02T00:00:00.000Z | - | 2018-05-01T00:00:00.000Z | 2010-01-03T00:00:00.000Z | - | 2018-06-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | - | 2018-06-01T00:00:00.000Z | 2010-01-02T00:00:00.000Z | - | 2018-06-01T00:00:00.000Z | 2010-01-03T00:00:00.000Z | - - Scenario: Running an if request that contains a contradictory beforeOrAt constraint within its if statement should be successful - Given foo is in set: - | 2018-01-01T00:00:00.000Z | - | 2018-02-01T00:00:00.000Z | - | 2018-03-01T00:00:00.000Z | - | 2018-04-01T00:00:00.000Z | - | 2018-05-01T00:00:00.000Z | - | 2018-06-01T00:00:00.000Z | - And foo is anything but null - And bar is in set: - | 2010-01-01T00:00:00.000Z | - | 2010-01-02T00:00:00.000Z | - | 2010-01-03T00:00:00.000Z | - | 2010-01-04T00:00:00.000Z | - | 2010-01-05T00:00:00.000Z | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "beforeOrAt", "value": { "date": "2009-01-01T00:00:00.000Z" } }, - "then": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-05T00:00:00.000Z" } }, - "else": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-03T00:00:00.000Z" } } - } - """ - Then the following data should be generated: - | foo | bar | - | 2018-01-01T00:00:00.000Z | 2010-01-03T00:00:00.000Z | - | 2018-02-01T00:00:00.000Z | 2010-01-03T00:00:00.000Z | - | 2018-03-01T00:00:00.000Z | 2010-01-03T00:00:00.000Z | - | 2018-04-01T00:00:00.000Z | 2010-01-03T00:00:00.000Z | - | 2018-05-01T00:00:00.000Z | 2010-01-03T00:00:00.000Z | - | 2018-06-01T00:00:00.000Z | 2010-01-03T00:00:00.000Z | - - Scenario: Running an if request that contains a contradictory beforeOrAt constraint within its then statement should be successful - Given foo is in set: - | 2018-01-01T00:00:00.000Z | - | 2018-02-01T00:00:00.000Z | - | 2018-03-01T00:00:00.000Z | - | 2018-04-01T00:00:00.000Z | - | 2018-05-01T00:00:00.000Z | - | 2018-06-01T00:00:00.000Z | - And foo is anything but null - And bar is in set: - | 2010-01-01T00:00:00.000Z | - | 2010-01-02T00:00:00.000Z | - | 2010-01-03T00:00:00.000Z | - | 2010-01-04T00:00:00.000Z | - | 2010-01-05T00:00:00.000Z | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": { "date": "2018-01-01T00:00:00.000Z" } }, - "then": { "field": "bar", "is": "beforeOrAt", "value": { "date": "2009-01-01T00:00:00.000Z" } }, - "else": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-03T00:00:00.000Z" } } - } - """ - Then the following data should be generated: - | foo | bar | - | 2018-02-01T00:00:00.000Z | 2010-01-03T00:00:00.000Z | - | 2018-03-01T00:00:00.000Z | 2010-01-03T00:00:00.000Z | - | 2018-04-01T00:00:00.000Z | 2010-01-03T00:00:00.000Z | - | 2018-05-01T00:00:00.000Z | 2010-01-03T00:00:00.000Z | - | 2018-06-01T00:00:00.000Z | 2010-01-03T00:00:00.000Z | - - Scenario: Running an if request that contains a contradictory beforeOrAt constraint within its else statement should be successful - Given foo is in set: - | 2018-01-01T00:00:00.000Z | - | 2018-02-01T00:00:00.000Z | - | 2018-03-01T00:00:00.000Z | - | 2018-04-01T00:00:00.000Z | - | 2018-05-01T00:00:00.000Z | - | 2018-06-01T00:00:00.000Z | - And foo is anything but null - And bar is in set: - | 2010-01-01T00:00:00.000Z | - | 2010-01-02T00:00:00.000Z | - | 2010-01-03T00:00:00.000Z | - | 2010-01-04T00:00:00.000Z | - | 2010-01-05T00:00:00.000Z | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": { "date": "2018-01-01T00:00:00.000Z" } }, - "then": { "field": "bar", "is": "equalTo", "value": { "date": "2010-01-01T00:00:00.000Z" } }, - "else": { "field": "bar", "is": "beforeOrAt", "value": { "date": "2009-01-01T00:00:00.000Z" } } - } - """ - Then the following data should be generated: - | foo | bar | - | 2018-01-01T00:00:00.000Z | 2010-01-01T00:00:00.000Z | - - Scenario: Running an if request that contains a non contradictory not constraint within its if statement should be successful - Given foo is in set: - | "a" | - | "b" | - And foo is anything but null - And bar is in set: - | 10 | - | 20 | - | 30 | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "not": { "field": "foo", "is": "equalTo", "value": "a" } }, - "then": { "field": "bar", "is": "equalTo", "value": 10 } - } - """ - Then the following data should be generated: - | foo | bar | - | "a" | 10 | - | "a" | 20 | - | "a" | 30 | - | "b" | 10 | - - Scenario: Running an if request that contains a non contradictory not constraint within its then statement should be successful - Given foo is in set: - | "a" | - | "b" | - And foo is anything but null - And bar is in set: - | 10 | - | 20 | - | 30 | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": "a" }, - "then": { "not": { "field": "bar", "is": "equalTo", "value": 10 } }, - "else": { "field": "bar", "is": "equalTo", "value": 10 } - } - """ - Then the following data should be generated: - | foo | bar | - | "a" | 20 | - | "a" | 30 | - | "b" | 10 | - - Scenario: Running an if request that contains a non contradictory not constraint within its else statement should be successful - Given foo is in set: - | "a" | - | "b" | - And foo is anything but null - And bar is in set: - | 10 | - | 20 | - | 30 | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": "a" }, - "then": { "field": "bar", "is": "equalTo", "value": 10 }, - "else": { "not": { "field": "bar", "is": "equalTo", "value": 10 } } - } - """ - Then the following data should be generated: - | foo | bar | - | "a" | 10 | - | "b" | 20 | - | "b" | 30 | - - Scenario: Running an if request that contains a contradictory not constraint within its if statement should be successful - Given foo is in set: - | "a" | - And foo is anything but null - And bar is in set: - | 10 | - | 20 | - | 30 | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "not": { "field": "foo", "is": "equalTo", "value": "a" } }, - "then": { "field": "bar", "is": "equalTo", "value": 10 }, - "else": { "field": "bar", "is": "equalTo", "value": 30 } - } - """ - Then the following data should be generated: - | foo | bar | - | "a" | 30 | - - Scenario: Running an if request that contains a contradictory not constraint within its then statement should be successful - Given foo is in set: - | "a" | - | "b" | - And foo is anything but null - And bar is in set: - | 10 | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": "a" }, - "then": { "not": { "field": "bar", "is": "equalTo", "value": 10 } } - } - """ - Then the following data should be generated: - | foo | bar | - | "b" | 10 | - - Scenario: Running an if request that contains a contradictory not constraint within its else statement should be successful - Given foo is in set: - | "a" | - | "b" | - And foo is anything but null - And bar is in set: - | 10 | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": "a" }, - "then": { "field": "bar", "is": "equalTo", "value": 10 }, - "else": { "not": { "field": "bar", "is": "equalTo", "value": 10 } } - } - """ - Then the following data should be generated: - | foo | bar | - | "a" | 10 | - - Scenario: Running an if request that contains a non contradictory anyOf constraint within its if statement should be successful - Given foo is in set: - | "a" | - | "b" | - | "c" | - | "d" | - | "e" | - And foo is anything but null - And bar is in set: - | 10 | - | 20 | - | 30 | - | 40 | - | 50 | - And bar is anything but null - And there is a constraint: - """ - { - "if": - { "anyOf": [ - { "field": "foo", "is": "equalTo", "value": "a" }, - { "field": "foo", "is": "equalTo", "value": "e" } - ]}, - "then": { "field": "bar", "is": "equalTo", "value": 10 }, - "else": { "field": "bar", "is": "equalTo", "value": 50 } - } - """ - Then the following data should be generated: - | foo | bar | - | "a" | 10 | - | "b" | 50 | - | "c" | 50 | - | "d" | 50 | - | "e" | 10 | - - Scenario: Running an if request that contains a non contradictory anyOf constraint within its then statement should be successful - Given foo is in set: - | "a" | - | "b" | - | "c" | - | "d" | - | "e" | - And foo is anything but null - And bar is in set: - | 10 | - | 20 | - | 30 | - | 40 | - | 50 | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": "a" }, - "then": - { "anyOf": [ - { "field": "bar", "is": "equalTo", "value": 20 }, - { "field": "bar", "is": "equalTo", "value": 40 } - ]}, - "else": { "field": "bar", "is": "equalTo", "value": 50 } - } - """ - Then the following data should be generated: - | foo | bar | - | "a" | 20 | - | "a" | 40 | - | "b" | 50 | - | "c" | 50 | - | "d" | 50 | - | "e" | 50 | - - Scenario: Running an if request that contains a non contradictory anyOf constraint within its then statement should be successful - Given foo is in set: - | "a" | - | "b" | - | "c" | - | "d" | - | "e" | - And foo is anything but null - And bar is in set: - | 10 | - | 20 | - | 30 | - | 40 | - | 50 | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": "a" }, - "then": { "field": "bar", "is": "equalTo", "value": 10 }, - "else": - { "anyOf": [ - { "field": "bar", "is": "equalTo", "value": 20 }, - { "field": "bar", "is": "equalTo", "value": 40 } - ]} - } - """ - Then the following data should be generated: - | foo | bar | - | "a" | 10 | - | "b" | 20 | - | "b" | 40 | - | "c" | 20 | - | "c" | 40 | - | "d" | 20 | - | "d" | 40 | - | "e" | 20 | - | "e" | 40 | - - Scenario: Running an if request that contains a contradictory anyOf constraint within its if statement should be successful - Given foo is in set: - | "a" | - | "b" | - | "c" | - | "d" | - | "e" | - And foo is anything but null - And bar is in set: - | 10 | - | 20 | - | 30 | - | 40 | - | 50 | - And bar is anything but null - And there is a constraint: - """ - { - "if": - { "anyOf": [ - { "field": "foo", "is": "equalTo", "value": "Test1" }, - { "field": "foo", "is": "equalTo", "value": "Test2" } - ]}, - "then": { "field": "bar", "is": "equalTo", "value": 10 }, - "else": { "field": "bar", "is": "equalTo", "value": 50 } - } - """ - Then the following data should be generated: - | foo | bar | - | "a" | 50 | - | "b" | 50 | - | "c" | 50 | - | "d" | 50 | - | "e" | 50 | - - - Scenario: Running an if request that contains a contradictory anyOf constraint within its then statement should be successful - Given foo is in set: - | "a" | - | "b" | - | "c" | - | "d" | - | "e" | - And foo is anything but null - And bar is in set: - | 10 | - | 20 | - | 30 | - | 40 | - | 50 | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": "a" }, - "then": - { "anyOf": [ - { "field": "bar", "is": "equalTo", "value": "Test1" }, - { "field": "bar", "is": "equalTo", "value": "Test2" } - ]}, - "else": { "field": "bar", "is": "equalTo", "value": 50 } - } - """ - Then the following data should be generated: - | foo | bar | - | "b" | 50 | - | "c" | 50 | - | "d" | 50 | - | "e" | 50 | - - Scenario: Running an if request that contains a contradictory anyOf constraint within its else statement should be successful - Given foo is in set: - | "a" | - | "b" | - | "c" | - | "d" | - | "e" | - And foo is anything but null - And bar is in set: - | 10 | - | 20 | - | 30 | - | 40 | - | 50 | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": "a" }, - "then": { "field": "bar", "is": "equalTo", "value": 10 }, - "else": { - "anyOf": [ - { "field": "bar", "is": "equalTo", "value": "Test1" }, - { "field": "bar", "is": "equalTo", "value": "Test2" } - ]} - } - """ - Then the following data should be generated: - | foo | bar | - | "a" | 10 | - - Scenario: Running an if request that contains a non contradictory allOf constraint within its if statement should be successful - Given foo is in set: - | "a" | - | "bb" | - | "ccc" | - | "dddd" | - | "eeeee" | - And foo is anything but null - And bar is in set: - | 1 | - | 22 | - | 333 | - | 4444 | - | 55555 | - And bar is anything but null - And there is a constraint: - """ - { - "if": - { "allOf": [ - { "field": "foo", "is": "longerThan", "value": 0 }, - { "field": "foo", "is": "shorterThan", "value": 2 } - ]}, - "then": { "field": "bar", "is": "equalTo", "value": 1 }, - "else": { "field": "bar", "is": "equalTo", "value": 55555 } - } - """ - Then the following data should be generated: - | foo | bar | - | "a" | 1 | - | "bb" | 55555 | - | "ccc" | 55555 | - | "dddd" | 55555 | - | "eeeee" | 55555 | - - Scenario: Running an if request that contains a non contradictory allOf constraint within its then statement should be successful - Given foo is in set: - | "a" | - | "bb" | - | "ccc" | - | "dddd" | - | "eeeee" | - And foo is anything but null - And bar is in set: - | 1 | - | 22 | - | 333 | - | 4444 | - | 55555 | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": "a" }, - "then": - { "allOf": [ - { "field": "bar", "is": "greaterThan", "value": 20 }, - { "field": "bar", "is": "lessThan", "value": 30 } - ]}, - "else": { "field": "bar", "is": "equalTo", "value": 55555 } - } - """ - Then the following data should be generated: - | foo | bar | - | "a" | 22 | - | "bb" | 55555 | - | "ccc" | 55555 | - | "dddd" | 55555 | - | "eeeee" | 55555 | - - Scenario: Running an if request that contains a non contradictory allOf constraint within its else statement should be successful - Given foo is in set: - | "a" | - | "bb" | - | "ccc" | - | "dddd" | - | "eeeee" | - And foo is anything but null - And bar is in set: - | 1 | - | 22 | - | 333 | - | 4444 | - | 55555 | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": "a" }, - "then": { "field": "bar", "is": "equalTo", "value": 1 }, - "else": - { "allOf": [ - { "field": "bar", "is": "greaterThan", "value": 20 }, - { "field": "bar", "is": "lessThan", "value": 30 } - ]} - } - """ - Then the following data should be generated: - | foo | bar | - | "a" | 1 | - | "bb" | 22 | - | "ccc" | 22 | - | "dddd" | 22 | - | "eeeee" | 22 | - - Scenario: Running an if request that contains a contradictory allOf constraint within its if statement should be successful - Given foo is in set: - | "a" | - | "bb" | - | "ccc" | - | "dddd" | - | "eeeee" | - And foo is anything but null - And bar is in set: - | 1 | - | 22 | - | 333 | - | 4444 | - | 55555 | - And bar is anything but null - And there is a constraint: - """ - { - "if": - { "allOf": [ - { "field": "foo", "is": "longerThan", "value": 88 }, - { "field": "foo", "is": "shorterThan", "value": 90 } - ]}, - "then": { "field": "bar", "is": "equalTo", "value": 1 }, - "else": { "field": "bar", "is": "equalTo", "value": 55555 } - } - """ - Then the following data should be generated: - | foo | bar | - | "a" | 55555 | - | "bb" | 55555 | - | "ccc" | 55555 | - | "dddd" | 55555 | - | "eeeee" | 55555 | - - Scenario: Running an if request that contains a non contradictory allOf constraint within its then statement should be successful - Given foo is in set: - | "a" | - | "bb" | - | "ccc" | - | "dddd" | - | "eeeee" | - And foo is anything but null - And bar is in set: - | 1 | - | 22 | - | 333 | - | 4444 | - | 55555 | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": "a" }, - "then": - { "allOf": [ - { "field": "bar", "is": "greaterThan", "value": 200 }, - { "field": "bar", "is": "lessThan", "value": 300 } - ]}, - "else": { "field": "bar", "is": "equalTo", "value": 55555 } - } - """ - Then the following data should be generated: - | foo | bar | - | "bb" | 55555 | - | "ccc" | 55555 | - | "dddd" | 55555 | - | "eeeee" | 55555 | - - Scenario: Running an if request that contains a non contradictory allOf constraint within its else statement should be successful - Given foo is in set: - | "a" | - | "bb" | - | "ccc" | - | "dddd" | - | "eeeee" | - And foo is anything but null - And bar is in set: - | 1 | - | 22 | - | 333 | - | 4444 | - | 55555 | - And bar is anything but null - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": "a" }, - "then": { "field": "bar", "is": "equalTo", "value": 1 }, - "else": - { "allOf": [ - { "field": "bar", "is": "greaterThan", "value": 200 }, - { "field": "bar", "is": "lessThan", "value": 300 } - ]} - } - """ - Then the following data should be generated: - | foo | bar | - | "a" | 1 | diff --git a/orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/features/operators/string/LongerThan.feature b/orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/features/operators/string/LongerThan.feature index 03e57550b..124d56523 100644 --- a/orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/features/operators/string/LongerThan.feature +++ b/orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/features/operators/string/LongerThan.feature @@ -231,6 +231,7 @@ Feature: User can specify that a string length is longer than, a specified numbe Scenario: A longer than constraint combined with a non-ISIN constraint generates data that matches the longer than constraint and contains no valid ISINs Given foo is longer than 2 + And foo is anything but null And foo is anything but of type "ISIN" And foo is in set: | "US0000XVGZA3" | @@ -238,7 +239,6 @@ Feature: User can specify that a string length is longer than, a specified numbe | "twelvedigits" | Then the following data should be generated: | foo | - | null | | "US0000XVGZA3" | | "U10378331005" | | "twelvedigits" | @@ -265,6 +265,7 @@ Feature: User can specify that a string length is longer than, a specified numbe Scenario: A not longer than constraint combined with a non-ISIN constraint generates data that contains no valid ISINs Given foo is anything but longer than 12 + And foo is anything but null And foo is anything but of type "ISIN" And foo is in set: | "US0000XVGZA3" | @@ -272,7 +273,6 @@ Feature: User can specify that a string length is longer than, a specified numbe | "twelvedigits" | Then the following data should be generated: | foo | - | null | | "US0000XVGZA3" | | "U10000XVGZA3" | | "twelvedigits" | @@ -292,6 +292,7 @@ Feature: User can specify that a string length is longer than, a specified numbe Scenario: A longer than constraint combined with a non-SEDOL constraint generates data that matches the longer than constraint and contains no valid SEDOLs Given foo is longer than 2 + And foo is anything but null And foo is anything but of type "SEDOL" And foo is in set: | "0263499" | @@ -299,7 +300,6 @@ Feature: User can specify that a string length is longer than, a specified numbe | "string7" | Then the following data should be generated: | foo | - | null | | "0263499" | | "3091352" | | "string7" | @@ -326,6 +326,7 @@ Feature: User can specify that a string length is longer than, a specified numbe Scenario: A not longer than constraint combined with a non-SEDOL constraint generates data that matches the longer than constraint and contains no valid SEDOLs Given foo is anything but longer than 7 + And foo is anything but null And foo is anything but of type "SEDOL" And foo is in set: | "0263497" | @@ -333,7 +334,6 @@ Feature: User can specify that a string length is longer than, a specified numbe | "string7" | Then the following data should be generated: | foo | - | null | | "0263497" | | "3091354" | | "string7" | @@ -353,6 +353,7 @@ Feature: User can specify that a string length is longer than, a specified numbe Scenario: A longer than constraint combined with a non-CUSIP constraint generates data that matches the longer than constraint and contains no valid CUSIPs Given foo is longer than 2 + And foo is anything but null And foo is anything but of type "CUSIP" And foo is in set: | "38259W508" | @@ -360,7 +361,6 @@ Feature: User can specify that a string length is longer than, a specified numbe | "strngnine" | Then the following data should be generated: | foo | - | null | | "38259W508" | | "5F4918104" | | "strngnine" | @@ -387,6 +387,7 @@ Feature: User can specify that a string length is longer than, a specified numbe Scenario: A not longer than constraint combined with a non-CUSIP constraint generates data that matches the not longer than constraint and contains no valid CUSIPs Given foo is anything but longer than 9 + And foo is anything but null And foo is anything but of type "CUSIP" And foo is in set: | "38259W508" | @@ -394,7 +395,6 @@ Feature: User can specify that a string length is longer than, a specified numbe | "strngnine" | Then the following data should be generated: | foo | - | null | | "38259W508" | | "5F4918104" | | "strngnine" | diff --git a/orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/testframework/utils/CucumberTestState.java b/orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/testframework/utils/CucumberTestState.java index c1e711b34..09065d8a1 100644 --- a/orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/testframework/utils/CucumberTestState.java +++ b/orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/testframework/utils/CucumberTestState.java @@ -36,7 +36,7 @@ public class CucumberTestState { public DataGenerationType dataGenerationType = DataGenerationType.FULL_SEQUENTIAL; public CombinationStrategyType combinationStrategyType = CombinationStrategyType.PINNING; - public TreeWalkerType walkerType = TreeWalkerType.REDUCTIVE; + public TreeWalkerType walkerType = TreeWalkerType.DECISION_BASED; /** * Boolean to represent if the generation mode is validating or violating. From 662390001120696d7bfe25e7e1ce7551e829f7f0 Mon Sep 17 00:00:00 2001 From: Paul Daulby Date: Fri, 26 Jul 2019 14:58:19 +0100 Subject: [PATCH 09/14] Make decision based walker the default --- .../deg/generator/guice/DecisionTreeWalkerProvider.java | 3 ++- .../deg/generator/guice/RowSpecTreeSolverProvider.java | 3 +-- .../deg/orchestrator/generate/GenerateCommandLine.java | 4 ++-- .../cucumber/features/operators/grammatical/If.feature | 2 -- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/generator/src/main/java/com/scottlogic/deg/generator/guice/DecisionTreeWalkerProvider.java b/generator/src/main/java/com/scottlogic/deg/generator/guice/DecisionTreeWalkerProvider.java index fa143f4f9..efb06d14f 100644 --- a/generator/src/main/java/com/scottlogic/deg/generator/guice/DecisionTreeWalkerProvider.java +++ b/generator/src/main/java/com/scottlogic/deg/generator/guice/DecisionTreeWalkerProvider.java @@ -18,6 +18,7 @@ import com.google.inject.Inject; import com.google.inject.Provider; +import com.scottlogic.deg.common.ValidationException; import com.scottlogic.deg.generator.config.detail.DataGenerationType; import com.scottlogic.deg.generator.generation.GenerationConfigSource; import com.scottlogic.deg.generator.walker.*; @@ -61,7 +62,7 @@ public DecisionTreeWalker get() { return reductiveDecisionTreeWalker; default: - return reductiveDecisionTreeWalker; + throw new ValidationException("no WalkerType selected"); } } } diff --git a/generator/src/main/java/com/scottlogic/deg/generator/guice/RowSpecTreeSolverProvider.java b/generator/src/main/java/com/scottlogic/deg/generator/guice/RowSpecTreeSolverProvider.java index d26912b6b..a966b0d41 100644 --- a/generator/src/main/java/com/scottlogic/deg/generator/guice/RowSpecTreeSolverProvider.java +++ b/generator/src/main/java/com/scottlogic/deg/generator/guice/RowSpecTreeSolverProvider.java @@ -24,12 +24,11 @@ public RowSpecTreeSolverProvider(GenerationConfigSource config, CartesianProduct @Override public RowSpecTreeSolver get() { switch (config.getWalkerType()) { + case REDUCTIVE: case DECISION_BASED: return decisionBasedSolver; case CARTESIAN_PRODUCT: return cartesianProductRowSpecTreeSolver; - case REDUCTIVE: - return decisionBasedSolver; default: throw new ValidationException("no WalkerType selected"); } diff --git a/orchestrator/src/main/java/com/scottlogic/deg/orchestrator/generate/GenerateCommandLine.java b/orchestrator/src/main/java/com/scottlogic/deg/orchestrator/generate/GenerateCommandLine.java index 68c12b107..b153d5ea2 100644 --- a/orchestrator/src/main/java/com/scottlogic/deg/orchestrator/generate/GenerateCommandLine.java +++ b/orchestrator/src/main/java/com/scottlogic/deg/orchestrator/generate/GenerateCommandLine.java @@ -33,8 +33,8 @@ import static com.scottlogic.deg.generator.config.detail.CombinationStrategyType.MINIMAL; import static com.scottlogic.deg.common.util.Defaults.DEFAULT_MAX_ROWS; import static com.scottlogic.deg.generator.config.detail.DataGenerationType.RANDOM; +import static com.scottlogic.deg.generator.config.detail.TreeWalkerType.DECISION_BASED; import static com.scottlogic.deg.output.guice.OutputFormat.CSV; -import static com.scottlogic.deg.generator.config.detail.TreeWalkerType.REDUCTIVE; /** * This class holds the generate specific command line options. @@ -110,7 +110,7 @@ public Integer call() throws Exception { @CommandLine.Option(names = {"-w", "--walker-type"}, description = "Determines the tree walker that should be used (${COMPLETION-CANDIDATES})", hidden = true) - private TreeWalkerType walkerType = REDUCTIVE; + private TreeWalkerType walkerType = DECISION_BASED; @CommandLine.Option( names = {"-n", "--max-rows"}, diff --git a/orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/features/operators/grammatical/If.feature b/orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/features/operators/grammatical/If.feature index 4268fb4a6..fbe279adc 100644 --- a/orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/features/operators/grammatical/If.feature +++ b/orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/features/operators/grammatical/If.feature @@ -1,7 +1,5 @@ Feature: Values can be specified by using if, then and else constraints - # this feature is a duplicated in IfDecisionBased.feature. this one tests the reductive walker - Background: Given the generation strategy is full And the combination strategy is exhaustive From 0247ff467299baf355e9f878d00fe34ca3ededb9 Mon Sep 17 00:00:00 2001 From: Paul Daulby Date: Fri, 26 Jul 2019 15:12:48 +0100 Subject: [PATCH 10/14] update docs --- .../decisionTreeWalkers/DecisionBasedWalker.md | 9 +++++++++ .../decisionTreeWalkers/TreeWalkerTypes.md | 13 ++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 docs/developer/decisionTreeWalkers/DecisionBasedWalker.md diff --git a/docs/developer/decisionTreeWalkers/DecisionBasedWalker.md b/docs/developer/decisionTreeWalkers/DecisionBasedWalker.md new file mode 100644 index 000000000..9efe84604 --- /dev/null +++ b/docs/developer/decisionTreeWalkers/DecisionBasedWalker.md @@ -0,0 +1,9 @@ +The Decision Based Tree solver generates row specs by: + 1. choosing and removing a decision from the tree + 2. selecting an option from that decision + 3. adding the constraints from the chosen option to the root of the tree + - adding the sub decisions from the chosen option to the root of the tree + 4. "pruning" the tree by removing any options from the tree that contradict with the new root node + - any decisions that only have 1 remaining option will have that option also moved up the tree, and pruned again. + 5. restarting from 1, until there are no decision left + 6. creating a rowspec from the constraints in the remaining root node. \ No newline at end of file diff --git a/docs/developer/decisionTreeWalkers/TreeWalkerTypes.md b/docs/developer/decisionTreeWalkers/TreeWalkerTypes.md index a7702cd4e..a1bc372d0 100644 --- a/docs/developer/decisionTreeWalkers/TreeWalkerTypes.md +++ b/docs/developer/decisionTreeWalkers/TreeWalkerTypes.md @@ -4,9 +4,15 @@ The generator transforms each profile into one or more [decision trees](../decis The following walker strategies exist: -* Cartesian product (default) +* Decision based +* Cartesian product * Reductive +## Decision Based +This is a recursive algorithm that selects an option from the decision tree, then reduces the tree for the constraints in that option. + +See [Decision Based Walker](DecisionBasedWalker.md) for more details. + ## Cartesian product This strategy is the a recursive algorithm which will 'multiply' each leaf node of the tree against every other leaf node of the decision tree in order to generate data. As such it can create vast numbers of permutations. This strategy makes no attempt to overcome the chance of a combinatorial explosion which can occur with relatively few rules and constraints. @@ -14,7 +20,8 @@ This strategy uses certain methods of the Java Streams API which are known to bl This strategy is also known to have limited-to-no intelligence when it comes to [contradictions](../../user/Contradictions.md). The strategy will back track when they are found, but makes no attempt to preemptively check for them or prevent the walker from entering a contradictory path of the tree. -## Reductive (default) -This strategy takes a different approach to the others above and follows the following process. The strategy focuses on reducing the size of the problem (the tree) progressively until it cannot be any further (then back-tracking occurs) or sufficient information is known (then row/s can be emitted.) +## Reductive +The strategy selects a value for a field, then reduces the size of the problem (the tree) progressively until it cannot be any further (then back-tracking occurs) or sufficient information is known (then row/s can be emitted.) See [Reductive tree walker](ReductiveTreeWalker.md) for more details. + From 420152b02d419443fbe21ac14003575acdd36433 Mon Sep 17 00:00:00 2001 From: Paul Daulby Date: Fri, 26 Jul 2019 16:03:14 +0100 Subject: [PATCH 11/14] update md --- docs/developer/decisionTreeWalkers/TreeWalkerTypes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/developer/decisionTreeWalkers/TreeWalkerTypes.md b/docs/developer/decisionTreeWalkers/TreeWalkerTypes.md index a1bc372d0..1b32c3173 100644 --- a/docs/developer/decisionTreeWalkers/TreeWalkerTypes.md +++ b/docs/developer/decisionTreeWalkers/TreeWalkerTypes.md @@ -4,7 +4,7 @@ The generator transforms each profile into one or more [decision trees](../decis The following walker strategies exist: -* Decision based +* Decision based (default) * Cartesian product * Reductive From 6e6848e4c4723427eecb3267154e7171186f955b Mon Sep 17 00:00:00 2001 From: Matthew Date: Fri, 26 Jul 2019 12:19:39 +0100 Subject: [PATCH 12/14] refactor(#91): Remove ignored test --- .../operators/grammatical/AllOf.feature | 22 ------------------- 1 file changed, 22 deletions(-) diff --git a/orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/features/operators/grammatical/AllOf.feature b/orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/features/operators/grammatical/AllOf.feature index 40674ea60..0124eb7c3 100644 --- a/orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/features/operators/grammatical/AllOf.feature +++ b/orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/features/operators/grammatical/AllOf.feature @@ -59,28 +59,6 @@ Feature: User can specify that data must be created to conform to each of multip | foo | | null | - @ignore #91 Reduce duplication where (eg) decisions have overlapping options - Scenario: Running an 'allOf' request that contains soft contradictory restraints in a nested anyOf request should be successful - Given there is a field foo - And foo is in set: - | 5 | - | "ack" | - And there is a constraint: - """ - { "allOf": [ - { "anyOf": [ - {"field": "foo", "is": "matchingRegex", "value": "[a-z]{3}" }, - {"field": "foo", "is": "matchingRegex", "value": "[a-k]{3}" } - ]}, - { "field": "foo", "is": "ofType", "value": "integer" }, - { "field": "foo", "is": "equalTo", "value": 5 } - ]} - """ - Then the following data should be generated: - | foo | - | 5 | - | null | - Scenario: Running a 'allOf' request that includes multiple values within the same statement should be successful Given there is a field foo And foo is of type "string" From c7b4130e34fa9bbef5e600745589a431677e6635 Mon Sep 17 00:00:00 2001 From: Matthew Date: Fri, 26 Jul 2019 16:13:35 +0100 Subject: [PATCH 13/14] test(#1141): Added basic integration tests for the Decision Based Solver. --- .../DecisionBasedSolverTests.java | 114 ++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 generator/src/test/java/com/scottlogic/deg/generator/walker/decisionbased/DecisionBasedSolverTests.java diff --git a/generator/src/test/java/com/scottlogic/deg/generator/walker/decisionbased/DecisionBasedSolverTests.java b/generator/src/test/java/com/scottlogic/deg/generator/walker/decisionbased/DecisionBasedSolverTests.java new file mode 100644 index 000000000..4b9959a83 --- /dev/null +++ b/generator/src/test/java/com/scottlogic/deg/generator/walker/decisionbased/DecisionBasedSolverTests.java @@ -0,0 +1,114 @@ +package com.scottlogic.deg.generator.walker.decisionbased; + +import com.scottlogic.deg.common.profile.Field; +import com.scottlogic.deg.common.profile.ProfileFields; +import com.scottlogic.deg.generator.builders.ConstraintNodeBuilder; +import com.scottlogic.deg.generator.decisiontree.ConstraintNode; +import com.scottlogic.deg.generator.decisiontree.DecisionTree; +import com.scottlogic.deg.generator.fieldspecs.*; +import com.scottlogic.deg.generator.fieldspecs.whitelist.DistributedSet; +import com.scottlogic.deg.generator.fieldspecs.whitelist.NullDistributedSet; +import com.scottlogic.deg.generator.reducer.ConstraintReducer; +import com.scottlogic.deg.generator.restrictions.StringRestrictionsFactory; +import com.scottlogic.deg.generator.walker.reductive.ReductiveTreePruner; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; +import static org.hamcrest.MatcherAssert.assertThat; + +class DecisionBasedSolverTests { + private Field fieldA = new Field("A"); + private Field fieldB = new Field("B"); + private List fields = new ArrayList<>(); + private ProfileFields profileFields; + private ConstraintReducer constraintReducer; + private ReductiveTreePruner pruner; + private OptionPicker optionPicker; + private DecisionBasedSolver decisionBasedSolver; + + @BeforeEach + void setup() { + fields.add(fieldA); + fields.add(fieldB); + profileFields = new ProfileFields(fields); + + constraintReducer = new ConstraintReducer(new FieldSpecFactory(new StringRestrictionsFactory()), new FieldSpecMerger()); + pruner = new ReductiveTreePruner(new FieldSpecMerger(), constraintReducer, new FieldSpecHelper()); + optionPicker = new SequentialOptionPicker(); + decisionBasedSolver = new DecisionBasedSolver(constraintReducer, pruner, optionPicker); + } + + @Test + void createRowSpecs_whenRootNodeHasNoDecisions_returnsRowSpecOfRoot() { + //Arrange + ConstraintNode root = ConstraintNodeBuilder.constraintNode().build(); + DecisionTree tree = new DecisionTree(root, profileFields); + + //Act + Stream rowSpecs = decisionBasedSolver.createRowSpecs(tree); + + //Assert + List expectedRowSpecs = new ArrayList<>(); + Map fieldToFieldSpec = new HashMap<>(); + fieldToFieldSpec.put(fieldA, FieldSpec.Empty); + fieldToFieldSpec.put(fieldB, FieldSpec.Empty); + expectedRowSpecs.add(new RowSpec(profileFields, fieldToFieldSpec)); + assertThat(expectedRowSpecs, sameBeanAs(rowSpecs.collect(Collectors.toList()))); + } + + @Test + void createRowSpecs_whenRootNodeHasDecisionsButNoChildren_returnsRowSpecOfRoot() { + //Arrange + ConstraintNode root = ConstraintNodeBuilder.constraintNode().where(fieldA).isInSet(1, 2, 3).build(); + DecisionTree tree = new DecisionTree(root, profileFields); + + //Act + Stream rowSpecs = decisionBasedSolver.createRowSpecs(tree); + + //Assert + List expectedRowSpecs = new ArrayList<>(); + Map fieldToFieldSpec = new HashMap<>(); + DistributedSet whitelist = new NullDistributedSet<>(); + fieldToFieldSpec.put(fieldA, FieldSpec.Empty.withWhitelist(whitelist)); + fieldToFieldSpec.put(fieldB, FieldSpec.Empty); + expectedRowSpecs.add(new RowSpec(profileFields, fieldToFieldSpec)); + assertThat(expectedRowSpecs, sameBeanAs(rowSpecs.collect(Collectors.toList()))); + } + + @Test + void createRowSpecs_whenRootNodeHasSomeDecisions_returnsRowSpecOfRoot() { + //Arrange + ConstraintNode root = ConstraintNodeBuilder.constraintNode() + .withDecision( + ConstraintNodeBuilder.constraintNode() + .where(fieldB).isNull(), + ConstraintNodeBuilder.constraintNode() + .where(fieldB).isInSet(1, 2, 3)) + .build(); + DecisionTree tree = new DecisionTree(root, profileFields); + + //Act + Stream rowSpecs = decisionBasedSolver.createRowSpecs(tree); + + //Assert + List expectedRowSpecs = new ArrayList<>(); + Map option0 = new HashMap<>(); + DistributedSet whitelist = new NullDistributedSet<>(); + option0.put(fieldA, FieldSpec.Empty); + option0.put(fieldB, FieldSpec.Empty.withWhitelist(whitelist)); + expectedRowSpecs.add(new RowSpec(profileFields, option0)); + Map option1 = new HashMap<>(); + option1.put(fieldA, FieldSpec.Empty); + option1.put(fieldB, FieldSpec.NullOnly); + expectedRowSpecs.add(new RowSpec(profileFields, option1)); + assertThat(expectedRowSpecs, sameBeanAs(rowSpecs.collect(Collectors.toList()))); + } +} From 8bfa0dd86a8f1e087e48dcc6bc609d978b18359f Mon Sep 17 00:00:00 2001 From: Matthew Date: Fri, 26 Jul 2019 16:35:39 +0100 Subject: [PATCH 14/14] Changed name of functions to be clearer. Added newlines for readability. --- .../walker/decisionbased/DecisionBasedSolverTests.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/generator/src/test/java/com/scottlogic/deg/generator/walker/decisionbased/DecisionBasedSolverTests.java b/generator/src/test/java/com/scottlogic/deg/generator/walker/decisionbased/DecisionBasedSolverTests.java index 4b9959a83..fb4d1fc3d 100644 --- a/generator/src/test/java/com/scottlogic/deg/generator/walker/decisionbased/DecisionBasedSolverTests.java +++ b/generator/src/test/java/com/scottlogic/deg/generator/walker/decisionbased/DecisionBasedSolverTests.java @@ -61,11 +61,12 @@ void createRowSpecs_whenRootNodeHasNoDecisions_returnsRowSpecOfRoot() { fieldToFieldSpec.put(fieldA, FieldSpec.Empty); fieldToFieldSpec.put(fieldB, FieldSpec.Empty); expectedRowSpecs.add(new RowSpec(profileFields, fieldToFieldSpec)); + assertThat(expectedRowSpecs, sameBeanAs(rowSpecs.collect(Collectors.toList()))); } @Test - void createRowSpecs_whenRootNodeHasDecisionsButNoChildren_returnsRowSpecOfRoot() { + void createRowSpecs_whenRootNodeHasNoDecisionsButSomeConstraints_returnsRowSpecOfRoot() { //Arrange ConstraintNode root = ConstraintNodeBuilder.constraintNode().where(fieldA).isInSet(1, 2, 3).build(); DecisionTree tree = new DecisionTree(root, profileFields); @@ -80,6 +81,7 @@ void createRowSpecs_whenRootNodeHasDecisionsButNoChildren_returnsRowSpecOfRoot() fieldToFieldSpec.put(fieldA, FieldSpec.Empty.withWhitelist(whitelist)); fieldToFieldSpec.put(fieldB, FieldSpec.Empty); expectedRowSpecs.add(new RowSpec(profileFields, fieldToFieldSpec)); + assertThat(expectedRowSpecs, sameBeanAs(rowSpecs.collect(Collectors.toList()))); } @@ -109,6 +111,7 @@ void createRowSpecs_whenRootNodeHasSomeDecisions_returnsRowSpecOfRoot() { option1.put(fieldA, FieldSpec.Empty); option1.put(fieldB, FieldSpec.NullOnly); expectedRowSpecs.add(new RowSpec(profileFields, option1)); + assertThat(expectedRowSpecs, sameBeanAs(rowSpecs.collect(Collectors.toList()))); } }