Skip to content

Preserve newlines when converting @CsvSource(textBlock = ...) to @ValueSource#998

Merged
timtebeek merged 2 commits into
mainfrom
tim/csv-source-preserve-newlines
May 16, 2026
Merged

Preserve newlines when converting @CsvSource(textBlock = ...) to @ValueSource#998
timtebeek merged 2 commits into
mainfrom
tim/csv-source-preserve-newlines

Conversation

@timtebeek
Copy link
Copy Markdown
Member

Summary

When CsvSourceToValueSource converts a multi-line @CsvSource(textBlock = """...""") to @ValueSource, each value is now placed on its own indented line instead of being collapsed onto a single line. Previously the textBlock branch produced output like @ValueSource(strings = {"a", "b", "c"}); it now produces a block-style array aligned with the annotation. Internal cleanup along the way: the five per-type format* helpers collapse into one Function<String,String> mapper pipeline using Collectors.joining, and the custom indent helper is replaced with Space.getIndent().

Test plan

  • Updated existing replaceTextBlockAttribute* test expectations to match the new layout
  • Added replaceTextBlockAttributePlacesEachItemOnItsOwnLine regression test mirroring the FindLocaleDateTimeFormatsTest case from the issue
  • Full ./gradlew test passes

…ValueSource`

When a `@CsvSource(textBlock = ...)` is replaced by `@ValueSource`, each value is now placed on its own indented line instead of being collapsed onto a single line.
@timtebeek timtebeek marked this pull request as ready for review May 16, 2026 10:48
@timtebeek timtebeek merged commit 6316a74 into main May 16, 2026
1 check passed
@timtebeek timtebeek deleted the tim/csv-source-preserve-newlines branch May 16, 2026 11:15
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenRewrite May 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant