Skip to content

Commit

Permalink
Bugfix/li 58415 handle no such method exception (#145)
Browse files Browse the repository at this point in the history
* LI_58415 - Replace get constructor method
  • Loading branch information
grmeyer-hw-dev authored Aug 24, 2024
1 parent 5e13ea8 commit c16514c
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ allprojects {
mavenCentral()
mavenLocal()
}
project.version = "1.0.0-beta12"
project.version = "1.0.0-beta13"
}

task clean(type: Delete) {
Expand Down
8 changes: 8 additions & 0 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ android {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

// Rename the artifact to core-<version>.aar, required since gradle 7
libraryVariants.all { variant ->
variant.outputs.all { output ->
outputFileName = "${archivesBaseName}-${defaultConfig.versionName}.aar"
}
}
}
debug {
testCoverageEnabled true
Expand All @@ -36,6 +43,7 @@ android {
dependencies {

implementation "androidx.appcompat:appcompat:1.2.0"
implementation "androidx.annotation:annotation:1.8.2"

testImplementation 'junit:junit:4.13.2'
testImplementation 'org.robolectric:robolectric:4.12.2'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public Connection(@NonNull final JSONObject data, @NonNull final Class clazz) th
mPageInfo = new PageInfo(pageInfoObject);
}

Constructor<?> constructor = clazz.getConstructor(JSONObject.class);
Constructor<?> constructor = clazz.getDeclaredConstructor(JSONObject.class);
JSONArray jsonArray = data.optJSONArray(NODES);
if (jsonArray != null) {
mNodes = new ArrayList<>(jsonArray.length());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class GqlResponse<T> {
*/
public GqlResponse(@NonNull final JSONObject response, @NonNull final Class clazz)
throws ReflectiveOperationException, JSONException {
Constructor<?> constructor = clazz.getConstructor(JSONObject.class);
Constructor<?> constructor = clazz.getDeclaredConstructor(JSONObject.class);
mData = (T) constructor.newInstance(response.get(DATA));
mGqlErrors = new GqlErrors(response);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public MappedConnection(@NonNull final JSONObject data, @NonNull Class clazz) th
JSONException, IllegalAccessException, InstantiationException, InvocationTargetException {

super(data, clazz);
Constructor<?> constructor = clazz.getConstructor(JSONObject.class);
Constructor<?> constructor = clazz.getDeclaredConstructor(JSONObject.class);
JSONArray jsonArray = data.optJSONArray(NODES);
if (jsonArray != null && jsonArray.length() != 0) {
mNodes = new LinkedHashMap<>(jsonArray.length());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public PageList(@NonNull final JSONObject page, @NonNull final Class<T> clazz)
if (jsonArray != null) {
mDataList = new ArrayList<>();
for (int i = 0; i < jsonArray.length(); i++) {
Constructor<T> constructor = clazz.getConstructor(JSONObject.class);
Constructor<T> constructor = clazz.getDeclaredConstructor(JSONObject.class);
mDataList.add(constructor.newInstance(jsonArray.getJSONObject(i)));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public static <T> T fromJsonString(@NonNull final String data, @NonNull final Ty
Class<T> parameterType =
(Class<T>) ((ParameterizedType) typeReference.getType()).getActualTypeArguments()[0];
JSONObject jsonObject = new JSONObject(data);
Constructor<T> rawTypeConstructor = rawType.getConstructor(JSONObject.class, parameterType.getClass());
Constructor<T> rawTypeConstructor = rawType.getDeclaredConstructor(JSONObject.class, parameterType.getClass());
return rawTypeConstructor.newInstance(jsonObject, parameterType);
}

Expand All @@ -196,7 +196,7 @@ private static <T> T fromJsonString(@Nullable final String jsonString, @NonNull
throws JSONException, InvocationTargetException, NoSuchMethodException, InstantiationException,
IllegalAccessException {
JSONObject jsonObject = new JSONObject(jsonString);
Constructor<T> constructor = fromClass.getConstructor(JSONObject.class);
Constructor<T> constructor = fromClass.getDeclaredConstructor(JSONObject.class);
return constructor.newInstance(jsonObject);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void testBuild_withRequiredParametersOnly() throws JSONException {
assertThat(headers.get("Content-Type"), is("application/json"));
assertThat(headers.get("User-Agent"), is("HyperwalletSDK/Android/" + BuildConfig.VERSION_NAME +
"; App: HyperwalletSDK; Android: " + Build.VERSION.RELEASE));
assertThat(headers.get("X-Sdk-Version"), is("1.0.0-beta12"));
assertThat(headers.get("X-Sdk-Version"), is("1.0.0-beta13"));
assertThat(headers.get("X-Sdk-Type"), is("android"));
assertThat(headers.get("X-Sdk-ContextId"), is(notNullValue()));
assertThat(headers.get("X-Sdk-ContextId"), is(contextId));
Expand Down Expand Up @@ -104,7 +104,7 @@ public void testBuild_withJsonModelOptionalParameter() throws JSONException {
assertThat(headers.get("Content-Type"), is("application/json"));
assertThat(headers.get("User-Agent"), is("HyperwalletSDK/Android/" + BuildConfig.VERSION_NAME +
"; App: HyperwalletSDK; Android: " + Build.VERSION.RELEASE));
assertThat(headers.get("X-Sdk-Version"), is("1.0.0-beta12"));
assertThat(headers.get("X-Sdk-Version"), is("1.0.0-beta13"));
assertThat(headers.get("X-Sdk-Type"), is("android"));
assertThat(headers.get("X-Sdk-ContextId"), is(notNullValue()));
assertThat(headers.get("X-Sdk-ContextId"), is(contextId));
Expand Down Expand Up @@ -140,7 +140,7 @@ public void testBuild_withQueryModelOptionalParameter() throws JSONException {
assertThat(headers.get("Content-Type"), is("application/json"));
assertThat(headers.get("User-Agent"), is("HyperwalletSDK/Android/" + BuildConfig.VERSION_NAME +
"; App: HyperwalletSDK; Android: " + Build.VERSION.RELEASE));
assertThat(headers.get("X-Sdk-Version"), is("1.0.0-beta12"));
assertThat(headers.get("X-Sdk-Version"), is("1.0.0-beta13"));
assertThat(headers.get("X-Sdk-Type"), is("android"));
assertThat(headers.get("X-Sdk-ContextId"), is(notNullValue()));
assertThat(headers.get("X-Sdk-ContextId"), is(contextId));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void testCreateVenmoAccount_withSuccess() throws InterruptedException {
assertThat(venmoAccount.getField(VENMO_ACCOUNT_ID), is("9876543210"));

Hyperwallet.getDefault().createVenmoAccount(venmoAccount, mListener);
mAwait.await(50, TimeUnit.MILLISECONDS);
mAwait.await(300, TimeUnit.MILLISECONDS);

RecordedRequest recordedRequest = mServer.getRequest();
assertThat(recordedRequest.getMethod(), is(POST.name()));
Expand Down

0 comments on commit c16514c

Please sign in to comment.