Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ protected void setDefaultHeaders(final Request.Builder builder) {
* @param converter the converter
* @return the service call
*/
protected final <T> ServiceCall<T> createServiceCall(final Request request, final ResponseConverter<T> converter) {
protected <T> ServiceCall<T> createServiceCall(final Request request, final ResponseConverter<T> converter) {
final Call call = createCall(request);
return new IBMCloudSDKServiceCall<>(call, converter);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright IBM Corp. 2015, 2019.
* (C) Copyright IBM Corp. 2015, 2021.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
Expand All @@ -22,12 +22,15 @@

import com.ibm.cloud.sdk.core.http.HttpClientSingleton;
import com.ibm.cloud.sdk.core.http.HttpConfigOptions;
import com.ibm.cloud.sdk.core.http.ResponseConverter;
import com.ibm.cloud.sdk.core.http.ServiceCall;
import com.ibm.cloud.sdk.core.http.gzip.GzipRequestInterceptor;
import com.ibm.cloud.sdk.core.security.NoAuthAuthenticator;
import com.ibm.cloud.sdk.core.service.BaseService;

import com.ibm.cloud.sdk.core.util.ResponseConverterUtils;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.internal.tls.OkHostnameVerifier;

/**
Expand Down Expand Up @@ -183,4 +186,25 @@ public void testOverriddenConfigureHttpClient() {
assertEquals(60 * 1000, client.writeTimeoutMillis());
assertEquals(5 * 60 * 1000, client.readTimeoutMillis());
}

@Test
public void testCreateServiceCallOverride() {
class ExtendingService extends BaseService {

@Override
protected <T> ServiceCall<T> createServiceCall(final Request request, final ResponseConverter<T> converter) {
// For test purposes override to just return null
return null;
}

public ServiceCall<String> testOperation() {
Request r = new Request.Builder().url("https://foo.example").get().build();
return createServiceCall(r, ResponseConverterUtils.getString());
}
};
ExtendingService extendingService = new ExtendingService();
ServiceCall<String> testCall = extendingService.testOperation();
// Assert that the override was in place
assertNull("The service call should have been overridden to return null.", testCall);
}
}