Skip to content

Commit

Permalink
Improving lookupJobsForBuild to return what is shown in the Sauce d…
Browse files Browse the repository at this point in the history
  • Loading branch information
diemol committed Oct 31, 2023

Verified

This commit was signed with the committer’s verified signature.
noctuid Fox Kiester
1 parent 7bc85cd commit a437f1f
Showing 6 changed files with 270 additions and 101 deletions.
10 changes: 5 additions & 5 deletions src/main/java/com/saucelabs/saucerest/api/BuildsEndpoint.java
Original file line number Diff line number Diff line change
@@ -4,9 +4,10 @@
import com.saucelabs.saucerest.HttpMethod;
import com.saucelabs.saucerest.JobSource;
import com.saucelabs.saucerest.model.builds.Build;
import com.saucelabs.saucerest.model.builds.JobInBuild;
import com.saucelabs.saucerest.model.builds.JobsInBuild;
import com.saucelabs.saucerest.model.builds.LookupBuildsParameters;
import com.saucelabs.saucerest.model.builds.LookupJobsParameters;
import com.saucelabs.saucerest.model.jobs.Job;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
@@ -81,16 +82,15 @@ public List<Build> lookupBuilds(JobSource jobSource, LookupBuildsParameters para
* JobSource}
* @param parameters A {@link LookupJobsParameters} object containing the parameters to filter the
* results
* @return A list of {@link Job} objects
* @return A {@link JobsInBuild} object containing a list of {@link JobInBuild} objects
* @throws IOException when the request fails
*/
public List<Job> lookupJobsForBuild(
public JobsInBuild lookupJobsForBuild(
JobSource jobSource, String buildID, LookupJobsParameters parameters) throws IOException {
String url = getBaseEndpoint(jobSource) + buildID + "/jobs/";

return deserializeJSONObject(
requestWithQueryParameters(url, HttpMethod.GET, parameters.toMap()),
Collections.singletonList(Job.class));
requestWithQueryParameters(url, HttpMethod.GET, parameters.toMap()), JobsInBuild.class);
}

