title: Stub an interface
body: <p>I have to build against an interface. To test I need to override 3 methods of an interface.
  I searched for examples but wasn't able to find something that works and is well explained. I don't have a preference regarding a Mocking Framework, just suggest what suits my use case the best. </p>
  
  <p>I need to stub this functionality and do not want to have 400 lines of unused overrides.</p>
  
  <pre><code>public class StubInventory implements Inventory
  {
      private final ItemStack[] contents;
  
      public StubInventory (int size)
      {
           contents = new ItemStack[size];
      }
  
      @Override
      public void setItem (int index, ItemStack item)
      {
           contents[index] = item;
      }
  
      @Override
      public ItemStack getItem (int index)
      {
           return contents[index];
      }
  
      @Override
      public void clear ()
      {
          Arrays.fill(contents, null);
      }
  
      //&lt;-- Insert 400 lines of unused @Override's here        
  
  }
  </code></pre>
  
  <p><strong>Update:</strong></p>
  
  <p>The getters and especially the setters are used by my code and have to work. The values are not predefined. The values will be set by my code and my test code will verify the result.</p>
  
  <pre><code>mockInventory = mock(Inventory.class);
  //Not "nice" but will probably work
  for (int i = 0; i &lt; size * 9; i++)
      when(mockInventory.getItem(i)).thenReturn(contents[i]);
  //This is where the problem is. I need to take item (ItemStack)
  // and set it in my stubbed class. Basically I need to access the parameter.
  for (int i = 0; i &lt; size * 9; i++)
      when(mockInventory.setItem(i, item)).then(contents[i] = item);
  </code></pre>