March 2018
Intermediate to advanced
324 pages
8h 30m
English
We can unify the launchers by accepting a BooksEndpoint dependency. If we don't specify it, it will register the dependency with the real instance of BooksRepository. Otherwise, it will register the received one:
public class MyApplication
extends ResourceConfig {
public MyApplication() {
this(new BooksEndpoint(
new BooksRepository()));
}
public MyApplication
(BooksEndpoint booksEndpoint) {
register(booksEndpoint);
register(RequestContextFilter.class);
register(JacksonJaxbJsonProvider.class);
register(CustomExceptionMapper.class);
}
}
In this case, we have opted for constructor chaining to avoid repetition in the constructors.
After doing this refactor, the BooksEndpointInteractionTest class is as follows in ...
Read now
Unlock full access