/**
151 changes: 91 additions & 60 deletions src/main/java/com/saucelabs/saucerest/model/builds/Build.java
Original file line number Diff line number Diff line change
@@ -1,67 +1,98 @@

package com.saucelabs.saucerest.model.builds;

import com.saucelabs.saucerest.model.AbstractModel;
import com.squareup.moshi.Json;

public class Build extends AbstractModel {

@Json(name = "creation_time")
public Integer creationTime;
@Json(name = "deletion_time")
public Integer deletionTime;
@Json(name = "end_time")
public Integer endTime;
@Json(name = "group_id")
public String groupId;
@Json(name = "id")
public String id;
@Json(name = "jobs")
public Jobs jobs;
@Json(name = "modification_time")
public Integer modificationTime;
@Json(name = "name")
public String name;
@Json(name = "org_id")
public String orgId;
@Json(name = "owner_id")
public String ownerId;
@Json(name = "passed")
public Object passed;
@Json(name = "public")
public Boolean _public;
@Json(name = "run")
public Integer run;
@Json(name = "source")
public String source;
@Json(name = "start_time")
public Integer startTime;
@Json(name = "status")
public String status;
@Json(name = "team_id")
public String teamId;

public Build() {
}

public Build(Integer creationTime, Integer deletionTime, Integer endTime, String groupId, String id, Jobs jobs, Integer modificationTime, String name, String orgId, String ownerId, Object passed, Boolean _public, Integer run, String source, Integer startTime, String status, String teamId) {
super();
this.creationTime = creationTime;
this.deletionTime = deletionTime;
this.endTime = endTime;
this.groupId = groupId;
this.id = id;
this.jobs = jobs;
this.modificationTime = modificationTime;
this.name = name;
this.orgId = orgId;
this.ownerId = ownerId;
this.passed = passed;
this._public = _public;
this.run = run;
this.source = source;
this.startTime = startTime;
this.status = status;
this.teamId = teamId;
}
}
@Json(name = "creation_time")
public Integer creationTime;

@Json(name = "deletion_time")
public Integer deletionTime;

@Json(name = "end_time")
public Integer endTime;

@Json(name = "group_id")
public String groupId;

@Json(name = "id")
public String id;

@Json(name = "jobs")
public Jobs jobs;

@Json(name = "modification_time")
public Integer modificationTime;

@Json(name = "name")
public String name;

@Json(name = "org_id")
public String orgId;

@Json(name = "owner_id")
public String ownerId;

@Json(name = "passed")
public Object passed;

@Json(name = "public")
public Boolean _public;

@Json(name = "run")
public Integer run;

@Json(name = "source")
public String source;

@Json(name = "start_time")
public Integer startTime;

@Json(name = "status")
public String status;

@Json(name = "team_id")
public String teamId;

public Build() {}

public Build(
Integer creationTime,
Integer deletionTime,
Integer endTime,
String groupId,
String id,
Jobs jobs,
Integer modificationTime,
String name,
String orgId,
String ownerId,
Object passed,
Boolean _public,
Integer run,
String source,
Integer startTime,
String status,
String teamId) {
super();
this.creationTime = creationTime;
this.deletionTime = deletionTime;
this.endTime = endTime;
this.groupId = groupId;
this.id = id;
this.jobs = jobs;
this.modificationTime = modificationTime;
this.name = name;
this.orgId = orgId;
this.ownerId = ownerId;
this.passed = passed;
this._public = _public;
this.run = run;
this.source = source;
this.startTime = startTime;
this.status = status;
this.teamId = teamId;
}
}
37 changes: 37 additions & 0 deletions src/main/java/com/saucelabs/saucerest/model/builds/JobInBuild.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.saucelabs.saucerest.model.builds;

import com.squareup.moshi.Json;

public class JobInBuild {

@Json(name = "creation_time")
public Integer creationTime;

@Json(name = "deletion_time")
public Integer deletionTime;

@Json(name = "id")
public String id;

@Json(name = "modification_time")
public Integer modificationTime;

@Json(name = "state")
public State state;

/** No args constructor for use in serialization */
public JobInBuild() {}

public JobInBuild(
Integer creationTime,
Integer deletionTime,
String id,
Integer modificationTime,
State state) {
this.creationTime = creationTime;
this.deletionTime = deletionTime;
this.id = id;
this.modificationTime = modificationTime;
this.state = state;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.saucelabs.saucerest.model.builds;

import com.squareup.moshi.Json;

import java.util.List;

public class JobsInBuild {

@Json(name = "jobs")
public List<JobInBuild> jobs;

/** No args constructor for use in serialization */
public JobsInBuild() {}

public JobsInBuild(List<JobInBuild> jobs) {
this.jobs = jobs;
}
}
57 changes: 57 additions & 0 deletions src/main/java/com/saucelabs/saucerest/model/builds/State.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package com.saucelabs.saucerest.model.builds;

import com.squareup.moshi.Json;

public class State {

@Json(name = "completed")
public Boolean completed;

@Json(name = "errored")
public Boolean errored;

@Json(name = "failed")
public Boolean failed;

@Json(name = "finished")
public Boolean finished;

@Json(name = "new")
public Boolean _new;

@Json(name = "passed")
public Boolean passed;

@Json(name = "public")
public Boolean _public;

@Json(name = "queued")
public Boolean queued;

@Json(name = "running")
public Boolean running;

/** No args constructor for use in serialization */
public State() {}

public State(
Boolean completed,
Boolean errored,
Boolean failed,
Boolean finished,
Boolean _new,
Boolean passed,
Boolean _public,
Boolean queued,
Boolean running) {
this.completed = completed;
this.errored = errored;
this.failed = failed;
this.finished = finished;
this._new = _new;
this.passed = passed;
this._public = _public;
this.queued = queued;
this.running = running;
}
}
Loading

0 comments on commit a437f1f

Please sign in to comment.