@Ignore @Test public void should_get_last_build_number() throws Exception { TeamCityBuilds buildList = new TeamCityBuilds(); for (int i = 1; i <= 10; i++) { TeamCityBuildItem item = new TeamCityBuildItem(); item.setNumber(Integer.toString(i)); buildList.getBuilds().add(item); } when(teamCity.findBuildList(anyString())).thenReturn(buildList); when(teamCity.findRunningBuild()).thenThrow(new TeamCityBuildNotFoundException("")); TeamCityBuildType buildType = new TeamCityBuildType(); List<TeamCityBuildType> buildTypes = new ArrayList<TeamCityBuildType>(); TeamCityProject project = new TeamCityProject(); project.setBuildTypes(buildTypes); project.getBuildTypes().add(buildType); when(teamCity.findProject(anyString())).thenReturn(project); String lastBuildId = teamCityConnection.getLastBuildId(softwareProjectId()); assertEquals("10", lastBuildId); }
@Override public String getLastBuildId(SoftwareProjectId softwareProjectId) throws ProjectNotFoundException, BuildIdNotFoundException { checkConnected(); checkSoftwareProjectId(softwareProjectId); TeamCityAbstractBuild lastBuild; try { lastBuild = teamCity.findLastBuild(softwareProjectId.getProjectId()); return lastBuild.getId(); } catch (TeamCityBuildNotFoundException e) { throw new BuildIdNotFoundException("Cannot find project with software project id " + softwareProjectId, e); } }
TeamCityConnection implements BuildCapability, TestCapability, ViewCapability { @Override public String getLastBuildId(SoftwareProjectId softwareProjectId) throws ProjectNotFoundException, BuildIdNotFoundException { checkConnected(); checkSoftwareProjectId(softwareProjectId); TeamCityAbstractBuild lastBuild; try { lastBuild = teamCity.findLastBuild(softwareProjectId.getProjectId()); return lastBuild.getId(); } catch (TeamCityBuildNotFoundException e) { throw new BuildIdNotFoundException("Cannot find project with software project id " + softwareProjectId, e); } } }
TeamCityConnection implements BuildCapability, TestCapability, ViewCapability { @Override public String getLastBuildId(SoftwareProjectId softwareProjectId) throws ProjectNotFoundException, BuildIdNotFoundException { checkConnected(); checkSoftwareProjectId(softwareProjectId); TeamCityAbstractBuild lastBuild; try { lastBuild = teamCity.findLastBuild(softwareProjectId.getProjectId()); return lastBuild.getId(); } catch (TeamCityBuildNotFoundException e) { throw new BuildIdNotFoundException("Cannot find project with software project id " + softwareProjectId, e); } }  }
TeamCityConnection implements BuildCapability, TestCapability, ViewCapability { @Override public String getLastBuildId(SoftwareProjectId softwareProjectId) throws ProjectNotFoundException, BuildIdNotFoundException { checkConnected(); checkSoftwareProjectId(softwareProjectId); TeamCityAbstractBuild lastBuild; try { lastBuild = teamCity.findLastBuild(softwareProjectId.getProjectId()); return lastBuild.getId(); } catch (TeamCityBuildNotFoundException e) { throw new BuildIdNotFoundException("Cannot find project with software project id " + softwareProjectId, e); } }  @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); }
TeamCityConnection implements BuildCapability, TestCapability, ViewCapability { @Override public String getLastBuildId(SoftwareProjectId softwareProjectId) throws ProjectNotFoundException, BuildIdNotFoundException { checkConnected(); checkSoftwareProjectId(softwareProjectId); TeamCityAbstractBuild lastBuild; try { lastBuild = teamCity.findLastBuild(softwareProjectId.getProjectId()); return lastBuild.getId(); } catch (TeamCityBuildNotFoundException e) { throw new BuildIdNotFoundException("Cannot find project with software project id " + softwareProjectId, e); } }  @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);  }