Skip to content

Commit

Permalink
Revert "Add caching when not dirty" (#65)
Browse files Browse the repository at this point in the history
This reverts commit d7fbe5b.
  • Loading branch information
seongahjo committed Oct 8, 2021
1 parent ae09333 commit af1fdce
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,6 @@ public ArbitraryBuilder<T> generator(ArbitraryGenerator generator) {
}

public Arbitrary<T> build() {
if (!this.isDirty() && this.tree.getArbitrary() != null) { // not build if not changed
return this.tree.getArbitrary();
}

ArbitraryBuilder<T> buildArbitraryBuilder = this.copy();
return buildArbitraryBuilder.tree.result(() -> {
ArbitraryTree<T> buildTree = buildArbitraryBuilder.tree;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,7 @@ public Arbitrary<T> result(
ArbitraryValidator validator,
boolean validOnly
) {
return new ArbitraryValue(
generateArbitrary,
validator,
validOnly,
new ConcurrentHashMap<>()
);
return new ArbitraryValue(generateArbitrary, validator, validOnly, new ConcurrentHashMap<>());
}

@SuppressWarnings("unchecked")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
import com.navercorp.fixturemonkey.ArbitraryBuilder;
import com.navercorp.fixturemonkey.FixtureMonkey;
import com.navercorp.fixturemonkey.generator.BuilderArbitraryGenerator;
import com.navercorp.fixturemonkey.test.ComplexManipulatorTest.ComplexClass;

class FixtureMonkeyTest {
private final FixtureMonkey sut = FixtureMonkey.builder()
Expand Down Expand Up @@ -1457,34 +1456,6 @@ void copyValidOnly() {
.sample());
}

@Property
void giveMeBuilderCachedReturnsDiff() {
// given
Arbitrary<ComplexClass> sut = this.sut.giveMeBuilder(ComplexClass.class)
.build();

// when
ComplexClass actual1 = sut.sample();
ComplexClass actual2 = sut.sample();

then(actual1).isNotEqualTo(actual2);
}

@Property
void giveMeBuilderFixedCachedReturnsDiff() {
// given
Arbitrary<ComplexClass> sut = this.sut.giveMeBuilder(ComplexClass.class)
.apply((it, builder) -> {
})
.build();

// when
ComplexClass actual1 = sut.sample();
ComplexClass actual2 = sut.sample();

then(actual1).isNotEqualTo(actual2);
}

@Data
public static class IntegerWrapperClass {
int value;
Expand Down

0 comments on commit af1fdce

Please sign in to comment.