-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Feature/2955 #3010
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
Feature/2955 #3010
Conversation
processor/src/main/java/org/mapstruct/ap/internal/model/LifecycleMethodResolver.java
Outdated
Show resolved
Hide resolved
processor/src/main/java/org/mapstruct/ap/internal/model/source/selector/TypeSelector.java
Outdated
Show resolved
Hide resolved
|
So basically this entire PR is changing 1 method call and a lot of tests to make certain it works as expected. |
filiphr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR needs a bit of clean up before we can merge it.
I see that we have some tests which are testing that stack overflow errors are thrown. I do not believe that we should have such tests. It is enough to have a test which fails without the fixes and it is green after we fix it.
I also see that we are modifying some existing tests such as the NumberMapperContext and removing certain things from the NumberMapperWithContext. I think that we should not remove nor update existing things and only add new fresh tests. If something is failing with the new changes then the changes are most likely not right.
…ges to the test setup. (Keep the boyscouting changes though.)
Looking at the tests again, the tests in the cycles package can be removed.
The test added here is actually the correct one. Did some clean-up so that this becomes better visible. |
|
It looks much cleaner now @Zegveld, thanks. I played around with this and I can actually recommend simplifying it a bit more. Looking at the generated code we actually have 2 methods that will be called:
If we change the test case to look something like: @ProcessorTest
void numberUpdateMappingWithContextCallsCache() {
Number target = new Number();
NumberMapperWithContext.INSTANCE.integerToNumber( 2342, target );
try {
assertThat( NumberMapperContext.getVisited() ).containsExactly( target );
NumberMapperContext.clearVisited();
NumberMapperContext.putCache( target );
NumberMapperWithContext.INSTANCE.integerToNumber( 25342, target );
assertThat( NumberMapperContext.getVisited() ).isEmpty();
}
finally {
NumberMapperContext.clearCache();
NumberMapperContext.clearVisited();
}
}WDYT @Zegveld? |
|
@filiphr that test fails, because the putCache object ends up in a different hash-bucket then the object used for retrieval during getCache. I did change the test somewhat and removed the cache checking. Because I feel that is what you were aiming for. |
|
I had a typo in it @Zegveld. The second call needs to be done with |
… try-finally in each test.
indeed without the typo it passes. The other thing I do not like about that test that it doesn't fit the I moved the clean-up-code into an Feel free to adjust it if you see more room for improvement at the tests, @filiphr |
When collecting lifecycle callback methods also collect the methods with returntype equal to the lifecycle callback result type.
Currently this is only done when no other callback methods are found, perhaps this should always be done.
Fixes #2955