@Test(expected = ProjectNotFoundException.class) public void should_throw_exception_when_identifying_inexistant_project() throws Exception { Throwable notFound = new SonarResourceNotFoundException("not found"); when(sonarClient.findResource(anyString())).thenThrow(notFound); ProjectKey projectKey = new ProjectKey(); sonar.identify(projectKey); }
@Override public SoftwareProjectId identify(ProjectKey projectKey) throws ProjectNotFoundException { checkConnected(); Preconditions.checkNotNull(projectKey, "projectKey is mandatory"); try { String mavenId = projectKey.getMavenId(); if (mavenId != null) { Resource resource = sonarClient.findResource(mavenId); SoftwareProjectId softwareProjectId = new SoftwareProjectId(resource.getKey()); return softwareProjectId; } } catch (SonarResourceNotFoundException e) { throw new ProjectNotFoundException("Can't identify project key: " + projectKey, e); } throw new ProjectNotFoundException("Can't identify project key, there is not enough informations: " + projectKey); }
SonarConnection implements MetricCapability, TestCapability { @Override public SoftwareProjectId identify(ProjectKey projectKey) throws ProjectNotFoundException { checkConnected(); Preconditions.checkNotNull(projectKey, "projectKey is mandatory"); try { String mavenId = projectKey.getMavenId(); if (mavenId != null) { Resource resource = sonarClient.findResource(mavenId); SoftwareProjectId softwareProjectId = new SoftwareProjectId(resource.getKey()); return softwareProjectId; } } catch (SonarResourceNotFoundException e) { throw new ProjectNotFoundException("Can't identify project key: " + projectKey, e); } throw new ProjectNotFoundException("Can't identify project key, there is not enough informations: " + projectKey); } }
SonarConnection implements MetricCapability, TestCapability { @Override public SoftwareProjectId identify(ProjectKey projectKey) throws ProjectNotFoundException { checkConnected(); Preconditions.checkNotNull(projectKey, "projectKey is mandatory"); try { String mavenId = projectKey.getMavenId(); if (mavenId != null) { Resource resource = sonarClient.findResource(mavenId); SoftwareProjectId softwareProjectId = new SoftwareProjectId(resource.getKey()); return softwareProjectId; } } catch (SonarResourceNotFoundException e) { throw new ProjectNotFoundException("Can't identify project key: " + projectKey, e); } throw new ProjectNotFoundException("Can't identify project key, there is not enough informations: " + projectKey); } SonarConnection(); }
SonarConnection implements MetricCapability, TestCapability { @Override public SoftwareProjectId identify(ProjectKey projectKey) throws ProjectNotFoundException { checkConnected(); Preconditions.checkNotNull(projectKey, "projectKey is mandatory"); try { String mavenId = projectKey.getMavenId(); if (mavenId != null) { Resource resource = sonarClient.findResource(mavenId); SoftwareProjectId softwareProjectId = new SoftwareProjectId(resource.getKey()); return softwareProjectId; } } catch (SonarResourceNotFoundException e) { throw new ProjectNotFoundException("Can't identify project key: " + projectKey, e); } throw new ProjectNotFoundException("Can't identify project key, there is not enough informations: " + projectKey); } SonarConnection(); @Override void connect(String url, String login, String password); @Override Map<String, List<QualityMetric>> getMetricsByCategory(); @Override Map<SoftwareProjectId, String> listSoftwareProjectIds(); @Override void close(); @Override boolean equals(Object o); @Override int hashCode(); @Override String getDescription(SoftwareProjectId softwareProjectId); @Override SoftwareProjectId identify(ProjectKey projectKey); @Override TestResult analyzeUnitTests(SoftwareProjectId projectId); @Override TestResult analyzeIntegrationTests(SoftwareProjectId projectId); @Override QualityResult analyzeQuality(SoftwareProjectId projectId, String... metrics); @Override String getMavenId(SoftwareProjectId softwareProjectId); @Override String getName(SoftwareProjectId softwareProjectId); @Override boolean isClosed(); @Override boolean isProjectDisabled(SoftwareProjectId softwareProjectId); BuildTime getBuildTime(SoftwareProjectId softwareProjectId, Integer buildId); @Deprecated // NOT USED List<Integer> getBuildIds(SoftwareProjectId softwareProjectId); @Deprecated // NOT USED BuildState getBuildState(SoftwareProjectId softwareProjectId, Integer buildId); @Deprecated // NOT USED Date getEstimatedFinishTime(SoftwareProjectId softwareProjectId, Integer buildId); @Deprecated // NOT USED boolean isBuilding(SoftwareProjectId softwareProjectId, Integer buildId); @Deprecated // NOT USED int getLastBuildId(SoftwareProjectId softwareProjectId); @Deprecated // NOT USED List<Commiter> getBuildCommiters(SoftwareProjectId softwareProjectId, Integer buildId); }
SonarConnection implements MetricCapability, TestCapability { @Override public SoftwareProjectId identify(ProjectKey projectKey) throws ProjectNotFoundException { checkConnected(); Preconditions.checkNotNull(projectKey, "projectKey is mandatory"); try { String mavenId = projectKey.getMavenId(); if (mavenId != null) { Resource resource = sonarClient.findResource(mavenId); SoftwareProjectId softwareProjectId = new SoftwareProjectId(resource.getKey()); return softwareProjectId; } } catch (SonarResourceNotFoundException e) { throw new ProjectNotFoundException("Can't identify project key: " + projectKey, e); } throw new ProjectNotFoundException("Can't identify project key, there is not enough informations: " + projectKey); } SonarConnection(); @Override void connect(String url, String login, String password); @Override Map<String, List<QualityMetric>> getMetricsByCategory(); @Override Map<SoftwareProjectId, String> listSoftwareProjectIds(); @Override void close(); @Override boolean equals(Object o); @Override int hashCode(); @Override String getDescription(SoftwareProjectId softwareProjectId); @Override SoftwareProjectId identify(ProjectKey projectKey); @Override TestResult analyzeUnitTests(SoftwareProjectId projectId); @Override TestResult analyzeIntegrationTests(SoftwareProjectId projectId); @Override QualityResult analyzeQuality(SoftwareProjectId projectId, String... metrics); @Override String getMavenId(SoftwareProjectId softwareProjectId); @Override String getName(SoftwareProjectId softwareProjectId); @Override boolean isClosed(); @Override boolean isProjectDisabled(SoftwareProjectId softwareProjectId); BuildTime getBuildTime(SoftwareProjectId softwareProjectId, Integer buildId); @Deprecated // NOT USED List<Integer> getBuildIds(SoftwareProjectId softwareProjectId); @Deprecated // NOT USED BuildState getBuildState(SoftwareProjectId softwareProjectId, Integer buildId); @Deprecated // NOT USED Date getEstimatedFinishTime(SoftwareProjectId softwareProjectId, Integer buildId); @Deprecated // NOT USED boolean isBuilding(SoftwareProjectId softwareProjectId, Integer buildId); @Deprecated // NOT USED int getLastBuildId(SoftwareProjectId softwareProjectId); @Deprecated // NOT USED List<Commiter> getBuildCommiters(SoftwareProjectId softwareProjectId, Integer buildId);  }