diff --git a/README.md b/README.md
index 5df2c03..16982de 100644
--- a/README.md
+++ b/README.md
@@ -1,18 +1,18 @@
# Java SDK for [Visual Regression Tracker](https://github.com/Visual-Regression-Tracker/Visual-Regression-Tracker)
## Gradle
-```
+```yml
repositories {
maven { url 'https://jitpack.io' }
}
```
-```
+```yml
dependencies {
- implementation group: 'com.github.visual-regression-tracker', name: 'sdk-java', version: '${VERSION}'
+ implementation group: 'com.github.visual-regression-tracker', name: 'sdk-java', version: '${REPLACE_THIS_VALUE}'
}
```
## Maven
-```
+```xml
jitpack.io
@@ -20,11 +20,11 @@ dependencies {
```
-```
+```xml
com.github.Visual-Regression-Tracker
sdk-java
- ${VERSION}
+ ${REPLACE_THIS_VALUE}
```
[Available versions](https://github.com/Visual-Regression-Tracker/sdk-java/releases)
@@ -33,41 +33,41 @@ More info about https://jitpack.io/
## Usage
* Create config
-```
+```java
VisualRegressionTrackerConfig config = new VisualRegressionTrackerConfig(
- // apiUrl - URL to Visual Regression Tracker backend
+ // apiUrl - URL where backend is running
"http://localhost:4200",
- // projectId - copy from project details
+ // project - Project name or ID
"003f5fcf-6c5f-4f1f-a99f-82a697711382",
- // apiKey - copy from user details
+ // apiKey - User apiKey
"F5Z2H0H2SNMXZVHX0EA4YQM1MGDD",
- // branch - helps to identify version of application under test
+ // branch - Current git branch
"develop"
);
```
* Create an instance of `VisualRegressionTracker`
-```
+```java
VisualRegressionTracker visualRegressionTracker = new VisualRegressionTracker(config);
```
* Take a screenshot as String in Base64 format
-```
+```java
// Selenium example
String screenshotBase64 = ((TakesScreenshot) driver).getScreenshotAs(OutputType.BASE64);
```
* Track image
Default options
-```
+```java
visualRegressionTracker.track(
"Name for test",
screenshotBase64
);
```
With specific options
-```
+```java
visualRegressionTracker.track(
"Name for test",
screenshotBase64,
diff --git a/build.gradle b/build.gradle
index 8211b50..18f4a55 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,5 +1,5 @@
group 'io.visual-regression-tracker.sdk-java'
-version '1.3.0'
+version '2.0.0'
apply plugin: 'java'
apply plugin: "io.freefair.lombok"
diff --git a/src/main/java/io/visual_regression_tracker/sdk_java/VisualRegressionTracker.java b/src/main/java/io/visual_regression_tracker/sdk_java/VisualRegressionTracker.java
index 70e63b0..3810b4a 100644
--- a/src/main/java/io/visual_regression_tracker/sdk_java/VisualRegressionTracker.java
+++ b/src/main/java/io/visual_regression_tracker/sdk_java/VisualRegressionTracker.java
@@ -15,6 +15,7 @@ public class VisualRegressionTracker {
Gson gson = new Gson();
VisualRegressionTrackerConfig visualRegressionTrackerConfig;
String buildId;
+ String projectId;
OkHttpClient client;
public VisualRegressionTracker(VisualRegressionTrackerConfig visualRegressionTrackerConfig) {
@@ -27,7 +28,7 @@ void startBuild() throws IOException {
if (this.buildId == null) {
BuildRequest newBuild = BuildRequest.builder()
.branchName(this.visualRegressionTrackerConfig.branchName)
- .projectId(this.visualRegressionTrackerConfig.projectId)
+ .project(this.visualRegressionTrackerConfig.project)
.build();
RequestBody body = RequestBody.create(gson.toJson(newBuild), JSON);
@@ -41,13 +42,14 @@ void startBuild() throws IOException {
try (ResponseBody responseBody = client.newCall(request).execute().body()) {
BuildResponse buildDTO = new Gson().fromJson(responseBody.string(), BuildResponse.class);
this.buildId = buildDTO.getId();
+ this.projectId = buildDTO.getProjectId();
}
}
}
TestRunResponse submitTestRun(String name, String imageBase64, TestRunOptions testRunOptions) throws IOException {
TestRunRequest newTestRun = TestRunRequest.builder()
- .projectId(this.visualRegressionTrackerConfig.projectId)
+ .projectId(this.projectId)
.buildId(this.buildId)
.name(name)
.imageBase64(imageBase64)
diff --git a/src/main/java/io/visual_regression_tracker/sdk_java/VisualRegressionTrackerConfig.java b/src/main/java/io/visual_regression_tracker/sdk_java/VisualRegressionTrackerConfig.java
index 3b66e23..6e4b1fe 100644
--- a/src/main/java/io/visual_regression_tracker/sdk_java/VisualRegressionTrackerConfig.java
+++ b/src/main/java/io/visual_regression_tracker/sdk_java/VisualRegressionTrackerConfig.java
@@ -5,7 +5,7 @@
@AllArgsConstructor
public class VisualRegressionTrackerConfig {
String apiUrl;
- String projectId;
+ String project;
String apiKey;
String branchName;
}
diff --git a/src/main/java/io/visual_regression_tracker/sdk_java/request/BuildRequest.java b/src/main/java/io/visual_regression_tracker/sdk_java/request/BuildRequest.java
index be5ca5b..ed909b7 100644
--- a/src/main/java/io/visual_regression_tracker/sdk_java/request/BuildRequest.java
+++ b/src/main/java/io/visual_regression_tracker/sdk_java/request/BuildRequest.java
@@ -4,6 +4,6 @@
@Builder
public class BuildRequest {
- String projectId;
+ String project;
String branchName;
}
diff --git a/src/main/java/io/visual_regression_tracker/sdk_java/response/BuildResponse.java b/src/main/java/io/visual_regression_tracker/sdk_java/response/BuildResponse.java
index 55ba471..d1da56c 100644
--- a/src/main/java/io/visual_regression_tracker/sdk_java/response/BuildResponse.java
+++ b/src/main/java/io/visual_regression_tracker/sdk_java/response/BuildResponse.java
@@ -7,4 +7,5 @@
@Getter
public class BuildResponse {
String id;
+ String projectId;
}
diff --git a/src/test/java/io/visual_regression_tracker/sdk_java/VisualRegressionTrackerTest.java b/src/test/java/io/visual_regression_tracker/sdk_java/VisualRegressionTrackerTest.java
index b190204..86c44fc 100644
--- a/src/test/java/io/visual_regression_tracker/sdk_java/VisualRegressionTrackerTest.java
+++ b/src/test/java/io/visual_regression_tracker/sdk_java/VisualRegressionTrackerTest.java
@@ -50,12 +50,14 @@ void tearDown() {
@Test
void shouldStartBuild() throws IOException, InterruptedException {
String buildId = "123123";
+ String projectId = "projectId";
BuildRequest buildRequest = BuildRequest.builder()
.branchName(this.config.branchName)
- .projectId(this.config.projectId)
+ .project(this.config.project)
.build();
BuildResponse buildResponse = BuildResponse.builder()
.id(buildId)
+ .projectId(projectId)
.build();
server.enqueue(new MockResponse().setBody(gson.toJson(buildResponse)));
@@ -65,11 +67,13 @@ void shouldStartBuild() throws IOException, InterruptedException {
MatcherAssert.assertThat(request.getHeader(vrt.apiKeyHeaderName), CoreMatchers.is(config.apiKey));
MatcherAssert.assertThat(request.getBody().readUtf8(), CoreMatchers.is(gson.toJson(buildRequest)));
MatcherAssert.assertThat(vrt.buildId, CoreMatchers.is(buildId));
+ MatcherAssert.assertThat(vrt.projectId, CoreMatchers.is(projectId));
}
@Test
void shouldSubmitTestRun() throws IOException, InterruptedException {
String buildId = "123123";
+ String projectId = "projectId";
String name = "Test name";
String imageBase64 = "image";
TestRunOptions testRunOptions = TestRunOptions.builder()
@@ -80,7 +84,7 @@ void shouldSubmitTestRun() throws IOException, InterruptedException {
.diffTollerancePercent(5)
.build();
TestRunRequest testRunRequest = TestRunRequest.builder()
- .projectId(this.config.projectId)
+ .projectId(projectId)
.buildId(buildId)
.name(name)
.imageBase64(imageBase64)