0

I'm testing the api - after the request, I check that the values have appeared in the database. A simple example is I'm throwing JSON

   {
    "field_1": "Value_1",
    "field_2": "Value_2",
    "field_3": "Value_3"
    }

And I need to check that these values have appeared in the DataBase. But there is a problem - not all the data has time to appear at the time of verification, that is, I read the database and there are the following fields

  {
    "field_1": null,
    "field_2": "Value_2",
    "field_3": "Value_3"
    }

And after some time, the value field_1 appears.That is, the test fails because there is no value, I manually check the database - the value is there.There's just some kind of delay.

How can I find out before executing a query in the database that the Table has been completely updated?Are there ready-made solutions in Java? The developers told me that they need to make a separate API request that finds out whether the database has been updated or not - but it is very long and expensive. And the best way out for me would be to wait with Thread.sleep for 30 seconds after executing the request, so if nothing has been updated after 30 seconds, then there is definitely some kind of error.

1 Answer 1

0

I'd look to use some sort of retry implementation.

In .NET, I use Polly to, for example, check that the database contains what I want and to retry if not. You can configure how long to wait between retries and how many retries to attempt.

Not sure what there is equivalent for Java but that might be something to investigate.

Not the answer you're looking for? Browse other questions tagged or ask your own question.