@Test public void testGetAll() { List<Task> expectedTasks = Collections.singletonList(task1); when(taskService.getAll()).thenReturn(expectedTasks); Collection<Task> tasks = taskRes.getTasks(); assertThat(tasks, contains(task1)); }
@Operation(description = "Get all tasks") @GET @Produces(MediaType.APPLICATION_JSON) public Collection<Task> getTasks() { if (this.counter != null) { this.counter.inc(); } return taskService.getAll(); }
TaskResource { @Operation(description = "Get all tasks") @GET @Produces(MediaType.APPLICATION_JSON) public Collection<Task> getTasks() { if (this.counter != null) { this.counter.inc(); } return taskService.getAll(); } }
TaskResource { @Operation(description = "Get all tasks") @GET @Produces(MediaType.APPLICATION_JSON) public Collection<Task> getTasks() { if (this.counter != null) { this.counter.inc(); } return taskService.getAll(); } TaskResource(TaskService taskService, MetricRegistry metricRegistry); }
TaskResource { @Operation(description = "Get all tasks") @GET @Produces(MediaType.APPLICATION_JSON) public Collection<Task> getTasks() { if (this.counter != null) { this.counter.inc(); } return taskService.getAll(); } TaskResource(TaskService taskService, MetricRegistry metricRegistry); @Operation(summary = "Get single task by id", description = "Get single task by id") @GET @Path("{id}") Response getTask(@PathParam("id") Integer id); @Operation(description = "Add task") @POST Response addTask(Task task); @Operation(description = "Get all tasks") @GET @Produces(MediaType.APPLICATION_JSON) Collection<Task> getTasks(); @Operation(description = "Change task") @PUT @Path("{id}") void updateTask(@PathParam("id") Integer id, Task task); @Operation(description = "Delete task") @DELETE @Path("{id}") void deleteTask(@PathParam("id") Integer id); }
TaskResource { @Operation(description = "Get all tasks") @GET @Produces(MediaType.APPLICATION_JSON) public Collection<Task> getTasks() { if (this.counter != null) { this.counter.inc(); } return taskService.getAll(); } TaskResource(TaskService taskService, MetricRegistry metricRegistry); @Operation(summary = "Get single task by id", description = "Get single task by id") @GET @Path("{id}") Response getTask(@PathParam("id") Integer id); @Operation(description = "Add task") @POST Response addTask(Task task); @Operation(description = "Get all tasks") @GET @Produces(MediaType.APPLICATION_JSON) Collection<Task> getTasks(); @Operation(description = "Change task") @PUT @Path("{id}") void updateTask(@PathParam("id") Integer id, Task task); @Operation(description = "Delete task") @DELETE @Path("{id}") void deleteTask(@PathParam("id") Integer id);  }