title: Powermockito giving me a null exception
body: <p>I am trying to mock some static methods but I am getting the following stack trace</p>
  
  <pre><code>java.lang.NullPointerException
  at de.unibonn.iai.eis.luzzu.semantics.utilities.SPARQLHelper.toSPARQL(SPARQLHelper.java:12)
  at de.unibonn.iai.eis.luzzu.semantics.utilities.DAQHelper.getDomainResource(DAQHelper.java:51)
  at de.unibonn.iai.eis.luzzu.semantics.utilities.DAQHelper.getCategoryResource(DAQHelper.java:47)
  at de.unibonn.iai.eis.luzzu.annotations.QualityMetadataTest.createMockedMetric(QualityMetadataTest.java:211)
  at de.unibonn.iai.eis.luzzu.annotations.QualityMetadataTest.&lt;init&gt;(QualityMetadataTest.java:81)
  ....
  </code></pre>
  
  <p>DAQHelper is a static class which is called from a method which I am currently testing. To keep the story short, I have a method addMetricData(...) which calls getCategoryResource(...) etc.. This getCategoryResource(..) is a public static method which in turn calls getDomainResource (a private static method in DAQHelper). The getDomainResource(...) method calls the static SPARQLHelper.toSPARQL(...) method.</p>
  
  <p>DO you hav an idea why I am having this problem? The test code is the following:</p>
  
  <pre><code>@RunWith(Parameterized.class)
  </code></pre>
  
  <p>@PrepareForTest({DAQHelper.class, SPARQLHelper.class})
  public class QualityMetadataTest extends Assert {</p>
  
  <pre><code>@Rule
  public PowerMockRule rule = new PowerMockRule();
  
  private QualityMetric metric;
  private Model m = ModelFactory.createDefaultModel();
  private QualityMetadata _testClass;
  private Dataset _dataset;
  
  private Resource metricResource = m.createResource("example:mockedMetric");
  private Resource categoryResource = m.createResource("example:mockedCategory");
  private Resource dimensionResource = m.createResource("example:mockedDimension");
  private Resource dimensionProperty = m.createResource("example:hasMockedDimensionProperty");
  private Resource metricProperty = m.createResource("example:hasMockedMetricProperty");
  private Resource computedOn = m.createResource("example:testing");
  private Resource qualityGraphURI;
  
  private Resource categoryURI;
  private Resource dimensionURI;
  private Resource metricURI;
  
  private boolean parameter;
  
  @Parameters
  public static Collection&lt;Object[]&gt; data() {
      Object[][] data = new Object[][] { { false } };
      return Arrays.asList(data);
  }
  
  public QualityMetadataTest(boolean QualityMetadataExists) throws Exception{
      this.parameter = QualityMetadataExists;
      if (QualityMetadataExists){
          // fill model m with quality metadata
      }
  
      this.createMockedMetric();
  
      _testClass = new QualityMetadata(m,computedOn);
      _testClass.addMetricData(metric);
      _dataset = _testClass.createQualityMetadata();
  } 
  // some test methods
      private void createMockedMetric() throws Exception{     
      metric = mock(QualityMetric.class);
      when(metric.getMetricURI()).thenReturn(metricResource);
      when(metric.metricValue()).thenReturn(0.5);
  
  
      mockStatic(DAQHelper.class);    
      PowerMockito.when(DAQHelper.getCategoryResource(metricResource)).thenReturn(categoryResource);
      PowerMockito.when(DAQHelper.getDimensionResource(metricResource)).thenReturn(dimensionResource);
      PowerMockito.when(DAQHelper.getPropertyResource(dimensionResource)).thenReturn(dimensionProperty);
      PowerMockito.when(DAQHelper.getPropertyResource(metricResource)).thenReturn(metricProperty);
  }
  </code></pre>
  
  <p>My belief is that once 'when' methods are created, they are created globally and does not really execute the method but just return the result. I might have a misconception there. Do you have any ideas?</p>
  
  <p>Cheers!</p>