File tree Expand file tree Collapse file tree 2 files changed +21
-3
lines changed
main/java/io/visual_regression_tracker/sdk_java
test/java/io/visual_regression_tracker/sdk_java Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -45,12 +45,15 @@ protected void startBuild() throws IOException {
4545 .build ();
4646
4747 try (Response response = client .newCall (request ).execute ()) {
48- if (response .code () == 404 ) {
49- throw new TestRunException ("Project not found" );
50- }
5148 if (response .code () == 401 ) {
5249 throw new TestRunException ("Unauthorized" );
5350 }
51+ if (response .code () == 403 ) {
52+ throw new TestRunException ("Api key not authenticated" );
53+ }
54+ if (response .code () == 404 ) {
55+ throw new TestRunException ("Project not found" );
56+ }
5457
5558 String responseBody = Optional .ofNullable (response .body ())
5659 .orElseThrow (() -> new TestRunException ("Cannot get response body" ))
Original file line number Diff line number Diff line change @@ -102,6 +102,21 @@ public void shouldThrowExceptionIfUnauthorized() throws IOException {
102102 MatcherAssert .assertThat (exceptionMessage , CoreMatchers .is ("Unauthorized" ));
103103 }
104104
105+ @ Test
106+ public void shouldThrowExceptionIfForbidden () throws IOException {
107+ server .enqueue (new MockResponse ()
108+ .setResponseCode (403 )
109+ .setBody ("{\r \n \" statusCode\" : 403,\r \n \" message\" : \" Forbidden\" \r \n }" ));
110+
111+ String exceptionMessage = "" ;
112+ try {
113+ vrt .startBuild ();
114+ } catch (TestRunException ex ) {
115+ exceptionMessage = ex .getMessage ();
116+ }
117+ MatcherAssert .assertThat (exceptionMessage , CoreMatchers .is ("Api key not authenticated" ));
118+ }
119+
105120 @ Test
106121 public void shouldSubmitTestRun () throws IOException , InterruptedException {
107122 String buildId = "123123" ;
You can’t perform that action at this time.
0 commit comments