@Test public void testGetAllPosts() throws Exception { String path = "/posts"; WebTarget targetGetAll = client.target(URI.create("http: try (Response resGetAll = targetGetAll.request().accept(MediaType.APPLICATION_JSON_TYPE).get()) { assertEquals(200, resGetAll.getStatus()); List<Post> results = resGetAll.readEntity(new GenericType<List<Post>>() {}); assertTrue(results != null); LOGGER.info("results.size()::" + results.size()); assertTrue(results.size() == 2); } }
private void getAllPosts(ServerRequest serverRequest, ServerResponse serverResponse) { this.posts.all() .thenApply(EntityUtils::toJsonArray) .thenCompose(data -> serverResponse.send(data)) .exceptionally(throwable -> { LOGGER.log(Level.WARNING, "Failed to getAllPosts", throwable); serverRequest.next(throwable); return null; }); }
PostService implements Service { private void getAllPosts(ServerRequest serverRequest, ServerResponse serverResponse) { this.posts.all() .thenApply(EntityUtils::toJsonArray) .thenCompose(data -> serverResponse.send(data)) .exceptionally(throwable -> { LOGGER.log(Level.WARNING, "Failed to getAllPosts", throwable); serverRequest.next(throwable); return null; }); } }
PostService implements Service { private void getAllPosts(ServerRequest serverRequest, ServerResponse serverResponse) { this.posts.all() .thenApply(EntityUtils::toJsonArray) .thenCompose(data -> serverResponse.send(data)) .exceptionally(throwable -> { LOGGER.log(Level.WARNING, "Failed to getAllPosts", throwable); serverRequest.next(throwable); return null; }); } PostService(PostRepository posts, CommentRepository comments); }
PostService implements Service { private void getAllPosts(ServerRequest serverRequest, ServerResponse serverResponse) { this.posts.all() .thenApply(EntityUtils::toJsonArray) .thenCompose(data -> serverResponse.send(data)) .exceptionally(throwable -> { LOGGER.log(Level.WARNING, "Failed to getAllPosts", throwable); serverRequest.next(throwable); return null; }); } PostService(PostRepository posts, CommentRepository comments); @Override void update(Routing.Rules rules); }
PostService implements Service { private void getAllPosts(ServerRequest serverRequest, ServerResponse serverResponse) { this.posts.all() .thenApply(EntityUtils::toJsonArray) .thenCompose(data -> serverResponse.send(data)) .exceptionally(throwable -> { LOGGER.log(Level.WARNING, "Failed to getAllPosts", throwable); serverRequest.next(throwable); return null; }); } PostService(PostRepository posts, CommentRepository comments); @Override void update(Routing.Rules rules);  }