Skip to content

Commit c261b68

Browse files
committed
updated
1 parent d4f41fa commit c261b68

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import okhttp3.ResponseBody;
1414

1515
import java.io.IOException;
16+
import java.util.Optional;
1617

1718
public class VisualRegressionTracker {
1819
static final MediaType JSON = MediaType.get("application/json; charset=utf-8");
@@ -51,8 +52,11 @@ void startBuild() throws IOException {
5152
if (response.code() == 401) {
5253
throw new TestRunException("Unauthorized");
5354
}
54-
ResponseBody responseBody = response.body();
55-
BuildResponse buildDTO = new Gson().fromJson(responseBody.string(), BuildResponse.class);
55+
56+
String responseBody = Optional.ofNullable(response.body())
57+
.orElseThrow(() -> new TestRunException("Cannot get response body"))
58+
.string();
59+
BuildResponse buildDTO = new Gson().fromJson(responseBody, BuildResponse.class);
5660
this.buildId = buildDTO.getId();
5761
this.projectId = buildDTO.getProjectId();
5862
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class VisualRegressionTrackerTest {
2424
MockWebServer server;
2525
VisualRegressionTracker vrt;
2626
VisualRegressionTrackerConfig config = new VisualRegressionTrackerConfig(
27-
"http://localhost:4200",
27+
"http://localhost",
2828
"733c148e-ef70-4e6d-9ae5-ab22263697cc",
2929
"XHGDZDFD3GMJDNM87JKEMP0JS1G5",
3030
"develop"

0 commit comments

Comments
 (0)