json-path/fix-Upgrade-to-Hamcrest-2.2.patch

190 lines
7.6 KiB
Diff
Raw Permalink Normal View History

2023-10-07 16:55:40 +08:00
From eb75a8f1df9e6f03b71391dc9e34e8405c25de45 Mon Sep 17 00:00:00 2001
From: Valery Yatsynovich <valfirst@yandex.ru>
Date: Tue, 15 Oct 2019 22:52:32 +0300
Subject: [PATCH] Upgrade to Hamcrest 2.1
Reference: https://github.com/json-path/JsonPath/commit/f07a582497809ecd7f27bfa563c28e2f937d59ac
https://github.com/hamcrest/JavaHamcrest/releases/tag/v2.1:
"After a long hiatus without releases, this version simplifies the packaging of
Hamcrest into a single jar: hamcrest-2.1.jar. Other big changes include
Java 9 module compatibility, along with numerous other improvements and bug
fixes."
---
build.gradle | 5 ++---
json-path-assert/build.gradle | 3 +--
.../jsonassert/impl/matcher/IsCollectionWithSize.java | 6 ++----
.../jayway/jsonassert/impl/matcher/IsEmptyCollection.java | 5 ++---
.../jayway/jsonassert/impl/matcher/IsMapContainingKey.java | 4 +---
.../jsonassert/impl/matcher/IsMapContainingValue.java | 4 +---
6 files changed, 9 insertions(+), 18 deletions(-)
diff --git a/build.gradle b/build.gradle
index 504f45b..3e15d32 100644
--- a/build.gradle
+++ b/build.gradle
@@ -16,10 +16,9 @@ ext {
jacksonDatabind: 'com.fasterxml.jackson.core:jackson-databind:2.6.3',
gson: 'com.google.code.gson:gson:2.3.1',
jsonOrg: 'org.json:json:20140107',
- hamcrestCore: 'org.hamcrest:hamcrest-core:1.3',
- hamcrestLibrary: 'org.hamcrest:hamcrest-library:1.3',
+ hamcrest: 'org.hamcrest:hamcrest:2.2',
- test: ['org.slf4j:slf4j-simple:1.7.12', 'org.assertj:assertj-core:2.1.0', 'commons-io:commons-io:2.4','org.hamcrest:hamcrest-core:1.3', 'org.hamcrest:hamcrest-library:1.3', 'junit:junit:4.12']
+ test: ['org.slf4j:slf4j-simple:1.7.12', 'org.assertj:assertj-core:2.1.0', 'commons-io:commons-io:2.4','org.hamcrest:hamcrest:2.2', 'junit:junit:4.12']
]
snapshotVersion = false
}
diff --git a/json-path-assert/build.gradle b/json-path-assert/build.gradle
index 0a47bd0..4f23ac5 100644
--- a/json-path-assert/build.gradle
+++ b/json-path-assert/build.gradle
@@ -13,8 +13,7 @@ jar {
dependencies {
compile project(':json-path')
- compile libs.hamcrestCore
- compile libs.hamcrestLibrary
+ compile libs.hamcrest
compile libs.slf4jApi
testCompile libs.test
diff --git a/json-path-assert/src/main/java/com/jayway/jsonassert/impl/matcher/IsCollectionWithSize.java b/json-path-assert/src/main/java/com/jayway/jsonassert/impl/matcher/IsCollectionWithSize.java
index c4b7c1d..2a80384 100644
--- a/json-path-assert/src/main/java/com/jayway/jsonassert/impl/matcher/IsCollectionWithSize.java
+++ b/json-path-assert/src/main/java/com/jayway/jsonassert/impl/matcher/IsCollectionWithSize.java
@@ -30,7 +30,6 @@ DAMAGE.
package com.jayway.jsonassert.impl.matcher;
import org.hamcrest.Description;
-import org.hamcrest.Factory;
import org.hamcrest.Matcher;
import java.util.Collection;
@@ -52,6 +51,7 @@ public class IsCollectionWithSize<E> extends CollectionMatcher<Collection<? exte
return sizeMatcher.matches(item.size());
}
+ @Override
public void describeTo(Description description) {
description.appendText("a collection with size ")
.appendDescriptionOf(sizeMatcher);
@@ -60,7 +60,6 @@ public class IsCollectionWithSize<E> extends CollectionMatcher<Collection<? exte
/**
* Does collection size satisfy a given matcher?
*/
- @Factory
public static <E> Matcher<? super Collection<? extends E>> hasSize(Matcher<? super Integer> size) {
return new IsCollectionWithSize<E>(size);
}
@@ -71,9 +70,8 @@ public class IsCollectionWithSize<E> extends CollectionMatcher<Collection<? exte
* For example, assertThat(hasSize(equal_to(x)))
* vs. assertThat(hasSize(x))
*/
- @Factory
public static <E> Matcher<? super Collection<? extends E>> hasSize(int size) {
Matcher<? super Integer> matcher = equalTo(size);
return IsCollectionWithSize.<E>hasSize(matcher);
}
-}
\ No newline at end of file
+}
diff --git a/json-path-assert/src/main/java/com/jayway/jsonassert/impl/matcher/IsEmptyCollection.java b/json-path-assert/src/main/java/com/jayway/jsonassert/impl/matcher/IsEmptyCollection.java
index 23b12d0..2f4ec21 100644
--- a/json-path-assert/src/main/java/com/jayway/jsonassert/impl/matcher/IsEmptyCollection.java
+++ b/json-path-assert/src/main/java/com/jayway/jsonassert/impl/matcher/IsEmptyCollection.java
@@ -30,7 +30,6 @@ DAMAGE.
package com.jayway.jsonassert.impl.matcher;
import org.hamcrest.Description;
-import org.hamcrest.Factory;
import org.hamcrest.Matcher;
import java.util.Collection;
@@ -45,6 +44,7 @@ public class IsEmptyCollection<E> extends CollectionMatcher<Collection<E>> {
return item.isEmpty();
}
+ @Override
public void describeTo(Description description) {
description.appendText("an empty collection");
}
@@ -52,8 +52,7 @@ public class IsEmptyCollection<E> extends CollectionMatcher<Collection<E>> {
/**
* Matches an empty collection.
*/
- @Factory
public static <E> Matcher<Collection<E>> empty() {
return new IsEmptyCollection<E>();
}
-}
\ No newline at end of file
+}
diff --git a/json-path-assert/src/main/java/com/jayway/jsonassert/impl/matcher/IsMapContainingKey.java b/json-path-assert/src/main/java/com/jayway/jsonassert/impl/matcher/IsMapContainingKey.java
index 9766944..c246716 100644
--- a/json-path-assert/src/main/java/com/jayway/jsonassert/impl/matcher/IsMapContainingKey.java
+++ b/json-path-assert/src/main/java/com/jayway/jsonassert/impl/matcher/IsMapContainingKey.java
@@ -30,7 +30,6 @@ DAMAGE.
package com.jayway.jsonassert.impl.matcher;
import org.hamcrest.Description;
-import org.hamcrest.Factory;
import org.hamcrest.Matcher;
import java.util.Map;
@@ -54,17 +53,16 @@ public class IsMapContainingKey<K> extends MapTypeSafeMatcher<Map<K,?>> {
return false;
}
+ @Override
public void describeTo(Description description) {
description.appendText("map with key ")
.appendDescriptionOf(keyMatcher);
}
- @Factory
public static <K> Matcher<Map<K,?>> hasKey(K key) {
return hasKey(equalTo(key));
}
- @Factory
public static <K> Matcher<Map<K,?>> hasKey(Matcher<K> keyMatcher) {
return new IsMapContainingKey<K>(keyMatcher);
}
diff --git a/json-path-assert/src/main/java/com/jayway/jsonassert/impl/matcher/IsMapContainingValue.java b/json-path-assert/src/main/java/com/jayway/jsonassert/impl/matcher/IsMapContainingValue.java
index 9fb3a6d..d60462b 100644
--- a/json-path-assert/src/main/java/com/jayway/jsonassert/impl/matcher/IsMapContainingValue.java
+++ b/json-path-assert/src/main/java/com/jayway/jsonassert/impl/matcher/IsMapContainingValue.java
@@ -30,7 +30,6 @@ DAMAGE.
package com.jayway.jsonassert.impl.matcher;
import org.hamcrest.Description;
-import org.hamcrest.Factory;
import org.hamcrest.Matcher;
import java.util.Map;
@@ -54,17 +53,16 @@ public class IsMapContainingValue<V> extends MapTypeSafeMatcher<Map<?,V>>{
return false;
}
+ @Override
public void describeTo(Description description) {
description.appendText("map with value ")
.appendDescriptionOf(valueMatcher);
}
- @Factory
public static <V> Matcher<? super Map<?,V>> hasValue(V value) {
return IsMapContainingValue.<V>hasValue(equalTo(value));
}
- @Factory
public static <V> Matcher<? super Map<?,V>> hasValue(Matcher<? super V> valueMatcher) {
return new IsMapContainingValue<V>(valueMatcher);
}
--
2.27.0