summaryrefslogtreecommitdiffstats
path: root/cps-ri/src/test/groovy/org
diff options
context:
space:
mode:
authorraviteja.karumuri <raviteja.karumuri@est.tech>2023-05-05 14:52:07 +0100
committerraviteja.karumuri <raviteja.karumuri@est.tech>2023-05-05 15:41:43 +0100
commitec061d5caba23c76f0cdc183c1f5a37e0c11b6c7 (patch)
treef157e0b288b976a488288b692cd4fd342847d991 /cps-ri/src/test/groovy/org
parent61e8551cf91c95844963f0e52cefddb6a7477d38 (diff)
[CPS] RI: Code Refactoring
# Replace '[\s\S]' to '.' as it is same as '.' while grouping in regex # Updated the groovy files to add 'assert' and to replace deprecated method # Removed deprecated 'storeDataNode' method. Issue-ID: CPS-1594 Signed-off-by: raviteja.karumuri <raviteja.karumuri@est.tech> Change-Id: Iaa5f8b0cc8d66473c993060a8fc5a54e37e373b1
Diffstat (limited to 'cps-ri/src/test/groovy/org')
-rwxr-xr-xcps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsDataPersistenceServiceIntegrationSpec.groovy24
-rw-r--r--cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsDataPersistenceServiceSpec.groovy9
-rw-r--r--cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsModulePersistenceServiceIntegrationSpec.groovy4
3 files changed, 14 insertions, 23 deletions
diff --git a/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsDataPersistenceServiceIntegrationSpec.groovy b/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsDataPersistenceServiceIntegrationSpec.groovy
index 93d7662014..67ccc805ae 100755
--- a/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsDataPersistenceServiceIntegrationSpec.groovy
+++ b/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsDataPersistenceServiceIntegrationSpec.groovy
@@ -170,7 +170,7 @@ class CpsDataPersistenceServiceIntegrationSpec extends CpsPersistenceSpecBase {
when: 'the new data node (list elements) are added to an existing parent node'
objectUnderTest.addMultipleLists(DATASPACE_NAME, ANCHOR_NAME3, '/parent-201', [listElements])
then: 'new entries are successfully persisted, parent node now contains 5 children (2 new + 3 existing before)'
- def parentFragment = fragmentRepository.getById(LIST_DATA_NODE_PARENT201_FRAGMENT_ID)
+ def parentFragment = fragmentRepository.getReferenceById(LIST_DATA_NODE_PARENT201_FRAGMENT_ID)
def allChildXpaths = parentFragment.childFragments.collect { it.xpath }
assert allChildXpaths.size() == 5
assert allChildXpaths.containsAll(listElementXpaths)
@@ -325,7 +325,7 @@ class CpsDataPersistenceServiceIntegrationSpec extends CpsPersistenceSpecBase {
objectUnderTest.updateDataLeaves(DATASPACE_NAME, ANCHOR_FOR_DATA_NODES_WITH_LEAVES,
'/parent-200/child-201', ['leaf-value': 'new'])
then: 'leaves are updated for selected data node'
- def updatedFragment = fragmentRepository.getById(DATA_NODE_202_FRAGMENT_ID)
+ def updatedFragment = fragmentRepository.getReferenceById(DATA_NODE_202_FRAGMENT_ID)
def updatedLeaves = getLeavesMap(updatedFragment)
assert updatedLeaves.size() == 1
assert updatedLeaves.'leaf-value' == 'new'
@@ -356,7 +356,7 @@ class CpsDataPersistenceServiceIntegrationSpec extends CpsPersistenceSpecBase {
when: 'update data nodes and descendants is performed'
objectUnderTest.updateDataNodesAndDescendants(DATASPACE_NAME, ANCHOR_FOR_DATA_NODES_WITH_LEAVES, submittedDataNodes)
then: 'leaves have been updated for selected data node'
- def updatedFragment = fragmentRepository.getById(DATA_NODE_202_FRAGMENT_ID)
+ def updatedFragment = fragmentRepository.getReferenceById(DATA_NODE_202_FRAGMENT_ID)
def updatedLeaves = getLeavesMap(updatedFragment)
assert updatedLeaves.size() == 1
assert updatedLeaves.'leaf-value' == 'new'
@@ -375,7 +375,7 @@ class CpsDataPersistenceServiceIntegrationSpec extends CpsPersistenceSpecBase {
when: 'update is performed including descendants'
objectUnderTest.updateDataNodesAndDescendants(DATASPACE_NAME, ANCHOR_FOR_DATA_NODES_WITH_LEAVES, submittedDataNodes)
then: 'leaves have been updated for selected data node'
- def updatedFragment = fragmentRepository.getById(DATA_NODE_202_FRAGMENT_ID)
+ def updatedFragment = fragmentRepository.getReferenceById(DATA_NODE_202_FRAGMENT_ID)
def updatedLeaves = getLeavesMap(updatedFragment)
assert updatedLeaves.size() == 1
assert updatedLeaves.'leaf-value' == 'new'
@@ -395,7 +395,7 @@ class CpsDataPersistenceServiceIntegrationSpec extends CpsPersistenceSpecBase {
when: 'update is performed including descendants'
objectUnderTest.updateDataNodesAndDescendants(DATASPACE_NAME, ANCHOR_FOR_DATA_NODES_WITH_LEAVES, submittedDataNodes)
then: 'leaves have been updated for selected data node'
- def updatedFragment = fragmentRepository.getById(DATA_NODE_202_FRAGMENT_ID)
+ def updatedFragment = fragmentRepository.getReferenceById(DATA_NODE_202_FRAGMENT_ID)
def updatedLeaves = getLeavesMap(updatedFragment)
assert updatedLeaves.size() == 1
assert updatedLeaves.'leaf-value' == 'new'
@@ -415,7 +415,7 @@ class CpsDataPersistenceServiceIntegrationSpec extends CpsPersistenceSpecBase {
when: 'update is performed including descendants'
objectUnderTest.updateDataNodesAndDescendants(DATASPACE_NAME, ANCHOR_FOR_DATA_NODES_WITH_LEAVES, submittedDataNodes)
then: 'leaves have been updated for selected data node'
- def updatedFragment = fragmentRepository.getById(DATA_NODE_202_FRAGMENT_ID)
+ def updatedFragment = fragmentRepository.getReferenceById(DATA_NODE_202_FRAGMENT_ID)
def updatedLeaves = getLeavesMap(updatedFragment)
assert updatedLeaves.size() == 1
assert updatedLeaves.'leaf-value' == 'new'
@@ -451,13 +451,13 @@ class CpsDataPersistenceServiceIntegrationSpec extends CpsPersistenceSpecBase {
objectUnderTest.addListElements(DATASPACE_NAME, ANCHOR_NAME1, parentXpath, originalListEntriesAsDataNodes)
}
and: 'each original list element has one child'
- def originalParentFragment = fragmentRepository.getById(PARENT_3_FRAGMENT_ID)
+ def originalParentFragment = fragmentRepository.getReferenceById(PARENT_3_FRAGMENT_ID)
originalParentFragment.childFragments.each {assert it.childFragments.size() == 1 }
when: 'it is updated with #scenario'
def replacementListEntriesAsDataNodes = createChildListAllHavingAttributeValue(parentXpath, 'new value', replacementKeys, false)
objectUnderTest.replaceListContent(DATASPACE_NAME, ANCHOR_NAME1, parentXpath, replacementListEntriesAsDataNodes)
then: 'the result list ONLY contains the expected replacement elements'
- def parentFragment = fragmentRepository.getById(PARENT_3_FRAGMENT_ID)
+ def parentFragment = fragmentRepository.getReferenceById(PARENT_3_FRAGMENT_ID)
def allChildXpaths = parentFragment.childFragments.collect { it.xpath }
def expectedListEntriesAfterUpdateAsXpaths = keysToXpaths(parentXpath, replacementKeys)
assert allChildXpaths.size() == replacementKeys.size()
@@ -485,7 +485,7 @@ class CpsDataPersistenceServiceIntegrationSpec extends CpsPersistenceSpecBase {
def replacementListEntriesAsDataNodes = createChildListAllHavingAttributeValue(parentXpath, 'new', ['A'], true)
objectUnderTest.replaceListContent(DATASPACE_NAME, ANCHOR_NAME1, parentXpath, replacementListEntriesAsDataNodes)
then: 'The updated fragment has a child-list with ONLY element "A"'
- def parentFragment = fragmentRepository.getById(PARENT_3_FRAGMENT_ID)
+ def parentFragment = fragmentRepository.getReferenceById(PARENT_3_FRAGMENT_ID)
parentFragment.childFragments.size() == 1
def childListElementA = parentFragment.childFragments[0]
childListElementA.xpath == "/parent-3/child-list[@key='A']"
@@ -506,7 +506,7 @@ class CpsDataPersistenceServiceIntegrationSpec extends CpsPersistenceSpecBase {
def replacementListEntriesAsDataNodes = createChildListAllHavingAttributeValue(XPATH_DATA_NODE_WITH_DESCENDANTS, 'new', ['A','B'], false)
objectUnderTest.replaceListContent(DATASPACE_NAME, ANCHOR_NAME1, XPATH_DATA_NODE_WITH_DESCENDANTS, replacementListEntriesAsDataNodes)
then: 'the parent will have 3 children after the replacement'
- def parentFragment = fragmentRepository.getById(ID_DATA_NODE_WITH_DESCENDANTS)
+ def parentFragment = fragmentRepository.getReferenceById(ID_DATA_NODE_WITH_DESCENDANTS)
parentFragment.childFragments.size() == 3
def xpaths = parentFragment.childFragments.collect {it.xpath}
and: 'one of the children is the original child fragment'
@@ -539,7 +539,7 @@ class CpsDataPersistenceServiceIntegrationSpec extends CpsPersistenceSpecBase {
when: 'deleting list is executed for: #scenario.'
objectUnderTest.deleteListDataNode(DATASPACE_NAME, ANCHOR_NAME3, targetXpaths)
and: 'remaining children are fetched'
- def parentFragment = fragmentRepository.getById(parentFragmentId)
+ def parentFragment = fragmentRepository.getReferenceById(parentFragmentId)
def remainingChildXpaths = parentFragment.childFragments.collect { it.xpath }
then: 'only the expected children remain'
assert remainingChildXpaths.size() == expectedRemainingChildXpaths.size()
@@ -557,7 +557,7 @@ class CpsDataPersistenceServiceIntegrationSpec extends CpsPersistenceSpecBase {
when: 'deleting nodes is executed for: #scenario.'
objectUnderTest.deleteDataNodes(DATASPACE_NAME, ANCHOR_NAME3, targetXpaths)
and: 'remaining children are fetched'
- def parentFragment = fragmentRepository.getById(LIST_DATA_NODE_PARENT203_FRAGMENT_ID)
+ def parentFragment = fragmentRepository.getReferenceById(LIST_DATA_NODE_PARENT203_FRAGMENT_ID)
def remainingChildXpaths = parentFragment.childFragments.collect { it.xpath }
then: 'only the expected children remain'
assert remainingChildXpaths.size() == expectedRemainingChildXpaths.size()
diff --git a/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsDataPersistenceServiceSpec.groovy b/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsDataPersistenceServiceSpec.groovy
index c8e3283a91..8a5838827a 100644
--- a/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsDataPersistenceServiceSpec.groovy
+++ b/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsDataPersistenceServiceSpec.groovy
@@ -68,15 +68,6 @@ class CpsDataPersistenceServiceSpec extends Specification {
2 * mockFragmentRepository.save(_)
}
- def 'Store single data node.'() {
- given: 'a data node'
- def dataNode = new DataNode()
- when: 'storing a single data node'
- objectUnderTest.storeDataNode('dataspace1', 'anchor1', dataNode)
- then: 'the call is redirected to storing a collection of data nodes with just the given data node'
- 1 * objectUnderTest.storeDataNodes('dataspace1', 'anchor1', [dataNode])
- }
-
def 'Handling of StaleStateException (caused by concurrent updates) during update data nodes and descendants.'() {
given: 'the system can update one datanode and has two more datanodes that throw an exception while updating'
def dataNodes = createDataNodesAndMockRepositoryMethodSupportingThem([
diff --git a/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsModulePersistenceServiceIntegrationSpec.groovy b/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsModulePersistenceServiceIntegrationSpec.groovy
index 53f42f5a9f..3a5d9ef769 100644
--- a/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsModulePersistenceServiceIntegrationSpec.groovy
+++ b/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsModulePersistenceServiceIntegrationSpec.groovy
@@ -260,10 +260,10 @@ class CpsModulePersistenceServiceIntegrationSpec extends CpsPersistenceSpecBase
objectUnderTest.deleteUnusedYangResourceModules()
then: 'any orphaned (not used by any schema set anymore) yang resources are deleted'
def orphanedResourceId = 3100L
- yangResourceRepository.findById(orphanedResourceId).isPresent() == false
+ assert !yangResourceRepository.findById(orphanedResourceId).isPresent()
and: 'any shared (still in use by other schema set) yang resources still persists'
def sharedResourceId = 3003L
- yangResourceRepository.findById(sharedResourceId).isPresent()
+ assert yangResourceRepository.findById(sharedResourceId).isPresent()
}
@Sql([CLEAR_DATA, SET_DATA])