title: jMock "unexpected invocation" for a method that I have a oneOf(instance).method() expected
body: <p>I can't seem to figure out what I'm doing wrong here:</p>
  
  <p>This is the method I'm testing:</p>
  
  <pre><code>public List&lt;Mo&gt; filterDuplicatesByName(List&lt;Mo&gt; dbMos) {
      List&lt;String&gt; names = Lists.newArrayList();
      for(Mo mo : dbMos) {
          try {
              String name = mo.getName();
              if(names.contains(name)) {
                  dbMos.remove(mo);
              } else {
                  names.add(name);
              }
          } catch (DataLayerException ex) {
              dbMos.remove(mo);
          }
      }
      return dbMos;
  }
  </code></pre>
  
  <p>And this is my test class:</p>
  
  <pre><code>package com.rondavu.wt.service.recommendations;
  
  import com.google.common.collect.Lists;
  import com.rondavu.data.api.Mo;
  import org.jmock.Expectations;
  import org.jmock.Mockery;
  import org.jmock.lib.legacy.ClassImposteriser;
  import org.junit.Before;
  import org.junit.Test;
  
  import java.util.ArrayList;
  import java.util.List;
  
  import static org.junit.Assert.assertEquals;
  
  public class RecommendationsUtilsTest  {
  
      Mockery context = new Mockery();
  
      RecommendationsUtils recommendationsUtils = new RecommendationsUtils();
  
      final Mo mo = context.mock(Mo.class);
  
      @Test
      public void testFilterDuplicatesByName_oneMo() throws DataLayerException {
          List&lt;Mo&gt; input = Lists.newArrayList(mo);
          List&lt;Mo&gt; expected = Lists.newArrayList(mo);
  
          context.checking(new Expectations() {{
              oneOf (mo).getName(); will(returnValue("Mo 1"));
          }});
  
          List&lt;Mo&gt; actual = recommendationsUtils.filterDuplicatesByName(input);
  
          context.assertIsSatisfied();
  
          assertEquals(expected, actual);
      }
  }
  </code></pre>
  
  <p>When I run the test I get this output:</p>
  
  <pre><code>unexpected invocation: mo.getName()
  no expectations specified: did you...
   - forget to start an expectation with a cardinality clause?
   - call a mocked method to specify the parameter of an expectation?
  what happened before this: nothing!
      [stack trace]
  </code></pre>
  
  <p>I'm pretty new to jMock, and Java is not my strongest language in general but I thought that my <code>oneOf (mo).getName()</code> would make it expect that invocation. What am I doing wrong here?</p>