title: How to pass Sonarqube exception test coverage
body: <p>I'm passing the JUnit test but Sonarqube keeps informing me that my method is not covered by my tests. <br><br>Here is my test method:</p>
  
  <pre><code>@Test(expected = DataNotFoundException.class)
  public void testNullApplicationData() {
      appFilter.setApplicationId(null);
      appFilter.setPolicyNumber(null);
  
      Mockito.when(impl.getApplication(appFilter, null)).thenThrow(DataNotFoundException.class);
      assertNotEquals(null, impl.getApplication(appFilter, null));
  }
  </code></pre>
  
  <p>And here is the method that I'm testing:</p>
  
  <pre><code>@Override
  public ApplicationData getApplication(ApplicationFilter filter, String systemId) {
      try {
          ApplicationData appData = retrieveAppData(filter, systemId);
          if (Objects.isNull(appData)) {
              throw new DataNotFoundException(
                      StringUtils.join("Application ", ApplicationUtil.getApplicationFilterId(filter), " not found"));
          }
  
          return retrieveAppData(filter, systemId);
      } catch (DataAccessException ex) {
          throw new DataException(
                  StringUtils.join("Error retrieving application ", ApplicationUtil.getApplicationFilterId(filter)));
      }
  }
  </code></pre>
  
  <p><b>A few notes:</b><br>
  I am certain that the <code>retrieveAppData(filter, systemId)</code> method will return a <code>null</code> result which will ensure that the <code>DataNotFoundException</code> will be triggered</p>
  
  <p>I have not yet written a test method for the <code>DataAccessException</code> since I'm trying to figure out first how to pass the first exception in Sonarqube</p>
  
  <p>Here are the commands I used when I built the project:<br>
  <code>mvn clean install</code><br>
  <code>mvn clean package sonar:sonar</code></p>