From f505533302a02574bc9fafd5056fe9a978bfe1c6 Mon Sep 17 00:00:00 2001 From: Jozua Sijsling Date: Mon, 30 Aug 2021 16:04:23 +0200 Subject: [PATCH] Use hamcrest public apis rather than internal, for forward compatibility. --- .../android/barista/assertion/BaristaListAssertions.kt | 8 ++++---- .../barista/assertion/BaristaVisibilityAssertions.kt | 2 +- .../barista/interaction/BaristaKeyboardInteractions.kt | 2 +- .../barista/interaction/BaristaListInteractions.kt | 6 +++--- .../barista/internal/matcher/DisplayedMatchers.java | 2 +- .../android/barista/internal/viewaction/SwipeActions.kt | 4 ++-- .../android/barista/sample/BaristaRuleActivityTest.java | 4 ++-- .../android/barista/sample/ListViewAssertionTest.kt | 6 +++--- .../sample/assertion/VisibilityAssertionsTest.java | 2 +- 9 files changed, 18 insertions(+), 18 deletions(-) diff --git a/library/src/main/java/com/adevinta/android/barista/assertion/BaristaListAssertions.kt b/library/src/main/java/com/adevinta/android/barista/assertion/BaristaListAssertions.kt index bcee354a..3b19e450 100644 --- a/library/src/main/java/com/adevinta/android/barista/assertion/BaristaListAssertions.kt +++ b/library/src/main/java/com/adevinta/android/barista/assertion/BaristaListAssertions.kt @@ -24,9 +24,9 @@ import com.adevinta.android.barista.internal.matcher.ListViewNotEmptyAssertion import com.adevinta.android.barista.internal.matcher.RecyclerViewItemCountAssertion import com.adevinta.android.barista.internal.matcher.RecyclerViewNotEmptyAssertion import com.adevinta.android.barista.internal.matcher.withCompatText -import org.hamcrest.CoreMatchers import org.hamcrest.Description import org.hamcrest.Matcher +import org.hamcrest.Matchers import org.hamcrest.TypeSafeMatcher object BaristaListAssertions { @@ -82,7 +82,7 @@ object BaristaListAssertions { position = position, targetViewId = targetViewId, viewAssertion = ViewAssertions.matches( - CoreMatchers.anyOf( + Matchers.anyOf( ViewMatchers.withChild(withCompatText(text)), withCompatText(text) ) @@ -102,7 +102,7 @@ object BaristaListAssertions { position = position, targetViewId = targetViewId, viewAssertion = ViewAssertions.matches( - CoreMatchers.anyOf( + Matchers.anyOf( ViewMatchers.withChild(ViewMatchers.withText(textId)), ViewMatchers.withText(textId) ) @@ -124,7 +124,7 @@ object BaristaListAssertions { position = position, targetViewId = targetViewId, viewAssertion = ViewAssertions.matches( - CoreMatchers.anyOf( + Matchers.anyOf( ViewMatchers.hasDescendant(DrawableMatcher.withDrawable(drawableRes)), DrawableMatcher.withDrawable(drawableRes) ) diff --git a/library/src/main/java/com/adevinta/android/barista/assertion/BaristaVisibilityAssertions.kt b/library/src/main/java/com/adevinta/android/barista/assertion/BaristaVisibilityAssertions.kt index 0aa07e62..6235ac2e 100644 --- a/library/src/main/java/com/adevinta/android/barista/assertion/BaristaVisibilityAssertions.kt +++ b/library/src/main/java/com/adevinta/android/barista/assertion/BaristaVisibilityAssertions.kt @@ -16,9 +16,9 @@ import com.adevinta.android.barista.internal.matcher.TextColorMatcher import com.adevinta.android.barista.internal.matcher.TextStyleableColorMatcher import com.adevinta.android.barista.internal.util.resourceMatcher import com.adevinta.android.barista.internal.matcher.withCompatText -import org.hamcrest.CoreMatchers.containsString import org.hamcrest.Matcher import org.hamcrest.Matchers.allOf +import org.hamcrest.Matchers.containsString import org.hamcrest.Matchers.not object BaristaVisibilityAssertions { diff --git a/library/src/main/java/com/adevinta/android/barista/interaction/BaristaKeyboardInteractions.kt b/library/src/main/java/com/adevinta/android/barista/interaction/BaristaKeyboardInteractions.kt index 10499fcf..6dd53442 100644 --- a/library/src/main/java/com/adevinta/android/barista/interaction/BaristaKeyboardInteractions.kt +++ b/library/src/main/java/com/adevinta/android/barista/interaction/BaristaKeyboardInteractions.kt @@ -10,7 +10,7 @@ import androidx.test.espresso.matcher.ViewMatchers.hasFocus import androidx.test.espresso.matcher.ViewMatchers.isRoot import androidx.test.espresso.matcher.ViewMatchers.withId import com.adevinta.android.barista.internal.performAction -import org.hamcrest.core.AllOf.allOf +import org.hamcrest.Matchers.allOf object BaristaKeyboardInteractions { diff --git a/library/src/main/java/com/adevinta/android/barista/interaction/BaristaListInteractions.kt b/library/src/main/java/com/adevinta/android/barista/interaction/BaristaListInteractions.kt index 3c76631b..1f987a01 100644 --- a/library/src/main/java/com/adevinta/android/barista/interaction/BaristaListInteractions.kt +++ b/library/src/main/java/com/adevinta/android/barista/interaction/BaristaListInteractions.kt @@ -25,10 +25,10 @@ import com.adevinta.android.barista.internal.failurehandler.description import com.adevinta.android.barista.internal.failurehandler.withFailureHandler import com.adevinta.android.barista.internal.viewaction.ClickChildAction.clickChildWithId import com.adevinta.android.barista.internal.viewaction.PerformClickAction.clickUsingPerformClick -import org.hamcrest.CoreMatchers.allOf -import org.hamcrest.CoreMatchers.anyOf -import org.hamcrest.CoreMatchers.anything import org.hamcrest.Matcher +import org.hamcrest.Matchers.allOf +import org.hamcrest.Matchers.anyOf +import org.hamcrest.Matchers.anything object BaristaListInteractions { diff --git a/library/src/main/java/com/adevinta/android/barista/internal/matcher/DisplayedMatchers.java b/library/src/main/java/com/adevinta/android/barista/internal/matcher/DisplayedMatchers.java index 1ff9c7b4..25226d75 100644 --- a/library/src/main/java/com/adevinta/android/barista/internal/matcher/DisplayedMatchers.java +++ b/library/src/main/java/com/adevinta/android/barista/internal/matcher/DisplayedMatchers.java @@ -8,7 +8,7 @@ import static androidx.test.espresso.matcher.ViewMatchers.isAssignableFrom; import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; import static androidx.test.espresso.matcher.ViewMatchers.withId; -import static org.hamcrest.core.AllOf.allOf; +import static org.hamcrest.Matchers.allOf; public class DisplayedMatchers { diff --git a/library/src/main/java/com/adevinta/android/barista/internal/viewaction/SwipeActions.kt b/library/src/main/java/com/adevinta/android/barista/internal/viewaction/SwipeActions.kt index 48496642..ae595c8c 100644 --- a/library/src/main/java/com/adevinta/android/barista/internal/viewaction/SwipeActions.kt +++ b/library/src/main/java/com/adevinta/android/barista/internal/viewaction/SwipeActions.kt @@ -23,9 +23,9 @@ import com.adevinta.android.barista.internal.viewaction.SwipeActions.swipeLeft import com.adevinta.android.barista.internal.viewaction.SwipeActions.swipeRight import com.adevinta.android.barista.internal.viewaction.ViewPager2SwipeAction.Direction.BACKWARD import com.adevinta.android.barista.internal.viewaction.ViewPager2SwipeAction.Direction.FORWARD -import org.hamcrest.CoreMatchers.allOf -import org.hamcrest.CoreMatchers.anyOf import org.hamcrest.Matcher +import org.hamcrest.Matchers.allOf +import org.hamcrest.Matchers.anyOf object SwipeActions { diff --git a/sample/src/androidTest/java/com/adevinta/android/barista/sample/BaristaRuleActivityTest.java b/sample/src/androidTest/java/com/adevinta/android/barista/sample/BaristaRuleActivityTest.java index b9bd4263..9a8016fd 100644 --- a/sample/src/androidTest/java/com/adevinta/android/barista/sample/BaristaRuleActivityTest.java +++ b/sample/src/androidTest/java/com/adevinta/android/barista/sample/BaristaRuleActivityTest.java @@ -4,8 +4,8 @@ import org.junit.Rule; import org.junit.Test; -import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.IsNull.notNullValue; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.notNullValue; import static org.junit.Assert.assertThat; public class BaristaRuleActivityTest { diff --git a/sample/src/androidTest/java/com/adevinta/android/barista/sample/ListViewAssertionTest.kt b/sample/src/androidTest/java/com/adevinta/android/barista/sample/ListViewAssertionTest.kt index 225093c8..79f38632 100644 --- a/sample/src/androidTest/java/com/adevinta/android/barista/sample/ListViewAssertionTest.kt +++ b/sample/src/androidTest/java/com/adevinta/android/barista/sample/ListViewAssertionTest.kt @@ -12,7 +12,7 @@ import com.adevinta.android.barista.assertion.BaristaListAssertions.assertListIt import com.adevinta.android.barista.assertion.BaristaListAssertions.assertListNotEmpty import com.adevinta.android.barista.internal.failurehandler.BaristaException import junit.framework.AssertionFailedError -import org.hamcrest.CoreMatchers +import org.hamcrest.Matchers import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith @@ -124,7 +124,7 @@ class ListViewAssertionTest { position = 4, targetViewId = android.R.id.text1, viewAssertion = ViewAssertions.matches( - CoreMatchers.anyOf( + Matchers.anyOf( ViewMatchers.withChild(ViewMatchers.withText("Bilberry")), ViewMatchers.withText("Bilberry") ) @@ -140,7 +140,7 @@ class ListViewAssertionTest { position = 19, targetViewId = R.id.textview, viewAssertion = ViewAssertions.matches( - CoreMatchers.anyOf( + Matchers.anyOf( ViewMatchers.withChild(ViewMatchers.withText("Dragonfruit")), ViewMatchers.withText("Dragonfruit") ) diff --git a/sample/src/androidTest/java/com/adevinta/android/barista/sample/assertion/VisibilityAssertionsTest.java b/sample/src/androidTest/java/com/adevinta/android/barista/sample/assertion/VisibilityAssertionsTest.java index 8386a756..0a664f25 100644 --- a/sample/src/androidTest/java/com/adevinta/android/barista/sample/assertion/VisibilityAssertionsTest.java +++ b/sample/src/androidTest/java/com/adevinta/android/barista/sample/assertion/VisibilityAssertionsTest.java @@ -14,7 +14,7 @@ import static com.adevinta.android.barista.assertion.BaristaVisibilityAssertions.assertNotExist; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.ThrowableAssert.catchThrowable; -import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.Matchers.is; public class VisibilityAssertionsTest {