Search in sources :

Example 6 with JsonVerifiable

use of com.toomuchcoding.jsonassert.JsonVerifiable in project wiremock by wiremock.

the class AdminApiTest method getLoggedRequestsWithLimitAndSinceDate.

@Test
public void getLoggedRequestsWithLimitAndSinceDate() throws Exception {
    for (int i = 1; i <= 5; i++) {
        testClient.get("/received-request/" + i);
    }
    String midPoint = new ISO8601DateFormat().format(new Date());
    for (int i = 6; i <= 9; i++) {
        testClient.get("/received-request/" + i);
    }
    String body = testClient.get("/__admin/requests?since=" + midPoint + "&limit=3").content();
    JsonVerifiable check = JsonAssertion.assertThat(body);
    check.field("meta").field("total").isEqualTo(9);
    check.field("requests").hasSize(3);
    check.field("requests").elementWithIndex(0).field("request").field("url").isEqualTo("/received-request/9");
    check.field("requests").elementWithIndex(2).field("request").field("url").isEqualTo("/received-request/7");
}
Also used : ISO8601DateFormat(com.fasterxml.jackson.databind.util.ISO8601DateFormat) JsonVerifiable(com.toomuchcoding.jsonassert.JsonVerifiable) Date(java.util.Date) Test(org.junit.jupiter.api.Test)

Aggregations

JsonVerifiable (com.toomuchcoding.jsonassert.JsonVerifiable)6 Test (org.junit.jupiter.api.Test)6 WireMockResponse (com.github.tomakehurst.wiremock.testsupport.WireMockResponse)2 ISO8601DateFormat (com.fasterxml.jackson.databind.util.ISO8601DateFormat)1 ServeEvent (com.github.tomakehurst.wiremock.stubbing.ServeEvent)1 Date (java.util.Date)1 UUID (java.util.UUID)1