@Test @Order(1) public void testAll() { List<Employee> employees = given() .contentType(ContentType.JSON) .when().get("/all").as(new TypeRef<List<Employee>>() {}); assertThat(employees, hasSize(5)); assertThat(employees.get(0).getId(), equalTo(1L)); assertThat(employees.get(0).getName(), equalTo("Penny")); assertThat(employees.get(1).getId(), equalTo(2L)); assertThat(employees.get(1).getName(), equalTo("Sheldon")); assertThat(employees.get(2).getId(), equalTo(3L)); assertThat(employees.get(2).getName(), equalTo("Amy")); assertThat(employees.get(3).getId(), equalTo(4L)); assertThat(employees.get(3).getName(), equalTo("Leonard")); assertThat(employees.get(4).getId(), equalTo(5L)); assertThat(employees.get(4).getName(), equalTo("Bernadette")); }
@GET @Path("{id}") @Produces("application/json") public CompletionStage<Response> get(@PathParam("id") long id) { return employee.get(id) .thenApply(employee -> employee != null ? Response.ok(employee) : Response.status(Response.Status.NOT_FOUND)) .thenApply(Response.ResponseBuilder::build); }
EmployeeResource { @GET @Path("{id}") @Produces("application/json") public CompletionStage<Response> get(@PathParam("id") long id) { return employee.get(id) .thenApply(employee -> employee != null ? Response.ok(employee) : Response.status(Response.Status.NOT_FOUND)) .thenApply(Response.ResponseBuilder::build); } }
EmployeeResource { @GET @Path("{id}") @Produces("application/json") public CompletionStage<Response> get(@PathParam("id") long id) { return employee.get(id) .thenApply(employee -> employee != null ? Response.ok(employee) : Response.status(Response.Status.NOT_FOUND)) .thenApply(Response.ResponseBuilder::build); }  }
EmployeeResource { @GET @Path("{id}") @Produces("application/json") public CompletionStage<Response> get(@PathParam("id") long id) { return employee.get(id) .thenApply(employee -> employee != null ? Response.ok(employee) : Response.status(Response.Status.NOT_FOUND)) .thenApply(Response.ResponseBuilder::build); }  @GET @Path("all") @Produces("application/json") CompletionStage<List<Employee>> getAll(); @GET @Path("{id}") @Produces("application/json") CompletionStage<Response> get(@PathParam("id") long id); @POST CompletionStage<Response> register(@QueryParam("name") String name); @DELETE @Path("{id}") CompletionStage<Response> resign(@PathParam("id") long id); }
EmployeeResource { @GET @Path("{id}") @Produces("application/json") public CompletionStage<Response> get(@PathParam("id") long id) { return employee.get(id) .thenApply(employee -> employee != null ? Response.ok(employee) : Response.status(Response.Status.NOT_FOUND)) .thenApply(Response.ResponseBuilder::build); }  @GET @Path("all") @Produces("application/json") CompletionStage<List<Employee>> getAll(); @GET @Path("{id}") @Produces("application/json") CompletionStage<Response> get(@PathParam("id") long id); @POST CompletionStage<Response> register(@QueryParam("name") String name); @DELETE @Path("{id}") CompletionStage<Response> resign(@PathParam("id") long id);  }