v3.3.0
Code fixtures and Hamcrest parity: generate seed data in code with SeedSource, and compose every assertion with standard Hamcrest matchers.
Highlights
- 01
SeedSource code fixtures
A class or lambda produces the documents a seed inserts — reference it from @MongoSeed(sources = …) or the static helpers, with the same re-apply lifecycle as file seeds and a deterministic randomSeed for reproducible generated data.
Read the guide → - 02
Hamcrest everywhere
Matcher forms of the counting and per-document predicates, hasIdMatching/hasJsonPathMatching/matchesDocument, and MongoDocumentMatchers — the document vocabulary as standalone Matcher<Document> factories for Hamcrest-native suites.
Read the guide → - 03
valueEqualTo and numberComparing
Hamcrest's equalTo uses equals(), so equalTo(4999) fails against a stored NumberLong. These two matchers apply the library's cross-BSON-type comparison, making equality and ranges work regardless of the stored numeric type.
Read the guide →
Full notes
Added
- SeedSource, SeedContext, SeedPhase and PlaceholderLookup in io.typecheck.bonsai.core.seed; the @MongoSeed sources() attribute; MongoTestData.seedFrom(...) and SpringMongoTestData.insertAll(collection, source). Sources are instantiated fresh per application (Spring singleton beans excepted — documented), resolve as Spring beans with constructor injection, and fail fast with SeedSourceException naming the source class and element index. The plain-JUnit harness accepts Document, Map and BsonDocument elements and rejects entities by name; the Spring harness maps entities through the application's converter.
- Hamcrest parity: hasDocumentCount(Matcher<? super Long>) plus a requirements overload, Matcher forms of containsDocumentSatisfying, containsExactlyOneDocumentSatisfying, allDocumentsSatisfy and noDocumentSatisfies, the chainable hasFieldValues(field, matcher), hasIdMatching, hasJsonPathMatching, matchesDocument, the MongoDocumentMatchers factory class, and MongoFieldMatchers.valueEqualTo / numberComparing. Existing Object-parameter methods are untouched and a lambda still binds to the Consumer overloads.
- mongo:8.3 joined the differential test matrices, with zero divergences across the scenario corpus.
Changed
- The seed DEBUG line's phase vocabulary is the SeedPhase enum in both harnesses, preserving the reapply-after-cleanup token; a re-applied suite seed keeps its suite spelling. MongoSeeder.SEED_PHASE_MDC_KEY is deprecated for removal. containsDocumentSatisfying(null) is now an ambiguous-reference compile error.
- Dependency refresh, built and verified against Spring Boot 4.1.1: MongoDB sync driver 5.5.1 to 5.10.0 and Nitrite 5.0.0 to 5.1.0, with the full 672-scenario differential lane reporting zero divergences on mongo:8.0 and mongo:8.3 after both bumps. A Trivy (latest) runtime scan across every published module reports zero CRITICAL, HIGH or MEDIUM findings; the driver bump carries the upstream CVE-2026-18710 fix (SOCKS5 proxy credential logging, fixed in 5.9.2); the json-smart 2.5.2 CVE-2024-57699 pin remains in force.
Fixed
- The Spring harness no longer swallows a seed re-application failure into a WARN: the failing method's afterEach now throws, and later methods fail with the original cause until a re-application succeeds, cleared at test-class boundaries. The plain-JUnit harness gains the identical contract. A suite that silently depended on the old behaviour will now fail loudly — that is the fix.
- A throwing Hamcrest matcher now surfaces as an assertion failure carrying the collection name and document index with the original exception as cause, including when nested inside a Consumer, instead of escaping raw or being counted as a mismatch.
- The assertion classes' three divergent field-resolution copies were unified. extractingField keeps its documented absent-field-to-null contract, sortedBy keeps its ordering, and numeric comparison no longer throws on stored NaN, Infinity or Decimal128 negative zero — those mismatch instead.