jeudi 26 mars 2015

How to mock a service or stub a service method in a Spring Boot filter using Spock?

Currently i have a filter in my Spring Boot application that uses a Spring service to do some of the heavy lifting stuff..



public class HmacAuthenticationFilter implements Filter {

@Autowired
MyService myservice

public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
myservice.callMethod();
}
}


In my Spock test I would like to mock the entire service that the filter uses a stub the myservice.callMethod(); to return a specific value.


Any hints on how this could be done?


Aucun commentaire:

Enregistrer un commentaire