We have some APIs where we only need to hit one external api and the format is as below. However there are also cases when we need to hit a couple more external services.
How to maintain sequence in those cases? One call after another repeating the mock as well as actual hitting the controller API?
@Test
public void testSomething() throws Exception {
mocoServer.request(endsWith(uri("/sample-endpoint")))
.response(with(sampleResponse), status(STATUS_CODE_200), header(contentType ,contentTypeJsonUtf));
running(mocoServer, () -> {
//Test case fails without the below delay
TimeUnit.SECONDS.sleep(2);
Response svResponse = restAssuredAssistantAPIPOST(STATUS_CODE_400, dataUrl,
dataHappyRequestBody);
assertEquals(STATUS_CODE_400, svResponse.getStatusCode());
});
}
We have some APIs where we only need to hit one external api and the format is as below. However there are also cases when we need to hit a couple more external services.
How to maintain sequence in those cases? One call after another repeating the mock as well as actual hitting the controller API?