Skip to content

How to configure moco calls when one or more API is hit? #348

@ahsanbagwan

Description

@ahsanbagwan

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());

    });
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions