Skip to content

Commit

Permalink
Remove unnecessary method from interface
Browse files Browse the repository at this point in the history
  • Loading branch information
gthea committed Nov 28, 2023
1 parent eac19a6 commit 503089f
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ interface AuthenticatedRequest<T> {
@Nullable
Map<String, List<String>> getHeaders();

@Nullable
T getRequest();

int getStatusCode();

String getRequestUrl();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ public Request authenticate(@Nullable Route route, @NonNull Response response) {

try {
SplitAuthenticatedRequest authenticatedRequestResult = mSplitAuthenticator.authenticate(new SplitAuthenticatedRequest(response));
if (authenticatedRequestResult == null ||
authenticatedRequestResult.getRequest() == null) {
if (authenticatedRequestResult == null) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@ public Map<String, List<String>> getHeaders() {
return mRequest.headers().toMultimap();
}

@Nullable
@Override
public Request getRequest() {
return mRequest;
}

@Override
public int getStatusCode() {
return mStatusCode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,6 @@ public void resultIsNullIfSplitAuthenticatorReturnsNull() throws IOException {
assertNull(authenticate);
}

@Test
public void resultIsNullIfSplitAuthenticatorReturnsNullRequest() throws IOException {
SplitAuthenticatedRequest mockAuthRequest = mock(SplitAuthenticatedRequest.class);
when(mockAuthRequest.getRequest()).thenReturn(null);
when(mSplitAuthenticator.authenticate(any())).thenReturn(mockAuthRequest);

Request authenticate = mAuthenticator.authenticate(mock(Route.class), mock(Response.class));

assertNull(authenticate);
}

@Test
public void headersFromAuthenticationAreNotAddedToResultWhenTheyAreNull() throws IOException {
Response mockResponse = mock(Response.class);
Expand All @@ -69,7 +58,6 @@ public void headersFromAuthenticationAreNotAddedToResultWhenTheyAreNull() throws
when(mockBuilder.build()).thenReturn(mockResult);

SplitAuthenticatedRequest mockAuthRequest = mock(SplitAuthenticatedRequest.class);
when(mockAuthRequest.getRequest()).thenReturn(mockRequest);
when(mockAuthRequest.getHeaders()).thenReturn(null);
when(mSplitAuthenticator.authenticate(any())).thenReturn(mockAuthRequest);

Expand Down Expand Up @@ -102,7 +90,6 @@ public void authorizationHeadersAreAddedToResultRequest() {
when(mockBuilder.build()).thenReturn(mockResult);

SplitAuthenticatedRequest mockAuthRequest = mock(SplitAuthenticatedRequest.class);
when(mockAuthRequest.getRequest()).thenReturn(mockRequest);
when(mockAuthRequest.getHeaders()).thenReturn(Collections.singletonMap("Authorization", Collections.singletonList("Bearer 1234567890")));
when(mSplitAuthenticator.authenticate(any())).thenReturn(mockAuthRequest);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.split.android.client.network;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;

import androidx.annotation.NonNull;
Expand Down Expand Up @@ -29,11 +28,11 @@ public AuthenticatedRequest<MockRequest> authenticate(@NonNull AuthenticatedRequ
};

AuthenticatedMockRequest request = new AuthenticatedMockRequest(new MockRequest());
Map<String, List<String>> initialHeaders = new HashMap<>(request.getRequest().getHeaders());
Map<String, List<String>> initialHeaders = new HashMap<>(request.getHeaders());

splitAuthenticator.authenticate(request);

Map<String, List<String>> finalHeaders = new HashMap<>(request.getRequest().getHeaders());
Map<String, List<String>> finalHeaders = new HashMap<>(request.getHeaders());

assertEquals(2, initialHeaders.size());
assertTrue(initialHeaders.containsKey("header1"));
Expand Down Expand Up @@ -73,11 +72,6 @@ public Map<String, List<String>> getHeaders() {
return mRequest.getHeaders();
}

@Override
public MockRequest getRequest() {
return mRequest;
}

@Override
public int getStatusCode() {
return 0;
Expand Down

0 comments on commit 503089f

Please sign in to comment.