I have a very specific situation in an integration test.
I'm developing a Rest API composed by few micro services using spring boot. Some of those services have basically crud operations to be accessed by an UI application or to be consumed into internal validations/queries.
All the database manipulation is done through procedures by a legacy library (no jpa) and I'm using a non-standard database. I know that the good practices say to do not use real databases, but in this scenario, I cannot imagine how to use a dummy databases in the test time (like dbunit or h2). In this way:
1 - Is it ok to hit the real database in an integration test?
If 1 is ok, I have another question:
Usually, we do not change the data state in unit/integration tests; and the tests should be independent of each other.
However, in my case, I only know what is the entity id in the response of the post method, making difficult to implement the get/put/delete methods. Of course in the get/put/delete methods I can first insert and then make the another operation, but in this perspective, at the end, I will have a database in a different state of the beginning of the test. In this way, my another question is:
2 - How can I recover the database to the same status before the tests?
I know that it could be a specific situation but I really appreciate any help to find an elegant way of testing this scenario.
Thanks in advance.