BambooConnection implements BuildCapability, TestCapability { @Override public Map<SoftwareProjectId, String> listSoftwareProjectIds() { checkConnected(); Map<SoftwareProjectId, String> projects = new HashMap<SoftwareProjectId, String>(); List<Plan> plans = bamboo.findAllPlans(); for (Plan plan : plans) { String key = plan.getKey(); SoftwareProjectId softwareProjectId = new SoftwareProjectId(key); projects.put(softwareProjectId, plan.getName()); } return projects; }  @Override void connect(String url, String login, String password); @Override boolean isBuilding(SoftwareProjectId softwareProjectId, String buildId); @Override BuildState getBuildState(SoftwareProjectId projectId, String buildId); @Override String getLastBuildId(SoftwareProjectId projectId); @Override void close(); @Override String getDescription(SoftwareProjectId softwareProjectId); @Override SoftwareProjectId identify(ProjectKey projectKey); @Override Date getEstimatedFinishTime(SoftwareProjectId projectId, String buildId); @Override Map<SoftwareProjectId, String> listSoftwareProjectIds(); @Override List<String> getBuildIds(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 projectId); @Override TestResult analyzeIntegrationTests(SoftwareProjectId projectId);  }
@Test public void should_get_all_software_projects_ids() { Plan plan1 = new Plan(); plan1.setKey("key1"); plan1.setName("planName1"); Plan plan2 = new Plan(); plan2.setKey("key2"); plan2.setName("planName2"); List<Plan> plans = new ArrayList<Plan>(); plans.add(plan1); plans.add(plan2); when(bamboo.findAllPlans()).thenReturn(plans); Map<SoftwareProjectId, String> projectIds = bambooConnection.listSoftwareProjectIds(); assertEquals("planName1", projectIds.get(new SoftwareProjectId("key1"))); assertEquals("planName2", projectIds.get(new SoftwareProjectId("key2"))); }