Skip to content

Commit eb73869

Browse files
Fix type bounds on request (#2037)
* Fix type bounds on request * Fix formatting issues
1 parent 8b161a7 commit eb73869

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed

src/main/java/com/stripe/net/ApiService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.stripe.net;
22

33
import com.stripe.exception.StripeException;
4-
import com.stripe.model.StripeObjectInterface;
4+
import com.stripe.model.StripeObject;
55
import java.io.InputStream;
66
import java.lang.reflect.Type;
77
import lombok.AccessLevel;
@@ -17,7 +17,7 @@ protected ApiService(StripeResponseGetter responseGetter) {
1717
}
1818

1919
@SuppressWarnings("TypeParameterUnusedInFormals")
20-
protected <T extends StripeObjectInterface> T request(ApiRequest request, Type typeToken)
20+
protected <T extends StripeObject> T request(ApiRequest request, Type typeToken)
2121
throws StripeException {
2222
return this.getResponseGetter().request(request.addUsage("stripe_client"), typeToken);
2323
}

src/main/java/com/stripe/net/LiveStripeResponseGetter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ private StripeRequest toRawStripeRequest(RawApiRequest apiRequest, RequestOption
118118

119119
@Override
120120
@SuppressWarnings({"TypeParameterUnusedInFormals", "unchecked"})
121-
public <T extends StripeObjectInterface> T request(ApiRequest apiRequest, Type typeToken)
121+
public <T extends StripeObject> T request(ApiRequest apiRequest, Type typeToken)
122122
throws StripeException {
123123

124124
RequestOptions mergedOptions = RequestOptions.merge(this.options, apiRequest.getOptions());
@@ -230,7 +230,7 @@ public StripeResponse rawRequest(RawApiRequest apiRequest) throws StripeExceptio
230230

231231
@Override
232232
@SuppressWarnings({"TypeParameterUnusedInFormals", "deprecation"})
233-
public <T extends StripeObjectInterface> T request(
233+
public <T extends StripeObject> T request(
234234
BaseAddress baseAddress,
235235
ApiResource.RequestMethod method,
236236
String path,

src/main/java/com/stripe/net/StripeResponseGetter.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.stripe.net;
22

33
import com.stripe.exception.StripeException;
4-
import com.stripe.model.StripeObjectInterface;
4+
import com.stripe.model.StripeObject;
55
import java.io.InputStream;
66
import java.lang.reflect.Type;
77
import java.util.Map;
@@ -10,7 +10,7 @@ public interface StripeResponseGetter {
1010
/** @deprecated Use {@link #request(ApiRequest, Type)} instead. */
1111
@SuppressWarnings("TypeParameterUnusedInFormals")
1212
@Deprecated
13-
<T extends StripeObjectInterface> T request(
13+
<T extends StripeObject> T request(
1414
BaseAddress baseAddress,
1515
ApiResource.RequestMethod method,
1616
String path,
@@ -21,7 +21,7 @@ <T extends StripeObjectInterface> T request(
2121
throws StripeException;
2222

2323
@SuppressWarnings("TypeParameterUnusedInFormals")
24-
default <T extends StripeObjectInterface> T request(ApiRequest request, Type typeToken)
24+
default <T extends StripeObject> T request(ApiRequest request, Type typeToken)
2525
throws StripeException {
2626
return request(
2727
request.getBaseAddress(),

src/test/java/com/stripe/BaseStripeTest.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import com.google.gson.Gson;
88
import com.google.gson.reflect.TypeToken;
99
import com.stripe.exception.StripeException;
10-
import com.stripe.model.StripeObjectInterface;
10+
import com.stripe.model.StripeObject;
1111
import com.stripe.net.*;
1212
import java.io.BufferedReader;
1313
import java.io.ByteArrayOutputStream;
@@ -173,7 +173,7 @@ public static <T> void verifyRequest(
173173
verifyRequest(method, path, params, null);
174174
}
175175

176-
public static <T extends StripeObjectInterface> void verifyRequest(
176+
public static <T extends StripeObject> void verifyRequest(
177177
ApiResource.RequestMethod method,
178178
String path,
179179
Map<String, Object> params,
@@ -190,7 +190,7 @@ public static <T extends StripeObjectInterface> void verifyRequest(
190190
* @param options request options. If null, the options are not checked.
191191
*/
192192
@SuppressWarnings("AssertionFailureIgnored")
193-
public static <T extends StripeObjectInterface> void verifyRequest(
193+
public static <T extends StripeObject> void verifyRequest(
194194
BaseAddress baseAddress,
195195
ApiResource.RequestMethod method,
196196
String path,
@@ -216,8 +216,8 @@ public static <T extends StripeObjectInterface> void verifyRequest(
216216
}
217217

218218
@SuppressWarnings("AssertionFailureIgnored")
219-
public static <T extends StripeObjectInterface> void verifyRequest(
220-
Consumer<ApiRequest> assertOnApiRequest) throws StripeException {
219+
public static <T extends StripeObject> void verifyRequest(Consumer<ApiRequest> assertOnApiRequest)
220+
throws StripeException {
221221

222222
ArgumentCaptor<ApiRequest> requestCaptor = ArgumentCaptor.forClass(ApiRequest.class);
223223
List<AssertionError> exceptions = new ArrayList<AssertionError>();
@@ -249,7 +249,7 @@ public static <T extends StripeObjectInterface> void verifyRequest(
249249
}
250250

251251
@SuppressWarnings("AssertionFailureIgnored")
252-
public static <T extends StripeObjectInterface> void verifyStripeRequest(
252+
public static <T extends StripeObject> void verifyStripeRequest(
253253
Consumer<StripeRequest> assertOnStripeRequest) throws StripeException {
254254

255255
ArgumentCaptor<StripeRequest> requestCaptor = ArgumentCaptor.forClass(StripeRequest.class);
@@ -292,7 +292,7 @@ public static <T> void verifyNoMoreRequests() {
292292
* @see BaseStripeTest#stubRequest(ApiResource.RequestMethod, String, Map, RequestOptions, Class,
293293
* String)
294294
*/
295-
public static <T extends StripeObjectInterface> void stubRequest(
295+
public static <T extends StripeObject> void stubRequest(
296296
ApiResource.RequestMethod method, String path, Type typeToken, String response)
297297
throws StripeException {
298298
stubRequest(BaseAddress.API, method, path, null, null, typeToken, response);
@@ -304,7 +304,7 @@ public static <T extends StripeObjectInterface> void stubRequest(
304304
* @see BaseStripeTest#stubRequest(ApiResource.RequestMethod, String, Map, RequestOptions, Class,
305305
* String)
306306
*/
307-
public static <T extends StripeObjectInterface> void stubRequest(
307+
public static <T extends StripeObject> void stubRequest(
308308
ApiResource.RequestMethod method,
309309
String path,
310310
Map<String, Object> params,
@@ -325,7 +325,7 @@ public static <T extends StripeObjectInterface> void stubRequest(
325325
* @param typeToken Class of the API resource that will be returned for the stubbed request.
326326
* @param response JSON payload of the API resource that will be returned for the stubbed request.
327327
*/
328-
public static <T extends StripeObjectInterface> void stubRequest(
328+
public static <T extends StripeObject> void stubRequest(
329329
BaseAddress baseAddress,
330330
ApiResource.RequestMethod method,
331331
String path,
@@ -361,7 +361,7 @@ public static <T extends StripeObjectInterface> void stubRequest(
361361
* @param typeToken Class of the API resource that will be returned for the stubbed request.
362362
* @param response JSON payload of the API resource that will be returned for the stubbed request.
363363
*/
364-
public static <T extends StripeObjectInterface> void stubRequestReturnError(
364+
public static <T extends StripeObject> void stubRequestReturnError(
365365
BaseAddress baseAddress,
366366
ApiResource.RequestMethod method,
367367
String path,
@@ -380,8 +380,8 @@ public static <T extends StripeObjectInterface> void stubRequestReturnError(
380380
}
381381

382382
/** Stubs an OAuth API request. stripe-mock does not supported OAuth endpoints at this time. */
383-
public static <T extends StripeObjectInterface> void stubOAuthRequest(
384-
Class<T> clazz, String response) throws StripeException {
383+
public static <T extends StripeObject> void stubOAuthRequest(Class<T> clazz, String response)
384+
throws StripeException {
385385
Mockito.doReturn(ApiResource.GSON.fromJson(response, clazz))
386386
.when(networkSpy)
387387
.request(Mockito.any(ApiRequest.class), Mockito.<Type>any());

0 commit comments

Comments
 (0)