We were having integration test without saga implementation in place, it was working fine.
Once saga is introduced, saga is working as expected on first test. any subsequent tests are not working as expected if saga is involved.
We are cleaning up database and purge axon events before each test method invocation
ex. restClient.delete(format("http://localhost:%d/v1/devmode/purge-events", axonPort));
When we run application saga is working as expected. Only integration test has this problem.
Do you have any recommendation to overcome this problem.
What is used for the saga store in the integration tests? For example, if a JPA Sagastore is used with an h2 database, you likely also need to clean up the saga store table in the cleanup. Currently, you remove the events but not necessarily the sagas created based on those events.
Thanks Gerard for looking into this and for your immediate response.
We are using JPA and we are cleaning up database on every test using DbRider @DataSet(cleanBefore = true)
I don’t think you need to do something else, but I haven’t used DBRider. I did notice in a Spring Boot example, they auto wired the repositories used. So I think you might need to do something similar, so that the saga store is indeed cleaned up.