File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed
main/kotlin/pl/droidsonroids/testing/mockwebserver/condition
test/kotlin/pl/droidsonroids/testing/mockwebserver Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ data class PathQueryCondition(
1919
2020 override fun compareTo (other : Condition ) = when {
2121 other == this -> 0
22+ other is PathQueryCondition && httpMethod == HTTPMethod .ANY && httpMethod != other.httpMethod -> - 1
2223 other is PathQueryCondition && score == other.score -> path.compareTo(other.path)
2324 other is PathQueryCondition && score > other.score -> - 1
2425 else -> 1
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import org.assertj.core.api.Assertions.assertThat
77import org.junit.Before
88import org.junit.Test
99import pl.droidsonroids.testing.mockwebserver.condition.Condition
10+ import pl.droidsonroids.testing.mockwebserver.condition.HTTPMethod
1011import pl.droidsonroids.testing.mockwebserver.condition.PathQueryCondition
1112import pl.droidsonroids.testing.mockwebserver.condition.PathQueryConditionFactory
1213
@@ -153,6 +154,17 @@ class PathQueryConditionTest {
153154 .isGreaterThan(0 )
154155 }
155156
157+ @Test
158+ fun `compareTo should return -1 when the first condition has ANY http method and the second is different` () {
159+ val firstCondition = PathQueryConditionFactory ()
160+ .withPathSuffix(" /abc" , HTTPMethod .ANY )
161+ val secondCondition = PathQueryConditionFactory ()
162+ .withPathSuffix(" /abc" , HTTPMethod .GET )
163+
164+ assertThat(firstCondition.compareTo(secondCondition))
165+ .isEqualTo(- 1 )
166+ }
167+
156168 @Test
157169 fun `compareTo should return -1 when the first condition has a parameter name and the second one does not` () {
158170 val firstCondition = PathQueryConditionFactory ()
You can’t perform that action at this time.
0 commit comments