Skip to content

Commit c16514c

Browse files
Bugfix/li 58415 handle no such method exception (#145)
* LI_58415 - Replace get constructor method
1 parent 5e13ea8 commit c16514c

File tree

9 files changed

+19
-11
lines changed

9 files changed

+19
-11
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ allprojects {
2020
mavenCentral()
2121
mavenLocal()
2222
}
23-
project.version = "1.0.0-beta12"
23+
project.version = "1.0.0-beta13"
2424
}
2525

2626
task clean(type: Delete) {

core/build.gradle

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ android {
1919
release {
2020
minifyEnabled false
2121
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
22+
23+
// Rename the artifact to core-<version>.aar, required since gradle 7
24+
libraryVariants.all { variant ->
25+
variant.outputs.all { output ->
26+
outputFileName = "${archivesBaseName}-${defaultConfig.versionName}.aar"
27+
}
28+
}
2229
}
2330
debug {
2431
testCoverageEnabled true
@@ -36,6 +43,7 @@ android {
3643
dependencies {
3744

3845
implementation "androidx.appcompat:appcompat:1.2.0"
46+
implementation "androidx.annotation:annotation:1.8.2"
3947

4048
testImplementation 'junit:junit:4.13.2'
4149
testImplementation 'org.robolectric:robolectric:4.12.2'

core/src/main/java/com/hyperwallet/android/model/graphql/Connection.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public Connection(@NonNull final JSONObject data, @NonNull final Class clazz) th
6060
mPageInfo = new PageInfo(pageInfoObject);
6161
}
6262

63-
Constructor<?> constructor = clazz.getConstructor(JSONObject.class);
63+
Constructor<?> constructor = clazz.getDeclaredConstructor(JSONObject.class);
6464
JSONArray jsonArray = data.optJSONArray(NODES);
6565
if (jsonArray != null) {
6666
mNodes = new ArrayList<>(jsonArray.length());

core/src/main/java/com/hyperwallet/android/model/graphql/GqlResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public class GqlResponse<T> {
4545
*/
4646
public GqlResponse(@NonNull final JSONObject response, @NonNull final Class clazz)
4747
throws ReflectiveOperationException, JSONException {
48-
Constructor<?> constructor = clazz.getConstructor(JSONObject.class);
48+
Constructor<?> constructor = clazz.getDeclaredConstructor(JSONObject.class);
4949
mData = (T) constructor.newInstance(response.get(DATA));
5050
mGqlErrors = new GqlErrors(response);
5151
}

core/src/main/java/com/hyperwallet/android/model/graphql/keyed/MappedConnection.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public MappedConnection(@NonNull final JSONObject data, @NonNull Class clazz) th
5656
JSONException, IllegalAccessException, InstantiationException, InvocationTargetException {
5757

5858
super(data, clazz);
59-
Constructor<?> constructor = clazz.getConstructor(JSONObject.class);
59+
Constructor<?> constructor = clazz.getDeclaredConstructor(JSONObject.class);
6060
JSONArray jsonArray = data.optJSONArray(NODES);
6161
if (jsonArray != null && jsonArray.length() != 0) {
6262
mNodes = new LinkedHashMap<>(jsonArray.length());

core/src/main/java/com/hyperwallet/android/model/paging/PageList.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public PageList(@NonNull final JSONObject page, @NonNull final Class<T> clazz)
5959
if (jsonArray != null) {
6060
mDataList = new ArrayList<>();
6161
for (int i = 0; i < jsonArray.length(); i++) {
62-
Constructor<T> constructor = clazz.getConstructor(JSONObject.class);
62+
Constructor<T> constructor = clazz.getDeclaredConstructor(JSONObject.class);
6363
mDataList.add(constructor.newInstance(jsonArray.getJSONObject(i)));
6464
}
6565
}

core/src/main/java/com/hyperwallet/android/util/JsonUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public static <T> T fromJsonString(@NonNull final String data, @NonNull final Ty
179179
Class<T> parameterType =
180180
(Class<T>) ((ParameterizedType) typeReference.getType()).getActualTypeArguments()[0];
181181
JSONObject jsonObject = new JSONObject(data);
182-
Constructor<T> rawTypeConstructor = rawType.getConstructor(JSONObject.class, parameterType.getClass());
182+
Constructor<T> rawTypeConstructor = rawType.getDeclaredConstructor(JSONObject.class, parameterType.getClass());
183183
return rawTypeConstructor.newInstance(jsonObject, parameterType);
184184
}
185185

@@ -196,7 +196,7 @@ private static <T> T fromJsonString(@Nullable final String jsonString, @NonNull
196196
throws JSONException, InvocationTargetException, NoSuchMethodException, InstantiationException,
197197
IllegalAccessException {
198198
JSONObject jsonObject = new JSONObject(jsonString);
199-
Constructor<T> constructor = fromClass.getConstructor(JSONObject.class);
199+
Constructor<T> constructor = fromClass.getDeclaredConstructor(JSONObject.class);
200200
return constructor.newInstance(jsonObject);
201201
}
202202
}

core/src/test/java/com/hyperwallet/android/RestTransactionBuilderTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public void testBuild_withRequiredParametersOnly() throws JSONException {
6767
assertThat(headers.get("Content-Type"), is("application/json"));
6868
assertThat(headers.get("User-Agent"), is("HyperwalletSDK/Android/" + BuildConfig.VERSION_NAME +
6969
"; App: HyperwalletSDK; Android: " + Build.VERSION.RELEASE));
70-
assertThat(headers.get("X-Sdk-Version"), is("1.0.0-beta12"));
70+
assertThat(headers.get("X-Sdk-Version"), is("1.0.0-beta13"));
7171
assertThat(headers.get("X-Sdk-Type"), is("android"));
7272
assertThat(headers.get("X-Sdk-ContextId"), is(notNullValue()));
7373
assertThat(headers.get("X-Sdk-ContextId"), is(contextId));
@@ -104,7 +104,7 @@ public void testBuild_withJsonModelOptionalParameter() throws JSONException {
104104
assertThat(headers.get("Content-Type"), is("application/json"));
105105
assertThat(headers.get("User-Agent"), is("HyperwalletSDK/Android/" + BuildConfig.VERSION_NAME +
106106
"; App: HyperwalletSDK; Android: " + Build.VERSION.RELEASE));
107-
assertThat(headers.get("X-Sdk-Version"), is("1.0.0-beta12"));
107+
assertThat(headers.get("X-Sdk-Version"), is("1.0.0-beta13"));
108108
assertThat(headers.get("X-Sdk-Type"), is("android"));
109109
assertThat(headers.get("X-Sdk-ContextId"), is(notNullValue()));
110110
assertThat(headers.get("X-Sdk-ContextId"), is(contextId));
@@ -140,7 +140,7 @@ public void testBuild_withQueryModelOptionalParameter() throws JSONException {
140140
assertThat(headers.get("Content-Type"), is("application/json"));
141141
assertThat(headers.get("User-Agent"), is("HyperwalletSDK/Android/" + BuildConfig.VERSION_NAME +
142142
"; App: HyperwalletSDK; Android: " + Build.VERSION.RELEASE));
143-
assertThat(headers.get("X-Sdk-Version"), is("1.0.0-beta12"));
143+
assertThat(headers.get("X-Sdk-Version"), is("1.0.0-beta13"));
144144
assertThat(headers.get("X-Sdk-Type"), is("android"));
145145
assertThat(headers.get("X-Sdk-ContextId"), is(notNullValue()));
146146
assertThat(headers.get("X-Sdk-ContextId"), is(contextId));

core/src/test/java/com/hyperwallet/android/transfermethod/CreateVenmoAccountTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public void testCreateVenmoAccount_withSuccess() throws InterruptedException {
7878
assertThat(venmoAccount.getField(VENMO_ACCOUNT_ID), is("9876543210"));
7979

8080
Hyperwallet.getDefault().createVenmoAccount(venmoAccount, mListener);
81-
mAwait.await(50, TimeUnit.MILLISECONDS);
81+
mAwait.await(300, TimeUnit.MILLISECONDS);
8282

8383
RecordedRequest recordedRequest = mServer.getRequest();
8484
assertThat(recordedRequest.getMethod(), is(POST.name()));

0 commit comments

Comments
 (0)