Pull request to fix the issue: #655 - #908
andreconrado wants to merge 6 commits into
Conversation
…arity. - Unwrap `UndeclaredThrowableException` for proxy-related exceptions. - Unwrap `InvocationTargetException` for reflection-related exceptions. - Add null-safe handling for exception messages. - Improve readability of PostgreSQL-specific checks. - Improve readability of SQL Server-specific checks. - Ensure compatibility with standard JDBC constraint violations.
|
Hey @andreconrado . This looks great. Could you add a cross-dialect test for this? Adding it to |
|
Is this actually to fix #655 ? |
|
Yes, sorry, I had it wrong in the title and description, I copied the wrong link 😁 |
|
Hi @badgerwithagun, I only added some validations before checking the source of the Exception, so the existing tests should confirm that my changes work - or at least don’t affect what was already there. In this case, do I need to change the tests? |
|
It's pretty straightforward; I'm happy to help. Obviously for the existing scenarios we have this test. You've added support for wrapped exceptions, so all we need to do is create a version of that test which causes the exception to be wrapped. First thing I would try is something like this. In this new test, copy the existing one but change: To This should result in any exceptions in the |
|
Hi @badgerwithagun, thanks for the tips! I think I’ll still need your help. The line The |
|
Hi again @badgerwithagun, To be able to run the test, we need to change the dependency from: <dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.10.19</version>
<scope>test</scope>
</dependency>to: <dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>5.19.0</version>
<scope>test</scope>
</dependency>Are you interested in making this change? Is it worth it just for this test? Thanks. |
|
Hi again @badgerwithagun , Have you been able to look into this situation? Thanks. |
|
Are we on a really old Mockito? Yes quite happy to update. |
mocking - Add testInsertDuplicateException to AbstractPersistorTest - Refine static imports for clarity and explicitness - Import Mockito and related classes for test mocking - Add mock-maker-inline to Mockito extensions for inline mocking - Ensure duplicate entry throws AlreadyScheduledException - Minor formatting and import optimizations
|
Having a more recent version normally is always better, but I’m not sure it’s worth doing it just for these tests. I’ve merged the latest changes, and this PR no longer has any conflicts. |
|
Hi again @badgerwithagun , Have you been able to look into this situation? Thanks. |
|
Hi @andreconrado , apologies for letting this gather dust.
Each implementation specifies the Rather than messing around with mocking final classes (which is a debatable pattern) I suggest you:
with a transaction manager that displays the error you are trying to protect against. The key thing here is to start from whatever mistake a developer might make, simulate that mistake and work backwards from there. |
|
Closing stale PR |
Pull request to fix the issue: #655
Refactor
indexViolationto handle wrapped exceptions and improve clarity.UndeclaredThrowableExceptionfor proxy-related exceptions.InvocationTargetExceptionfor reflection-related exceptions.