title: Mockito & Junit null pointer exception: name must not be null
body: <p>I have been trying to run the following test using mockito and junit and I keep on getting "java.lang.NullPointerException: name must not be null"
  Can anyone tell me why this is happening? </p>
  
  <p>On debugging, I found out that this exception is thrown when the test executes the following statement in isStopValid(String) method: </p>
  
  <p><strong>FacilityValidationUtil facUtil = new FacilityValidationUtil();</strong></p>
  
  <pre><code>@RunWith(MockitoJUnitRunner.class)
  public class MyFormTest{
      @InjectMocks MyForm form = new MyForm();
      @Mock FacilityValidationUtil facUtil;
      @Test
      public void testIsStopValid() throws FinderException{
          when(facUtil.isFacilityValid("")).thenReturn(false);
          form.setOrigin("");
          assertEquals(false, form.isStopValid(form.getOrigin()));        
      }
  }
  </code></pre>
  
  <p><strong>Class with method to be tested:</strong> </p>
  
  <pre><code>public class MyForm{
      FacilityValidationUtil facUtil = new FacilityValidationUtil();
      public boolean isStopValid(String stop){
  
          try {
              return facUtil.isFacilityValid(stop);
          } catch (FinderException e) {
              log.error("Error finding the stop. "+e.getCause());
              return false;
          }
      }
  }
  </code></pre>
  
  <hr>
  
  <pre><code>public class FacilityValidationUtil{
      private FacilityDAO facilityDao = new HibernateFacilityDAO();
      public boolean isFacilityValid(String facility) throws FinderException{
          boolean test;
          FacilityImpl facilityImpl = facilityDao.findFacilityByNassCode(facility);
          test = (facilityImpl==null)?false : true;
          return test;
      }
  }
  </code></pre>
  
  <hr>
  
  <pre><code>public class HibernateFacilityDAO extends HibernateAbstractDeltaDAO implements FacilityDAO {
      public HibernateFacilityDAO() {
          super(false);
      }
  }
  </code></pre>