Skip to content
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

Make possible to have multiple accessors for overloaded methods #3016

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

velo
Copy link

@velo velo commented Sep 7, 2022

Proposed fix for #1135

@Zegveld
Copy link
Contributor

Zegveld commented Sep 19, 2022

I haven't taken a good look at the production code yet, but the following was what I noticed about the test-code.

I feel that the test setup has too many components intertwined. What is it that is actually being tested?

  • MapperConfig
  • Mapping method with different source/target
  • Overloaded setters
    Or is this something that only fails when all three these components are combined?

If I'm correct this is mainly focussed on the overloaded setters. So it would be better to have that as the single component in the test setup.

Then concerning the test itself. Currently it just tests if it compiles. You do nothing to check the value inside the resulting object. This feels like it would be the same as having no code inside the test method. I believe it would be better to also test if the resulting value is as wanted. Perhaps also test the reverse mapping as it is present to see if you get something that is equal to the original object back.

Next it would be nice to have an unhappy-flow test, an overloaded situation where there is still no match for the types. The expectation here would be the compilation error that is normally thrown when you need to supply a mapping method yourself.

@velo
Copy link
Author

velo commented Sep 21, 2022

Hi @Zegveld thank you for your feedback.

Based on that, I simplified the original tests provided by alex.

Also added the unhappy path.

Please take a look and lemme know what you think

Cheers

@velo
Copy link
Author

velo commented Sep 21, 2022

build failed with

Error:  COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
Error:  /home/runner/work/mapstruct/mapstruct/integrationtest/target/tmp/org.mapstruct.itest.tests.freeBuilderBuilderTest/javac/src/main/java/org/mapstruct/itest/freebuilder/PersonMapper.java:[17,12] Several possible source properties for target property "address".

I didn't touched that, in any case, I will merge latest master into my fork and see if helps

@filiphr filiphr mentioned this pull request May 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants