// Path: src/main/java/org/netmelody/cieye/spies/teamcity/jsondomain/BuildDetail.java
// public final class BuildDetail {
//     public long id;
//     public String number;
//     public String status;
//     public String href;
//     public String webUrl;
//     public boolean personal;
//     public boolean history;
//     public boolean pinned;
//     public String statusText;
//     //buildType
//     public Date startDate;
//     public Date finishDate;
//     //agent
//     public Comment comment;
//     //tags
//     //properties
//     //revisions
//     public ChangesHref changes;
//     //relatedIssues
//     
//     public Status status() {
//         if (status == null || "SUCCESS".equals(status)) {
//             return Status.GREEN;
//         }
//         if (comment != null && comment.text != null && !comment.text.isEmpty()) {
//             return Status.UNDER_INVESTIGATION;
//         }
//         return Status.BROKEN;
//     }
// 
//     public long startDateTime() {
//         return (null == startDate) ? 0L : startDate.getTime();
//     }
// }
// 
// Path: src/main/java/org/netmelody/cieye/spies/teamcity/jsondomain/Investigation.java
// public final class Investigation {
//     public String id;
//     public String state;
//     public User responsible;
//     public Assignment assignment;
//     // scope;
//     
//     public long startDateTime() {
//         if (null == assignment) {
//             return 0L;
//         }
//         return (null == assignment.timestamp) ? 0L : assignment.timestamp.getTime();
//     }
// 
//     public boolean underInvestigation() {
//         return "TAKEN".equals(state) || "FIXED".equals(state);
//     }
// }


import static com.google.common.collect.Iterables.find;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.netmelody.cieye.core.domain.Feature;
import org.netmelody.cieye.core.observation.Contact;
import org.netmelody.cieye.spies.teamcity.jsondomain.Build;
import org.netmelody.cieye.spies.teamcity.jsondomain.BuildDetail;
import org.netmelody.cieye.spies.teamcity.jsondomain.BuildType;
import org.netmelody.cieye.spies.teamcity.jsondomain.BuildTypeDetail;
import org.netmelody.cieye.spies.teamcity.jsondomain.BuildTypes;
import org.netmelody.cieye.spies.teamcity.jsondomain.Builds;
import org.netmelody.cieye.spies.teamcity.jsondomain.Change;
import org.netmelody.cieye.spies.teamcity.jsondomain.ChangeDetail;
import org.netmelody.cieye.spies.teamcity.jsondomain.Investigation;
import org.netmelody.cieye.spies.teamcity.jsondomain.Investigations;
import org.netmelody.cieye.spies.teamcity.jsondomain.Project;
import org.netmelody.cieye.spies.teamcity.jsondomain.ProjectDetail;
import org.netmelody.cieye.spies.teamcity.jsondomain.TeamCityProjects;
import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableList;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonNull;
    }

    public Collection<BuildType> buildTypes() {
        return makeTeamCityRestCall(endpoint + prefix + "/buildTypes", BuildTypes.class).buildType();
    }

    public Collection<BuildType> buildTypesFor(Project projectDigest) {
        return makeTeamCityRestCall(endpoint + projectDigest.href, ProjectDetail.class).buildTypes.buildType();
    }

    public BuildTypeDetail detailsFor(BuildType buildType) {
        return makeTeamCityRestCall(endpoint + buildType.href, BuildTypeDetail.class);
    }

    public Build lastCompletedBuildFor(BuildTypeDetail buildTypeDetail) {
        final Builds completedBuilds = makeTeamCityRestCall(endpoint + buildTypeDetail.builds.href, Builds.class);
        if (null == completedBuilds.build() || completedBuilds.build().isEmpty()) {
            return null;
        }
        return find(completedBuilds.build(), primaryBranchBuilds);
    }

    public List<Build> runningBuildsFor(BuildType buildType) {
        return makeTeamCityRestCall(endpoint + prefix + "/builds/?locator=running:true,buildType:id:" + buildType.id, Builds.class).build();
    }

    public List<Investigation> investigationsOf(BuildType buildType) {
        return makeTeamCityRestCall(endpoint + buildType.href + "/investigations", Investigations.class).investigation();
    }

