11package io .split .engine .sse ;
22
33import io .split .TestHelper ;
4+ import io .split .client .RequestDecorator ;
45import io .split .engine .sse .dtos .AuthenticationResponse ;
6+ import io .split .service .SplitHttpClient ;
7+ import io .split .service .SplitHttpClientImpl ;
58import io .split .telemetry .storage .InMemoryTelemetryStorage ;
69import io .split .telemetry .storage .TelemetryStorage ;
710import org .apache .commons .lang3 .StringUtils ;
1417
1518import java .io .IOException ;
1619import java .lang .reflect .InvocationTargetException ;
20+ import java .net .URISyntaxException ;
1721
1822public class AuthApiClientTest {
1923 private static TelemetryStorage TELEMETRY_STORAGE = Mockito .mock (InMemoryTelemetryStorage .class );
@@ -23,10 +27,10 @@ public void setUp() {
2327 TELEMETRY_STORAGE = Mockito .mock (InMemoryTelemetryStorage .class );
2428 }
2529 @ Test
26- public void authenticateWithPushEnabledShouldReturnSuccess () throws IOException , IllegalAccessException , NoSuchMethodException , InvocationTargetException {
30+ public void authenticateWithPushEnabledShouldReturnSuccess () throws IOException , IllegalAccessException , NoSuchMethodException , InvocationTargetException , URISyntaxException {
2731 CloseableHttpClient httpClientMock = TestHelper .mockHttpClient ("streaming-auth-push-enabled.json" , HttpStatus .SC_OK );
28-
29- AuthApiClient authApiClient = new AuthApiClientImp ( "www.split-test.io" , httpClientMock , TELEMETRY_STORAGE );
32+ SplitHttpClient splitHttpClient = SplitHttpClientImpl . create ( httpClientMock , new RequestDecorator ( null ));
33+ AuthApiClient authApiClient = new AuthApiClientImp ( "www.split-test.io" , splitHttpClient , TELEMETRY_STORAGE );
3034 AuthenticationResponse result = authApiClient .Authenticate ();
3135
3236 Assert .assertTrue (result .isPushEnabled ());
@@ -41,10 +45,11 @@ public void authenticateWithPushEnabledShouldReturnSuccess() throws IOException,
4145 }
4246
4347 @ Test
44- public void authenticateWithPushEnabledWithWrongTokenShouldReturnError () throws IOException , IllegalAccessException , NoSuchMethodException , InvocationTargetException {
48+ public void authenticateWithPushEnabledWithWrongTokenShouldReturnError () throws IOException , IllegalAccessException , NoSuchMethodException , InvocationTargetException , URISyntaxException {
4549 CloseableHttpClient httpClientMock = TestHelper .mockHttpClient ("streaming-auth-push-enabled-wrong-token.json" , HttpStatus .SC_OK );
50+ SplitHttpClient splitHttpClient = SplitHttpClientImpl .create (httpClientMock , new RequestDecorator (null ));
4651
47- AuthApiClient authApiClient = new AuthApiClientImp ( "www.split-test.io" , httpClientMock , TELEMETRY_STORAGE );
52+ AuthApiClient authApiClient = new AuthApiClientImp ( "www.split-test.io" , splitHttpClient , TELEMETRY_STORAGE );
4853 AuthenticationResponse result = authApiClient .Authenticate ();
4954
5055 Assert .assertFalse (result .isPushEnabled ());
@@ -55,10 +60,11 @@ public void authenticateWithPushEnabledWithWrongTokenShouldReturnError() throws
5560 }
5661
5762 @ Test
58- public void authenticateWithPushDisabledShouldReturnSuccess () throws IOException , IllegalAccessException , NoSuchMethodException , InvocationTargetException {
63+ public void authenticateWithPushDisabledShouldReturnSuccess () throws IOException , IllegalAccessException , NoSuchMethodException , InvocationTargetException , URISyntaxException {
5964 CloseableHttpClient httpClientMock = TestHelper .mockHttpClient ("streaming-auth-push-disabled.json" , HttpStatus .SC_OK );
65+ SplitHttpClient splitHttpClient = SplitHttpClientImpl .create (httpClientMock , new RequestDecorator (null ));
6066
61- AuthApiClient authApiClient = new AuthApiClientImp ("www.split-test.io" , httpClientMock , TELEMETRY_STORAGE );
67+ AuthApiClient authApiClient = new AuthApiClientImp ("www.split-test.io" , splitHttpClient , TELEMETRY_STORAGE );
6268 AuthenticationResponse result = authApiClient .Authenticate ();
6369
6470 Assert .assertFalse (result .isPushEnabled ());
@@ -68,10 +74,11 @@ public void authenticateWithPushDisabledShouldReturnSuccess() throws IOException
6874 }
6975
7076 @ Test
71- public void authenticateServerErrorShouldReturnErrorWithRetry () throws IOException , IllegalAccessException , NoSuchMethodException , InvocationTargetException {
77+ public void authenticateServerErrorShouldReturnErrorWithRetry () throws IOException , IllegalAccessException , NoSuchMethodException , InvocationTargetException , URISyntaxException {
7278 CloseableHttpClient httpClientMock = TestHelper .mockHttpClient ("" , HttpStatus .SC_INTERNAL_SERVER_ERROR );
79+ SplitHttpClient splitHttpClient = SplitHttpClientImpl .create (httpClientMock , new RequestDecorator (null ));
7380
74- AuthApiClient authApiClient = new AuthApiClientImp ("www.split-test.io" , httpClientMock , TELEMETRY_STORAGE );
81+ AuthApiClient authApiClient = new AuthApiClientImp ("www.split-test.io" , splitHttpClient , TELEMETRY_STORAGE );
7582 AuthenticationResponse result = authApiClient .Authenticate ();
7683
7784 Assert .assertFalse (result .isPushEnabled ());
@@ -81,10 +88,11 @@ public void authenticateServerErrorShouldReturnErrorWithRetry() throws IOExcepti
8188 }
8289
8390 @ Test
84- public void authenticateServerBadRequestShouldReturnErrorWithoutRetry () throws IOException , IllegalAccessException , NoSuchMethodException , InvocationTargetException {
91+ public void authenticateServerBadRequestShouldReturnErrorWithoutRetry () throws IOException , IllegalAccessException , NoSuchMethodException , InvocationTargetException , URISyntaxException {
8592 CloseableHttpClient httpClientMock = TestHelper .mockHttpClient ("" , HttpStatus .SC_BAD_REQUEST );
93+ SplitHttpClient splitHttpClient = SplitHttpClientImpl .create (httpClientMock , new RequestDecorator (null ));
8694
87- AuthApiClient authApiClient = new AuthApiClientImp ("www.split-test.io" , httpClientMock , TELEMETRY_STORAGE );
95+ AuthApiClient authApiClient = new AuthApiClientImp ("www.split-test.io" , splitHttpClient , TELEMETRY_STORAGE );
8896 AuthenticationResponse result = authApiClient .Authenticate ();
8997
9098 Assert .assertFalse (result .isPushEnabled ());
@@ -94,10 +102,11 @@ public void authenticateServerBadRequestShouldReturnErrorWithoutRetry() throws I
94102 }
95103
96104 @ Test
97- public void authenticateServerUnauthorizedShouldReturnErrorWithoutRetry () throws IOException , IllegalAccessException , NoSuchMethodException , InvocationTargetException {
105+ public void authenticateServerUnauthorizedShouldReturnErrorWithoutRetry () throws IOException , IllegalAccessException , NoSuchMethodException , InvocationTargetException , URISyntaxException {
98106 CloseableHttpClient httpClientMock = TestHelper .mockHttpClient ("" , HttpStatus .SC_UNAUTHORIZED );
107+ SplitHttpClient splitHttpClient = SplitHttpClientImpl .create (httpClientMock , new RequestDecorator (null ));
99108
100- AuthApiClient authApiClient = new AuthApiClientImp ("www.split-test.io" , httpClientMock , TELEMETRY_STORAGE );
109+ AuthApiClient authApiClient = new AuthApiClientImp ("www.split-test.io" , splitHttpClient , TELEMETRY_STORAGE );
101110 AuthenticationResponse result = authApiClient .Authenticate ();
102111
103112 Assert .assertFalse (result .isPushEnabled ());
0 commit comments