From 43013ffb1fcfaece2fa634745cec1fd839933d05 Mon Sep 17 00:00:00 2001 From: "ah.jo" Date: Fri, 16 Jun 2023 13:01:50 +0900 Subject: [PATCH] Fix Jqwik memoization equals bug (#677) --- .../fixturemonkey/tree/ObjectTree.java | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/fixture-monkey/src/main/java/com/navercorp/fixturemonkey/tree/ObjectTree.java b/fixture-monkey/src/main/java/com/navercorp/fixturemonkey/tree/ObjectTree.java index 14179303d..def928668 100644 --- a/fixture-monkey/src/main/java/com/navercorp/fixturemonkey/tree/ObjectTree.java +++ b/fixture-monkey/src/main/java/com/navercorp/fixturemonkey/tree/ObjectTree.java @@ -171,19 +171,21 @@ private CombinableArbitrary generateIntrospected( generated = generated.filter(predicate); } - FixtureCustomizer customizer = ctx.getFixtureCustomizers().stream() - .filter(it -> it.match(node.getProperty())) - .map(MatcherOperator::getOperator) - .findFirst() - .orElse(null); + boolean hasCustomizer = ctx.getFixtureCustomizers().stream() + .anyMatch(it -> it.match(node.getProperty())); CombinableArbitrary arbitrary = generated; - if (customizer != null) { - arbitrary = new FixedCombinableArbitrary( - generated.combined().map(obj -> customizer.customizeFixture(obj)) - ); + if (hasCustomizer) { + arbitrary = new FixedCombinableArbitrary(generated.combined()); } - return arbitrary; + return arbitrary.map( + object -> ctx.getFixtureCustomizers().stream() + .filter(it -> it.match(node.getProperty())) + .map(MatcherOperator::getOperator) + .findFirst() + .map(it -> it.customizeFixture(object)) + .orElse(object) + ); } }