Merge "Watchdog-process that changes CM Handles state"
[cps.git] / cps-ri / src / test / groovy / org / onap / cps / spi / impl / CpsDataPersistenceServiceSpec.groovy
index c508762..b37f471 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * ============LICENSE_START=======================================================
  * Copyright (c) 2021 Bell Canada.
+ * Modifications Copyright (C) 2021-2022 Nordix Foundation
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -45,7 +46,7 @@ class CpsDataPersistenceServiceSpec extends Specification {
 
     def 'Handling of StaleStateException (caused by concurrent updates) during data node tree update.'() {
 
-        def parentXpath = 'parent-01'
+        def parentXpath = '/parent-01'
         def myDataspaceName = 'my-dataspace'
         def myAnchorName = 'my-anchor'
 
@@ -82,7 +83,7 @@ class CpsDataPersistenceServiceSpec extends Specification {
         }
         when: 'getting the data node represented by this fragment'
         def dataNode = objectUnderTest.getDataNode('my-dataspace', 'my-anchor',
-                'parent-01', FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS)
+                '/parent-01', FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS)
         then: 'the leaf is of the correct value and data type'
         def attributeValue = dataNode.leaves.get('some attribute')
         assert attributeValue == expectedValue
@@ -108,7 +109,7 @@ class CpsDataPersistenceServiceSpec extends Specification {
         }
         when: 'getting the data node represented by this fragment'
         def dataNode = objectUnderTest.getDataNode('my-dataspace', 'my-anchor',
-                'parent-01', FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS)
+                '/parent-01', FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS)
         then: 'a data validation exception is thrown'
         thrown(DataValidationException)
     }
@@ -128,4 +129,11 @@ class CpsDataPersistenceServiceSpec extends Specification {
         then: 'the session manager method to close session is invoked with parameter'
             1 * mockSessionManager.closeSession(someSessionId)
     }
+
+    def 'Lock anchor.'(){
+        when: 'lock anchor method is called with anchor entity details'
+            objectUnderTest.lockAnchor('mySessionId', 'myDataspaceName', 'myAnchorName', 123L)
+        then: 'the session manager method to lock anchor is invoked with same parameters'
+            1 * mockSessionManager.lockAnchor('mySessionId', 'myDataspaceName', 'myAnchorName', 123L)
+    }
 }
\ No newline at end of file