Skip to content

Pilot @ObjectSource/@TableSource migration across all three phases - #291

Merged
em3s merged 5 commits into
mainfrom
chore/test-migration-pilot-phase-0
Apr 28, 2026
Merged

em3s merged 5 commits into
mainfrom
chore/test-migration-pilot-phase-0

Conversation

@em3s

@em3s em3s commented Apr 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Phase 0 pilot — migrates one Kotlin test per phase to validate the @ObjectSource / @TableSource pattern end-to-end before scaling. Picking one file per phase surfaces concerns specific to each shape early: @CsvSource density preservation (Phase 1), @Test consolidation under @ObjectSource (Phase 2), and primitive-matrix @TableSource (Phase 3).

Part of #271.

Changes

  • Phase 1: engine/.../experiments/hbase/PerCellTTLTest.kt — @CsvSource (14 rows) → @TableSource (14 rows). Single-quoted YAML for cells with commas; ~ for null cells.
  • Phase 2: core/.../metadata/AliasSerializationTest.kt — 2× @Test → 2× @ObjectSource. Test count preserved (2 → 2). Also adopts PrettyObjectWriter.DEFAULT (new companion-object constant for the (indentSize=2, lineLengthLimit=80) preset that 9 test files repeat).
  • Phase 3: server/.../v3/metadata/MetadataStatusTest.kt — 3× @Test → 1× @TableSource wrapped in @Nested MatchesTest (3 → 6 invocations; the wrapping brings @Nested into scope so ktlint's function-naming rule accepts the backtick-quoted method name).
  • Infra fix: core/src/testFixtures/.../params/ObjectSourceParameterResolver.kt — supportsParameter now gates on parameterContext.declaringExecutable == testMethod. Previously it matched any parameter whose index fit within parameterNames.size, which competed with class-level extensions for constructor parameters (HBaseTestingClusterExtension's Table injection in PerCellTTLTest → ParameterResolutionException). Surfaced by the Phase 1 pilot. Unblocks any extension-injected test class (HBase, Spring, …) from adopting @ObjectSource / @TableSource.

After this PR, rg "@CsvSource|@ValueSource" core engine server (Kotlin paths) drops by one file. 35 Kotlin files remain across Phases 1–3 (Phase 1: 8 → 7, Phase 2: 17 → 16, Phase 3: 11 → 10).

How to Test

./gradlew :core:test --tests '*AliasSerializationTest'      # 2/2 pass
./gradlew :server:test --tests '*MetadataStatusTest'        # 6/6 pass
./gradlew :engine:test --tests '*PerCellTTLTest'            # 14/14 pass (HBase mini-cluster)
./gradlew :core:test --tests '*ObjectSourceTest' --tests '*TableSourceTest'  # green (no resolver regression)
./gradlew :core:test --tests '*DatastoreUriTest' --tests '*V3NameValidatorTest'  # green

AI Assistance

  • This PR was written largely with AI assistance.
    • Tool / model: Claude Code with Claude Opus 4.7 (1M context)

…ses (#271)

Migrates one representative file per phase to validate the pattern end-to-end
before scaling to the full 36-file effort.

- Phase 1: PerCellTTLTest @CsvSource (14 rows) -> @TableSource (14 rows)
- Phase 2: AliasSerializationTest @test -> @ObjectSource (2 -> 2)
- Phase 3: MetadataStatusTest @test -> @TableSource (3 -> 6)

Also fixes ObjectSourceParameterResolver.supportsParameter so it only resolves
parameters of the test method itself. Previously it matched any parameter whose
index fit within parameterNames.size, which competed with class-level
extensions (HBaseTestingClusterExtension's Table injection in PerCellTTLTest's
constructor) and raised ParameterResolutionException. With the guard,
extension-injected test classes can now adopt @ObjectSource and @TableSource.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. maintenance Maintenance work. labels Apr 28, 2026
em3s and others added 4 commits April 28, 2026 11:07
…tion-naming

ktlint standard:function-naming rejects backtick-named functions in files that
lack any test annotation imports (@test / @nested). V3NameValidatorTest and
TableSourceTest pass because each imports @nested or @test; the new
MetadataStatusTest had no such import, so spotlessKotlinCheck failed on CI.

Wrapping the method in a @nested MatchesTest brings @nested into scope and
matches the convention used elsewhere in this package. Test count unchanged
(6 invocations).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Replace double quotes with single quotes for cells that need quoting (the
operations column, where commas would otherwise split flow elements), and
unquote the name column entirely (no flow indicators in those values).
Single quotes are literal — no escape interpretation — which suits test
data better than double quotes' escape semantics.

Test count and behavior unchanged (14/14 pass).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
The (indentSize=2, lineLengthLimit=80) configuration is repeated in 9 test
files (8 Serialization tests + 1 PrettyObjectWriterTest). Promote it to a
companion-object constant so callers can write `PrettyObjectWriter.DEFAULT`
instead of re-instantiating with the same numbers.

Applied to AliasSerializationTest only as part of the Phase 0 pilot. The
remaining 8 call sites will switch over when Phase 2 migrates them to
@ObjectSource (#271).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
The previous comment named a specific caller (HBaseTestingClusterExtension)
and restated what the guard does. Per coding-style.md, comments should
explain WHY when non-obvious — neither applies here: the code reads cleanly
on its own, and the bug context belongs in the PR description, not the
source.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@em3s

em3s commented Apr 28, 2026

Copy link
Copy Markdown
Contributor Author

Reviewed. Merging.

@em3s em3s changed the title test: pilot @ObjectSource/@TableSource migration across all three phases Pilot @ObjectSource/@TableSource migration across all three phases Apr 28, 2026
@em3s
em3s merged commit 7f48b4d into main Apr 28, 2026
6 checks passed
@em3s
em3s deleted the chore/test-migration-pilot-phase-0 branch April 28, 2026 05:58
@em3s em3s self-assigned this May 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance Maintenance work. size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant