online-auction-java
online-auction-java copied to clipboard
Using ctx.commandFailed with a subclass of TransportException breaks test
Current state:
- AuctionEntity
- Throws subclass of
TransportException
:BidValidationException
which doesn't implementequals
andhashCode
Test is passing
- Throws subclass of
- PItemEntity
- Use
ctx.commandFailed
withUpdateFailureException
which isn't a subclass of TransportException and implementsequals
andhashCode
Test is also passing - Use
ctx.commandFailed
withNotFound
which is a subclass of TransportException Test is ignored
- Use
- TransactionEntity
We need to tidy up this, whether throwing an exception or using ctx.commandFailed
in all services
Hmmm, this is interesting.
It looks like the TestDriver doesn't capture the exceptions when thrown
(instead of ctx.failed
) and so the exception is not serialized/deserialized. That would explain why tests in AuctionEntity
and TransactionEntity
pass even though the exceptions used in those tests not alway simplement equals
and hashCode
.
This could be an issue. IIRC in actual core code throwing or using ctx.commandFailed
on a remote singleton (PersistentEntity) is captured, serialized and sent back to the invocation point. The driver.issues()
method asserts all messages are serializable but may not be asserting the serializability of the exceptions thrown. 🤔
Oh! Or maybe the common denominator is throwing an exception on a readOnlyCommandhandler
. When no events are emitted (even if a response is returned), the PersistentEntityTestDriver
doesn't verify serialiazablity of messages (responses or exceptions).
Should we raise an issue in lagom/lagom about this?
Should we raise an issue in lagom/lagom about this?
I'd like a double-check with this set of tests to make sure my suspicion is correct. We can raise the issue already and link it back here, I think the four tests listed by @yg-apaza are a great starting point to track and solve the issue.
Is this the same issue? https://github.com/lagom/lagom/issues/783
The creator closed it, but it sounds like he only found a workaround and it is still an actual bug.
Is this the same issue? lagom/lagom#783
It's not the same issue. lagom/lagom#783 is about return types in a scaladsl
service call while this is about serialization checks of arguments, exceptions and returned values in a persistent entity test.
There's an issue now: https://github.com/lagom/lagom/issues/1279