title: Using Mockito WhiteBox for setting a member variable inside a method scope
body: <p>I am new to Mockito and is trying to figure out whether there is a way to set the value of a member variable inside a public method using WhiteBox features of Mockito.</p>
  
  <p>I tried searching for this but seems no references are talking about this.</p>
  
  <p>Is it doable or not.</p>
  
  <p>Thanks</p>
  
  <p>Added an example of what I want to achieve. Consider the following class.</p>
  
  <pre><code>public class FinancialsCalculator {
      private int va11;
      private int val2; 
  
      public int calculateFinancialsAppliedSum() {
          //In actual application this calc get's Injected using Guice
          Calculator calc;
  
          //Some pre-processing to the values val1 and val2 will be performed here
  
          return calc.getSum(val1, val2);
      }
  }
  </code></pre>
  
  <p>Now I need to unit test the above class. And I want to mock the Calculator class instance inside the scope of the calculateFinancialsAppliedSum method. </p>
  
  <p>If it was in the FinancialsCalculator class level (i.e. in the same level as val1 and val2 variables), I could have mocked it easily and use Whitebox.setInternalState() of mockito to set the mocked instance to that class level private instance of Calculator.</p>
  
  <p>Unfortunately due to other reasons, I cannot make this Calculator instance a class level private instance of FinancialsCalculator class. It has to be within the calculateFinancialsAppliedSum method. </p>
  
  <p>So how can I mock this Calculator instance inside the calculateFinancialsAppliedSum method for testing?        </p>