summary |
shortlog |
log |
commit | commitdiff |
review |
tree
raw |
patch |
inline | side by side (from parent 1:
79c0442)
When we are asked to create intermediate nodes for a path, whose
parent is the conceptual root (i.e. its parent is empty), we should
not attempt to merge it, as it just does not make sense.
JIRA: MDSAL-534
Change-Id: Ia5f6ef2857903d8e88030f4c1f3867b8ed8f5a0e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
ed271c6322092bccf8ff9500b1bbb0fb62683419)
private void ensureParentsByMerge(final LogicalDatastoreType store, final YangInstanceIdentifier domPath,
final InstanceIdentifier<?> path) {
final YangInstanceIdentifier parentPath = domPath.getParent();
private void ensureParentsByMerge(final LogicalDatastoreType store, final YangInstanceIdentifier domPath,
final InstanceIdentifier<?> path) {
final YangInstanceIdentifier parentPath = domPath.getParent();
- if (parentPath != null) {
+ if (parentPath != null && !parentPath.isEmpty()) {
final NormalizedNode<?, ?> parentNode = getCodec().instanceIdentifierToNode(parentPath);
getDelegate().merge(store, YangInstanceIdentifier.create(parentNode.getIdentifier()), parentNode);
}
final NormalizedNode<?, ?> parentNode = getCodec().instanceIdentifierToNode(parentPath);
getDelegate().merge(store, YangInstanceIdentifier.create(parentNode.getIdentifier()), parentNode);
}
assertTrue("List node must exists after commit",listNode.isPresent());
}
assertTrue("List node must exists after commit",listNode.isPresent());
}
+ @Test
+ public void testPutCreateParentsSuperfluous() throws InterruptedException, ExecutionException {
+ final WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
+ writeTx.mergeParentStructurePut(LogicalDatastoreType.OPERATIONAL, TOP_PATH, new TopBuilder().build());
+ writeTx.commit().get();
+ }
+
@Test
public void testMergeCreateParentsSuccess() throws InterruptedException, ExecutionException {
final WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
@Test
public void testMergeCreateParentsSuccess() throws InterruptedException, ExecutionException {
final WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
final Optional<TopLevelList> listNode = readTx.read(LogicalDatastoreType.OPERATIONAL, NODE_PATH).get();
assertTrue("List node must exists after commit",listNode.isPresent());
}
final Optional<TopLevelList> listNode = readTx.read(LogicalDatastoreType.OPERATIONAL, NODE_PATH).get();
assertTrue("List node must exists after commit",listNode.isPresent());
}
+
+ @Test
+ public void testMergeCreateParentsSuperfluous() throws InterruptedException, ExecutionException {
+ final WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
+ writeTx.mergeParentStructurePut(LogicalDatastoreType.OPERATIONAL, TOP_PATH, new TopBuilder().build());
+ writeTx.commit().get();
+ }