2020import java .io .IOException ;
2121
2222public class VisualRegressionTrackerTest {
23- Gson gson = new Gson ();
24- MockWebServer server ;
25- VisualRegressionTracker vrt ;
26- VisualRegressionTrackerConfig config = new VisualRegressionTrackerConfig (
23+ private final Gson gson = new Gson ();
24+ private final VisualRegressionTrackerConfig config = new VisualRegressionTrackerConfig (
2725 "http://localhost" ,
2826 "733c148e-ef70-4e6d-9ae5-ab22263697cc" ,
2927 "XHGDZDFD3GMJDNM87JKEMP0JS1G5" ,
3028 "develop"
3129 );
30+ private MockWebServer server ;
31+ private VisualRegressionTracker vrt ;
3232
3333 @ SneakyThrows
3434 @ BeforeMethod
35- void setup () {
35+ private void setup () {
3636 server = new MockWebServer ();
3737 server .start ();
3838
3939 // target to mock server
40- this .config .apiUrl = server .url ("/" ).toString ();
40+ this .config .setApiUrl ( server .url ("/" ).toString () );
4141 vrt = new VisualRegressionTracker (config );
4242 }
4343
4444 @ SneakyThrows
4545 @ AfterMethod
46- void tearDown () {
46+ private void tearDown () {
4747 server .shutdown ();
4848 }
4949
5050 @ Test
51- void shouldStartBuild () throws IOException , InterruptedException {
51+ public void shouldStartBuild () throws IOException , InterruptedException {
5252 String buildId = "123123" ;
5353 String projectId = "projectId" ;
5454 BuildRequest buildRequest = BuildRequest .builder ()
55- .branchName (this .config .branchName )
56- .project (this .config .project )
55+ .branchName (this .config .getBranchName () )
56+ .project (this .config .getProject () )
5757 .build ();
5858 BuildResponse buildResponse = BuildResponse .builder ()
5959 .id (buildId )
@@ -66,14 +66,14 @@ void shouldStartBuild() throws IOException, InterruptedException {
6666 vrt .startBuild ();
6767
6868 RecordedRequest request = server .takeRequest ();
69- MatcherAssert .assertThat (request .getHeader (vrt .apiKeyHeaderName ), CoreMatchers .is (config .apiKey ));
69+ MatcherAssert .assertThat (request .getHeader (vrt .apiKeyHeaderName ), CoreMatchers .is (config .getApiKey () ));
7070 MatcherAssert .assertThat (request .getBody ().readUtf8 (), CoreMatchers .is (gson .toJson (buildRequest )));
7171 MatcherAssert .assertThat (vrt .buildId , CoreMatchers .is (buildId ));
7272 MatcherAssert .assertThat (vrt .projectId , CoreMatchers .is (projectId ));
7373 }
7474
7575 @ Test
76- void shouldThrowExceptionIfProjectNotFound () throws IOException {
76+ public void shouldThrowExceptionIfProjectNotFound () throws IOException {
7777 server .enqueue (new MockResponse ()
7878 .setResponseCode (404 )
7979 .setBody ("{\r \n \" statusCode\" : 404,\r \n \" message\" : \" Project not found\" \r \n }" ));
@@ -88,7 +88,7 @@ void shouldThrowExceptionIfProjectNotFound() throws IOException {
8888 }
8989
9090 @ Test
91- void shouldThrowExceptionIfUnauthorized () throws IOException {
91+ public void shouldThrowExceptionIfUnauthorized () throws IOException {
9292 server .enqueue (new MockResponse ()
9393 .setResponseCode (401 )
9494 .setBody ("{\r \n \" statusCode\" : 401,\r \n \" message\" : \" Unauthorized\" \r \n }" ));
@@ -103,7 +103,7 @@ void shouldThrowExceptionIfUnauthorized() throws IOException {
103103 }
104104
105105 @ Test
106- void shouldSubmitTestRun () throws IOException , InterruptedException {
106+ public void shouldSubmitTestRun () throws IOException , InterruptedException {
107107 String buildId = "123123" ;
108108 String projectId = "projectId" ;
109109 String name = "Test name" ;
@@ -117,7 +117,7 @@ void shouldSubmitTestRun() throws IOException, InterruptedException {
117117 .build ();
118118 TestRunRequest testRunRequest = TestRunRequest .builder ()
119119 .projectId (projectId )
120- .branchName (config .branchName )
120+ .branchName (config .getBranchName () )
121121 .buildId (buildId )
122122 .name (name )
123123 .imageBase64 (imageBase64 )
@@ -137,7 +137,7 @@ void shouldSubmitTestRun() throws IOException, InterruptedException {
137137 TestRunResponse result = vrt .submitTestRun (name , imageBase64 , testRunOptions );
138138
139139 RecordedRequest request = server .takeRequest ();
140- MatcherAssert .assertThat (request .getHeader (vrt .apiKeyHeaderName ), CoreMatchers .is (config .apiKey ));
140+ MatcherAssert .assertThat (request .getHeader (vrt .apiKeyHeaderName ), CoreMatchers .is (config .getApiKey () ));
141141 MatcherAssert .assertThat (request .getBody ().readUtf8 (), CoreMatchers .is (gson .toJson (testRunRequest )));
142142 MatcherAssert .assertThat (gson .toJson (result ), CoreMatchers .is (gson .toJson (testRunResponse )));
143143 }
@@ -163,7 +163,7 @@ public Object[][] shouldTrackThrowExceptionCases() {
163163 }
164164
165165 @ Test (dataProvider = "shouldTrackThrowExceptionCases" )
166- void shouldTrackThrowException (TestRunResponse testRunResponse , String expectedExceptionMessage ) throws IOException {
166+ public void shouldTrackThrowException (TestRunResponse testRunResponse , String expectedExceptionMessage ) throws IOException {
167167 VisualRegressionTracker vrtMocked = Mockito .mock (VisualRegressionTracker .class );
168168 Mockito .when (vrtMocked .submitTestRun (Mockito .anyString (), Mockito .anyString (), Mockito .any ())).thenReturn (testRunResponse );
169169
@@ -190,7 +190,7 @@ public Object[][] shouldTrackPassCases() {
190190 }
191191
192192 @ Test (dataProvider = "shouldTrackPassCases" )
193- void shouldTrackPass (TestRunResponse testRunResponse ) throws IOException {
193+ public void shouldTrackPass (TestRunResponse testRunResponse ) throws IOException {
194194 VisualRegressionTracker vrtMocked = Mockito .mock (VisualRegressionTracker .class );
195195 Mockito .when (vrtMocked .submitTestRun (Mockito .anyString (), Mockito .anyString (), Mockito .any ())).thenReturn (testRunResponse );
196196
@@ -199,7 +199,7 @@ void shouldTrackPass(TestRunResponse testRunResponse) throws IOException {
199199 }
200200
201201 @ Test ()
202- void shouldTrackOverload () throws IOException {
202+ public void shouldTrackOverload () throws IOException {
203203 VisualRegressionTracker vrtMocked = Mockito .mock (VisualRegressionTracker .class );
204204
205205 Mockito .doCallRealMethod ().when (vrtMocked ).track (Mockito .anyString (), Mockito .anyString ());
0 commit comments