title: Spring - Unit Test with Mock - How to mock a Custom Collector in a Service unit test
body: <p>I have an annoying problem.</p>
  
  <p>I have a service(used in a RestController) which fetches data from Repository and doing some transformation to fetched data. I use a custom collector in my transformation. So it looks like:</p>
  
  <pre><code>@RestController
  class myController() {
      Service myService
  
      @GetMapping()
      void getResults{
         Collection col = myService.fetch();
         // some file download logic
      }
  
  }
  
  @Service
  class myService() {
  Repository repository
  Collector myCollector
  
      Collection fetch() {
      return repository
          .getSomeResults()
          .stream()
          .collect(Collectors.groupingBy(someKey, myCollector)
          .values();
      }
  
  }
  </code></pre>
  
  <p>Here, when I want to unit test the service method fetch(), I can mock repository but if I want to mock custom collector, I need to stub all 5 methods. Except finishing(), others are quite meaningless to mock.</p>
  
  <p>I don't want to decrease test coverage.
  How should I approach this problem?</p>