@Test
public void getCommitChainWithPaginationAndLinksTest() {

    Response response = target().path("catalogs/" + encode(LOCAL_IRI) + "/records/" + encode(RECORD_IRI)
            + "/branches/" + encode(BRANCH_IRI) + "/commits").queryParam("offset", 1).queryParam("limit", 1)
            .request().get();
    assertEquals(response.getStatus(), 200);
    verify(catalogManager).getCommitChain(vf.createIRI(LOCAL_IRI), vf.createIRI(RECORD_IRI), vf.createIRI(BRANCH_IRI));
    MultivaluedMap<String, Object> headers = response.getHeaders();
    assertEquals(headers.get("X-Total-Count").get(0), "" + COMMIT_IRIS.length);
    Set<Link> links = response.getLinks();
    assertEquals(links.size(), 2);
    links.forEach(link -> {
        assertTrue(link.getUri().getRawPath().contains("catalogs/" + encode(LOCAL_IRI) + "/records/"
                + encode(RECORD_IRI) + "/branches/" + encode(BRANCH_IRI) + "/commits"));
        assertTrue(link.getRel().equals("prev") || link.getRel().equals("next"));
    });
    try {
        JSONArray array = JSONArray.fromObject(response.readEntity(String.class));
        assertEquals(array.size(), 1);
        JSONObject commitObj = array.getJSONObject(0);
        assertTrue(commitObj.containsKey("id"));
        assertEquals(commitObj.getString("id"), COMMIT_IRIS[1]);
    } catch (Exception e) {
        fail("Expected no exception, but got: " + e.getMessage());
    }
}