We have a system that we send notification asynchronously to users under certain conditions. We also keep the notifications in a DB repository.
We want to write a test to ensure that if the notification conditions are not satisfied, notification is not sent. In that case no entry is written to DB (notifications repository).
As an ad-hoc solution we check the Notification Repository to see whether the notification is sent or not. However, a notification might have been sent even if it is not present in the repository at the time we check since sending notification happens asynchronously.
Is there a proper way to wait all async tasks are completed before checking Notif. Repository?
Note: We handle the converse (notifications should be send) rather easily with awaitility by checking the notif. repo. every 100 ms until the notification has reached timeout of 60 seconds reached.