diff options
Diffstat (limited to 'cps-path-parser/src')
3 files changed, 10 insertions, 1 deletions
diff --git a/cps-path-parser/src/main/antlr4/org/onap/cps/cpspath/parser/antlr4/CpsPath.g4 b/cps-path-parser/src/main/antlr4/org/onap/cps/cpspath/parser/antlr4/CpsPath.g4 index 86095459ee..a4fd58e9c0 100644 --- a/cps-path-parser/src/main/antlr4/org/onap/cps/cpspath/parser/antlr4/CpsPath.g4 +++ b/cps-path-parser/src/main/antlr4/org/onap/cps/cpspath/parser/antlr4/CpsPath.g4 @@ -25,7 +25,7 @@ ancestorAxis: SLASH KW_ANCESTOR COLONCOLON ancestorPath ; ancestorPath: yangElement (SLASH yangElement)* ; -cpsPathWithSingleLeafCondition: prefix singleValueCondition ; +cpsPathWithSingleLeafCondition: prefix singleValueCondition postfix? ; /* No need to ditinguish between cpsPathWithDescendant | cpsPathWithDescendantAndLeafConditions really! @@ -40,6 +40,8 @@ descendant: SLASH prefix ; prefix: (SLASH yangElement)* SLASH containerName ; +postfix: (SLASH yangElement)+ ; + yangElement: containerName listElementRef? ; containerName: QName ; diff --git a/cps-path-parser/src/main/java/org/onap/cps/cpspath/parser/CpsPathBuilder.java b/cps-path-parser/src/main/java/org/onap/cps/cpspath/parser/CpsPathBuilder.java index a67cbeb870..afe01f644c 100644 --- a/cps-path-parser/src/main/java/org/onap/cps/cpspath/parser/CpsPathBuilder.java +++ b/cps-path-parser/src/main/java/org/onap/cps/cpspath/parser/CpsPathBuilder.java @@ -28,6 +28,7 @@ import org.onap.cps.cpspath.parser.antlr4.CpsPathParser.CpsPathWithDescendantCon import org.onap.cps.cpspath.parser.antlr4.CpsPathParser.CpsPathWithSingleLeafConditionContext; import org.onap.cps.cpspath.parser.antlr4.CpsPathParser.LeafConditionContext; import org.onap.cps.cpspath.parser.antlr4.CpsPathParser.MultipleValueConditionsContext; +import org.onap.cps.cpspath.parser.antlr4.CpsPathParser.PostfixContext; import org.onap.cps.cpspath.parser.antlr4.CpsPathParser.PrefixContext; import org.onap.cps.cpspath.parser.antlr4.CpsPathParser.SingleValueConditionContext; @@ -43,6 +44,11 @@ public class CpsPathBuilder extends CpsPathBaseListener { } @Override + public void exitPostfix(final PostfixContext ctx) { + throw new IllegalStateException(String.format("Unsupported postfix %s encountered in CpsPath.", ctx.getText())); + } + + @Override public void exitLeafCondition(final LeafConditionContext ctx) { Object comparisonValue = null; if (ctx.IntegerLiteral() != null) { diff --git a/cps-path-parser/src/test/groovy/org/onap/cps/cpspath/parser/CpsPathQuerySpec.groovy b/cps-path-parser/src/test/groovy/org/onap/cps/cpspath/parser/CpsPathQuerySpec.groovy index 0e7fc35cf4..116c9168e8 100644 --- a/cps-path-parser/src/test/groovy/org/onap/cps/cpspath/parser/CpsPathQuerySpec.groovy +++ b/cps-path-parser/src/test/groovy/org/onap/cps/cpspath/parser/CpsPathQuerySpec.groovy @@ -84,6 +84,7 @@ class CpsPathQuerySpec extends Specification { 'end with descendant and more than one attribute separated by "or"' | '//child[@int-leaf=5 or @leaf-name="leaf value"]' 'missing attribute value' | '//child[@int-leaf=5 and @name]' 'incomplete ancestor value' | '//books/ancestor::' + 'unsupported postfix after single value condition (JIRA CPS-450)' | '/parent/child[@id=1]/somePostFix' } def 'Parse cps path using ancestor by schema node identifier with a #scenario.'() { |