Here's the JAX-RS equivalent of the demo:
public class GreetingResource {
@POST
@Path("/make-greeting")
public MakeGreetingResponse greet(final MakeGreetingRequest request) {
if (request.addendum.isPresent()) {
return new MakeGreetingResponse("Hello, " + request.name + "! " + request.addendum.getValue());
} else {
return new MakeGreetingResponse("Hello, " + request.name + "!");
}
}
}
This is less noisy (no explicit parseBody) and much easier to test - you can just instantiate a GreetingResource and call the method, no mocking required.