Skip to content

Commit 5afafcd

Browse files
committed
project name added for build creation
1 parent 970b6f9 commit 5afafcd

File tree

7 files changed

+29
-22
lines changed

7 files changed

+29
-22
lines changed

README.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
# Java SDK for [Visual Regression Tracker](https://github.com/Visual-Regression-Tracker/Visual-Regression-Tracker)
22

33
## Gradle
4-
```
4+
```yml
55
repositories {
66
maven { url 'https://jitpack.io' }
77
}
88
```
9-
```
9+
```yml
1010
dependencies {
11-
implementation group: 'com.github.visual-regression-tracker', name: 'sdk-java', version: '${VERSION}'
11+
implementation group: 'com.github.visual-regression-tracker', name: 'sdk-java', version: '${REPLACE_THIS_VALUE}'
1212
}
1313
```
1414
## Maven
15-
```
15+
```xml
1616
<repositories>
1717
<repository>
1818
<id>jitpack.io</id>
1919
<url>https://jitpack.io</url>
2020
</repository>
2121
</repositories>
2222
```
23-
```
23+
```xml
2424
<dependency>
2525
<groupId>com.github.Visual-Regression-Tracker</groupId>
2626
<artifactId>sdk-java</artifactId>
27-
<version>${VERSION}</version>
27+
<version>${REPLACE_THIS_VALUE}</version>
2828
</dependency>
2929
```
3030
[Available versions](https://github.com/Visual-Regression-Tracker/sdk-java/releases)
@@ -33,41 +33,41 @@ More info about https://jitpack.io/
3333

3434
## Usage
3535
* Create config
36-
```
36+
```java
3737
VisualRegressionTrackerConfig config = new VisualRegressionTrackerConfig(
38-
// apiUrl - URL to Visual Regression Tracker backend
38+
// apiUrl - URL where backend is running
3939
"http://localhost:4200",
4040

41-
// projectId - copy from project details
41+
// project - Project name or ID
4242
"003f5fcf-6c5f-4f1f-a99f-82a697711382",
4343

44-
// apiKey - copy from user details
44+
// apiKey - User apiKey
4545
"F5Z2H0H2SNMXZVHX0EA4YQM1MGDD",
4646

47-
// branch - helps to identify version of application under test
47+
// branch - Current git branch
4848
"develop"
4949
);
5050
```
5151
* Create an instance of `VisualRegressionTracker`
52-
```
52+
```java
5353
VisualRegressionTracker visualRegressionTracker = new VisualRegressionTracker(config);
5454
```
5555
* Take a screenshot as String in Base64 format
56-
```
56+
```java
5757
// Selenium example
5858
String screenshotBase64 = ((TakesScreenshot) driver).getScreenshotAs(OutputType.BASE64);
5959
```
6060
* Track image
6161

6262
Default options
63-
```
63+
```java
6464
visualRegressionTracker.track(
6565
"Name for test",
6666
screenshotBase64
6767
);
6868
```
6969
With specific options
70-
```
70+
```java
7171
visualRegressionTracker.track(
7272
"Name for test",
7373
screenshotBase64,

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
group 'io.visual-regression-tracker.sdk-java'
2-
version '1.3.0'
2+
version '2.0.0'
33

44
apply plugin: 'java'
55
apply plugin: "io.freefair.lombok"

src/main/java/io/visual_regression_tracker/sdk_java/VisualRegressionTracker.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public class VisualRegressionTracker {
1515
Gson gson = new Gson();
1616
VisualRegressionTrackerConfig visualRegressionTrackerConfig;
1717
String buildId;
18+
String projectId;
1819
OkHttpClient client;
1920

2021
public VisualRegressionTracker(VisualRegressionTrackerConfig visualRegressionTrackerConfig) {
@@ -27,7 +28,7 @@ void startBuild() throws IOException {
2728
if (this.buildId == null) {
2829
BuildRequest newBuild = BuildRequest.builder()
2930
.branchName(this.visualRegressionTrackerConfig.branchName)
30-
.projectId(this.visualRegressionTrackerConfig.projectId)
31+
.project(this.visualRegressionTrackerConfig.project)
3132
.build();
3233

3334
RequestBody body = RequestBody.create(gson.toJson(newBuild), JSON);
@@ -41,13 +42,14 @@ void startBuild() throws IOException {
4142
try (ResponseBody responseBody = client.newCall(request).execute().body()) {
4243
BuildResponse buildDTO = new Gson().fromJson(responseBody.string(), BuildResponse.class);
4344
this.buildId = buildDTO.getId();
45+
this.projectId = buildDTO.getProjectId();
4446
}
4547
}
4648
}
4749

4850
TestRunResponse submitTestRun(String name, String imageBase64, TestRunOptions testRunOptions) throws IOException {
4951
TestRunRequest newTestRun = TestRunRequest.builder()
50-
.projectId(this.visualRegressionTrackerConfig.projectId)
52+
.projectId(this.projectId)
5153
.buildId(this.buildId)
5254
.name(name)
5355
.imageBase64(imageBase64)

src/main/java/io/visual_regression_tracker/sdk_java/VisualRegressionTrackerConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
@AllArgsConstructor
66
public class VisualRegressionTrackerConfig {
77
String apiUrl;
8-
String projectId;
8+
String project;
99
String apiKey;
1010
String branchName;
1111
}

src/main/java/io/visual_regression_tracker/sdk_java/request/BuildRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44

55
@Builder
66
public class BuildRequest {
7-
String projectId;
7+
String project;
88
String branchName;
99
}

src/main/java/io/visual_regression_tracker/sdk_java/response/BuildResponse.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@
77
@Getter
88
public class BuildResponse {
99
String id;
10+
String projectId;
1011
}

src/test/java/io/visual_regression_tracker/sdk_java/VisualRegressionTrackerTest.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,14 @@ void tearDown() {
5050
@Test
5151
void shouldStartBuild() throws IOException, InterruptedException {
5252
String buildId = "123123";
53+
String projectId = "projectId";
5354
BuildRequest buildRequest = BuildRequest.builder()
5455
.branchName(this.config.branchName)
55-
.projectId(this.config.projectId)
56+
.project(this.config.project)
5657
.build();
5758
BuildResponse buildResponse = BuildResponse.builder()
5859
.id(buildId)
60+
.projectId(projectId)
5961
.build();
6062
server.enqueue(new MockResponse().setBody(gson.toJson(buildResponse)));
6163

@@ -65,11 +67,13 @@ void shouldStartBuild() throws IOException, InterruptedException {
6567
MatcherAssert.assertThat(request.getHeader(vrt.apiKeyHeaderName), CoreMatchers.is(config.apiKey));
6668
MatcherAssert.assertThat(request.getBody().readUtf8(), CoreMatchers.is(gson.toJson(buildRequest)));
6769
MatcherAssert.assertThat(vrt.buildId, CoreMatchers.is(buildId));
70+
MatcherAssert.assertThat(vrt.projectId, CoreMatchers.is(projectId));
6871
}
6972

7073
@Test
7174
void shouldSubmitTestRun() throws IOException, InterruptedException {
7275
String buildId = "123123";
76+
String projectId = "projectId";
7377
String name = "Test name";
7478
String imageBase64 = "image";
7579
TestRunOptions testRunOptions = TestRunOptions.builder()
@@ -80,7 +84,7 @@ void shouldSubmitTestRun() throws IOException, InterruptedException {
8084
.diffTollerancePercent(5)
8185
.build();
8286
TestRunRequest testRunRequest = TestRunRequest.builder()
83-
.projectId(this.config.projectId)
87+
.projectId(projectId)
8488
.buildId(buildId)
8589
.name(name)
8690
.imageBase64(imageBase64)

0 commit comments

Comments
 (0)