How to remove `Thread.sleep(1000)` and start secon...
# spring
q
How to remove
Thread.sleep(1000)
and start second part of test, right directly after launch will be complited?
c
With this specific example, I would modify getResult to do limited number of retries with each uuid it could not find outright and then throw or return error result if UUID has not been found after the last retry.
q
oh i see. will try that way
c
something like this:
Copy code
fun getResult(uuid: UUID) {
    return source.tryGetUuidResult(
        id = uuid,
        maxRetries = 3,
        retryStrategy = ConstantRetryStrategy(ms = 500)
    )
}
This only makes sense if your actual usage will be similar, I mean very short delay between create and retrieve. Another (arguably better) way to do that though would be returning result from the post mapping itself.
If your application does not work that way though, you're better off with what you got. It does look a bit dirty and can break if your test server is overloaded, but is more realistic. You could implement retry in your tests to mitigate that.
i
Hi @Czar Please what Class/API do you use to achieve this
Copy code
source.tryGetUuidResult(
        id = uuid,
        maxRetries = 3,
        retryStrategy = ConstantRetryStrategy(ms = 500)
    )
?
c
It's just an illustration of the idea. It's not a specific API. You can either implement it yourself or use some retry library. I don't remember any from the top of my head aside from EIP implementations like Spring-integration or Camel, but those are an overkill for such a simple task.
i
Ook, thanks! Thought it was in built with Spring Boot APIs
d