+ def 'Get module references'() {
+ given: 'cps module service returns a collection of module references'
+ def moduleReferences = [new ModuleReference('moduleName','revision','namespace')]
+ mockCpsModuleService.getYangResourcesModuleReferences('NFP-Operational','some-cmHandle-Id') >> moduleReferences
+ when: 'get yang resources module references by cmHandle is invoked'
+ def result = objectUnderTest.getYangResourcesModuleReferences('some-cmHandle-Id')
+ then: 'the returned result is a collection of module definitions'
+ assert result == moduleReferences
+ }
+
+ def 'Save list elements'() {
+ when: 'the method to save list elements is called'
+ objectUnderTest.saveListElements('sample Json data')
+ then: 'the data service method to save list elements is called once'
+ 1 * mockCpsDataService.saveListElements('NCMP-Admin','ncmp-dmi-registry','/dmi-registry','sample Json data',null)
+ }
+
+ def 'Delete list or list elements'() {
+ when: 'the method to delete list or list elements is called'
+ objectUnderTest.deleteListOrListElement('sample xPath')
+ then: 'the data service method to save list elements is called once'
+ 1 * mockCpsDataService.deleteListOrListElement('NCMP-Admin','ncmp-dmi-registry','sample xPath',null)
+ }
+
+ def 'Delete schema set with a valid schema set name'() {
+ when: 'the method to delete schema set is called with valid schema set name'
+ objectUnderTest.deleteSchemaSetWithCascade('validSchemaSetName')
+ then: 'the module service to delete schemaSet is invoked once'
+ 1 * mockCpsModuleService.deleteSchemaSet('NFP-Operational', 'validSchemaSetName', CascadeDeleteAllowed.CASCADE_DELETE_ALLOWED)
+ }
+
+ def 'Delete schema set with an invalid schema set name'() {
+ when: 'the method to delete schema set is called with an invalid schema set name'
+ objectUnderTest.deleteSchemaSetWithCascade('invalid SchemaSet name')
+ then: 'a data validation exception is thrown'
+ thrown(DataValidationException)
+ and: 'the module service to delete schemaSet is not called'
+ 0 * mockCpsModuleService.deleteSchemaSet('NFP-Operational', 'sampleSchemaSetName', CascadeDeleteAllowed.CASCADE_DELETE_ALLOWED)
+ }
+
+ def 'Query data nodes via cpsPath'() {
+ when: 'the method to query data nodes is called'
+ objectUnderTest.queryDataNodes('sample cpsPath')
+ then: 'the data persistence service method to query data nodes is invoked once'
+ 1 * mockCpsDataPersistenceService.queryDataNodes('NCMP-Admin','ncmp-dmi-registry','sample cpsPath', INCLUDE_ALL_DESCENDANTS)
+ }
+
+ def 'Get data node via xPath'() {
+ when: 'the method to get data nodes is called'
+ objectUnderTest.getDataNode('sample xPath')
+ then: 'the data persistence service method to get data node is invoked once'
+ 1 * mockCpsDataPersistenceService.getDataNode('NCMP-Admin','ncmp-dmi-registry','sample xPath', INCLUDE_ALL_DESCENDANTS)
+ }
+
+ def 'Query anchors'() {
+ when: 'the method to query anchors is called'
+ objectUnderTest.queryAnchors(['sample-module-name'])
+ then: 'the admin persistence service method to query anchors is invoked once with the same parameter'
+ 1 * mockCpsAdminPersistenceService.queryAnchors('NFP-Operational',['sample-module-name'])
+ }
+
+ def 'Get anchors'() {
+ when: 'the method to get anchors with no parameters is called'
+ objectUnderTest.getAnchors()
+ then: 'the admin persistence service method to query anchors is invoked once with a specific dataspace name'
+ 1 * mockCpsAdminPersistenceService.getAnchors('NFP-Operational')
+ }