TaskResource { @Operation(description = "Change task") @PUT @Path("{id}") public void updateTask(@PathParam("id") Integer id, Task task) { if (!task.getId().equals(id)) { throw new IllegalStateException("Id from path and content must be the same"); } taskService.addOrUpdate(task); } 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);  }
@Test public void testUpdate() { taskRes.updateTask(1, task1); verify(taskService).addOrUpdate(task1); }
@Test(expected = IllegalStateException.class) public void testUpdateIllegal() { taskRes.updateTask(2, task1); }