[test] Improve test coverage for utils.* classes - #4292
Open
jay1466 wants to merge 1 commit into
Open
Conversation
Add comprehensive unit tests for utility classes that were previously excluded from code-coverage checks (apache#883, part of apache#641): - AbstractIteratorTest: normal iteration, peek, empty, remove, idempotent hasNext, failed-state transitions - CollectionUtilsTest: newHashMapWithExpectedSize, computeRequiredCapacity boundary and edge cases (including Integer.MAX_VALUE threshold) - CopyOnWriteMapTest: all ConcurrentMap operations (put, get, remove, clear, putAll, putIfAbsent, conditional remove/replace) - EncodingUtilsTest: escapeIdentifier, escapeBackticks, escapeSingleQuotes - OperatingSystemTest: OS detection, isWindows/isMac consistency, enum values - PropertiesUtilsTest: asPrefixedMap, extractAndRemovePrefix, extractPrefix, excludeByPrefix Also fix a copy-paste error in OperatingSystem.isMac() Javadoc that incorrectly described it as checking for Windows.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #883 (sub-issue of umbrella #641 – Improve Test Code Coverage for Ignored Classes).
Several utility classes in
org.apache.fluss.utilswere excluded from the JaCoCo coverage check because they had no tests. This PR adds comprehensive unit tests for them and removes the need for those exclusions by ensuring >= 70% line coverage.New test classes
AbstractIteratorTestAbstractIteratorCollectionUtilsTestCollectionUtilsCopyOnWriteMapTestCopyOnWriteMapEncodingUtilsTestEncodingUtilsOperatingSystemTestOperatingSystemPropertiesUtilsTestPropertiesUtilsTotal: 31 new tests, 0 failures.
Minor fix
Fix a copy-paste error in the Javadoc of
OperatingSystem.isMac()which incorrectly stated it checks for Windows.Test Plan
mvn test -Dtest="CollectionUtilsTest,PropertiesUtilsTest,EncodingUtilsTest,AbstractIteratorTest,CopyOnWriteMapTest,OperatingSystemTest" -pl fluss-commonmvn spotless:check -pl fluss-commonpasses.API and Format
No API or storage format changes.
Documentation
No documentation changes needed.
🤖 AI-assisted changes – reviewed by human developer