You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jmeter.apache.org by artem-fedorov <gi...@git.apache.org> on 2017/11/29 14:22:55 UTC
[GitHub] jmeter pull request #344: Migrate JSON Path Assertion into JMeter core
GitHub user artem-fedorov opened a pull request:
https://github.com/apache/jmeter/pull/344
Migrate JSON Path Assertion into JMeter core
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/artem-fedorov/jmeter donate-json-assertion
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/jmeter/pull/344.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #344
----
commit bb4a2f46b64073726d3224fc8d6f791604f8109f
Author: Artem Fedorov <ar...@blazemeter.com>
Date: 2017-11-29T14:03:35Z
add JSONPAthAssertion class
commit e058138654fc9832aa899ca9033dc998a7264d5e
Author: Artem Fedorov <ar...@blazemeter.com>
Date: 2017-11-29T14:03:50Z
add JSONPathAssertionGui class
commit 28903c3ddd6aaa515e283c109fb12b07ce0aa7e9
Author: Artem Fedorov <ar...@blazemeter.com>
Date: 2017-11-29T14:04:00Z
add tests classes
commit 0e327c996270e9ac0318326523b45a015916381a
Author: Artem Fedorov <ar...@blazemeter.com>
Date: 2017-11-29T14:04:14Z
add message properties
commit 1a0588c767d5aaa9a6a9c6fc1b243249e6800d4a
Author: Artem Fedorov <ar...@blazemeter.com>
Date: 2017-11-29T14:04:31Z
add saveService properties
commit 5d4582090984d20a0e40f6bea611814bb26bf500
Author: Artem Fedorov <ar...@blazemeter.com>
Date: 2017-11-29T14:05:12Z
add html docs
commit 9c3a6283db1773bf7694954676ac8d44e6de2cc4
Author: Artem Fedorov <ar...@blazemeter.com>
Date: 2017-11-29T14:05:28Z
add xdocs
commit cb6411c9fb39a211521df02066be1170b730a92a
Author: Artem Fedorov <ar...@blazemeter.com>
Date: 2017-11-29T14:17:45Z
add changelog
----
---
[GitHub] jmeter issue #344: Migrate JSON Path Assertion into JMeter core
Posted by pmouawad <gi...@git.apache.org>.
Github user pmouawad commented on the issue:
https://github.com/apache/jmeter/pull/344
Hi @artem-fedorov ,
Thanks for the PR
Regarding build:
- You might have to merge the trunk as I made a fix in JMS few minutes ago.
Regarding PR itself:
- Package for assertions is org.apache.jmeter.assertions , so I think you should move the class to it
- I don't see JUnit tests for JSONAssertion , only for GUI, am I missing something ? If they are really missing it would be nice if you could add some possibly spock / groovy based or Junit only
Regards
---
[GitHub] jmeter pull request #344: Migrate JSON Path Assertion into JMeter core
Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:
https://github.com/apache/jmeter/pull/344
---
[GitHub] jmeter issue #344: Migrate JSON Path Assertion into JMeter core
Posted by artem-fedorov <gi...@git.apache.org>.
Github user artem-fedorov commented on the issue:
https://github.com/apache/jmeter/pull/344
@pmouawad
I moved classes to `org.apache.jmeter.assertions` folder.
Regarding Tests: You are really missed this class `test/src/org/apache/jmeter/assertions/TestJSONPathAssertion.java`
---
[GitHub] jmeter pull request #344: Migrate JSON Path Assertion into JMeter core
Posted by ham1 <gi...@git.apache.org>.
Github user ham1 commented on a diff in the pull request:
https://github.com/apache/jmeter/pull/344#discussion_r153870336
--- Diff: src/components/org/apache/jmeter/extractor/json/jsonpath/JSONPathAssertion.java ---
@@ -0,0 +1,218 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.jmeter.extractor.json.jsonpath;
+
+import com.jayway.jsonpath.JsonPath;
+import net.minidev.json.JSONArray;
+import net.minidev.json.JSONObject;
+import org.apache.jmeter.assertions.Assertion;
+import org.apache.jmeter.assertions.AssertionResult;
+import org.apache.jmeter.samplers.SampleResult;
+import org.apache.jmeter.testelement.AbstractTestElement;
+import org.apache.jmeter.util.JMeterUtils;
+import org.apache.oro.text.regex.Pattern;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.Serializable;
+import java.text.DecimalFormat;
+import java.util.Map;
+
+/**
+ * This is main class for JSONPath Assertion which verifies assertion on
+ * previous sample result using JSON path expression
+ */
+public class JSONPathAssertion extends AbstractTestElement implements Serializable, Assertion {
+ private static final Logger log = LoggerFactory.getLogger(JSONPostProcessor.class);
+ private static final long serialVersionUID = 1L;
+ public static final String JSONPATH = "JSON_PATH";
+ public static final String EXPECTEDVALUE = "EXPECTED_VALUE";
+ public static final String JSONVALIDATION = "JSONVALIDATION";
+ public static final String EXPECT_NULL = "EXPECT_NULL";
+ public static final String INVERT = "INVERT";
+ public static final String ISREGEX = "ISREGEX";
+
+ public static final DecimalFormat decimalFormatter = new DecimalFormat("#.#");
+
+ static {
+ decimalFormatter.setMaximumFractionDigits(340); // java.text.DecimalFormat.DOUBLE_FRACTION_DIGITS == 340
+ decimalFormatter.setMinimumFractionDigits(1);
+ }
+
+ public String getJsonPath() {
+ return getPropertyAsString(JSONPATH);
+ }
+
+ public void setJsonPath(String jsonPath) {
+ setProperty(JSONPATH, jsonPath);
+ }
+
+ public String getExpectedValue() {
+ return getPropertyAsString(EXPECTEDVALUE);
+ }
+
+ public void setExpectedValue(String expectedValue) {
+ setProperty(EXPECTEDVALUE, expectedValue);
+ }
+
+ public void setJsonValidationBool(boolean jsonValidation) {
+ setProperty(JSONVALIDATION, jsonValidation);
+ }
+
+ public void setExpectNull(boolean val) {
+ setProperty(EXPECT_NULL, val);
+ }
+
+ public boolean isExpectNull() {
+ return getPropertyAsBoolean(EXPECT_NULL);
+ }
+
+ public boolean isJsonValidationBool() {
+ return getPropertyAsBoolean(JSONVALIDATION);
+ }
+
+ public void setInvert(boolean invert) {
+ setProperty(INVERT, invert);
+ }
+
+ public boolean isInvert() {
+ return getPropertyAsBoolean(INVERT);
+ }
+
+ public void setIsRegex(boolean flag) {
+ setProperty(ISREGEX, flag);
+ }
+
+ public boolean isUseRegex() {
+ return getPropertyAsBoolean(ISREGEX, true);
+ }
+
+ private void doAssert(String jsonString) {
+ Object value = JsonPath.read(jsonString, getJsonPath());
+
+ if (isJsonValidationBool()) {
+ if (value instanceof JSONArray) {
+ if (arrayMatched((JSONArray) value)) {
+ return;
+ }
+ } else {
+ if (isExpectNull() && value == null) {
+ return;
+ } else if (isEquals(value)) {
+ return;
+ }
+ }
+
+ if (isExpectNull()) {
+ throw new RuntimeException(String.format("Value expected to be null, but found '%s'", value));
+ } else {
+ String msg;
+ if (isUseRegex()) {
+ msg="Value expected to match regexp '%s', but it did not match: '%s'";
+ } else {
+ msg="Value expected to be '%s', but found '%s'";
+ }
+ throw new RuntimeException(String.format(msg, getExpectedValue(), objectToString(value)));
+ }
+ }
+ }
+
+ private boolean arrayMatched(JSONArray value) {
+ if (value.isEmpty() && getExpectedValue().equals("[]")) {
--- End diff --
Would this work with both regex on and off? I'm probably wrong but if you were looking for `[]` with a regex it would be `\[\]`?
---
[GitHub] jmeter issue #344: Migrate JSON Path Assertion into JMeter core
Posted by codecov-io <gi...@git.apache.org>.
Github user codecov-io commented on the issue:
https://github.com/apache/jmeter/pull/344
# [Codecov](https://codecov.io/gh/apache/jmeter/pull/344?src=pr&el=h1) Report
> Merging [#344](https://codecov.io/gh/apache/jmeter/pull/344?src=pr&el=desc) into [trunk](https://codecov.io/gh/apache/jmeter/commit/16fbe550ac422b257e24b68a6e084707c894ee16?src=pr&el=desc) will **increase** coverage by `0.25%`.
> The diff coverage is `96.21%`.
[![Impacted file tree graph](https://codecov.io/gh/apache/jmeter/pull/344/graphs/tree.svg?width=650&height=150&src=pr&token=6Q7CI1wFSh)](https://codecov.io/gh/apache/jmeter/pull/344?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## trunk #344 +/- ##
============================================
+ Coverage 58.09% 58.34% +0.25%
- Complexity 10109 10195 +86
============================================
Files 1154 1158 +4
Lines 73958 74381 +423
Branches 7342 7363 +21
============================================
+ Hits 42966 43399 +433
+ Misses 28510 28487 -23
- Partials 2482 2495 +13
```
| [Impacted Files](https://codecov.io/gh/apache/jmeter/pull/344?src=pr&el=tree) | Coverage Δ | Complexity Δ | |
|---|---|---|---|
| [src/core/org/apache/jmeter/save/SaveService.java](https://codecov.io/gh/apache/jmeter/pull/344?src=pr&el=tree#diff-c3JjL2NvcmUvb3JnL2FwYWNoZS9qbWV0ZXIvc2F2ZS9TYXZlU2VydmljZS5qYXZh) | `68.91% <ø> (ø)` | `37 <0> (ø)` | :arrow_down: |
| [...apache/jmeter/extractor/TestJSONPathAssertion.java](https://codecov.io/gh/apache/jmeter/pull/344?src=pr&el=tree#diff-dGVzdC9zcmMvb3JnL2FwYWNoZS9qbWV0ZXIvZXh0cmFjdG9yL1Rlc3RKU09OUGF0aEFzc2VydGlvbi5qYXZh) | `100% <100%> (ø)` | `26 <26> (?)` | |
| [...che/jmeter/extractor/TestJSONPathAssertionGui.java](https://codecov.io/gh/apache/jmeter/pull/344?src=pr&el=tree#diff-dGVzdC9zcmMvb3JnL2FwYWNoZS9qbWV0ZXIvZXh0cmFjdG9yL1Rlc3RKU09OUGF0aEFzc2VydGlvbkd1aS5qYXZh) | `100% <100%> (ø)` | `8 <8> (?)` | |
| [...ter/extractor/json/jsonpath/JSONPathAssertion.java](https://codecov.io/gh/apache/jmeter/pull/344?src=pr&el=tree#diff-c3JjL2NvbXBvbmVudHMvb3JnL2FwYWNoZS9qbWV0ZXIvZXh0cmFjdG9yL2pzb24vanNvbnBhdGgvSlNPTlBhdGhBc3NlcnRpb24uamF2YQ==) | `85.05% <85.05%> (ø)` | `36 <36> (?)` | |
| [...ractor/json/jsonpath/gui/JSONPathAssertionGui.java](https://codecov.io/gh/apache/jmeter/pull/344?src=pr&el=tree#diff-c3JjL2NvbXBvbmVudHMvb3JnL2FwYWNoZS9qbWV0ZXIvZXh0cmFjdG9yL2pzb24vanNvbnBhdGgvZ3VpL0pTT05QYXRoQXNzZXJ0aW9uR3VpLmphdmE=) | `95.23% <95.23%> (ø)` | `8 <8> (?)` | |
| [...c/core/org/apache/jmeter/reporters/Summariser.java](https://codecov.io/gh/apache/jmeter/pull/344?src=pr&el=tree#diff-c3JjL2NvcmUvb3JnL2FwYWNoZS9qbWV0ZXIvcmVwb3J0ZXJzL1N1bW1hcmlzZXIuamF2YQ==) | `86.15% <0%> (+0.76%)` | `19% <0%> (+1%)` | :arrow_up: |
| ... and [2 more](https://codecov.io/gh/apache/jmeter/pull/344?src=pr&el=tree-more) | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/jmeter/pull/344?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/jmeter/pull/344?src=pr&el=footer). Last update [16fbe55...d42f9cc](https://codecov.io/gh/apache/jmeter/pull/344?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
---
[GitHub] jmeter pull request #344: Migrate JSON Path Assertion into JMeter core
Posted by ham1 <gi...@git.apache.org>.
Github user ham1 commented on a diff in the pull request:
https://github.com/apache/jmeter/pull/344#discussion_r154070701
--- Diff: test/src/org/apache/jmeter/assertions/TestJSONPathAssertion.java ---
@@ -0,0 +1,383 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.jmeter.assertions;
+
+import org.apache.jmeter.samplers.SampleResult;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class TestJSONPathAssertion {
+
+ @Test
+ public void testGetJsonPath() {
+ JSONPathAssertion instance = new JSONPathAssertion();
+ String expResult = "";
+ String result = instance.getJsonPath();
+ assertEquals(expResult, result);
+ }
+
+ @Test
+ public void testSetJsonPath() {
+ String jsonPath = "";
+ JSONPathAssertion instance = new JSONPathAssertion();
+ instance.setJsonPath(jsonPath);
+ }
+
+ @Test
+ public void testGetExpectedValue() {
+ JSONPathAssertion instance = new JSONPathAssertion();
+ String expResult = "";
+ String result = instance.getExpectedValue();
+ assertEquals(expResult, result);
+ }
+
+ @Test
+ public void testSetExpectedValue() {
+ String expectedValue = "";
+ JSONPathAssertion instance = new JSONPathAssertion();
+ instance.setExpectedValue(expectedValue);
+ }
+
+ @Test
+ public void testSetJsonValidationBool() {
+ JSONPathAssertion instance = new JSONPathAssertion();
+ instance.setJsonValidationBool(false);
+ }
+
+ @Test
+ public void testIsJsonValidationBool() {
+ JSONPathAssertion instance = new JSONPathAssertion();
+ boolean result = instance.isJsonValidationBool();
+ assertEquals(false, result);
+ }
+
+ @Test
+ public void testGetResult_positive() {
--- End diff --
These tests would work really well in Spock e.g.:
```groovy
def samplerResult = new SampleResult()
def sut = new JSONPathAssertion()
@Unroll
def "get #jsonPath expect #expectedValue to fail=#failure"() {
given:
samplerResult.setResponseData("{\"myval\": 123}".getBytes())
sut.setJsonPath("$.myval")
sut.setJsonValidationBool(true)
sut.setExpectedValue("123")
when:
def result = sut.getResult(samplerResult)
then:
result.getName() == new AssertionResult("").getName()
result.isFailure() == failure
where:
jsonPath || expectedValue | failure
"$.myval" || "123" | false
"$.myval" || "(123|456)" | false
"$.myval" || "1234" | true
}
```
---
[GitHub] jmeter pull request #344: Migrate JSON Path Assertion into JMeter core
Posted by artem-fedorov <gi...@git.apache.org>.
Github user artem-fedorov commented on a diff in the pull request:
https://github.com/apache/jmeter/pull/344#discussion_r154099867
--- Diff: test/src/org/apache/jmeter/assertions/TestJSONPathAssertion.java ---
@@ -0,0 +1,383 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.jmeter.assertions;
+
+import org.apache.jmeter.samplers.SampleResult;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class TestJSONPathAssertion {
+
+ @Test
+ public void testGetJsonPath() {
+ JSONPathAssertion instance = new JSONPathAssertion();
+ String expResult = "";
+ String result = instance.getJsonPath();
+ assertEquals(expResult, result);
+ }
+
+ @Test
+ public void testSetJsonPath() {
+ String jsonPath = "";
+ JSONPathAssertion instance = new JSONPathAssertion();
+ instance.setJsonPath(jsonPath);
+ }
+
+ @Test
+ public void testGetExpectedValue() {
+ JSONPathAssertion instance = new JSONPathAssertion();
+ String expResult = "";
+ String result = instance.getExpectedValue();
+ assertEquals(expResult, result);
+ }
+
+ @Test
+ public void testSetExpectedValue() {
+ String expectedValue = "";
+ JSONPathAssertion instance = new JSONPathAssertion();
+ instance.setExpectedValue(expectedValue);
+ }
+
+ @Test
+ public void testSetJsonValidationBool() {
+ JSONPathAssertion instance = new JSONPathAssertion();
+ instance.setJsonValidationBool(false);
+ }
+
+ @Test
+ public void testIsJsonValidationBool() {
+ JSONPathAssertion instance = new JSONPathAssertion();
+ boolean result = instance.isJsonValidationBool();
+ assertEquals(false, result);
+ }
+
+ @Test
+ public void testGetResult_positive() {
--- End diff --
It's also work fine in Java :smile:
---
[GitHub] jmeter pull request #344: Migrate JSON Path Assertion into JMeter core
Posted by artem-fedorov <gi...@git.apache.org>.
Github user artem-fedorov commented on a diff in the pull request:
https://github.com/apache/jmeter/pull/344#discussion_r154098390
--- Diff: src/components/org/apache/jmeter/extractor/json/jsonpath/JSONPathAssertion.java ---
@@ -0,0 +1,218 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.jmeter.extractor.json.jsonpath;
+
+import com.jayway.jsonpath.JsonPath;
+import net.minidev.json.JSONArray;
+import net.minidev.json.JSONObject;
+import org.apache.jmeter.assertions.Assertion;
+import org.apache.jmeter.assertions.AssertionResult;
+import org.apache.jmeter.samplers.SampleResult;
+import org.apache.jmeter.testelement.AbstractTestElement;
+import org.apache.jmeter.util.JMeterUtils;
+import org.apache.oro.text.regex.Pattern;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.Serializable;
+import java.text.DecimalFormat;
+import java.util.Map;
+
+/**
+ * This is main class for JSONPath Assertion which verifies assertion on
+ * previous sample result using JSON path expression
+ */
+public class JSONPathAssertion extends AbstractTestElement implements Serializable, Assertion {
+ private static final Logger log = LoggerFactory.getLogger(JSONPostProcessor.class);
+ private static final long serialVersionUID = 1L;
+ public static final String JSONPATH = "JSON_PATH";
+ public static final String EXPECTEDVALUE = "EXPECTED_VALUE";
+ public static final String JSONVALIDATION = "JSONVALIDATION";
+ public static final String EXPECT_NULL = "EXPECT_NULL";
+ public static final String INVERT = "INVERT";
+ public static final String ISREGEX = "ISREGEX";
+
+ public static final DecimalFormat decimalFormatter = new DecimalFormat("#.#");
+
+ static {
+ decimalFormatter.setMaximumFractionDigits(340); // java.text.DecimalFormat.DOUBLE_FRACTION_DIGITS == 340
+ decimalFormatter.setMinimumFractionDigits(1);
+ }
+
+ public String getJsonPath() {
+ return getPropertyAsString(JSONPATH);
+ }
+
+ public void setJsonPath(String jsonPath) {
+ setProperty(JSONPATH, jsonPath);
+ }
+
+ public String getExpectedValue() {
+ return getPropertyAsString(EXPECTEDVALUE);
+ }
+
+ public void setExpectedValue(String expectedValue) {
+ setProperty(EXPECTEDVALUE, expectedValue);
+ }
+
+ public void setJsonValidationBool(boolean jsonValidation) {
+ setProperty(JSONVALIDATION, jsonValidation);
+ }
+
+ public void setExpectNull(boolean val) {
+ setProperty(EXPECT_NULL, val);
+ }
+
+ public boolean isExpectNull() {
+ return getPropertyAsBoolean(EXPECT_NULL);
+ }
+
+ public boolean isJsonValidationBool() {
+ return getPropertyAsBoolean(JSONVALIDATION);
+ }
+
+ public void setInvert(boolean invert) {
+ setProperty(INVERT, invert);
+ }
+
+ public boolean isInvert() {
+ return getPropertyAsBoolean(INVERT);
+ }
+
+ public void setIsRegex(boolean flag) {
+ setProperty(ISREGEX, flag);
+ }
+
+ public boolean isUseRegex() {
+ return getPropertyAsBoolean(ISREGEX, true);
+ }
+
+ private void doAssert(String jsonString) {
+ Object value = JsonPath.read(jsonString, getJsonPath());
+
+ if (isJsonValidationBool()) {
+ if (value instanceof JSONArray) {
+ if (arrayMatched((JSONArray) value)) {
+ return;
+ }
+ } else {
+ if (isExpectNull() && value == null) {
+ return;
+ } else if (isEquals(value)) {
+ return;
+ }
+ }
+
+ if (isExpectNull()) {
+ throw new RuntimeException(String.format("Value expected to be null, but found '%s'", value));
+ } else {
+ String msg;
+ if (isUseRegex()) {
+ msg="Value expected to match regexp '%s', but it did not match: '%s'";
+ } else {
+ msg="Value expected to be '%s', but found '%s'";
+ }
+ throw new RuntimeException(String.format(msg, getExpectedValue(), objectToString(value)));
+ }
+ }
+ }
+
+ private boolean arrayMatched(JSONArray value) {
+ if (value.isEmpty() && getExpectedValue().equals("[]")) {
--- End diff --
Tests covered a lot of users scenarios that were formed by users for years. I think that this scenario also covered in one of tests (for example in `TestJSONPathAssertion.testGetResult_list_*`)
---