@Test public void testGetAgent() throws Exception { final Agent expectedAgent = allAgents.stream().findAny().get(); final String expectedJson = toJson(expectedAgent).toJSONString(); String result = given().pathParam("agentId", expectedAgent.getName()).expect().statusCode(SC_OK).when() .get(env.host("{agentId}")).asString(); assertThat(result, SameJSONAs.sameJSONAs(expectedJson).allowingAnyArrayOrdering()); }
@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) } ) public Response getAgent( @HeaderParam("Accept") String acceptHeader, @PathParam("agentId") String id) throws Exception { final Agent agent = agentStateService.getAgent(id); if (agent == null) { return ApiResponses.notFound("Cannot find an agent with id '%s'.", id); } return ApiResponses.Json.ok(acceptHeader, generateJsonAgent(agent)); }
CaptureAgentsEndpoint { @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) } ) public Response getAgent( @HeaderParam("Accept") String acceptHeader, @PathParam("agentId") String id) throws Exception { final Agent agent = agentStateService.getAgent(id); if (agent == null) { return ApiResponses.notFound("Cannot find an agent with id '%s'.", id); } return ApiResponses.Json.ok(acceptHeader, generateJsonAgent(agent)); } }
CaptureAgentsEndpoint { @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) } ) public Response getAgent( @HeaderParam("Accept") String acceptHeader, @PathParam("agentId") String id) throws Exception { final Agent agent = agentStateService.getAgent(id); if (agent == null) { return ApiResponses.notFound("Cannot find an agent with id '%s'.", id); } return ApiResponses.Json.ok(acceptHeader, generateJsonAgent(agent)); }  }
CaptureAgentsEndpoint { @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) } ) public Response getAgent( @HeaderParam("Accept") String acceptHeader, @PathParam("agentId") String id) throws Exception { final Agent agent = agentStateService.getAgent(id); if (agent == null) { return ApiResponses.notFound("Cannot find an agent with id '%s'.", id); } return ApiResponses.Json.ok(acceptHeader, generateJsonAgent(agent)); }  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); }
CaptureAgentsEndpoint { @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) } ) public Response getAgent( @HeaderParam("Accept") String acceptHeader, @PathParam("agentId") String id) throws Exception { final Agent agent = agentStateService.getAgent(id); if (agent == null) { return ApiResponses.notFound("Cannot find an agent with id '%s'.", id); } return ApiResponses.Json.ok(acceptHeader, generateJsonAgent(agent)); }  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);  }