Skip to content

Commit 0f1ac30

Browse files
committed
required params added
1 parent 51c9398 commit 0f1ac30

File tree

4 files changed

+25
-28
lines changed

4 files changed

+25
-28
lines changed
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
package io.visual_regression_tracker.sdk_java;
22

3-
import lombok.Builder;
4-
import lombok.Getter;
3+
import lombok.AllArgsConstructor;
54

6-
@Builder
7-
@Getter
5+
@AllArgsConstructor
86
public class Config {
97
String apiUrl;
10-
String branchName;
118
String projectId;
129
String token;
10+
String branchName;
1311
}

src/main/java/io/visual_regression_tracker/sdk_java/TestRun.java renamed to src/main/java/io/visual_regression_tracker/sdk_java/TestRunOptions.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55

66
@Builder
77
@Getter
8-
public class TestRun {
9-
String name;
10-
String imageBase64;
8+
public class TestRunOptions {
119
String os;
1210
String browser;
1311
String viewport;

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,17 @@ void startBuild() throws IOException {
4040
}
4141
}
4242

43-
TestResultDTO submitTestRun(TestRun testRun) throws IOException {
43+
TestResultDTO submitTestRun(String name, String imageBase64, TestRunOptions testRunOptions) throws IOException {
4444
Map<String, Object> data = new HashMap<>();
4545
data.put("projectId", this.config.projectId);
4646
data.put("buildId", this.buildId);
47-
data.put("name", testRun.getName());
48-
data.put("imageBase64", testRun.getImageBase64());
49-
data.put("os", testRun.getOs());
50-
data.put("browser", testRun.getBrowser());
51-
data.put("viewport", testRun.getViewport());
52-
data.put("device", testRun.getDevice());
53-
data.put("diffTollerancePercent", testRun.getDiffTollerancePercent());
47+
data.put("name", name);
48+
data.put("imageBase64", imageBase64);
49+
data.put("os", testRunOptions.getOs());
50+
data.put("browser", testRunOptions.getBrowser());
51+
data.put("viewport", testRunOptions.getViewport());
52+
data.put("device", testRunOptions.getDevice());
53+
data.put("diffTollerancePercent", testRunOptions.getDiffTollerancePercent());
5454

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

@@ -66,10 +66,10 @@ TestResultDTO submitTestRun(TestRun testRun) throws IOException {
6666
}
6767
}
6868

69-
public void track(TestRun testRun) throws IOException {
69+
public void track(String name, String imageBase64, TestRunOptions testRunOptions) throws IOException {
7070
this.startBuild();
7171

72-
TestResultDTO testResultDTO = this.submitTestRun(testRun);
72+
TestResultDTO testResultDTO = this.submitTestRun(name, imageBase64, testRunOptions);
7373

7474
if (testResultDTO.getStatus().equals("new")) {
7575
throw new TestRunException("No baseline: ".concat(testResultDTO.getUrl()));

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

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
import java.util.Base64;
99

1010
public class Example {
11-
Config config = Config.builder()
12-
.apiUrl("http://localhost:4200")
13-
.branchName("develop")
14-
.projectId("003f5fcf-6c5f-4f1f-a99f-82a697711382")
15-
.token("F5Z2H0H2SNMXZVHX0EA4YQM1MGDD")
16-
.build();
11+
Config config = new Config(
12+
"http://localhost:4200",
13+
"003f5fcf-6c5f-4f1f-a99f-82a697711382",
14+
"F5Z2H0H2SNMXZVHX0EA4YQM1MGDD",
15+
"develop"
16+
);
1717

1818
@Test
1919
public void asdas() throws IOException {
@@ -28,9 +28,10 @@ public void asdas() throws IOException {
2828
.getFile()
2929
));
3030

31-
visualRegressionTracker.track(TestRun.builder()
32-
.name("Java test")
33-
.imageBase64(Base64.getEncoder().encodeToString(fileContent))
34-
.build());
31+
visualRegressionTracker.track(
32+
"Java test",
33+
Base64.getEncoder().encodeToString(fileContent),
34+
TestRunOptions.builder().build()
35+
);
3536
}
3637
}

0 commit comments

Comments
 (0)