title: Mockito when().thenReturn doesn't give expected result
body: <p>I am new to Junit and Mockito.
  Trying to mock one of the object of the class, but it is not working.
  The mock method is returning an empty list, due to which test case is getting failed.
  This is the code which I have written.</p>
  <p>Junit Test Class : Here I have mocked the object and method to return an Arraylist, but when the code is executed this mock method is returning an empty list due to which test case is getting failed.</p>
  <pre><code>package com.business;
  
  import static org.junit.Assert.*;
  import static org.mockito.Mockito.mock;
  import static org.mockito.Mockito.when;
  
  import java.util.Arrays;
  import java.util.List;
  
  import org.junit.After;
  import org.junit.Before;
  import org.junit.Test;
  import org.mockito.Mockito;
  
  import com.data.api.ToDoService;
  
  public class TodoBusinessImplMockTest {
  
      @Before
      public void setUp() throws Exception {
      }
  
      @After
      public void tearDown() throws Exception {
      }
  
      @Test
      public void testRetrieveTodosRelatedToSpringUsingMock() 
      {
          ToDoService todoServiceMock = mock(ToDoService.class);
          
          List&lt;String&gt; todoList=Arrays.asList(&quot;Learn Spring MVC&quot;, &quot;Learn Spring&quot;,&quot;Learn to Dance&quot;);
          
          Mockito.when(todoServiceMock.retrieveTodos(&quot;Dummy&quot;)).thenReturn(todoList);
          
          TodoBusinessImpl todoBusinessImpl = new TodoBusinessImpl(todoServiceMock);
          
          List&lt;String&gt; todos = todoBusinessImpl.retrieveTodosRelatedToSpring(&quot;Ranga&quot;);
          
          assertEquals(2, todos.size());
      }
  
  }
  </code></pre>
  <p>Interface : ToDoService.java</p>
  <pre><code>package com.data.api;
  
  import java.util.List;
  
  public interface ToDoService {
      public List&lt;String&gt; retrieveTodos(String s);
  } 
  </code></pre>
  <p>TodoBusinessImpl.java</p>
  <pre><code>package com.business;
  
  import java.util.ArrayList;
  import java.util.List;
  
  import com.data.api.ToDoService;
  
  public class TodoBusinessImpl {
      
      private ToDoService todoService;
  
      TodoBusinessImpl(ToDoService todoService) {
          this.todoService = todoService;
      }
  
      public List&lt;String&gt; retrieveTodosRelatedToSpring(String s) {
          List&lt;String&gt; filteredTodos = new ArrayList&lt;String&gt;();
          List&lt;String&gt; allTodos = todoService.retrieveTodos(s);
          for (String todo : allTodos) {
              if (todo.contains(&quot;Spring&quot;)) {
                  filteredTodos.add(todo);
              }
          }
          return filteredTodos;
      }
  }
  </code></pre>