Skip to content

Add unit tests for ExtractedTextFormatter#6559

Open
gaoxiaolei-s59 wants to merge 1 commit into
spring-projects:mainfrom
gaoxiaolei-s59:test-extracted-text-formatter
Open

Add unit tests for ExtractedTextFormatter#6559
gaoxiaolei-s59 wants to merge 1 commit into
spring-projects:mainfrom
gaoxiaolei-s59:test-extracted-text-formatter

Conversation

@gaoxiaolei-s59

Copy link
Copy Markdown

ExtractedTextFormatter in spring-ai-commons implements the text clean-up pipeline used by the document readers (PDF, Tika) — blank-line consolidation, left alignment, top/bottom line deletion with page-skip and custom line separators — but has no dedicated unit tests today (it is only exercised indirectly through document-reader tests).

This PR adds ExtractedTextFormatterTests (19 tests, JUnit 5 + AssertJ, no mocks) covering:

  • trimAdjacentBlankLines: consecutive blank lines collapsed, space-only lines treated as blank, single blank line preserved
  • alignToLeft: leading-space stripping, inner space-run collapsing, trailing-space removal
  • deleteBottomTextLines / deleteTopTextLines: requested-line removal, more-lines-than-present edge cases, blank/null passthrough, custom (\r\n) separators
  • format(...): default blank-line-only behavior, left alignment, top/bottom deletion, numberOfTopPagesToSkipBeforeDelete threshold behavior across page numbers, no-arg format treating the page as page 0, and the combined pipeline
  • builder/defaults() returning fresh instances

Verification:

./mvnw -pl spring-ai-commons test -Dtest=ExtractedTextFormatterTests
Tests run: 19, Failures: 0, Errors: 0, Skipped: 0
BUILD SUCCESS

spring-javaformat:validate passes and the commit is signed off per the DCO.

Signed-off-by: gaoxiaolei-s59 <2995484417@qq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants