class TeamCityConnection implements BuildCapability, TestCapability, ViewCapability {

    @Override
    public BuildTime getBuildTime(SoftwareProjectId softwareProjectId, String buildId) throws BuildNotFoundException,
            ProjectNotFoundException {
        checkConnected();
        checkSoftwareProjectId(softwareProjectId);
        checkBuildId(buildId);
        try {
            String projectId = softwareProjectId.getProjectId();
            TeamCityBuild teamcityBuild = teamCity.findBuild(projectId, buildId);
            return BuildTimes.createFrom(teamcityBuild);
        } catch (TeamCityBuildTypeNotFoundException e) {
            throw new ProjectNotFoundException("Cannot find build type with software project id:" + softwareProjectId,
                    e);
        } catch (TeamCityBuildNotFoundException e) {
            throw new BuildNotFoundException("Cannot find build #" + buildId + " for software project id:"
                    + softwareProjectId, e);
        }
    }

}