Skip to content

Support textBlock attribute in CsvSourceToValueSource#989

Merged
timtebeek merged 3 commits intomainfrom
tim/issue-985
May 5, 2026
Merged

Support textBlock attribute in CsvSourceToValueSource#989
timtebeek merged 3 commits intomainfrom
tim/issue-985

Conversation

@timtebeek
Copy link
Copy Markdown
Member

@timtebeek timtebeek commented May 4, 2026

Summary

  • Convert @CsvSource(textBlock = """...""") with a single-column parameter into @ValueSource(...), splitting on newlines and ignoring # comments and blank lines per JUnit's textBlock semantics.

  • Skip when the text block has multiple CSV columns, or when non-String values contain whitespace that would produce invalid Java.

  • Adds a String case to the @ValueSource builder so text-block-derived values render as @ValueSource(strings = {...}).

  • Resolves Preserve comments at csvsourcetovaluesource / support """ at conversion #985

Test plan

  • ./gradlew test --tests CsvSourceToValueSourceTest
  • ./gradlew test --tests "org.openrewrite.java.testing.junit5.*"

timtebeek added 2 commits May 4, 2026 21:35
Single quote is CsvSource's default quote character, so converting
'apple' to a ValueSource string literal would change the parsed value.
Replaces three local helpers with `StringUtils.containsWhitespace` for
the whitespace check and inline `String#indexOf` calls for the single-
character checks.
@timtebeek timtebeek merged commit 9104c05 into main May 5, 2026
1 check passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenRewrite May 5, 2026
@timtebeek timtebeek deleted the tim/issue-985 branch May 5, 2026 09:48
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.

Preserve comments at csvsourcetovaluesource / support """ at conversion

1 participant