I have a class of services that will receive a dependency injection of an object responsible for the persistence layer. In this service class are all my methods that will respond to the REST call of the web service.
The problem is:
I would need to test the service class, calling the path's web service REST, but I would need to mock the dependency injection of the persistence part, because at this point I just want to test the service layer. All this using junit and mockito, at most using something like spring. Would you like to hear from your colleagues if this is possible? If so, what am I supposed to do?
Below is an example:
@Path("/servico")
public class Servico() {
Persistencia persistencia;
@GET
@Path("/get")
@Produces("application/json")
public Response get(long id) {
Entidade entidade = persistencia.get(id);
return Response.ok().entity(entidade).build();
}
}