title: Nullpointer on Mockito when
body: <p>I use following test to test my utitiliesclass, I use mockito for the sql connection. </p>
  
  <pre><code>    @Mock
      public Connection connectionMock;
  
      @Before
      public void setUp(){
          MockitoAnnotations.initMocks(this);
      }    
  @Test
      public void testResource(){
          String sql = Utilities.resourceToString("testSql.sql");
          try {
              Mockito.when(connectionMock.createStatement().executeQuery(sql)).thenAnswer(new Answer&lt;String&gt;() {
                  @Override
                  public String answer(InvocationOnMock invocationOnMock) throws Throwable {
                      return "X";
                  }
              });
  </code></pre>
  
  <p>I get a nullpointer on the line Mockito.when, what is wrong?</p>