title: mock static method call in private static final field of the class
body: <p>I have a basic <code>Widget</code> class that uses utility class <code>Utils</code></p>
  
  <pre><code>public class Widget {
  
      private static final String BUTTON_KEY = Utils.getMessage("btn-key");
  
      public boolean comp() {
          String specialKey = Utils.getMessage("special-key");
          return specialKey.equals(BUTTON_KEY);
      }
  
  }
  
  class Utils {
  
      public static String getMessage(String key) {
          return key + " : message";
      }
  
  }
  </code></pre>
  
  <p>I want to create a test for <code>comp</code> method.</p>
  
  <p>My test looks like this</p>
  
  <pre><code>@RunWith(PowerMockRunner.class)
  @PrepareForTest(Utils.class)
  public class WidgetTest {
  
      private Widget widget;
  
      @Before
      public void setUp() {
          mockStatic(Utils.class);
          widget = new Widget();
      }
  
      @Test
      public void testComp() {
          expect(Utils.getMessage("btn-key")).andReturn("btn-key : message");
          expect(Utils.getMessage("special-key")).andReturn("special-key : message");
          replayAll();
          assertFalse(widget.comp());
          verifyAll();
      }
  
  }
  </code></pre>
  
  <p>The test fails with</p>
  
  <pre><code>java.lang.IllegalStateException: missing behavior definition for the preceding method call:
  Utils.getMessage("btn-key")
  Usage is: expect(a.foo()).andXXX()
  </code></pre>
  
  <p>If I remove method call in the constant field (and consequently remove expectation for it) test succeed.</p>
  
  <p>What is the problem?</p>