// Path: src/main/java/org/netmelody/cieye/spies/teamcity/jsondomain/BuildDetail.java
// public final class BuildDetail {
//     public long id;
//     public String number;
//     public String status;
//     public String href;
//     public String webUrl;
//     public boolean personal;
//     public boolean history;
//     public boolean pinned;
//     public String statusText;
//     //buildType
//     public Date startDate;
//     public Date finishDate;
//     //agent
//     public Comment comment;
//     //tags
//     //properties
//     //revisions
//     public ChangesHref changes;
//     //relatedIssues
//     
//     public Status status() {
//         if (status == null || "SUCCESS".equals(status)) {
//             return Status.GREEN;
//         }
//         if (comment != null && comment.text != null && !comment.text.isEmpty()) {
//             return Status.UNDER_INVESTIGATION;
//         }
//         return Status.BROKEN;
//     }
// 
//     public long startDateTime() {
//         return (null == startDate) ? 0L : startDate.getTime();
//     }
// }
// 
// Path: src/main/java/org/netmelody/cieye/spies/teamcity/jsondomain/Investigation.java
// public final class Investigation {
//     public String id;
//     public String state;
//     public User responsible;
//     public Assignment assignment;
//     // scope;
//     
//     public long startDateTime() {
//         if (null == assignment) {
//             return 0L;
//         }
//         return (null == assignment.timestamp) ? 0L : assignment.timestamp.getTime();
//     }
// 
//     public boolean underInvestigation() {
//         return "TAKEN".equals(state) || "FIXED".equals(state);
//     }
// }


// Path: src/main/java/org/netmelody/cieye/spies/teamcity/TeamCityCommunicator.java
import static com.google.common.collect.Iterables.find;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.netmelody.cieye.core.domain.Feature;
import org.netmelody.cieye.core.observation.Contact;
import org.netmelody.cieye.spies.teamcity.jsondomain.Build;
import org.netmelody.cieye.spies.teamcity.jsondomain.BuildDetail;
import org.netmelody.cieye.spies.teamcity.jsondomain.BuildType;
import org.netmelody.cieye.spies.teamcity.jsondomain.BuildTypeDetail;
import org.netmelody.cieye.spies.teamcity.jsondomain.BuildTypes;
import org.netmelody.cieye.spies.teamcity.jsondomain.Builds;
import org.netmelody.cieye.spies.teamcity.jsondomain.Change;
import org.netmelody.cieye.spies.teamcity.jsondomain.ChangeDetail;
import org.netmelody.cieye.spies.teamcity.jsondomain.Investigation;
import org.netmelody.cieye.spies.teamcity.jsondomain.Investigations;
import org.netmelody.cieye.spies.teamcity.jsondomain.Project;
import org.netmelody.cieye.spies.teamcity.jsondomain.ProjectDetail;
import org.netmelody.cieye.spies.teamcity.jsondomain.TeamCityProjects;
import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableList;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonNull;

    }

    public Collection<BuildType> buildTypes() {
        return makeTeamCityRestCall(endpoint + prefix + "/buildTypes", BuildTypes.class).buildType();
    }

    public Collection<BuildType> buildTypesFor(Project projectDigest) {
        return makeTeamCityRestCall(endpoint + projectDigest.href, ProjectDetail.class).buildTypes.buildType();
    }

    public BuildTypeDetail detailsFor(BuildType buildType) {
        return makeTeamCityRestCall(endpoint + buildType.href, BuildTypeDetail.class);
    }

    public Build lastCompletedBuildFor(BuildTypeDetail buildTypeDetail) {
        final Builds completedBuilds = makeTeamCityRestCall(endpoint + buildTypeDetail.builds.href, Builds.class);
        if (null == completedBuilds.build() || completedBuilds.build().isEmpty()) {
            return null;
        }
        return find(completedBuilds.build(), primaryBranchBuilds);
    }

    public List<Build> runningBuildsFor(BuildType buildType) {
        return makeTeamCityRestCall(endpoint + prefix + "/builds/?locator=running:true,buildType:id:" + buildType.id, Builds.class).build();
    }

    public List<Investigation> investigationsOf(BuildType buildType) {
        return makeTeamCityRestCall(endpoint + buildType.href + "/investigations", Investigations.class).investigation();
    }

    public BuildDetail detailsOf(Build build) {