diff options
11 files changed, 50 insertions, 50 deletions
diff --git a/cps-rest/docs/openapi/components.yml b/cps-rest/docs/openapi/components.yml index 850ecb6f72..25ef6a452a 100644 --- a/cps-rest/docs/openapi/components.yml +++ b/cps-rest/docs/openapi/components.yml @@ -141,17 +141,17 @@ components: name: kids deltaReportSample: value: - - action: "ADD" + - action: "create" xpath: "/bookstore/categories/[@code=3]" target-data: code: 3, name: "kidz" - - action: "REMOVE" + - action: "remove" xpath: "/bookstore/categories/[@code=1]" source-data: code: 1, name: "Fiction" - - action: "UPDATE" + - action: "replace" xpath: "/bookstore/categories/[@code=2]" source-data: name: "Funny" diff --git a/cps-rest/src/test/groovy/org/onap/cps/rest/controller/DataRestControllerSpec.groovy b/cps-rest/src/test/groovy/org/onap/cps/rest/controller/DataRestControllerSpec.groovy index d696af2e6c..5241f61bd9 100755 --- a/cps-rest/src/test/groovy/org/onap/cps/rest/controller/DataRestControllerSpec.groovy +++ b/cps-rest/src/test/groovy/org/onap/cps/rest/controller/DataRestControllerSpec.groovy @@ -350,7 +350,7 @@ class DataRestControllerSpec extends Specification { def 'Get delta between two anchors'() { given: 'the service returns a list containing delta reports' - def deltaReports = new DeltaReportBuilder().actionUpdate().withXpath('some xpath').withSourceData('some key': 'some value').withTargetData('some key': 'some value').build() + def deltaReports = new DeltaReportBuilder().actionReplace().withXpath('some xpath').withSourceData('some key': 'some value').withTargetData('some key': 'some value').build() def xpath = 'some xpath' def endpoint = "$dataNodeBaseEndpointV2/anchors/sourceAnchor/delta" mockCpsDataService.getDeltaByDataspaceAndAnchors(dataspaceName, 'sourceAnchor', 'targetAnchor', xpath, OMIT_DESCENDANTS) >> [deltaReports] @@ -363,12 +363,12 @@ class DataRestControllerSpec extends Specification { then: 'expected response code is returned' assert response.status == HttpStatus.OK.value() and: 'the response contains expected value' - assert response.contentAsString.contains("[{\"action\":\"update\",\"xpath\":\"some xpath\",\"sourceData\":{\"some key\":\"some value\"},\"targetData\":{\"some key\":\"some value\"}}]") + assert response.contentAsString.contains("[{\"action\":\"replace\",\"xpath\":\"some xpath\",\"sourceData\":{\"some key\":\"some value\"},\"targetData\":{\"some key\":\"some value\"}}]") } def 'Get delta between anchor and JSON payload with multipart file'() { given: 'sample delta report, xpath, yang model file and json payload' - def deltaReports = new DeltaReportBuilder().actionAdd().withXpath('some xpath').build() + def deltaReports = new DeltaReportBuilder().actionCreate().withXpath('some xpath').build() def xpath = 'some xpath' def endpoint = "$dataNodeBaseEndpointV2/anchors/$anchorName/delta" and: 'the service layer returns a list containing delta reports' @@ -384,7 +384,7 @@ class DataRestControllerSpec extends Specification { then: 'expected response code is returned' assert response.status == HttpStatus.OK.value() and: 'the response contains expected value' - assert response.contentAsString.contains("[{\"action\":\"add\",\"xpath\":\"some xpath\"}]") + assert response.contentAsString.contains("[{\"action\":\"create\",\"xpath\":\"some xpath\"}]") } def 'Get delta between anchor and JSON payload without multipart file'() { 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() diff --git a/docs/_static/cps-delta-mechanism.png b/docs/_static/cps-delta-mechanism.png Binary files differindex ab78ad9a1b..07923d4c26 100644 --- a/docs/_static/cps-delta-mechanism.png +++ b/docs/_static/cps-delta-mechanism.png diff --git a/docs/cps-delta-endpoints.rst b/docs/cps-delta-endpoints.rst index b2e4e6041b..ecb7550f44 100644 --- a/docs/cps-delta-endpoints.rst +++ b/docs/cps-delta-endpoints.rst @@ -38,7 +38,7 @@ Sample Delta Report [ { - "action": "ADD", + "action": "create", "xpath": "/bookstore/categories/[@code=3]", "target-data": { "code": "3,", @@ -46,7 +46,7 @@ Sample Delta Report } }, { - "action": "REMOVE", + "action": "remove", "xpath": "/bookstore/categories/[@code=1]", "source-data": { "code": "1,", @@ -54,7 +54,7 @@ Sample Delta Report } }, { - "action": "UPDATE", + "action": "replace", "xpath": "/bookstore/categories/[@code=2]", "source-data": { "name": "Funny" diff --git a/docs/cps-delta-feature.rst b/docs/cps-delta-feature.rst index f3a2f947e4..34aa43df53 100644 --- a/docs/cps-delta-feature.rst +++ b/docs/cps-delta-feature.rst @@ -22,10 +22,10 @@ Delta Report Format ------------------- The Delta Report is based on the RFC 9144, which defines a set of parameters to be included in the Delta Report. In CPS only the relevant parameters defined in RFC 9144 are used. These include: - - **action:** This parameter defines how the data nodes changed between two configurations. If data nodes are added, deleted or modified then the 'action' parameter in the delta report will be set to ADD, DELETE or UPDATE respectively for each data node. + - **action:** This parameter defines how the data nodes changed between two configurations. If data nodes are added, deleted or modified then the 'action' parameter in the delta report will be set to 'create', 'remove' or 'replace' respectively for each data node. - **xpath:** This parameter will provide the xpath of each data node that has been either added, deleted or modified. - - **source-data:** this parameter is added to the delta report when a data node is deleted or updated, this represents the source/reference data against which the delta is being generated. In case of newly added data node this field is not included in the delta report. - - **target-data:** this parameter is added to the delta report when a data node is added or updated, this represents the data values that are being compared to the source data. In case of a data node being deleted this field is not included in the delta report. + - **source-data:** this parameter is added to the delta report when a data node is removed or updated, this represents the source/reference data against which the delta is being generated. In case of newly added data node this field is not included in the delta report. + - **target-data:** this parameter is added to the delta report when a data node is added or updated, this represents the data values that are being compared to the source data. In case of a data node being removed this field is not included in the delta report. **Note.** In case of an existing data node being modified, both the source-data and target-data fields are present in the delta report. diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/functional/cps/DataServiceIntegrationSpec.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/functional/cps/DataServiceIntegrationSpec.groovy index d8395d0c91..d49931eb7e 100644 --- a/integration-test/src/test/groovy/org/onap/cps/integration/functional/cps/DataServiceIntegrationSpec.groovy +++ b/integration-test/src/test/groovy/org/onap/cps/integration/functional/cps/DataServiceIntegrationSpec.groovy @@ -463,11 +463,11 @@ class DataServiceIntegrationSpec extends FunctionalSpecBase { result = result.toList().sort { it.xpath } then: 'delta report contains expected number of changes' result.size() == 3 - and: 'delta report contains UPDATE action with expected xpath' - assert result[0].getAction() == 'update' + and: 'delta report contains REPLACE action with expected xpath' + assert result[0].getAction() == 'replace' assert result[0].getXpath() == '/bookstore' - and: 'delta report contains ADD action with expected xpath' - assert result[1].getAction() == 'add' + and: 'delta report contains CREATE action with expected xpath' + assert result[1].getAction() == 'create' assert result[1].getXpath() == "/bookstore-address[@bookstore-name='Crossword Bookstores']" and: 'delta report contains REMOVE action with expected xpath' assert result[2].getAction() == 'remove' @@ -515,11 +515,11 @@ class DataServiceIntegrationSpec extends FunctionalSpecBase { 'is empty' | "/bookstore/container-without-leaves" } - def 'Get delta between anchors for add action, where target data node #scenario'() { + def 'Get delta between anchors for "create" action, where target data node #scenario'() { when: 'attempt to get delta between leaves of data nodes present in 2 anchors' def result = objectUnderTest.getDeltaByDataspaceAndAnchors(FUNCTIONAL_TEST_DATASPACE_3, BOOKSTORE_ANCHOR_3, BOOKSTORE_ANCHOR_5, parentNodeXpath, INCLUDE_ALL_DESCENDANTS) then: 'the expected action is present in delta report' - result.get(0).getAction() == 'add' + result.get(0).getAction() == 'create' and: 'the expected xapth is present in delta report' result.get(0).getXpath() == parentNodeXpath where: 'following data was used' @@ -533,8 +533,8 @@ class DataServiceIntegrationSpec extends FunctionalSpecBase { def 'Get delta between anchors when leaves of existing data nodes are updated,: #scenario'() { when: 'attempt to get delta between leaves of existing data nodes' def result = objectUnderTest.getDeltaByDataspaceAndAnchors(FUNCTIONAL_TEST_DATASPACE_3, sourceAnchor, targetAnchor, xpath, OMIT_DESCENDANTS) - then: 'expected action is update' - assert result[0].getAction() == 'update' + then: 'expected action is "replace"' + assert result[0].getAction() == 'replace' and: 'the payload has expected leaf values' def sourceData = result[0].getSourceData() def targetData = result[0].getTargetData() @@ -550,8 +550,8 @@ class DataServiceIntegrationSpec extends FunctionalSpecBase { def 'Get delta between anchors when child data nodes under existing parent data nodes are updated: #scenario'() { when: 'attempt to get delta between leaves of existing data nodes' def result = objectUnderTest.getDeltaByDataspaceAndAnchors(FUNCTIONAL_TEST_DATASPACE_3, sourceAnchor, targetAnchor, xpath, DIRECT_CHILDREN_ONLY) - then: 'expected action is update' - assert result[0].getAction() == 'update' + then: 'expected action is "replace"' + assert result[0].getAction() == 'replace' and: 'the delta report has expected child node xpaths' def deltaReportEntities = getDeltaReportEntities(result) def childNodeXpathsInDeltaReport = deltaReportEntities.get('xpaths') @@ -573,8 +573,8 @@ class DataServiceIntegrationSpec extends FunctionalSpecBase { when: 'attempt to get delta between leaves of existing data nodes' def result = objectUnderTest.getDeltaByDataspaceAndAnchors(FUNCTIONAL_TEST_DATASPACE_3, BOOKSTORE_ANCHOR_3, BOOKSTORE_ANCHOR_5, parentNodeXpath, INCLUDE_ALL_DESCENDANTS) def deltaReportEntities = getDeltaReportEntities(result) - then: 'expected action is update' - assert result[0].getAction() == 'update' + then: 'expected action is "replace"' + assert result[0].getAction() == 'replace' and: 'the payload has expected parent node xpath' assert deltaReportEntities.get('xpaths').contains(parentNodeXpath) and: 'delta report has expected source and target data' @@ -593,14 +593,14 @@ class DataServiceIntegrationSpec extends FunctionalSpecBase { def result = objectUnderTest.getDeltaByDataspaceAnchorAndPayload(FUNCTIONAL_TEST_DATASPACE_3, BOOKSTORE_ANCHOR_3, '/', [:], jsonPayload, OMIT_DESCENDANTS) then: 'delta report contains expected number of changes' result.size() == 3 - and: 'delta report contains UPDATE action with expected xpath' - assert result[0].getAction() == 'update' + and: 'delta report contains "replace" action with expected xpath' + assert result[0].getAction() == 'replace' assert result[0].getXpath() == '/bookstore' - and: 'delta report contains REMOVE action with expected xpath' + and: 'delta report contains "remove" action with expected xpath' assert result[1].getAction() == 'remove' assert result[1].getXpath() == "/bookstore-address[@bookstore-name='Easons-1']" - and: 'delta report contains ADD action with expected xpath' - assert result[2].getAction() == 'add' + and: 'delta report contains "create" action with expected xpath' + assert result[2].getAction() == 'create' assert result[2].getXpath() == "/bookstore-address[@bookstore-name='Crossword Bookstores']" } |