Skip to content

feat: add keyMatchStrategy support for flexible key matching - #52

Open
nil-malh wants to merge 1 commit into
mainfrom
feat/key-regex-match
Open

nil-malh wants to merge 1 commit into
mainfrom
feat/key-regex-match

Conversation

@nil-malh

@nil-malh nil-malh commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

📝 Description

Extends the KeyMatchStrategy feature (introduced in ktestify-core) into the Cucumber DataTable layer, allowing users to specify an optional keyMatchStrategy column in any step that accepts expectedRecordKey.

What changed:

  • Added DATA_TABLE_KEY_MATCH_STRATEGY = "keyMatchStrategy" constant to DataTableUtils.
  • Added getKeyMatchStrategy(Map<String, String> row) private static helper to ConsumerValidationService that parses the DataTable column value via KeyMatchStrategy.fromString() (defaults to EXACT when absent or blank).
  • Wired .keyMatchStrategy(getKeyMatchStrategy(row)) into all 9 ConsumerContext.builder() calls and 3 MatchContext.builder() calls that set expectedRecordKey.
  • Added 10 reflection-based unit tests for getKeyMatchStrategy().
  • Added 17 integration test scenarios across 3 feature files (key-matchers.feature, key-filtering.feature, watcher.feature).
  • Updated documentation: step-reference.mdx, built-in-matchers.mdx, core-concepts.mdx, and ktestify-cucumber/README.md.

Why:
Users have record keys that are dynamically generated (UUIDs, prefixed keys, hash-based keys). Exact match is too restrictive for these use cases. The keyMatchStrategy column lets users choose contains, starts_with, ends_with, or regex matching at both the fetch-time pre-filter and the assertion-time matcher layers.

Resolves #46


🔄 Type of Change

  • ✨ New feature : non-breaking change that adds functionality

✅ Pre-Merge Checklist

Code Quality

  • My code follows the Palantir Java Format style (passes mvn spotless:check)
  • I have added or updated Javadoc on public types and methods

Tests

  • I have added unit tests that cover the new / changed behaviour
  • All existing and new tests pass locally (mvn verify)
  • JaCoCo line coverage ≥ 70 % is maintained
  • Tests using Testcontainers are isolated and do not leave containers running

Licensing

  • Apache 2.0 license header has been added to every new source file (using spotless)

🧪 How to Test Locally

# 1. Build and run all tests (requires Docker for Testcontainers)
mvn verify

# 2. Check code style
mvn spotless:check

# 3. Run only the key strategy integration scenarios
mvn verify -Pintegration-tests -Dcucumber.filter.tags="@keyStrategy"

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

📋 Unreleased Changelog Preview

This is what the next release notes will look like based on commits in this PR.

Changelog

All notable changes to this project will be documented in this file.

[Unreleased]

✨ Features

  • Add keyMatchStrategy support for flexible key matching in ConsumerValidationService

Generated by git-cliff


🔄 Run #131 · Thu, 01 Oct 2026 19:52:18 GMT

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

✅ Test Results

Metric Count
✅ Passed 0
❌ Failed 0
⏭️ Skipped 0
📊 Total 0

⚠️ Coverage report not available


🔄 CI run #147 · Thu, 01 Oct 2026 19:53:45 GMT

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Support multiple recordKey matching options in assertions

1 participant