title: Mocking getInstance of a singleton using PowerMock
body: <p>I have the following Singleton that returns an instance of a different class. I want to mock the method on that returned instance object. I've been reading on PowerMock mocking features for final classes and singletons but I don't know if my case falls under those or not. I appreciate some suggestion.</p>
  
  <pre><code>public final class SomeWrapper {
      private MyActualObject MyActualObject;
      private static final SomeWrapper instance = new SomeWrapper();
  
      private SomeWrapper() {
          // singleton
      }
  
      public static SomeWrapper getInstance() {
          return instance;
      }
  
      public void setMyActualObject(MyActualObject MyActualObject) {
          if(this.MyActualObject == null) {
              this.MyActualObject = MyActualObject;
          } else {
              throw new UnsupportedOperationException("MyActualObject is already set, cannot reset.");
          }
      }
  
      public MyActualObject getMyActualObject() {
          return MyActualObject;
      }
  }
  </code></pre>
  
  <p>So now in my unit test, I wanna mock the following line:</p>
  
  <pre><code>when(SomeWrapper.getInstance().getMyActualObject().isActive()).thenReturn(false);
  </code></pre>
  
  <p>Should I mock the SomeWrapper and MyActualObject? Any code sample as guidance? </p>