TaskResource { @GET @Path("/{taskId}") @ApiOperation("Get task by Id") @Consumes(MediaType.WILDCARD) public Task getTask(@PathParam("taskId") String taskId) { return taskService.getTask(taskId); } @Inject  TaskResource(TaskService taskService); @GET @Path("/poll/{tasktype}") @ApiOperation("Poll for a task of a certain type") @Consumes({MediaType.WILDCARD}) Task poll(@PathParam("tasktype") String taskType,
					 @QueryParam("workerid") String workerId,
					 @QueryParam("domain") String domain); @GET @Path("/poll/batch/{tasktype}") @ApiOperation("batch Poll for a task of a certain type") @Consumes({MediaType.WILDCARD}) List<Task> batchPoll(@PathParam("tasktype") String taskType,
								@QueryParam("workerid") String workerId,
								@QueryParam("domain") String domain,
								@DefaultValue("1") @QueryParam("count") Integer count,
								@DefaultValue("100") @QueryParam("timeout") Integer timeout); @GET @Path("/in_progress/{tasktype}") @ApiOperation("Get in progress tasks. The results are paginated.") @Consumes({MediaType.WILDCARD}) List<Task> getTasks(@PathParam("tasktype") String taskType,
							   @QueryParam("startKey") String startKey,
							   @QueryParam("count") @DefaultValue("100") Integer count); @GET @Path("/in_progress/{workflowId}/{taskRefName}") @ApiOperation("Get in progress task for a given workflow id.") @Consumes({MediaType.WILDCARD}) Task getPendingTaskForWorkflow(@PathParam("workflowId") String workflowId,
										  @PathParam("taskRefName") String taskReferenceName); @POST @ApiOperation("Update a task") @Produces({MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON}) String updateTask(TaskResult taskResult); @POST @Path("/{taskId}/ack") @ApiOperation("Ack Task is received") @Consumes({MediaType.WILDCARD}) String ack(@PathParam("taskId") String taskId,
					  @QueryParam("workerid") String workerId); @POST @Path("/{taskId}/log") @ApiOperation("Log Task Execution Details") void log(@PathParam("taskId") String taskId, String log); @GET @Path("/{taskId}/log") @ApiOperation("Get Task Execution Logs") List<TaskExecLog> getTaskLogs(@PathParam("taskId") String taskId); @GET @Path("/{taskId}") @ApiOperation("Get task by Id") @Consumes(MediaType.WILDCARD) Task getTask(@PathParam("taskId") String taskId); @DELETE @Path("/queue/{taskType}/{taskId}") @ApiOperation("Remove Task from a Task type queue") @Consumes({MediaType.WILDCARD}) void removeTaskFromQueue(@PathParam("taskType") String taskType,
									@PathParam("taskId") String taskId); @GET @Path("/queue/sizes") @ApiOperation("Get Task type queue sizes") @Consumes({MediaType.WILDCARD}) Map<String, Integer> size(@QueryParam("taskType") List<String> taskTypes); @GET @Path("/queue/all/verbose") @ApiOperation("Get the details about each queue") @Consumes({MediaType.WILDCARD}) Map<String, Map<String, Map<String, Long>>> allVerbose(); @GET @Path("/queue/all") @ApiOperation("Get the details about each queue") @Consumes({MediaType.WILDCARD}) Map<String, Long> all(); @GET @Path("/queue/polldata") @ApiOperation("Get the last poll data for a given task type") @Consumes({MediaType.WILDCARD}) List<PollData> getPollData(@QueryParam("taskType") String taskType); @GET @Path("/queue/polldata/all") @ApiOperation("Get the last poll data for all task types") @Consumes(MediaType.WILDCARD) List<PollData> getAllPollData(); @POST @Path("/queue/requeue") @ApiOperation("Requeue pending tasks for all the running workflows") String requeue(); @POST @Path("/queue/requeue/{taskType}") @ApiOperation("Requeue pending tasks") @Consumes(MediaType.WILDCARD) @Produces({ MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON }) String requeuePendingTask(@PathParam("taskType") String taskType); @ApiOperation(value="Search for tasks based in payload and other parameters", notes="use sort options as sort=<field>:ASC|DESC e.g. sort=name&sort=workflowId:DESC." + " If order is not specified, defaults to ASC") @GET @Consumes(MediaType.WILDCARD) @Produces(MediaType.APPLICATION_JSON) @Path("/search") SearchResult<TaskSummary> search(@QueryParam("start") @DefaultValue("0") int start,
											@QueryParam("size") @DefaultValue("100") int size,
											@QueryParam("sort") String sort,
											@QueryParam("freeText") @DefaultValue("*") String freeText,
											@QueryParam("query") String query); @GET @ApiOperation("Get the external uri where the task payload is to be stored") @Consumes(MediaType.WILDCARD) @Path("/externalstoragelocation") ExternalStorageLocation getExternalStorageLocation(@QueryParam("path") String path, @QueryParam("operation") String operation, @QueryParam("payloadType") String payloadType);  }
@Test public void testGetTask() throws Exception { Task task = new Task(); task.setTaskType("SIMPLE"); task.setWorkerId("123"); task.setDomain("test"); task.setStatus(Task.Status.IN_PROGRESS); when(mockTaskService.getTask(anyString())).thenReturn(task); assertEquals(task, taskResource.getTask("123")); }