Skip to content

1.2.4

Latest

Choose a tag to compare

@seongahjo seongahjo released this 13 Nov 02:23
· 9 commits to main since this release

⚠️ Breaking Changes

Using fixture-monkey-jakarta-validation without fixture-monkey-starter?
Hibernate Validator is no longer included, so add a Bean Validation provider to your test dependencies:

testImplementation("org.hibernate.validator:hibernate-validator:7.0.5.Final")
testImplementation("org.glassfish:jakarta.el:4.0.2")

Without a provider, generated values still respect the constraint annotations, but the generated object is no longer validated. If you use fixture-monkey-starter, nothing changes. (#1351) @onacit

register with a custom matcher or registerExactType now applies to nested properties too.

FixtureMonkey.builder()
    .register(new MatcherOperator<>(
        property -> property.getJvmType().getRawType() == Child.class,
        fm -> fm.giveMeBuilder(Child.class).set("name", "custom")
    ))
    .build();

Before, name was "custom" only for giveMeOne(Child.class). Now giveMeOne(Parent.class).getChild() gets "custom" too. The same goes for an interface registered with registerExactType, such as List, Set or Map, when it appears as a field or element. (#1343)

Writing your own plugin or calling internal classes?
object-farm-api is now 0.1.6, and some internal and experimental APIs changed. See the release notes for the full list.

🐛 Bug Fixes

  • An object you pass to set(...) or register(...) is no longer shared between samples. Changing one sampled object no longer changes the others, and a list you pass as Arrays.asList(...) or List.of(...) comes back as a regular, modifiable list. Use Values.just(...) if you need the exact same instance. (#1356)
  • Customizations that were ignored since 1.2.0 work again (#1343, #1354, #1355):
    • customize and postCondition on a wildcard path such as values[*]
    • set("list[0,1]", ...)
    • customize and postCondition on a field of an object set as a whole with set("$", ...) in a registered builder
    • a Values.just(...) value combined with size(...) or set(...)
  • You can set a list that mixes subtypes, such as a List<Animal> holding a Dog and a Cat. (#1353) @poketopa
  • A builder registered with register(Item.class, ...) now also applies to the elements of an Item[] array. (#1367) @YongGoose
  • @DecimalMin("10.5") or @DecimalMax with a fractional value on an int or long field no longer fails. (#1335) @been1118
  • You can set a nested collection (a list of lists, a map of maps, including ones made with List.of or Map.of) and then change an element inside it. (#1337)
  • A non-null Kotlin property of a sealed class or sealed interface type is no longer generated as null. (#1338)

⚡ Improvements

  • Object generation is about 43% faster. The same seed still produces the same values. (#1339)
  • The rule for which customization wins on the same property is now consistent (#1343, #1346, #1354, #1355):
    • what you declare on the builder you sample always wins over register(...),
    • between registered builders, the one with the higher priority (lower number) wins,
    • otherwise, the later declaration wins.

🙌 Contributors

Thanks to @onacit, @poketopa, @YongGoose and @been1118 for their contributions in this release.

Full Changelog: 1.2.3...1.2.4