You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2022/11/18 01:18:39 UTC

[GitHub] [skywalking-agent-test-tool] wu-sheng commented on a diff in pull request #47: Support `start with` and `end with`

wu-sheng commented on code in PR #47:
URL: https://github.com/apache/skywalking-agent-test-tool/pull/47#discussion_r1025897233


##########
validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/ExpressParser.java:
##########
@@ -19,50 +19,50 @@
 
 import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.element.ElementAssertor;
 import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.element.EqualsAssertor;
+import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.element.EndWithAssertor;
 import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.element.GreatThanAssertor;
-import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.element.GreetEqualAssertor;
+import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.element.GreatEqualAssertor;
 import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.element.NoopAssertor;
 import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.element.NotBlankAssertor;
 import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.element.NotEqualsAssertor;
 import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.element.NotNullAssertor;
 import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.element.NullAssertor;
+import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.element.StartWithAssertor;
 
 public class ExpressParser {
     public static ElementAssertor parse(String express) {
         if (express == null) {
             return new NoopAssertor();
         }
 
-        String expressTrim = express.trim();
-        if (expressTrim.equals("not null")) {
-            return new NotNullAssertor();
+        ExpressOperator expressOperator = ExpressOperator.parse(express);
+        if (expressOperator == null) {
+            return new EqualsAssertor(express);
         }
 
-        if (expressTrim.equals("not blank")) {
-            return new NotBlankAssertor();
-        }
-
-        if (expressTrim.equals("null")) {
-            return new NullAssertor();
-        }
+        String expectedValue = ExpressOperator.getExpectedValue(expressOperator, express);
 
-        String[] expressSegment = expressTrim.split(" ");
-        if (expressSegment.length == 1) {
-            return new EqualsAssertor(expressSegment[0]);
-        } else if (expressSegment.length == 2) {
-            String exceptedValue = expressSegment[1];
-            switch (expressSegment[0].trim()) {
-                case "nq":
-                    return new NotEqualsAssertor(exceptedValue);
-                case "eq":
-                    return new EqualsAssertor(exceptedValue);
-                case "gt":
-                    return new GreatThanAssertor(exceptedValue);
-                case "ge":
-                    return new GreetEqualAssertor(exceptedValue);
-            }
+        switch (expressOperator) {
+            case NULL:
+                return new NullAssertor();
+            case NOT_NULL:
+                return new NotNullAssertor();
+            case NOT_BLANK:
+                return new NotBlankAssertor();
+            case EQUALS:
+                return new EqualsAssertor(expectedValue);
+            case NOT_EQUALS:
+                return new NotEqualsAssertor(expectedValue);
+            case GREAT_THAN:
+                return new GreatThanAssertor(expectedValue);
+            case GREAT_EQUAL:
+                return new GreatEqualAssertor(expectedValue);
+            case START_WITH:
+                return new StartWithAssertor(expectedValue);
+            case END_WITH:
+                return new EndWithAssertor(expectedValue);
+            default:
+                return new EqualsAssertor(express);

Review Comment:
   This change seems wrong. KeyValuePair match drops into GreatEqualAssertor



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org