title: Mockito Verify variables set in a mock before calling a method
body: <p>I'm trying to write some unit tests around some legacy code and I'm struggling to work out how to test a piece of code. The pattern is basically:</p>
  
  <pre><code>Foo foo = ObjectGetter.getObject(Foo.class);
  foo.setVariableX("X");
  foo.setVariableY("Y");
  foo.performExecute();
  //The Foo object has now run some business logic
  String bar = foo.getVariableZ();
  </code></pre>
  
  <p>I have mocked the static ObjectGetter class via PowerMock and managed to get pass in a mocked Foo object. What I want to do now is when performExecute is run check that variable X &amp; Y are set to a predetermined value in Foo but not actually run any code in Foo. Then when getVariableZ is called pass back a certain value.</p>
  
  <p>I can get VariableZ passing back whatever I want but I can't work out how to make that a conditional that variable X and Y are set to certain values! I'm using Mockito and PowerMock. Suffice to say I can't change the code I'm testing for various reasons.</p>