diff --git a/confidence-json/build.gradle b/confidence-json/build.gradle index 131e66e..6592638 100644 --- a/confidence-json/build.gradle +++ b/confidence-json/build.gradle @@ -13,16 +13,14 @@ dependencies { annotationProcessor libs.bundles.srcless.processors implementation libs.jems2 implementation libs.jems2.confidence - implementation project(':confidence-core') + api project(':confidence-core') implementation libs.org.json - compileOnly libs.json.path compileOnly libs.express.json testImplementation project(':confidence-test') testImplementation libs.jems2.testing testImplementation libs.junit.jupiter.api testImplementation libs.express.json - testImplementation libs.json.path testRuntimeOnly libs.junit.jupiter.engine } diff --git a/confidence-json/src/main/java/org/saynotobugs/confidence/json/quality/JsonPathOf.java b/confidence-json/src/main/java/org/saynotobugs/confidence/json/quality/JsonPathOf.java deleted file mode 100644 index 13170c2..0000000 --- a/confidence-json/src/main/java/org/saynotobugs/confidence/json/quality/JsonPathOf.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2023 dmfs GmbH - * - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.saynotobugs.confidence.json.quality; - -import io.restassured.path.json.JsonPath; -import org.dmfs.srcless.annotations.staticfactory.StaticFactories; -import org.saynotobugs.confidence.Quality; -import org.saynotobugs.confidence.description.Text; -import org.saynotobugs.confidence.json.JsonElementAdapter; -import org.saynotobugs.confidence.json.jsonstringadapter.JsonStringElementAdapter; -import org.saynotobugs.confidence.quality.composite.Has; -import org.saynotobugs.confidence.quality.composite.QualityComposition; - -/** - * {@link Quality} of a {@link JsonPath}. - */ -@StaticFactories(value = "Json", packageName = "org.saynotobugs.confidence.json") -public final class JsonPathOf extends QualityComposition -{ - public JsonPathOf(Quality delegate) - { - /* - * We just convert the JSON to a String and use the JsonStringElementAdapter. - * Repeatedly invoking the JsonPath getters is way too slow. - */ - super(new Has<>(new Text("JsonPath"), new Text("JsonPath"), jsonPath -> new JsonStringElementAdapter(jsonPath.prettify()), delegate)); - } - -} diff --git a/confidence-json/src/test/java/org/saynotobugs/confidence/json/ExampleTests.java b/confidence-json/src/test/java/org/saynotobugs/confidence/json/ExampleTests.java index 923962b..e77df0b 100644 --- a/confidence-json/src/test/java/org/saynotobugs/confidence/json/ExampleTests.java +++ b/confidence-json/src/test/java/org/saynotobugs/confidence/json/ExampleTests.java @@ -18,7 +18,6 @@ package org.saynotobugs.confidence.json; -import io.restassured.path.json.JsonPath; import org.junit.jupiter.api.Test; import static org.saynotobugs.confidence.Assertion.assertThat; @@ -154,44 +153,4 @@ void testNotAnything() not(nullValue()) )))); } - - - @Test - void testNotAnythingJsonPath() - { - assertThat(JsonPath.from("123"), - is(jsonPathOf( - allOf( - not(object(anything())), - not(array(anything())), - not(string(anything())), - not(bool(anything())), - number(anything()), - not(nullValue()) - )))); - } - - @Test - void testNestedJsonpath() - { - assertThat(JsonPath.from("{\n" + - " \"key1\": {\n" + - " \"anyValue\": \"abc\",\n" + - " \"nullValue\": null\n" + - " },\n" + - " \"key2\": {\n" + - " \"numberValue\": 4\n" + - " }\n" + - "}"), - is(jsonPathOf(object( - with("key1", object( - with("anyValue"), - with("nullValue", nullValue()), - hasMemberCount(2) - )), - with("key2", object( - with("numberValue", 4) - )) - )))); - } } \ No newline at end of file diff --git a/confidence-json/src/test/java/org/saynotobugs/confidence/json/quality/JsonPathOfTest.java b/confidence-json/src/test/java/org/saynotobugs/confidence/json/quality/JsonPathOfTest.java deleted file mode 100644 index 52abcd5..0000000 --- a/confidence-json/src/test/java/org/saynotobugs/confidence/json/quality/JsonPathOfTest.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2023 dmfs GmbH - * - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.saynotobugs.confidence.json.quality; - -import io.restassured.path.json.JsonPath; -import org.junit.jupiter.api.Test; -import org.saynotobugs.confidence.quality.composite.AllOf; -import org.saynotobugs.confidence.quality.trivial.Anything; -import org.saynotobugs.confidence.test.quality.Fails; -import org.saynotobugs.confidence.test.quality.HasDescription; -import org.saynotobugs.confidence.test.quality.Passes; - -import java.io.IOException; - -import static org.saynotobugs.confidence.Assertion.assertThat; - -class JsonPathOfTest -{ - @Test - void test() throws IOException - { - assertThat(new JsonPathOf(new Object(new Anything())), - new AllOf<>( - new Passes<>(new JsonPath("{\"abc\": \"xyz\"}")), - new Fails<>(new JsonPath("[1,2,3]"), "JsonPath object not an object"), - new Fails<>(new JsonPath("123"), "JsonPath object not an object"), - new HasDescription("JsonPath object { }"))); - } -} \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 518cf34..a3678bc 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -4,7 +4,6 @@ eclipse-jdt = "2.2.600" express = "0.3.1" hamcrest = "2.2" jems2 = "2.22.0" -json-path = "5.4.0" junit = "5.8.2" junit-testkit = "1.9.2" mockito4 = "4.6.1" @@ -37,7 +36,6 @@ express-json = { module = "org.dmfs:express-json", version.ref = "express" } rxjava3 = { module = 'io.reactivex.rxjava3:rxjava', version.ref = "rxjava3" } org-json = { module = "org.json:json", version.ref = "org-json" } -json-path = { module = "io.rest-assured:json-path", version.ref = "json-path" } [bundles] srcless-processors = ["srcless-processors", "nullless-processors"]