From: Toine Siebelink Date: Thu, 22 Dec 2022 16:01:28 +0000 (+0000) Subject: Merge "Temp Table Creation improvements" X-Git-Tag: 3.2.1~30 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=30d76ed37b777e642854d5ab4e94a6fc5f6af84a;hp=-c;p=cps.git Merge "Temp Table Creation improvements" --- 30d76ed37b777e642854d5ab4e94a6fc5f6af84a diff --combined cps-path-parser/src/test/groovy/org/onap/cps/cpspath/parser/CpsPathUtilSpec.groovy index f6a768a0a,f1a878d63..36e89127c --- 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 +29,7 @@@ class CpsPathUtilSpec extends Specifica 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 +41,7 @@@ 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,22 -54,6 +54,22 @@@ '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 @@@ -90,16 -74,16 +90,16 @@@ def 'CPS Path Processing Performance Test.'() { when: '200,000 paths are processed' - def setupStopWatch = new StopWatch() - setupStopWatch.start() + def stopWatch = new StopWatch() + stopWatch.start() (1..100000).each { CpsPathUtil.getNormalizedXpath('/long/path/to/see/if/it/adds/paring/time/significantly/parent/child[@common-leaf-name="123"]') CpsPathUtil.getNormalizedXpath('//child[@other-leaf=1]/leaf-name[text()="search"]/ancestor::parent') } - setupStopWatch.stop() + stopWatch.stop() then: 'it takes less then 10,000 milliseconds' // In CI this actually takes about 3-5 sec which is approx. 50+ parser executions per millisecond! - assert setupStopWatch.getTotalTimeMillis() < 10000 + assert stopWatch.getTotalTimeMillis() < 10000 } }