title: Testing a method that returns an Object with Mockito
body: <p>I would like to test <code>makeBooks()</code> method that returns a book object with Mockito.
  So the test will check whether it returns a book object or not. How do I do that?</p>
  
  <p>Below is my factory that produces books. Below that class is my Mockito test class.
  I got an error code saying "I misused the Mockito"</p>
  
  <p>I am learning Mockito by the way. This is neither Homework or assignment. </p>
  
  <pre><code>public class ItemFactory {
      public Items getItems(String itemType)
      {      
          public static Books makeBooks(String bookName,String authorName, int ISBN, int id)
          {
              Books book = new Books(bookName, authorName, ISBN, id);
              return book;
          }
      }
  }
  
  public class TestItemFactory {
      private static final Books books = null;
      private static ItemFactory mockItemFactory;
  
      @BeforeClass
      public static void setUpBeforeClass() throws Exception {
          mockItemFactory = Mockito.mock(ItemFactory.class);
      }
  
      @Test
      public void testShouldReturnObjectBooks(){
          //ItemFactory methodMakeBooks = Mockito.mock(ItemFactory.class) ;
          //Books book = null;// = ItemFactory.makeBooks("Hamlet", "ShakeSpear", 123456, 9);
          //final Class&lt;?&gt; bookClass = Books.class;
          //Mockito.when(methodMakeBooks.makeBooks(null, null, 0, 0)).thenReturn(book);
          Books book = null;
  
          mockItemFactory = Mockito.spy(new ItemFactory());
          Books mockBook = Mockito.mock(Books.class);
          Mockito.when(mockItemFactory.makeBooks(null, null, 0, 0)).thenReturn(book);
          //Mockito.doReturn(mockBook).when(mockItemFactory).makeBooks(null, null, 0, 0);
      }
  }
  </code></pre>