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);
}
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();
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();
+ }
}