PaginationUtil { public static HttpHeaders generatePaginationHttpHeaders(Page<?> page) { return new HttpHeaders() {{ add("X-Total-Count", Long.toString(page.getTotalElements())); }}; } private  PaginationUtil(); static HttpHeaders generatePaginationHttpHeaders(Page<?> page);  }
@Test public void generatePaginationHttpHeadersTest() { Page<String> page = new PageImpl<>(new ArrayList<>(), PageRequest.of(6, 50), 400L); HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page); List<String> xTotalCountHeaders = headers.get("X-Total-Count"); assertEquals(1, xTotalCountHeaders.size()); assertEquals(400L, Long.valueOf(xTotalCountHeaders.get(0)).longValue()); }