private BuildDetail buildDetail(int size) {
   final BuildDetail buildDetail = new BuildDetail();
   buildDetail.changes = new ChangesHref();
   buildDetail.changes.count = size;
   buildDetail.changes.href = "/app/rest/changes/id:12345";
   return buildDetail;
 }
  public TargetDetail targetFrom(BuildType buildType) {
    final BuildTypeDetail buildTypeDetail = communicator.detailsFor(buildType);

    if (buildTypeDetail.paused) {
      return new TargetDetail(
          communicator.endpoint() + buildType.href,
          buildType.webUrl(),
          buildType.name,
          Status.DISABLED,
          0L);
    }

    final Set<Sponsor> sponsors = new HashSet<Sponsor>();
    final List<RunningBuild> runningBuilds = new ArrayList<RunningBuild>();
    long startTime = 0L;

    for (Build build : communicator.runningBuildsFor(buildType)) {
      final BuildDetail buildDetail = communicator.detailsOf(build);
      startTime = Math.max(buildDetail.startDateTime(), startTime);
      sponsors.addAll(sponsorsOf(buildDetail));
      runningBuilds.add(
          new RunningBuild(percentageOf(build.percentageComplete), buildDetail.status()));
    }

    Status currentStatus = Status.GREEN;
    final Build lastCompletedBuild = communicator.lastCompletedBuildFor(buildTypeDetail);
    if (null != lastCompletedBuild) {
      currentStatus = lastCompletedBuild.status();
      if (runningBuilds.isEmpty() || Status.BROKEN.equals(currentStatus)) {
        final BuildDetail buildDetail = communicator.detailsOf(lastCompletedBuild);
        startTime = Math.max(buildDetail.startDateTime(), startTime);
        sponsors.addAll(sponsorsOf(buildDetail));
        currentStatus = buildDetail.status();
      }
    }

    return new TargetDetail(
        communicator.endpoint() + buildType.href,
        buildType.webUrl(),
        buildType.name,
        currentStatus,
        startTime,
        runningBuilds,
        sponsors);
  }