title: How to test a method call in other method in Java Mockito?
body: <p>How to test with Mockito that some method was called in other method? In my case it's Collections.reverse(tasks) in a class below:</p>
  <p>My class:</p>
  <pre><code>public class TaskReadService {
  
  private final TaskRepository repository;
  
  public TaskReadService(TaskRepository repository) {
      this.repository = repository;
  }
  
  public List&lt;Task&gt; readAllOrdered(TasksListOrder order) {
    
      var tasks = repository.readAll();       
  
      if (order.equals(TasksListOrder.BY_STATUS)) {
  
          tasks.sort(Comparator.comparing(jpaEntity -&gt; jpaEntity.status));
      }
  
      if (order.equals(TasksListOrder.BY_PRIORITY)) {
  
          tasks.sort(Comparator.comparing(jpaEntity -&gt; jpaEntity.priority));
      }
  
      Collections.reverse(tasks);
  
      return tasks;
  }}
  </code></pre>