jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fschumac...@apache.org
Subject [jmeter] 02/04: Extract common code to simplify method
Date Sat, 28 Sep 2019 10:18:39 GMT
This is an automated email from the ASF dual-hosted git repository.

fschumacher pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jmeter.git

commit 2ac8052789a1ceafd5db712be2d1366f3b542426
Author: Felix Schumacher <felix.schumacher@internetallee.de>
AuthorDate: Sat Sep 28 11:51:40 2019 +0200

    Extract common code to simplify method
---
 .../assertions/jmespath/JMESPathAssertion.java     | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/src/components/src/main/java/org/apache/jmeter/assertions/jmespath/JMESPathAssertion.java
b/src/components/src/main/java/org/apache/jmeter/assertions/jmespath/JMESPathAssertion.java
index 52ee59c..4cda1ca 100644
--- a/src/components/src/main/java/org/apache/jmeter/assertions/jmespath/JMESPathAssertion.java
+++ b/src/components/src/main/java/org/apache/jmeter/assertions/jmespath/JMESPathAssertion.java
@@ -97,28 +97,20 @@ public class JMESPathAssertion extends AbstractTestElement implements
Serializab
             message.append("JMESPATH ")
                 .append(getJmesPath())
                 .append(" expected");
-            if (invert) {
-                message.append(" not");
-            }
+            addNegation(invert, message);
             message.append(" to exist");
         } else {
             message.append("Value expected");
             if (isExpectNull()) {
-                if (invert) {
-                    message.append(" not");
-                }
+                addNegation(invert, message);
                 message.append(" to be null");
             } else {
                 if (isUseRegex()) {
-                    if (invert) {
-                        message.append(" not");
-                    }
+                    addNegation(invert, message);
                     message.append(" to match ");
                     message.append(getExpectedValue());
                 } else {
-                    if (invert) {
-                        message.append(" not");
-                    }
+                    addNegation(invert, message);
                     message.append(" to be equal to ");
                     message.append(getExpectedValue());
                 }
@@ -127,6 +119,12 @@ public class JMESPathAssertion extends AbstractTestElement implements
Serializab
         return message.toString();
     }
 
+    private void addNegation(boolean invert, StringBuilder message) {
+        if (invert) {
+            message.append(" not");
+        }
+    }
+
     private boolean checkResult(ObjectMapper mapper, JsonNode jsonNode, AssertionResult result,
boolean invert)
             throws JsonProcessingException {
         if (!isJsonValidationBool()) {


Mime
View raw message