Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not expose getApiClient() in FineractClient (FINERACT-1220) #1451

Merged
merged 1 commit into from Oct 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -138,7 +138,7 @@
import org.apache.fineract.client.services.WorkingDaysApi;

/**
* Fineract Client Java SDK API entry point. This is recommended to be used instead of {@link ApiClient}.
* Fineract Client Java SDK API entry point. Use this instead of the {@link ApiClient}.
*
* @author Michael Vorburger.ch
*/
Expand Down Expand Up @@ -395,7 +395,7 @@ public Builder basicAuth(String username, String password) {
public Builder logging(Level level) {
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
logging.setLevel(level);
getApiClient().getOkBuilder().addInterceptor(logging);
apiClient.getOkBuilder().addInterceptor(logging);
return this;
}

Expand Down Expand Up @@ -458,13 +458,23 @@ public FineractClient build() {
}

/**
* Obtain the internal Retrofit ApiClient. This method is typically not required to be invoked for simple API
* Obtain the internal Retrofit Builder. This method is typically not required to be invoked for simple API
* usages, but can be a handy back door for non-trivial advanced customizations of the API client.
*
* @return the {@link ApiClient} which {@link #build()} will use.
*/
public ApiClient getApiClient() {
return apiClient;
public retrofit2.Retrofit.Builder getRetrofitBuilder() {
return apiClient.getAdapterBuilder();
}

/**
* Obtain the internal OkHttp Builder. This method is typically not required to be invoked for simple API
* usages, but can be a handy back door for non-trivial advanced customizations of the API client.
*
* @return the {@link ApiClient} which {@link #build()} will use.
*/
public okhttp3.OkHttpClient.Builder getOkBuilder() {
return apiClient.getOkBuilder();
}

private <T> T has(String propertyName, T value) throws IllegalStateException {
Expand Down
Expand Up @@ -54,11 +54,19 @@ void testRetrieveAllClientsFromLocalhostWithInsecureSelfSignedCert() throws IOEx
checkClients(fineract);
}

@Test
@Disabled // TODO FINERACT-1220
void testOfficesDateFormat() throws IOException {
FineractClient fineract = FineractClient.builder().baseURL("https://demo.fineract.dev/fineract-provider/api/v1/").tenant("default")
.basicAuth("mifos", "password").insecure(true).build();
ok(fineract.offices.retrieveOffices(true, null, null));
}

@Test
@Disabled // TODO remove Ignore once https://issues.apache.org/jira/browse/FINERACT-1221 is fixed
void testInvalidOperations() throws IOException {
FineractClient.Builder builder = FineractClient.builder().baseURL("http://test/").tenant("default").basicAuth("mifos", "password");
builder.getApiClient().getAdapterBuilder().validateEagerly(true); // see FINERACT-1221
builder.getRetrofitBuilder().validateEagerly(true); // see FINERACT-1221
builder.build();
}

Expand Down