Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,27 @@

public class VisualRegressionTracker {
static final MediaType JSON = MediaType.get("application/json; charset=utf-8");
Config config;
VisualRegressionTrackerConfig visualRegressionTrackerConfig;
String buildId;
OkHttpClient client;

public VisualRegressionTracker(Config config) {
this.config = config;
public VisualRegressionTracker(VisualRegressionTrackerConfig visualRegressionTrackerConfig) {
this.visualRegressionTrackerConfig = visualRegressionTrackerConfig;

this.client = new OkHttpClient();
}

void startBuild() throws IOException {
if (this.buildId == null) {
Map<String, String> data = new HashMap<>();
data.put("projectId", this.config.projectId);
data.put("branchName", this.config.branchName);
data.put("projectId", this.visualRegressionTrackerConfig.projectId);
data.put("branchName", this.visualRegressionTrackerConfig.branchName);

RequestBody body = RequestBody.create(new Gson().toJson(data), JSON);

Request request = new Request.Builder()
.url(this.config.apiUrl.concat("/builds"))
.addHeader("apiKey", this.config.apiKey)
.url(this.visualRegressionTrackerConfig.apiUrl.concat("/builds"))
.addHeader("apiKey", this.visualRegressionTrackerConfig.apiKey)
.post(body)
.build();

Expand All @@ -42,7 +42,7 @@ void startBuild() throws IOException {

TestResultDTO submitTestRun(String name, String imageBase64, TestRunOptions testRunOptions) throws IOException {
Map<String, Object> data = new HashMap<>();
data.put("projectId", this.config.projectId);
data.put("projectId", this.visualRegressionTrackerConfig.projectId);
data.put("buildId", this.buildId);
data.put("name", name);
data.put("imageBase64", imageBase64);
Expand All @@ -55,8 +55,8 @@ TestResultDTO submitTestRun(String name, String imageBase64, TestRunOptions test
RequestBody body = RequestBody.create(new Gson().toJson(data), JSON);

Request request = new Request.Builder()
.url(this.config.apiUrl.concat("/test"))
.addHeader("apiKey", this.config.apiKey)
.url(this.visualRegressionTrackerConfig.apiUrl.concat("/test"))
.addHeader("apiKey", this.visualRegressionTrackerConfig.apiKey)
.post(body)
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import lombok.AllArgsConstructor;

@AllArgsConstructor
public class Config {
public class VisualRegressionTrackerConfig {
String apiUrl;
String projectId;
String apiKey;
Expand Down