TeamCityConnection implements BuildCapability, TestCapability, ViewCapability { @Override public boolean isProjectDisabled(SoftwareProjectId softwareProjectId) throws ProjectNotFoundException { checkConnected(); checkSoftwareProjectId(softwareProjectId); try { String projectId = softwareProjectId.getProjectId(); TeamCityBuildType buildType = teamCity.findBuildType(projectId); return buildType.isPaused(); } catch (TeamCityBuildTypeNotFoundException e) { throw new ProjectNotFoundException("Can't 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);  }
@Test public void should_get_a_disabled_project() throws Exception { TeamCityBuildType project = new TeamCityBuildType(); project.setPaused(true); when(teamCity.findBuildType(anyString())).thenReturn(project); SoftwareProjectId softwareProjectId = new SoftwareProjectId("projectId"); boolean isDisabled = teamCityConnection.isProjectDisabled(softwareProjectId); assertTrue(isDisabled); }
@Test public void should_get_an_enabled_project() throws Exception { TeamCityBuildType project = new TeamCityBuildType(); project.setPaused(false); when(teamCity.findBuildType(anyString())).thenReturn(project); SoftwareProjectId softwareProjectId = new SoftwareProjectId("projectId"); boolean isDisabled = teamCityConnection.isProjectDisabled(softwareProjectId); assertFalse(isDisabled); }
@Test(expected = ProjectNotFoundException.class) public void should_throw_exception_when_project_is_not_found() throws Exception { Throwable notFound = new TeamCityBuildTypeNotFoundException("not found", null); when(teamCity.findBuildType(anyString())).thenThrow(notFound); SoftwareProjectId softwareProjectId = new SoftwareProjectId("projectId"); teamCityConnection.isProjectDisabled(softwareProjectId); }