@SuppressWarnings("unchecked")
  public List<FilesListRecursiveItem> listRecursive(String path)
      throws IOException, InvalidTokenException {
    String url;
    try {
      URIBuilder builder =
          getUriBuilder()
              .setPath(CONTENT_API_PATH_PREFIX + "/mounts/primary/files/listrecursive")
              .setParameter("path", path);
      url = builder.build().toString();
    } catch (URISyntaxException e) {
      throw new IllegalStateException("Could not produce url.", e);
    }

    Request.Builder requestBuilder = getRequestBuilder(url).get();

    try (Response response = getResponse(requestBuilder)) {
      int code = response.code();
      if (code == 404) {
        return ImmutableList.of();
      }
      ResponseBody body = response.body();
      if (code < 200 || code > 299) {
        throw new KoofrClientIOException(response);
      }

      try (final Reader bodyReader =
              new InputStreamReader(body.byteStream(), StandardCharsets.UTF_8);
          final BufferedReader bufferedBodyReader = new BufferedReader(bodyReader); ) {
        String line;
        List<FilesListRecursiveItem> items = new ArrayList<FilesListRecursiveItem>();
        while ((line = bufferedBodyReader.readLine()) != null) {
          items.add(objectMapper.readValue(line, FilesListRecursiveItem.class));
        }
        return items;
      }
    }
  }
@Test
  public void testListRecursiveNotFound() throws Exception {
    server.enqueue(
        new MockResponse()
            .setResponseCode(404)
            .setHeader("Content-Type", "application/json")
            .setBody(
                "{\"error\":{\"code\":\"NotFound\",\"message\":\"File not found\"},\"requestId\":\"bad2465e-300e-4079-57ad-46b256e74d21\"}"));

    List<FilesListRecursiveItem> items = client.listRecursive("/Data transfer");

    assertEquals(ImmutableList.of(), items);
  }