Add property factory support for data classes#41
Conversation
- Added `property()` method to `SomeConfigBuilder` for per-property overrides using `KProperty1`. - Updated `SomeConfig` to store and propagate property factories. - Integrated property factory resolution into `DataClassResolver`. - Added comprehensive integration tests in `PropertyFactoryIntegrationTest`. - Ensured type factories take precedence over property factories. - Added support for overriding optional parameters while preserving other defaults. Co-authored-by: MessiasLima <[email protected]>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
There was a problem hiding this comment.
Code Review
This pull request introduces the ability to register custom factory functions for specific properties within a data class, enhancing the flexibility of the fixture generation. Key changes include the addition of a propertyFactories map to the configuration, a new property method in the configuration builder, and updates to the DataClassResolver to utilize these factories during object instantiation. Feedback focuses on improving the DSL's robustness and performance by using reified type parameters to avoid reflection and hoisting the FixtureContext creation within the resolver to reduce redundant allocations.
This change introduces support for per-property overrides in data classes.
Previously, users had to provide all constructor arguments when using a custom factory for a data class.
With this update, users can use
property(MyClass::myProp) { value }to override only specific properties, while the library auto-generates the rest.Key changes:
SomeConfigBuilder.property(KProperty1<T, V>, FixtureContext.() -> V)registers an override.DataClassResolvernow receives the map of property factories and applies them during theresolveprocess.Fixes #39
PR created automatically by Jules for task 14335845514827790920 started by @MessiasLima