TeamCityConnection implements BuildCapability, TestCapability, ViewCapability { @Override public boolean isBuilding(SoftwareProjectId softwareProjectId, String buildId) throws ProjectNotFoundException, BuildNotFoundException { checkConnected(); checkSoftwareProjectId(softwareProjectId); checkBuildId(buildId); try { TeamCityBuild build = teamCity.findRunningBuild(); return softwareProjectId.getProjectId().equals(build.getBuildType().getId()) && buildId.equals(build.getId()); } catch (TeamCityBuildNotFoundException e) { return false; } }  @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);  }
@Test public void should_get_is_building() throws Exception { TeamCityBuild build = new TeamCityBuild(); build.setRunning(true); build.setId("1"); TeamCityBuildType buildType = new TeamCityBuildType(); buildType.setId("projectId"); build.setBuildType(buildType); when(teamCity.findRunningBuild()).thenReturn(build); boolean isBuilding = teamCityConnection.isBuilding(softwareProjectId(), "1"); assertTrue(isBuilding); }