@@ -24,9 +24,9 @@ public class VisualRegressionTrackerTest {
2424 MockWebServer server ;
2525 VisualRegressionTracker vrt ;
2626 VisualRegressionTrackerConfig config = new VisualRegressionTrackerConfig (
27- "http://localhost" ,
27+ "http://localhost:4200 " ,
2828 "733c148e-ef70-4e6d-9ae5-ab22263697cc" ,
29- "BAZ0EG0PRH4CRQPH19ZKAVADBP9E1 " ,
29+ "XHGDZDFD3GMJDNM87JKEMP0JS1G5 " ,
3030 "develop"
3131 );
3232
@@ -71,18 +71,33 @@ void shouldStartBuild() throws IOException, InterruptedException {
7171 }
7272
7373 @ Test
74- void shouldThrowExceptionIfProjectNotFound () throws IOException , InterruptedException {
75- String projectId = "non-existing" ;
76- BuildRequest buildRequest = BuildRequest .builder ()
77- .branchName (this .config .branchName )
78- .project (this .config .project )
79- .build ();
74+ void shouldThrowExceptionIfProjectNotFound () throws IOException {
8075 server .enqueue (new MockResponse ()
81- .setHttp2ErrorCode (404 )
76+ .setResponseCode (404 )
8277 .setBody ("{\r \n \" statusCode\" : 404,\r \n \" message\" : \" Project not found\" \r \n }" ));
8378
84- vrt .startBuild ();
79+ String exceptionMessage = "" ;
80+ try {
81+ vrt .startBuild ();
82+ } catch (TestRunException ex ) {
83+ exceptionMessage = ex .getMessage ();
84+ }
85+ MatcherAssert .assertThat (exceptionMessage , CoreMatchers .is ("Project not found" ));
86+ }
8587
88+ @ Test
89+ void shouldThrowExceptionIfUnauthorized () throws IOException {
90+ server .enqueue (new MockResponse ()
91+ .setResponseCode (401 )
92+ .setBody ("{\r \n \" statusCode\" : 401,\r \n \" message\" : \" Unauthorized\" \r \n }" ));
93+
94+ String exceptionMessage = "" ;
95+ try {
96+ vrt .startBuild ();
97+ } catch (TestRunException ex ) {
98+ exceptionMessage = ex .getMessage ();
99+ }
100+ MatcherAssert .assertThat (exceptionMessage , CoreMatchers .is ("Unauthorized" ));
86101 }
87102
88103 @ Test
@@ -144,7 +159,6 @@ public Object[][] shouldTrackThrowExceptionCases() {
144159 };
145160 }
146161
147-
148162 @ Test (dataProvider = "shouldTrackThrowExceptionCases" )
149163 public void shouldTrackThrowException (TestRunResponse testRunResponse , String expectedExceptionMessage ) throws IOException {
150164 VisualRegressionTracker vrtMocked = Mockito .mock (VisualRegressionTracker .class );
0 commit comments