From cc62a7e7cce368674ee3ed0d4d0c899136af3906 Mon Sep 17 00:00:00 2001 From: Oguz Kocer Date: Tue, 1 Feb 2022 14:19:34 -0500 Subject: [PATCH 1/3] Fixes androidx import issues in PermissMeTests --- src/test/java/com/tumblr/permissme/PermissMeTests.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/com/tumblr/permissme/PermissMeTests.java b/src/test/java/com/tumblr/permissme/PermissMeTests.java index beb98b6..7c1016d 100644 --- a/src/test/java/com/tumblr/permissme/PermissMeTests.java +++ b/src/test/java/com/tumblr/permissme/PermissMeTests.java @@ -5,8 +5,8 @@ import android.content.Context; import android.content.Intent; import android.os.Bundle; -import androidx.core.app.Fragment; -import android.support.v7.app.AppCompatActivity; +import androidx.fragment.app.Fragment; +import androidx.appcompat.app.AppCompatActivity; import com.tumblr.permissme.utils.PermissMeUtils; import org.junit.Before; import org.junit.Test; From c1a89c38dc2632ca512e7b8cbae64bc0e6092604 Mon Sep 17 00:00:00 2001 From: Oguz Kocer Date: Tue, 1 Feb 2022 14:24:22 -0500 Subject: [PATCH 2/3] Fixes "MockClassLoader cannot access jdk/internal/reflect superclass" See https://stackoverflow.com/questions/50456726/mockclassloader-cannot-access-jdk-internal-reflect-superclass-jdk-internal-refle/50457701 for details. --- src/test/java/com/tumblr/permissme/PermissMeTests.java | 2 ++ .../java/com/tumblr/permissme/utils/PermissMeUtilsTest.java | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/test/java/com/tumblr/permissme/PermissMeTests.java b/src/test/java/com/tumblr/permissme/PermissMeTests.java index 7c1016d..9efc17f 100644 --- a/src/test/java/com/tumblr/permissme/PermissMeTests.java +++ b/src/test/java/com/tumblr/permissme/PermissMeTests.java @@ -14,6 +14,7 @@ import org.mockito.ArgumentCaptor; import org.mockito.Matchers; import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; @@ -26,6 +27,7 @@ */ @RunWith(PowerMockRunner.class) @PrepareForTest({PermissMeUtils.class, PermissMe.class}) +@PowerMockIgnore("jdk.internal.reflect.*") public class PermissMeTests { private PermissMe mPermissMe; diff --git a/src/test/java/com/tumblr/permissme/utils/PermissMeUtilsTest.java b/src/test/java/com/tumblr/permissme/utils/PermissMeUtilsTest.java index a88b706..05d4596 100644 --- a/src/test/java/com/tumblr/permissme/utils/PermissMeUtilsTest.java +++ b/src/test/java/com/tumblr/permissme/utils/PermissMeUtilsTest.java @@ -12,6 +12,7 @@ import org.mockito.BDDMockito; import org.mockito.Mockito; import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; @@ -27,6 +28,7 @@ @RunWith(PowerMockRunner.class) @PrepareForTest(PermissionChecker.class) @SuppressWarnings("ConstantConditions") +@PowerMockIgnore("jdk.internal.reflect.*") public class PermissMeUtilsTest { private final Context mockContext; From f862146b2706ea8e402fb206b340d0f55b55ee8c Mon Sep 17 00:00:00 2001 From: Oguz Kocer Date: Tue, 1 Feb 2022 14:25:50 -0500 Subject: [PATCH 3/3] Fixes range lint error for getColumnIndex --- .../main/java/com/tumblr/permissme/sample/ContactsActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sample/src/main/java/com/tumblr/permissme/sample/ContactsActivity.java b/sample/src/main/java/com/tumblr/permissme/sample/ContactsActivity.java index 67aa91a..78de938 100644 --- a/sample/src/main/java/com/tumblr/permissme/sample/ContactsActivity.java +++ b/sample/src/main/java/com/tumblr/permissme/sample/ContactsActivity.java @@ -35,7 +35,7 @@ private ArrayList getListOfContacts() { if (cur != null && cur.getCount() > 0) { while (cur.moveToNext()) { - String name = cur.getString(cur.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME)); + String name = cur.getString(cur.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME)); contactsList.add(name); } }