+ futures.get(futures.size() - 1).get();
+
+ final DOMDataTreeListener mockedDataTreeListener = mock(DOMDataTreeListener.class);
+ doNothing().when(mockedDataTreeListener).onDataTreeChanged(anyCollection(), anyMap());
+
+ leaderShardFactory.registerListener(mockedDataTreeListener, Collections.singletonList(INNER_LIST_ID),
+ true, Collections.emptyList());
+
+ verify(mockedDataTreeListener, timeout(1000).times(1)).onDataTreeChanged(captorForChanges.capture(),
+ captorForSubtrees.capture());
+ verifyNoMoreInteractions(mockedDataTreeListener);
+ final List<Collection<DataTreeCandidate>> capturedValue = captorForChanges.getAllValues();
+
+ final NormalizedNode<?,?> expected =
+ ImmutableMapNodeBuilder
+ .create()
+ .withNodeIdentifier(new NodeIdentifier(TestModel.INNER_LIST_QNAME))
+ // only the values from the last run should be present
+ .withValue(createInnerListMapEntries(1000, "run-999"))
+ .build();
+
+ assertEquals("List values dont match the expected values from the last run",
+ expected, capturedValue.get(0).iterator().next().getRootNode().getDataAfter().get());
+
+ }
+
+ // top level shard at TEST element, with subshards on each outer-list map entry
+ @Test
+ @Ignore
+ public void testMultipleShardLevels() throws Exception {
+ initEmptyDatastores();
+
+ final DistributedShardRegistration testShardReg = waitOnAsyncTask(
+ leaderShardFactory.createDistributedShard(TEST_ID, SINGLE_MEMBER),
+ DistributedShardedDOMDataTree.SHARD_FUTURE_TIMEOUT_DURATION);
+
+ final ArrayList<DistributedShardRegistration> registrations = new ArrayList<>();
+ final int listSize = 5;
+ for (int i = 0; i < listSize; i++) {
+ final YangInstanceIdentifier entryYID = getOuterListIdFor(i);
+ final CompletionStage<DistributedShardRegistration> future = leaderShardFactory.createDistributedShard(
+ new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, entryYID), SINGLE_MEMBER);
+
+ registrations.add(waitOnAsyncTask(future, DistributedShardedDOMDataTree.SHARD_FUTURE_TIMEOUT_DURATION));
+ }
+
+ final DOMDataTreeIdentifier rootId =
+ new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.empty());
+ final DOMDataTreeProducer producer = leaderShardFactory.createProducer(Collections.singletonList(
+ rootId));
+
+ DOMDataTreeCursorAwareTransaction transaction = producer.createTransaction(false);
+
+ DOMDataTreeWriteCursor cursor = transaction.createCursor(rootId);
+ assertNotNull(cursor);
+
+ final MapNode outerList =
+ ImmutableMapNodeBuilder.create()
+ .withNodeIdentifier(new NodeIdentifier(TestModel.OUTER_LIST_QNAME)).build();
+
+ final ContainerNode testNode =
+ ImmutableContainerNodeBuilder.create()
+ .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
+ .withChild(outerList)
+ .build();
+
+ cursor.write(testNode.getIdentifier(), testNode);
+
+ cursor.close();
+ transaction.commit().get();
+
+ final DOMDataTreeListener mockedDataTreeListener = mock(DOMDataTreeListener.class);
+ doNothing().when(mockedDataTreeListener).onDataTreeChanged(anyCollection(), anyMap());
+
+ final MapNode wholeList = ImmutableMapNodeBuilder.create(outerList)
+ .withValue(createOuterEntries(listSize, "testing-values")).build();
+
+ transaction = producer.createTransaction(false);
+ cursor = transaction.createCursor(TEST_ID);
+ assertNotNull(cursor);
+
+ cursor.write(wholeList.getIdentifier(), wholeList);
+ cursor.close();
+
+ transaction.commit().get();
+
+ leaderShardFactory.registerListener(mockedDataTreeListener, Collections.singletonList(TEST_ID),
+ true, Collections.emptyList());
+
+ verify(mockedDataTreeListener, timeout(35000).atLeast(2)).onDataTreeChanged(captorForChanges.capture(),
+ captorForSubtrees.capture());
+ verifyNoMoreInteractions(mockedDataTreeListener);
+ final List<Map<DOMDataTreeIdentifier, NormalizedNode<?, ?>>> allSubtrees = captorForSubtrees.getAllValues();
+
+ final Map<DOMDataTreeIdentifier, NormalizedNode<?, ?>> lastSubtree = allSubtrees.get(allSubtrees.size() - 1);
+
+ final NormalizedNode<?, ?> actual = lastSubtree.get(TEST_ID);
+ assertNotNull(actual);
+
+ final NormalizedNode<?, ?> expected =
+ ImmutableContainerNodeBuilder.create()
+ .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
+ .withChild(ImmutableMapNodeBuilder.create(outerList)
+ .withValue(createOuterEntries(listSize, "testing-values")).build())
+ .build();