Skip to content

Commit

Permalink
Fix setLazy with value wrapped by Just would not be manipulated (#900)
Browse files Browse the repository at this point in the history
  • Loading branch information
seongahjo authored Jan 29, 2024
1 parent eaacb14 commit c4cedf6
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docs/content/v1.0.x/release-notes/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ sectionStart
### v.1.0.13
Add InterfacePlugin supports abstract classes through `abstractClassExtends` option.

Fix setLazy with value wrapped by Just would not be manipulated

sectionEnd

sectionStart
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import com.navercorp.fixturemonkey.api.introspector.FactoryMethodArbitraryIntros
import com.navercorp.fixturemonkey.api.introspector.FailoverIntrospector
import com.navercorp.fixturemonkey.api.introspector.FieldReflectionArbitraryIntrospector
import com.navercorp.fixturemonkey.api.type.Types.GeneratingWildcardType
import com.navercorp.fixturemonkey.customizer.Values
import com.navercorp.fixturemonkey.kotlin.KotlinPlugin
import com.navercorp.fixturemonkey.kotlin.get
import com.navercorp.fixturemonkey.kotlin.giveMeBuilder
Expand Down Expand Up @@ -389,6 +390,23 @@ class KotlinTest {
then(actual).isNull()
}

@RepeatedTest(TEST_COUNT)
fun setLazyJustNotChanged() {
// given
class StringObject(val string: String)

val expected = StringObject("test")

// when
val actual = SUT.giveMeBuilder<StringObject>()
.setLazy("$") { Values.just(expected) }
.setExp(StringObject::string, "notTest")
.sample()

// then
then(actual).isEqualTo(expected)
}

companion object {
private val SUT: FixtureMonkey = FixtureMonkey.builder()
.plugin(KotlinPlugin())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import net.jqwik.api.Arbitrary;

import com.navercorp.fixturemonkey.api.arbitrary.CombinableArbitrary;
import com.navercorp.fixturemonkey.api.container.DecomposedContainerValueFactory;
import com.navercorp.fixturemonkey.api.lazy.LazyArbitrary;
import com.navercorp.fixturemonkey.customizer.Values.Just;
Expand Down Expand Up @@ -64,7 +65,10 @@ public void manipulate(ObjectNode objectNode) {
}

if (value instanceof Just) {
value = (T)((Just)value).getValue();
Just just = (Just)value;
objectNode.setArbitrary(CombinableArbitrary.from(just::getValue));
lazyArbitrary.clear();
return;
}

NodeSetDecomposedValueManipulator<T> nodeSetDecomposedValueManipulator =
Expand Down

0 comments on commit c4cedf6

Please sign in to comment.