+ def 'Update CM Handle data producer identifier from #scenario'() {
+ given: 'an existing cm handle with no data producer identifier'
+ DataNode existingCmHandleDataNode = new DataNode(xpath: cmHandleXpath, leaves: ['id': 'cmHandleId','data-producer-identifier': oldDataProducerIdentifier])
+ and: 'an update request with a new data producer identifier'
+ def ncmpServiceCmHandle = new NcmpServiceCmHandle(cmHandleId: cmHandleId, dataProducerIdentifier: 'someDataProducerIdentifier')
+ when: 'data producer identifier updated'
+ objectUnderTest.updateDataProducerIdentifier(existingCmHandleDataNode, ncmpServiceCmHandle)
+ then: 'the update node leaves method is invoked once'
+ 1 * mockCpsDataService.updateNodeLeaves('NCMP-Admin', 'ncmp-dmi-registry', '/dmi-registry', _, _) >> { args ->
+ assert args[3].contains('someDataProducerIdentifier')
+ }
+ and: 'correct information is logged'
+ def lastLoggingEvent = logger.list[0]
+ assert lastLoggingEvent.level == Level.DEBUG
+ assert lastLoggingEvent.formattedMessage.contains('Updating data-producer-identifier')
+ where: 'the following scenarios are attempted'
+ scenario | oldDataProducerIdentifier
+ 'null to something' | null
+ 'blank to something' | ''
+ }
+
+ def 'Update CM Handle data producer identifier from some data producer identifier to another data producer identifier'() {
+ given: 'an existing cm handle with a data producer identifier'
+ DataNode existingCmHandleDataNode = new DataNode(xpath: cmHandleXpath, leaves: ['id': 'cmHandleId', 'data-producer-identifier': 'someDataProducerIdentifier'])
+ and: 'an update request with a new data producer identifier'
+ def ncmpServiceCmHandle = new NcmpServiceCmHandle(cmHandleId: cmHandleId, dataProducerIdentifier: 'someNewDataProducerIdentifier')
+ when: 'update data producer identifier is called with the update request'
+ objectUnderTest.updateDataProducerIdentifier(existingCmHandleDataNode, ncmpServiceCmHandle)
+ then: 'the update node leaves method is not invoked'
+ 0 * mockCpsDataService.updateNodeLeaves(*_)
+ and: 'correct information is logged'
+ def lastLoggingEvent = logger.list[0]
+ assert lastLoggingEvent.level == Level.WARN
+ assert lastLoggingEvent.formattedMessage.contains('Unable to update dataProducerIdentifier')
+ }
+