I have an event-driven framework with event handlers that might perform a write in a DB, through Hibernate. I would need to write integration tests, but I have no idea on how one can make it.
In fact, when one condition occurs, an event handler is triggered in a different thread, and this writes on the DB. How can I say that that write operation should be rolled back ?
If you want to make some asynchronous tests, take a look at Awaitility.
I have used it, and it does the job quite well 🙂
But if you want to rollback your write operations, you’ll have to get the transaction in the proper thread.