- and: 'details contains (not found) error code: 404'
- exceptionThrown.details.contains('404')
- }
-
- def 'Sync model for a (new) cm handle with #scenario'() {
- given: 'DMI Plug-in returns a list of module references'
- getModulesForCmHandle()
- def knownModule1 = new ModuleReference('module1', '1')
- def knownOtherModule = new ModuleReference('some other module', 'some revision')
- and: 'CPS-Core returns list of known modules'
- mockCpsModuleService.getYangResourceModuleReferences(_) >> [knownModule1, knownOtherModule]
- and: 'DMI-Plugin returns resource(s) for "new" module(s)'
- def moduleResources = new ResponseEntity<String>(sdncReponseBody, HttpStatus.OK)
- mockDmiOperations.getResourceFromDmiWithJsonData(_, _, _, 'moduleResources') >> moduleResources
- when: 'module Sync is triggered'
- objectUnderTest.createAnchorAndSyncModel(cmHandleForModelSync)
- then: 'the CPS module service is called once with the correct parameters'
- 1 * mockCpsModuleService.createSchemaSetFromModules(expectedDataspaceName, cmHandleForModelSync.getId(), expectedYangResourceToContentMap, [knownModule1])
- and: 'admin service create anchor method has been called with correct parameters'
- 1 * mockCpsAdminService.createAnchor(expectedDataspaceName, cmHandleForModelSync.getId(), cmHandleForModelSync.getId())
- where: 'the following responses are received from SDNC'
- scenario | sdncReponseBody || expectedYangResourceToContentMap
- 'one unknown module' | '[{"moduleName" : "someModule", "revision" : "1","yangSource": "[some yang source]"}]' || [someModule: 'some yang source']
- 'no unknown module' | '[]' || [:]
- }
-
-
- def 'Getting Yang Resources.'() {
- when: 'yang resources is called'
- objectUnderTest.getYangResourcesModuleReferences('some cm handle')
- then: 'CPS module services is invoked for the correct dataspace and cm handle'
- 1 * mockCpsModuleService.getYangResourcesModuleReferences('NFP-Operational','some cm handle')
- }
-
- def getModulesForCmHandle() {
- def jsonData = TestUtils.getResourceFileContent('cmHandleModules.json')
- mockDmiProperties.getAuthUsername() >> 'someUser'
- mockDmiProperties.getAuthPassword() >> 'somePassword'
- def moduleReferencesFromCmHandleAsJson = new ResponseEntity<String>(jsonData, HttpStatus.OK)
- mockDmiOperations.getResourceFromDmi(_, cmHandleForModelSync.getId(), 'modules') >> moduleReferencesFromCmHandleAsJson