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
12 changes: 6 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ buildscript {
}

dependencies {
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'com.google.code.gson:gson:2.9.0'
implementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'
testImplementation group: 'org.testng', name: 'testng', version: '7.3.0'
testImplementation 'commons-io:commons-io:2.7'
testImplementation 'org.mockito:mockito-core:3.5.13'
testImplementation "com.squareup.okhttp3:mockwebserver:4.8.1"
testImplementation group: 'org.testng', name: 'testng', version: '7.5'
testImplementation 'commons-io:commons-io:2.11.0'
testImplementation 'org.mockito:mockito-core:4.4.0'
testImplementation 'com.squareup.okhttp3:mockwebserver:4.9.3'
}

test {
Expand All @@ -45,4 +45,4 @@ jacocoTestReport {
}
}

check.dependsOn jacocoTestReport
check.dependsOn jacocoTestReport
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class VisualRegressionTracker {

private static final String TRACKER_NOT_STARTED = "Visual Regression Tracker has not been started";
protected static final String API_KEY_HEADER = "apiKey";
protected static final String PROJECT_HEADER = "project";
protected Gson gson;
protected VisualRegressionTrackerConfig configuration;
protected PathProvider paths;
Expand Down Expand Up @@ -56,7 +57,7 @@ public BuildResponse start() throws IOException, InterruptedException {
projectId = buildResponse.getProjectId();

log.info("Visual Regression Tracker is started for project <{}>: projectId: <{}>, buildId: <{}>, ciBuildId: <{}>",
projectName, projectId, buildId, buildResponse.getCiBuildId());
projectName, projectId, buildId, buildResponse.getCiBuildId());
return buildResponse;
}

Expand Down Expand Up @@ -142,6 +143,7 @@ private HttpResponse<String> getResponse(METHOD method, String url, HttpRequest.
HttpRequest.Builder requestBuilder = HttpRequest.newBuilder()
.timeout(Duration.ofSeconds(configuration.getHttpTimeoutInSeconds()))
.header(API_KEY_HEADER, configuration.getApiKey())
.header(PROJECT_HEADER, configuration.getProject())
.header("Content-Type", "application/json;charset=UTF-8")
.uri(URI.create(url));
HttpRequest request = getRequest(method, body, requestBuilder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public void shouldStartBuild() throws IOException, InterruptedException {

RecordedRequest recordedRequest = mockWebServer.takeRequest();
assertThat(recordedRequest.getHeader(VisualRegressionTracker.API_KEY_HEADER), is(config.getApiKey()));
assertThat(recordedRequest.getHeader(VisualRegressionTracker.PROJECT_HEADER), is(config.getProject()));
assertThat(recordedRequest.getBody().readUtf8(), is(gson.toJson(buildRequest)));
assertThat(vrt.buildId, is(BUILD_ID));
assertThat(vrt.projectId, is(PROJECT_ID));
Expand Down Expand Up @@ -130,6 +131,7 @@ public void shouldStopBuild() throws IOException, InterruptedException {
RecordedRequest recordedRequest = mockWebServer.takeRequest();
assertThat(recordedRequest.getMethod(), is("PATCH"));
assertThat(recordedRequest.getHeader(VisualRegressionTracker.API_KEY_HEADER), is(config.getApiKey()));
assertThat(recordedRequest.getHeader(VisualRegressionTracker.PROJECT_HEADER), is(config.getProject()));
assertThat(Objects.requireNonNull(recordedRequest.getRequestUrl()).encodedPath(), containsString(BUILD_ID));
assertThat(actualBuildResponse.isRunning(), is(false));
assertThat(actualBuildResponse.getStatus(), containsString("unresolved"));
Expand Down Expand Up @@ -184,6 +186,7 @@ public void shouldSubmitTestRun() throws IOException, InterruptedException {

RecordedRequest request = mockWebServer.takeRequest();
assertThat(request.getHeader(VisualRegressionTracker.API_KEY_HEADER), is(config.getApiKey()));
assertThat(request.getHeader(VisualRegressionTracker.PROJECT_HEADER), is(config.getProject()));
assertThat(request.getBody().readUtf8(), is(gson.toJson(testRunRequest)));
assertThat(gson.toJson(result), is(gson.toJson(testRunResponse)));
}
Expand Down