From 8e22c6a80b491cc98d4052e05dc94ee645bf2197 Mon Sep 17 00:00:00 2001 From: danielhanrahan Date: Sat, 31 Aug 2024 22:30:16 +0100 Subject: [Cps Path Parser] Refactoring leaf conditions Instead of DataLeaf and ComparativeOperators classes, we more simply have LeafConditions class with all info. Issue-ID: CPS-2365 Signed-off-by: danielhanrahan Change-Id: I8fd18bb56b8ed9d26a3f9d36f487d00a9274c8bc --- .../cps/cpspath/parser/CpsPathQuerySpec.groovy | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'cps-path-parser/src/test') 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 15f6b11823..730c826332 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 @@ -48,8 +48,8 @@ class CpsPathQuerySpec extends Specification { and: 'the right query parameters are set' assert result.xpathPrefix == expectedXpathPrefix assert result.hasLeafConditions() - assert result.leavesData[0].name == expectedLeafName - assert result.leavesData[0].value == expectedLeafValue + assert result.leafConditions[0].name() == expectedLeafName + assert result.leafConditions[0].value() == expectedLeafValue where: 'the following data is used' scenario | cpsPath || expectedXpathPrefix | expectedLeafName | expectedLeafValue 'leaf of type String' | '/parent/child[@common-leaf-name="common-leaf-value"]' || '/parent/child' | 'common-leaf-name' | 'common-leaf-value' @@ -123,11 +123,11 @@ class CpsPathQuerySpec extends Specification { when: 'the given cps path is parsed' def result = CpsPathQuery.createFrom(cpsPath) then: 'the expected number of leaves are returned' - result.leavesData.size() == expectedNumberOfLeaves + result.leafConditions.size() == expectedNumberOfLeaves and: 'the given operator(s) returns in the correct order' result.booleanOperators == expectedOperators and: 'the given comparativeOperator(s) returns in the correct order' - result.comparativeOperators == expectedComparativeOperator + result.leafConditions.operator == expectedComparativeOperator where: 'the following data is used' cpsPath || expectedNumberOfLeaves || expectedOperators || expectedComparativeOperator '/parent[@code=1]/child[@common-leaf-name-int=5]' || 1 || [] || ['='] @@ -234,19 +234,19 @@ class CpsPathQuerySpec extends Specification { when: 'the given cps path is parsed using multiple conditions on same leaf' def result = CpsPathQuery.createFrom('/test[@same-name="value1" or @same-name="value2"]') then: 'two leaves are present with correct values' - assert result.leavesData.size() == 2 - assert result.leavesData[0].name == "same-name" - assert result.leavesData[0].value == "value1" - assert result.leavesData[1].name == "same-name" - assert result.leavesData[1].value == "value2" + assert result.leafConditions.size() == 2 + assert result.leafConditions[0].name == "same-name" + assert result.leafConditions[0].value == "value1" + assert result.leafConditions[1].name == "same-name" + assert result.leafConditions[1].value == "value2" } def 'Ordering of data leaves is preserved.'() { when: 'the given cps path is parsed' def result = CpsPathQuery.createFrom(cpsPath) then: 'the order of the data leaves is preserved' - assert result.leavesData[0].name == expectedFirstLeafName - assert result.leavesData[1].name == expectedSecondLeafName + assert result.leafConditions[0].name == expectedFirstLeafName + assert result.leafConditions[1].name == expectedSecondLeafName where: 'the following data is used' cpsPath || expectedFirstLeafName | expectedSecondLeafName '/test[@name1="value1" and @name2="value2"]' || 'name1' | 'name2' -- cgit 1.2.3-korg