+
+ def 'Get a Cm-Handle where #scenario'() {
+ given: 'the inventory persistence service returns a collection of data nodes'
+ mockCmHandleQueries.queryCmHandlesByOperationalSyncState(DataStoreSyncState.UNSYNCHRONIZED) >> unSynchronizedDataNodes
+ mockCmHandleQueries.cmHandleHasState('cm-handle-123', CmHandleState.READY) >> cmHandleHasState
+ when: 'get advised cm handles are fetched'
+ def yangModelCollection = objectUnderTest.getUnsynchronizedReadyCmHandles()
+ then: 'the returned data node collection is the correct size'
+ yangModelCollection.size() == expectedDataNodeSize
+ and: 'the result contains the correct data'
+ yangModelCollection.stream().map(yangModel -> yangModel.id).collect(Collectors.toSet()) == expectedYangModelCollectionIds
+ where: 'the following scenarios are used'
+ scenario | unSynchronizedDataNodes | cmHandleHasState || expectedDataNodeSize | expectedYangModelCollectionIds
+ 'a Cm-Handle unsynchronized and ready' | [dataNode] | true || 1 | ['cm-handle-123'] as Set
+ 'a Cm-Handle unsynchronized but not ready' | [dataNode] | false || 0 | [] as Set
+ 'all Cm-Handle synchronized' | [] | false || 0 | [] as Set
+ }
+
+ def 'Get resource data through DMI Operations #scenario'() {
+ given: 'the inventory persistence service returns a collection of data nodes'
+ def jsonString = '{"stores:bookstore":{"categories":[{"code":"01"}]}}'
+ JsonNode jsonNode = jsonObjectMapper.convertToJsonNode(jsonString);
+ def responseEntity = new ResponseEntity<>(jsonNode, HttpStatus.OK)
+ mockDmiDataOperations.getResourceDataFromDmi(PASSTHROUGH_OPERATIONAL.datastoreName, 'cm-handle-123', _) >> responseEntity
+ when: 'get resource data is called'
+ def result = objectUnderTest.getResourceData('cm-handle-123')
+ then: 'the returned data is correct'
+ result == jsonString
+ }