summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorToine Siebelink <toine.siebelink@est.tech>2024-01-25 12:42:14 +0000
committerGerrit Code Review <gerrit@onap.org>2024-01-25 12:42:14 +0000
commit26804e49980bc1d3139b09b7934e94a2ea1e7743 (patch)
tree9b6f04a13772b13d04f149e763adc0bd57a3c283
parentad5d1fccb4e07ac0260ca4a6a0f7034861e631ad (diff)
parent1322b0f69d5e5401a14a728e45a289311ec7ac4a (diff)
Merge "CPS 1824: Delta Between 2 Anchors release notes"
-rw-r--r--cps-service/src/main/java/org/onap/cps/api/impl/CpsDeltaServiceImpl.java7
-rw-r--r--cps-service/src/test/groovy/org/onap/cps/api/impl/CpsDeltaServiceImplSpec.groovy28
-rw-r--r--docs/release-notes.rst2
3 files changed, 18 insertions, 19 deletions
diff --git a/cps-service/src/main/java/org/onap/cps/api/impl/CpsDeltaServiceImpl.java b/cps-service/src/main/java/org/onap/cps/api/impl/CpsDeltaServiceImpl.java
index 1e1fe819ac..2f99dbf7bb 100644
--- a/cps-service/src/main/java/org/onap/cps/api/impl/CpsDeltaServiceImpl.java
+++ b/cps-service/src/main/java/org/onap/cps/api/impl/CpsDeltaServiceImpl.java
@@ -165,10 +165,11 @@ public class CpsDeltaServiceImpl implements CpsDeltaService {
sourceDataInDeltaReport.put(key, sourceLeaf);
targetDataInDeltaReport.put(key, targetLeaf);
}
- } else if (sourceLeaf != null) {
- sourceDataInDeltaReport.put(key, sourceLeaf);
- } else if (targetLeaf != null) {
+ } else if (sourceLeaf == null) {
targetDataInDeltaReport.put(key, targetLeaf);
+
+ } else {
+ sourceDataInDeltaReport.put(key, sourceLeaf);
}
}
diff --git a/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsDeltaServiceImplSpec.groovy b/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsDeltaServiceImplSpec.groovy
index e21c6f0e2f..42d75f3eab 100644
--- a/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsDeltaServiceImplSpec.groovy
+++ b/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsDeltaServiceImplSpec.groovy
@@ -21,7 +21,6 @@
package org.onap.cps.api.impl
import org.onap.cps.spi.model.DataNode
-import spock.lang.Shared
import spock.lang.Specification
class CpsDeltaServiceImplSpec extends Specification{
@@ -36,7 +35,7 @@ class CpsDeltaServiceImplSpec extends Specification{
static def sourceDataNodeWithMultipleLeaves = [new DataNode(xpath: '/parent', leaves: ['leaf-1': 'leaf-1-in-source', 'leaf-2': 'leaf-2-in-source'])]
static def targetDataNodeWithMultipleLeaves = [new DataNode(xpath: '/parent', leaves: ['leaf-1': 'leaf-1-in-target', 'leaf-2': 'leaf-2-in-target'])]
- def 'Get delta between data nodes for REMOVED data where source data node has #scenario'() {
+ def 'Get delta between data nodes for REMOVED data'() {
when: 'attempt to get delta between 2 data nodes'
def result = objectUnderTest.getDeltaReports(sourceDataNodeWithLeafData, [])
then: 'the delta report contains expected "remove" action'
@@ -49,7 +48,7 @@ class CpsDeltaServiceImplSpec extends Specification{
assert result[0].targetData == null
}
- def 'Get delta between data nodes with ADDED data where target data node has #scenario'() {
+ def 'Get delta between data nodes for ADDED data'() {
when: 'attempt to get delta between 2 data nodes'
def result = objectUnderTest.getDeltaReports([], targetDataNodeWithLeafData)
then: 'the delta report contains expected "add" action'
@@ -62,23 +61,22 @@ class CpsDeltaServiceImplSpec extends Specification{
assert result[0].targetData == ['parent-leaf': 'parent-payload-in-target']
}
- def 'Delta Report between leaves for parent and child nodes, #scenario'() {
+ def 'Delta Report between leaves for parent and child nodes'() {
given: 'Two data nodes'
def sourceDataNode = [new DataNode(xpath: '/parent', leaves: ['parent-leaf': 'parent-payload'], childDataNodes: [new DataNode(xpath: '/parent/child', leaves: ['child-leaf': 'child-payload'])])]
def targetDataNode = [new DataNode(xpath: '/parent', leaves: ['parent-leaf': 'parent-payload-updated'], childDataNodes: [new DataNode(xpath: '/parent/child', leaves: ['child-leaf': 'child-payload-updated'])])]
when: 'attempt to get delta between 2 data nodes'
def result = objectUnderTest.getDeltaReports(sourceDataNode, targetDataNode)
- then: 'the delta report contains expected "update" action'
- assert result[index].action.equals('update')
- and: 'the delta report contains expected xpath'
- assert result[index].xpath == expectedXpath
- and: 'the delta report contains expected source and target data'
- assert result[index].sourceData == expectedSourceData
- assert result[index].targetData == expectedTargetData
- where: 'the following data was used'
- scenario | index || expectedXpath | expectedSourceData | expectedTargetData
- 'parent data node' | 0 || '/parent' | ['parent-leaf': 'parent-payload'] | ['parent-leaf': 'parent-payload-updated']
- 'child data node' | 1 || '/parent/child' | ['child-leaf': 'child-payload'] | ['child-leaf': 'child-payload-updated']
+ then: 'the delta report contains expected details for parent node'
+ assert result[0].action.equals('update')
+ assert result[0].xpath == '/parent'
+ assert result[0].sourceData == ['parent-leaf': 'parent-payload']
+ assert result[0].targetData == ['parent-leaf': 'parent-payload-updated']
+ and: 'the delta report contains expected details for child node'
+ assert result[1].action.equals('update')
+ assert result[1].xpath == '/parent/child'
+ assert result[1].sourceData == ['child-leaf': 'child-payload']
+ assert result[1].targetData == ['child-leaf': 'child-payload-updated']
}
def 'Delta report between leaves, #scenario'() {
diff --git a/docs/release-notes.rst b/docs/release-notes.rst
index 2b66caf7dd..f5cef76eda 100644
--- a/docs/release-notes.rst
+++ b/docs/release-notes.rst
@@ -43,7 +43,7 @@ Bug Fixes
Features
--------
-
+ - `CPS-1824 <https://jira.onap.org/browse/CPS-1824>`_ CPS Delta between 2 anchors.
Version: 3.4.2
==============