aboutsummaryrefslogtreecommitdiffstats
path: root/cps-service/src
diff options
context:
space:
mode:
authorArpit Singh <as00745003@techmahindra.com>2024-09-04 11:02:06 +0530
committerArpit Singh <as00745003@techmahindra.com>2024-09-10 10:10:29 +0000
commit3c8539cf17b1698cadf08e6f3acc4a8b9273af85 (patch)
tree491c24c147e6a303fcb68bbdf5b27bb6ae69ffd8 /cps-service/src
parent3a4dcb5af00b85ae3f48709dfa0f9d797e02aabd (diff)
Renaming Delta Operations as per RFC 9144
RFC 9144 recommends naming convention for operations that can be performed on any datastore. The recommended names are: - create - remove - replace Whereas in CPS Delta feature these operaitions were named: - add - remove - update So, "add" and "update" operations have been changed to "create" and "replace" respectively. Issue-ID: CPS-2393 Change-Id: Ie39f5f8ccc91e96cf484ca7fbc833a6be8758054 Signed-off-by: Arpit Singh <as00745003@techmahindra.com>
Diffstat (limited to 'cps-service/src')
-rw-r--r--cps-service/src/main/java/org/onap/cps/api/impl/CpsDeltaServiceImpl.java4
-rw-r--r--cps-service/src/main/java/org/onap/cps/spi/model/DeltaReport.java4
-rw-r--r--cps-service/src/main/java/org/onap/cps/spi/model/DeltaReportBuilder.java8
-rw-r--r--cps-service/src/test/groovy/org/onap/cps/api/impl/CpsDeltaServiceImplSpec.groovy14
-rw-r--r--cps-service/src/test/groovy/org/onap/cps/spi/model/DeltaReportBuilderSpec.groovy10
5 files changed, 20 insertions, 20 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 2f99dbf7bb..4df3a28145 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
@@ -179,7 +179,7 @@ public class CpsDeltaServiceImpl implements CpsDeltaService {
final List<DeltaReport> updatedDeltaReportEntries) {
for (final Map.Entry<Map<String, Serializable>, Map<String, Serializable>> entry:
updatedLeavesAsSourceDataToTargetData.entrySet()) {
- final DeltaReport updatedDataForDeltaReport = new DeltaReportBuilder().actionUpdate()
+ final DeltaReport updatedDataForDeltaReport = new DeltaReportBuilder().actionReplace()
.withXpath(xpath).withSourceData(entry.getKey()).withTargetData(entry.getValue()).build();
updatedDeltaReportEntries.add(updatedDataForDeltaReport);
}
@@ -195,7 +195,7 @@ public class CpsDeltaServiceImpl implements CpsDeltaService {
for (final Map.Entry<String, DataNode> entry: xpathToAddedNodes.entrySet()) {
final String xpath = entry.getKey();
final DataNode dataNode = entry.getValue();
- final DeltaReport addedDataForDeltaReport = new DeltaReportBuilder().actionAdd().withXpath(xpath)
+ final DeltaReport addedDataForDeltaReport = new DeltaReportBuilder().actionCreate().withXpath(xpath)
.withTargetData(dataNode.getLeaves()).build();
addedDeltaReportEntries.add(addedDataForDeltaReport);
}
diff --git a/cps-service/src/main/java/org/onap/cps/spi/model/DeltaReport.java b/cps-service/src/main/java/org/onap/cps/spi/model/DeltaReport.java
index 34715e70b9..c6270a41d2 100644
--- a/cps-service/src/main/java/org/onap/cps/spi/model/DeltaReport.java
+++ b/cps-service/src/main/java/org/onap/cps/spi/model/DeltaReport.java
@@ -32,9 +32,9 @@ import lombok.Setter;
@JsonInclude(JsonInclude.Include.NON_NULL)
public class DeltaReport {
- public static final String ADD_ACTION = "add";
+ public static final String CREATE_ACTION = "create";
public static final String REMOVE_ACTION = "remove";
- public static final String UPDATE_ACTION = "update";
+ public static final String REPLACE_ACTION = "replace";
DeltaReport() {}
diff --git a/cps-service/src/main/java/org/onap/cps/spi/model/DeltaReportBuilder.java b/cps-service/src/main/java/org/onap/cps/spi/model/DeltaReportBuilder.java
index 1e151eeb2d..a7e7aae215 100644
--- a/cps-service/src/main/java/org/onap/cps/spi/model/DeltaReportBuilder.java
+++ b/cps-service/src/main/java/org/onap/cps/spi/model/DeltaReportBuilder.java
@@ -48,8 +48,8 @@ public class DeltaReportBuilder {
return this;
}
- public DeltaReportBuilder actionAdd() {
- this.action = DeltaReport.ADD_ACTION;
+ public DeltaReportBuilder actionCreate() {
+ this.action = DeltaReport.CREATE_ACTION;
return this;
}
@@ -58,8 +58,8 @@ public class DeltaReportBuilder {
return this;
}
- public DeltaReportBuilder actionUpdate() {
- this.action = DeltaReport.UPDATE_ACTION;
+ public DeltaReportBuilder actionReplace() {
+ this.action = DeltaReport.REPLACE_ACTION;
return this;
}
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 42d75f3eab..f12afe61ec 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
@@ -51,8 +51,8 @@ class CpsDeltaServiceImplSpec extends Specification{
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'
- assert result[0].action.equals('add')
+ then: 'the delta report contains expected "create" action'
+ assert result[0].action.equals('create')
and: 'the delta report contains expected xpath'
assert result[0].xpath == '/parent'
and: 'the delta report contains no source data'
@@ -68,12 +68,12 @@ class CpsDeltaServiceImplSpec extends Specification{
when: 'attempt to get delta between 2 data nodes'
def result = objectUnderTest.getDeltaReports(sourceDataNode, targetDataNode)
then: 'the delta report contains expected details for parent node'
- assert result[0].action.equals('update')
+ assert result[0].action.equals('replace')
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].action.equals('replace')
assert result[1].xpath == '/parent/child'
assert result[1].sourceData == ['child-leaf': 'child-payload']
assert result[1].targetData == ['child-leaf': 'child-payload-updated']
@@ -82,8 +82,8 @@ class CpsDeltaServiceImplSpec extends Specification{
def 'Delta report between leaves, #scenario'() {
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[0].action.equals('update')
+ then: 'the delta report contains expected "replace" action'
+ assert result[0].action.equals('replace')
and: 'the delta report contains expected xpath'
assert result[0].xpath == '/parent'
and: 'the delta report contains expected source and target data'
@@ -100,7 +100,7 @@ class CpsDeltaServiceImplSpec extends Specification{
def 'Get delta between data nodes for updated data, where source and target data nodes have no leaves '() {
when: 'attempt to get delta between 2 data nodes'
def result = objectUnderTest.getDeltaReports(sourceDataNodeWithoutLeafData, targetDataNodeWithoutLeafData)
- then: 'the delta report contains "update" action with right data'
+ then: 'the delta report is empty'
assert result.isEmpty()
}
}
diff --git a/cps-service/src/test/groovy/org/onap/cps/spi/model/DeltaReportBuilderSpec.groovy b/cps-service/src/test/groovy/org/onap/cps/spi/model/DeltaReportBuilderSpec.groovy
index e19d120421..00b5499c2f 100644
--- a/cps-service/src/test/groovy/org/onap/cps/spi/model/DeltaReportBuilderSpec.groovy
+++ b/cps-service/src/test/groovy/org/onap/cps/spi/model/DeltaReportBuilderSpec.groovy
@@ -24,20 +24,20 @@ import spock.lang.Specification
class DeltaReportBuilderSpec extends Specification{
- def 'Generating delta report with for add action'() {
+ def 'Generating delta report for "create" action'() {
when: 'delta report is generated'
def result = new DeltaReportBuilder()
- .actionAdd()
+ .actionCreate()
.withXpath('/xpath')
.withTargetData(['data':'leaf-data'])
.build()
- then: 'the delta report contains the "add" action with expected target data'
- assert result.action == 'add'
+ then: 'the delta report contains the "create" action with expected target data'
+ assert result.action == 'create'
assert result.xpath == '/xpath'
assert result.targetData == ['data': 'leaf-data']
}
- def 'Generating delta report with attributes for remove action'() {
+ def 'Generating delta report with attributes for "remove" action'() {
when: 'delta report is generated'
def result = new DeltaReportBuilder()
.actionRemove()