-
Notifications
You must be signed in to change notification settings - Fork 18
Conformance test suite #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
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
feature: create test case for json encoding
…ptions handling - Refactored the encoding conformance tests to use dynamic tests via JUnit's TestFactory. - Introduced a new JsonTestOptions model to encapsulate encoding options. - Updated JsonTestCase to use JsonTestOptions instead of a String for options. - Improved test fixture loading and parsing for better maintainability.
- Removed unnecessary ObjectMapper instantiation from JToon. - Simplified the decodeToJson method in JToon by delegating to ValueDecoder. - Enhanced PrimitiveDecoder with a switch statement for better readability. - Updated ValueDecoder to streamline parsing logic and improve error handling.
…structures - Introduced EncodeTestFixture and DecodeTestFixture to encapsulate test data. - Added JsonEncodeTestCase and JsonDecodeTestCase for encoding and decoding test cases. - Refactored ConformanceTest to support dynamic test generation for both encoding and decoding. - Updated parsing methods to handle new test case structures and options. - Removed obsolete JsonTestCase and TestFixture classes for improved clarity.
…or model structures - Added error handling for decoding test cases, allowing tests to expect exceptions. - Updated JsonDecodeTestCase to include a shouldError flag for better test case management. - Refactored parsing methods to remove unnecessary ObjectMapper instantiation. - Removed ExpectedDecodeResult model as part of the cleanup process.
- Introduced PathExpansion enum to manage dotted key expansion modes. - Updated DecodeOptions to include expandPaths parameter with default set to OFF. - Refactored ValueDecoder to handle path expansion for keys, allowing nested object structures. - Enhanced parsing methods to validate and expand keys based on the specified path expansion mode. - Improved error handling for blank lines and delimiter mismatches in strict mode.
… parsing logic - Changed project SDK language level from JDK_25 to JDK_21. - Added checks in PrimitiveDecoder to return whole numbers as Long if within range. - Enhanced ValueDecoder to handle special cases for null input and improved error handling for blank lines. - Introduced new methods for parsing arrays and handling path expansion conflicts in strict mode.
- Enhanced parsing logic in ValueDecoder to streamline handling of keyed arrays and key-value pairs.
- Introduced methods for processing blank lines and direct child lines to improve readability and maintainability.
- Updated error handling for blank lines and indentation validation in strict mode.
- Removed redundant checks and improved comments for clarity.
…ut handling - Modified shouldTerminateListArray method to include line content checks for improved array parsing. - Enhanced parsing logic to handle empty values with nested content, ensuring correct object creation. - Updated JToonDecodeTest and RoundTripTest to assert empty input returns empty map instead of null, improving consistency in decoding behavior.
…validation - Enhanced parsing logic to avoid trimming leading whitespace, ensuring proper indentation validation. - Updated handling of trailing whitespace to prevent issues with empty lines. - Improved error handling for tab characters in strict mode, providing clearer feedback on indentation errors.
…ation - Updated testJSONFile methods to return DynamicNode instead of Stream<DynamicTest>, enhancing test structure. - Introduced createTestContainer method to group tests under their respective file names for better readability. - Simplified dynamic test creation by removing redundant parameters in createDynamicTest methods.
… to monthly; refactor ValueDecoder for improved parsing logic and error handling, including method simplifications and enhanced comments.
…andling - Simplified the validation of multiple primitives at root level by reducing redundant checks. - Introduced a new method for processing lines in tabular arrays, enhancing readability and maintainability. - Improved handling of blank lines and termination conditions in both tabular and list arrays. - Updated comments for clarity and better understanding of the parsing flow.
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.
Conformance Test Suite and Decoder Improvements
Overview
This PR introduces a comprehensive conformance test suite for both encoding and decoding operations, along with significant improvements to the
ValueDecoderparsing logic, error handling, and code maintainability.Changes Summary
Key Features
🧪 Comprehensive Conformance Test Suite
Decoding conformance tests covering:
Encoding conformance tests covering:
Test infrastructure:
ConformanceTestto utilize JUnit 5DynamicContainerfor better test organization🔧 Decoder Improvements
ValueDecoder Refactoring
DecodeOptionsandValueDecoderCode Quality Improvements
ValueDecoder🛠️ Additional Changes
StringEscaperclass with unescaping functionality for handling escaped stringsDecodeOptionswith path expansion capabilitiesTesting
All conformance tests are passing ✅
The test suite validates:
Impact
This PR significantly improves:
Files Changed
Core Changes
src/main/java/com/felipestanzani/jtoon/decoder/ValueDecoder.java- Major refactoring (1,228+ lines)src/main/java/com/felipestanzani/jtoon/decoder/PrimitiveDecoder.java- Improvementssrc/main/java/com/felipestanzani/jtoon/DecodeOptions.java- Path expansion supportsrc/main/java/com/felipestanzani/jtoon/PathExpansion.java- New utilitysrc/main/java/com/felipestanzani/jtoon/util/StringEscaper.java- New utilityTest Infrastructure
src/test/java/com/felipestanzani/jtoon/conformance/ConformanceTest.java- Comprehensive test suitesrc/test/java/com/felipestanzani/jtoon/conformance/model/- Test fixture modelssrc/test/resources/conformance/decode/- 13 decode test fixturessrc/test/resources/conformance/encode/- 8 encode test fixturesBreaking Changes
None - this is a backward-compatible enhancement.