Repository navigation
feat: enhance batch matching with expected record keys - #70
Merged
Merged
Conversation
Added support for expected record keys in batch matchers, allowing assertions to validate both record keys and values against expected files. This change introduces new validation logic to ensure that the number of expected keys matches the number of files, and enhances logging to provide clearer feedback on key mismatches. This update affects the behavior of both positional and lazy batch matching strategies, improving the flexibility and accuracy of record matching in batch processing scenarios.
Contributor
📋 Unreleased Changelog Preview
ChangelogAll notable changes to this project will be documented in this file. [Unreleased]♻️ Refactoring
✨ Features
Generated by git-cliff 🔄 Run #191 · Sun, 18 Oct 2026 15:04:23 GMT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📝 Summary
Add support for
expectedRecordKeysin batch assertion steps (Then expected records from filesandThen expected records from files based on schema):ktestify-core):expectedRecordKeys(List<String>) toConsumerContextandmatchKeys(List<String>) toMatchContext(wired inAbstractKafkaConsumer.buildMatchContext()).KafkaRecordFetcher.passesKeyFilter()so that whenexpectedRecordKeysis non-empty, only records matching at least one expected key (using the configuredkeyMatchStrategy) are claimed during batch polling.ktestify-core):FileRecordMatcherandAvroFileRecordMatcherto validatematchKeys.size() == matchFilePaths.size()whenmatchKeysis provided (throwingComparisonExceptionon count mismatch).POSITIONALmode: assert that record at indeximatches bothexpectedRecordKeys[i](viakeyMatchStrategy) andfiles[i].LAZYmode: perform order-independent 1-to-1 matching without replacement where a record claims indexjonly when both its key matchesexpectedRecordKeys[j]and its value matchesfiles[j].ktestify-cucumber&ktestify-doc):DATA_TABLE_EXPECTED_RECORD_KEYS = "expectedRecordKeys"inDataTableUtils.Constantsand parse comma-separated keys inConsumerValidationService.validateRawBatchandvalidateAvroBatch.expectedRecordKeysacrossbatch-assertions.mdx,step-reference.mdx,batch-testing.mdx,core-concepts.mdx,built-in-matchers.mdx,assertion-steps.mdx,complete.mdx, andREADME.md.Closes #
🔄 Type of change
fix): non-breaking change that fixes an issuefeat): non-breaking change that adds functionality!): changes existing behaviour, public API, Gherkin steps or config keysrefactor): no functional changeperf)docs)build(deps))ci/build): workflows,pom.xml, tooling✅ Checklist
Code
mvn spotless:check(runmvn spotless:applyto fix it and add the Apache 2.0 headers)Tests
mvn verifypasses locally, and JaCoCo line coverage stays ≥ 70 %Compatibility & docs
New or changed HOCON keys have a default inreference.confand a documented env-var overrideNew SPI implementations are registered inMETA-INF/services/🧪 How to test
📸 Logs / screenshots
Output
💬 Notes for reviewers