2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.yangtools.yang.data.impl.schema.tree;
10 import static org.junit.Assert.assertEquals;
12 import java.io.IOException;
13 import org.junit.Before;
14 import org.junit.Test;
15 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
16 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
17 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
18 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
19 import org.opendaylight.yangtools.yang.data.api.schema.tree.ModificationType;
20 import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType;
21 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
22 import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
23 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
26 * BUG-3674: issuing a delete on a non-existent entry must be preserved in
27 * DataTreeModification, but should appear as UNMODIFIED in the
28 * resulting DataTreeCandidate.
30 public class Bug3674Test {
31 private DataTree tree;
34 public void setUp() throws ReactorException, IOException, YangSyntaxErrorException {
35 tree = InMemoryDataTreeFactory.getInstance().create(TreeType.OPERATIONAL);
36 tree.setSchemaContext(TestModel.createTestContext());
38 // Create the top-level container
39 final DataTreeModification mod = tree.takeSnapshot().newModification();
40 mod.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
42 tree.commit(tree.prepare(mod));
46 public void testDeleteOfNonExistingNode() {
47 final DataTreeModification mod = tree.takeSnapshot().newModification();
48 mod.delete(TestModel.OUTER_LIST_PATH);
51 final DataTreeCandidate candidate = tree.prepare(mod);
52 final DataTreeCandidateNode root = candidate.getRootNode();
53 assertEquals(ModificationType.UNMODIFIED, root.getModificationType());