+ def responseFromDmi = new ResponseEntity([[moduleName: 'mod1', revision: 'A', yangSource: 'some yang source'],
+ [moduleName: 'mod2', revision: 'C', yangSource: 'other yang source']], HttpStatus.OK)
+ def expectedModuleReferencesInRequest = '{"name":"mod1","revision":"A"},{"name":"mod2","revision":"X"}'
+ mockDmiRestClient.postOperationWithJsonData("${dmiServiceName}/dmi/v1/ch/${cmHandleId}/moduleResources",
+ '{"data":{"modules":[' + expectedModuleReferencesInRequest + ']},"cmHandleProperties":{}}', [:]) >> responseFromDmi
+ when: 'get new yang resources from dmi service'
+ def result = objectUnderTest.getNewYangResourcesFromDmi(persistenceCmHandle, newModuleReferences)
+ then: 'the result has the 2 expected yang (re)sources (order is not guaranteed)'
+ assert result.size() == 2
+ assert result.get('mod1') == 'some yang source'
+ assert result.get('mod2') == 'other yang source'
+ }
+
+ def 'Retrieving yang resources, edge case: scenario.'() {
+ given: 'a persistence cm handle'
+ mockPersistenceCmHandleRetrieval([])
+ and: 'a positive response from dmi service when it is called with tha expected parameters'
+ // TODO (toine): production code ignores any error code from DMI, this should be improved in future
+ def responseFromDmi = new ResponseEntity(responseFromDmiBody, HttpStatus.NO_CONTENT)
+ mockDmiRestClient.postOperationWithJsonData(*_) >> responseFromDmi
+ when: 'get new yang resources from dmi service'
+ def result = objectUnderTest.getNewYangResourcesFromDmi(persistenceCmHandle, newModuleReferences)
+ then: 'the result is empty'
+ assert result == [:]
+ where: 'the dmi response body has the following content'
+ scenario | responseFromDmiBody
+ 'empty array' | []
+ 'null array' | null
+ }
+
+ def 'Retrieving yang resources, additional property handling #scenario.'() {
+ given: 'a persistence cm handle'
+ mockPersistenceCmHandleRetrieval(additionalPropertiesObject)
+ and: 'a positive response from dmi service when it is called with the expected parameters'
+ def responseFromDmi = new ResponseEntity<>([[moduleName: 'mod1', revision: 'A', yangSource: 'some yang source']], HttpStatus.OK)