title: Mockito UnfinishedStubbingException
body: <p>I am new to Mockito, I have tried looking into this Exception but I haven´t found a concrete answer. It happens in my code when I use two mocks together, meaning that I give through the constructor of a mock, another mock. Like so:</p>
  
  <pre><code>...
  OperationNode child = getNode(Operation.ADD);
  child.insertNode(getConstantNode(getIntegerValue(2));
  ...
  
   private ConstantNode getConstantNode(NumericalValue value){
      ConstantNode node = Mockito.mock(ConstantNode.class);
      Mockito.when(node.evaluate()).thenReturn(value);
      Mockito.when(node.toString()).thenReturn(value.toString());
      return node;
  }
  
  private IntegerValue getIntegerValue(int number) {
     IntegerValue integerValue = Mockito.mock(IntegerValue.class);
     Mockito.when(integerValue.getValue()).thenReturn(number);
     Mockito.when(integerValue.toString()).thenReturn(Integer.toString(number));
     return integerValue;
  }
  </code></pre>
  
  <p>In one of the forums I read about not sending a mock through a constructor of another mock, since Mockito might get confused with the mock calls, so I tried the following:</p>
  
  <pre><code>NumericalValue value = getIntegerValue(2);
  child.insertNode(getConstantNode(value));
  </code></pre>
  
  <p>But to no avail. I make sure that only the methods <code>toString()</code> and <code>getValue()</code> are called, because those are the only methods the class has. I don´t understand what´s going on.</p>
  
  <p>I have also tried using the mocks separately, to see if I have done something wrong:</p>
  
  <pre><code>child.insertNode(new ConstantNode(getIntegerValue(2)));
  </code></pre>
  
  <p>That works perfectly.</p>
  
  <pre><code>child.insertNode(getConstantNode(new IntegerValue(2)));
  </code></pre>
  
  <p>That works fine too.</p>