X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=cps-path-parser%2Fsrc%2Ftest%2Fgroovy%2Forg%2Fonap%2Fcps%2Fcpspath%2Fparser%2FCpsPathUtilSpec.groovy;h=36e89127c18db9e8d81c5b5470f105451a4a4867;hb=30d76ed37b777e642854d5ab4e94a6fc5f6af84a;hp=f1a878d63bceae6f80f91d3bb643485401cf332c;hpb=ded9f06f42bbe751bdec3d763ae5216d76df82c4;p=cps.git diff --git a/cps-path-parser/src/test/groovy/org/onap/cps/cpspath/parser/CpsPathUtilSpec.groovy b/cps-path-parser/src/test/groovy/org/onap/cps/cpspath/parser/CpsPathUtilSpec.groovy index f1a878d63..36e89127c 100644 --- a/cps-path-parser/src/test/groovy/org/onap/cps/cpspath/parser/CpsPathUtilSpec.groovy +++ b/cps-path-parser/src/test/groovy/org/onap/cps/cpspath/parser/CpsPathUtilSpec.groovy @@ -29,7 +29,7 @@ class CpsPathUtilSpec extends Specification { when: 'xpath with #scenario is parsed' def result = CpsPathUtil.getNormalizedXpath(xpath) then: 'normalized path uses single quotes for leave values' - result == "/parent/child[@common-leaf-name='123']" + assert result == "/parent/child[@common-leaf-name='123']" where: 'the following xpaths are used' scenario | xpath 'no quotes' | '/parent/child[@common-leaf-name=123]' @@ -41,7 +41,7 @@ class CpsPathUtilSpec extends Specification { when: 'a given xpath with #scenario is parsed' def result = CpsPathUtil.getNormalizedParentXpath(xpath) then: 'the result is the expected parent path' - result == expectedParentPath + assert result == expectedParentPath where: 'the following xpaths are used' scenario | xpath || expectedParentPath 'no child' | '/parent' || '' @@ -54,6 +54,22 @@ class CpsPathUtilSpec extends Specification { 'parent is list element using "' | '/parent/child[@id="x"]/grandChild' || "/parent/child[@id='x']" } + def 'Get node ID sequence for given xpath'() { + when: 'a given xpath with #scenario is parsed' + def result = CpsPathUtil.getXpathNodeIdSequence(xpath) + then: 'the result is the expected node ID sequence' + assert result == expectedNodeIdSequence + where: 'the following xpaths are used' + scenario | xpath || expectedNodeIdSequence + 'no child' | '/parent' || ["parent"] + 'child and parent' | '/parent/child' || ["parent","child"] + 'grand child' | '/parent/child/grandChild' || ["parent","child","grandChild"] + 'parent & top is list element' | '/parent[@id=1]/child' || ["parent","child"] + 'parent is list element' | '/parent/child[@id=1]/grandChild' || ["parent","child","grandChild"] + 'parent is list element with /' | "/parent/child[@id='a/b']/grandChild" || ["parent","child","grandChild"] + 'parent is list element with [' | "/parent/child[@id='a[b']/grandChild" || ["parent","child","grandChild"] + } + def 'Recognizing (absolute) xpaths to List elements'() { expect: 'check for list returns the correct values' assert CpsPathUtil.isPathToListElement(xpath) == expectList