CaptureAgentsEndpoint { @GET @Path("/") @RestQuery( name = "getagents", description = "Returns a list of agents.", returnDescription = "", restParameters = { @RestParameter(name = "limit", description = "The maximum number of results to return for a single request.", isRequired = false, type = Type.INTEGER), @RestParameter(name = "offset", description = "The index of the first result to return.", isRequired = false, type = Type.INTEGER) }, responses = { @RestResponse(description = "A (potentially empty) list of agents is returned.", responseCode = HttpServletResponse.SC_OK) } ) public Response getAgents( @HeaderParam("Accept") String acceptHeader, @QueryParam("offset") Integer offset, @QueryParam("limit") Integer limit) { List<Agent> agents = new ArrayList<>(agentStateService.getKnownAgents().values()); if (offset != null && offset > 0) { agents = agents.subList(Math.min(offset, agents.size()), agents.size()); } if (limit != null && limit > 0) { agents = agents.subList(0, Math.min(limit, agents.size())); } final List<JValue> agentsJSON = agents.stream() .map(a -> generateJsonAgent(a)) .collect(Collectors.toList()); return ApiResponses.Json.ok(acceptHeader, arr(agentsJSON)); }  CaptureAgentStateService getAgentStateService(); void setAgentStateService(CaptureAgentStateService agentStateService); @GET @Path("{agentId}") @RestQuery( name = "getagent", description = "Returns a single capture agent.", returnDescription = "", pathParameters = { @RestParameter(name = "agentId", description = "The agent id", isRequired = true, type = STRING) }, responses = { @RestResponse(description = "The agent is returned.", responseCode = HttpServletResponse.SC_OK), @RestResponse(description = "The specified agent does not exist.", responseCode = HttpServletResponse.SC_NOT_FOUND) } ) Response getAgent(
      @HeaderParam("Accept") String acceptHeader,
      @PathParam("agentId") String id); @GET @Path("/") @RestQuery( name = "getagents", description = "Returns a list of agents.", returnDescription = "", restParameters = { @RestParameter(name = "limit", description = "The maximum number of results to return for a single request.", isRequired = false, type = Type.INTEGER), @RestParameter(name = "offset", description = "The index of the first result to return.", isRequired = false, type = Type.INTEGER) }, responses = { @RestResponse(description = "A (potentially empty) list of agents is returned.", responseCode = HttpServletResponse.SC_OK) } ) Response getAgents(
      @HeaderParam("Accept") String acceptHeader,
      @QueryParam("offset") Integer offset,
      @QueryParam("limit") Integer limit);  }
@Test public void testGetAgents() { final String expectedJson = toJson(allAgents).toJSONString(); String result = given().expect().statusCode(SC_OK).when().get(env.host("")).asString(); assertThat(result, SameJSONAs.sameJSONAs(expectedJson).allowingAnyArrayOrdering()); }