+
+ def 'Retry Locked Cm-Handle where the last update time is #scenario'() {
+ when: 'retry locked cm handle is invoked'
+ def result = objectUnderTest.isReadyForRetry(new CompositeStateBuilder()
+ .withLockReason(LockReasonCategory.LOCKED_MODULE_SYNC_FAILED, details)
+ .withLastUpdatedTime(lastUpdateTime).build())
+ then: 'result returns #expectedResult'
+ result == expectedResult
+ where:
+ scenario | lastUpdateTime | details || expectedResult
+ 'the first attempt' | '1900-01-01T00:00:00.000+0100' | 'First Attempt' || true
+ 'greater than one minute' | '1900-01-01T00:00:00.000+0100' | 'Attempt #1 failed:' || true
+ 'less than eight minutes' | formattedDateAndTime | 'Attempt #3 failed:' || false
+ }
+
+
+ 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
+ }