@Test public void should_find_all_software_project_ids() throws Exception { Project project1 = new Project(); project1.setName("name1"); project1.setKey("key1"); Project project2 = new Project(); project2.setName("name2"); project2.setKey("key2"); Projects projects = new Projects(); projects.getProjects().add(project1); projects.getProjects().add(project2); when(sonarClient.findProjects()).thenReturn(projects); Map<SoftwareProjectId, String> softwareProjectIds = sonar.listSoftwareProjectIds(); assertEquals("name1", softwareProjectIds.get(new SoftwareProjectId("key1"))); assertEquals("name2", softwareProjectIds.get(new SoftwareProjectId("key2"))); }
@Override public Map<SoftwareProjectId, String> listSoftwareProjectIds() { checkConnected(); Map<SoftwareProjectId, String> projects = new HashMap<SoftwareProjectId, String>(); try { List<Project> names = sonarClient.findProjects().getProjects(); for (Project project : names) { String key = project.getKey(); projects.put(new SoftwareProjectId(key), project.getName()); } } catch (SonarProjectsNotFoundException e) { LOG.warn(e.getMessage(), e); } return projects; }
SonarConnection implements MetricCapability, TestCapability { @Override public Map<SoftwareProjectId, String> listSoftwareProjectIds() { checkConnected(); Map<SoftwareProjectId, String> projects = new HashMap<SoftwareProjectId, String>(); try { List<Project> names = sonarClient.findProjects().getProjects(); for (Project project : names) { String key = project.getKey(); projects.put(new SoftwareProjectId(key), project.getName()); } } catch (SonarProjectsNotFoundException e) { LOG.warn(e.getMessage(), e); } return projects; } }
SonarConnection implements MetricCapability, TestCapability { @Override public Map<SoftwareProjectId, String> listSoftwareProjectIds() { checkConnected(); Map<SoftwareProjectId, String> projects = new HashMap<SoftwareProjectId, String>(); try { List<Project> names = sonarClient.findProjects().getProjects(); for (Project project : names) { String key = project.getKey(); projects.put(new SoftwareProjectId(key), project.getName()); } } catch (SonarProjectsNotFoundException e) { LOG.warn(e.getMessage(), e); } return projects; } SonarConnection(); }
SonarConnection implements MetricCapability, TestCapability { @Override public Map<SoftwareProjectId, String> listSoftwareProjectIds() { checkConnected(); Map<SoftwareProjectId, String> projects = new HashMap<SoftwareProjectId, String>(); try { List<Project> names = sonarClient.findProjects().getProjects(); for (Project project : names) { String key = project.getKey(); projects.put(new SoftwareProjectId(key), project.getName()); } } catch (SonarProjectsNotFoundException e) { LOG.warn(e.getMessage(), e); } return projects; } 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 Map<SoftwareProjectId, String> listSoftwareProjectIds() { checkConnected(); Map<SoftwareProjectId, String> projects = new HashMap<SoftwareProjectId, String>(); try { List<Project> names = sonarClient.findProjects().getProjects(); for (Project project : names) { String key = project.getKey(); projects.put(new SoftwareProjectId(key), project.getName()); } } catch (SonarProjectsNotFoundException e) { LOG.warn(e.getMessage(), e); } return projects; } 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);  }