Sonar { public Projects findProjects() throws SonarProjectsNotFoundException { String projectsUrl = sonarUrl + "/api/projects"; try { return client.resource(projectsUrl, Projects.class, MediaType.APPLICATION_XML_TYPE); } catch (ResourceNotFoundException e) { throw new SonarProjectsNotFoundException("Can't find Sonar projects", e); } } Sonar(String url);  Sonar(String url, String login, String password); Measure findMeasure(String artifactId, String measureKey); Resource findResource(String resourceId); Map<String, SonarQualityMetric> findMetrics(); Projects findProjects(); Project findProject(String projectKey);  }
@Test(expected = SonarProjectsNotFoundException.class) public void should_throw_exception_when_projects_are_not_found() throws Exception { Throwable exception = new ResourceNotFoundException(""); when(genericSoftwareClient.resource(anyString(), eq(Projects.class), eq(MediaType.APPLICATION_XML_TYPE))) .thenThrow(exception); sonarClient.findProjects(); }