Skip to content

Commit

Permalink
Do not expose getApiClient() in FineractClient (FINERACT-1220)
Browse files Browse the repository at this point in the history
Because FineractClient is about to not use Swagger's ApiClient anymore.
  • Loading branch information
vorburger committed Oct 20, 2020
1 parent 800b7e0 commit 27bebff
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
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

0 comments on commit 27bebff

Please sign in to comment.