TeamCityConnection implements BuildCapability, TestCapability, ViewCapability { @Override public Map<SoftwareProjectId, String> listSoftwareProjectIds() { checkConnected(); Map<SoftwareProjectId, String> projectIds = new HashMap<SoftwareProjectId, String>(); try { List<TeamCityProject> projects = teamCity.findAllProjects(); for (TeamCityProject project : projects) { try { project = teamCity.findProject(project.getId()); List<TeamCityBuildType> buildTypes = project.getBuildTypes(); for (TeamCityBuildType teamCityBuildType : buildTypes) { String id = teamCityBuildType.getId(); SoftwareProjectId softwareProjectId = new SoftwareProjectId(id); projectIds.put(softwareProjectId, teamCityBuildType.getName()); } } catch (TeamCityProjectNotFoundException e) { LOG.warn("Cannot find project with id " + project.getId(), e); } } } catch (TeamCityProjectsNotFoundException e) { if (LOG.isDebugEnabled()) { LOG.debug("Cannot build list of software project ids.", e); } } return projectIds; }  @Override void connect(String url, String login, String password); @Override void close(); @Override String getDescription(SoftwareProjectId softwareProjectId); @Override SoftwareProjectId identify(ProjectKey projectKey); @Override List<String> getBuildIds(SoftwareProjectId softwareProjectId); @Override Map<SoftwareProjectId, String> listSoftwareProjectIds(); @Override BuildState getBuildState(SoftwareProjectId softwareProjectId, String buildId); @Override Date getEstimatedFinishTime(SoftwareProjectId softwareProjectId, String buildId); @Override boolean isBuilding(SoftwareProjectId softwareProjectId, String buildId); @Override String getLastBuildId(SoftwareProjectId softwareProjectId); @Override String getMavenId(SoftwareProjectId softwareProjectId); @Override String getName(SoftwareProjectId softwareProjectId); @Override boolean isClosed(); @Override BuildTime getBuildTime(SoftwareProjectId softwareProjectId, String buildId); @Override boolean isProjectDisabled(SoftwareProjectId softwareProjectId); @Override List<Commiter> getBuildCommiters(SoftwareProjectId softwareProjectId, String buildId); @Override TestResult analyzeUnitTests(SoftwareProjectId softwareProjectId); @Override TestResult analyzeIntegrationTests(SoftwareProjectId softwareProjectId); @Override List<SoftwareProjectId> findSoftwareProjectIdsByViews(List<String> views); @Override List<String> findViews(); @Override List<String> findProjectNamesByView(String viewName);  }
@Ignore @Test public void should_list_all_project_ids() throws Exception { addTwoProjects(); Map<SoftwareProjectId, String> projectIds = teamCityConnection.listSoftwareProjectIds(); assertEquals("name1", projectIds.get(new SoftwareProjectId("id1"))); assertEquals("name2", projectIds.get(new SoftwareProjectId("id2"))); }