Convert yang-data-impl to a JPMS module
[yangtools.git] / yang / yang-data-impl / src / test / java / org / opendaylight / yangtools / yang / data / impl / schema / tree / Bug5968MergeTest.java
index 32fc691ba6189f615f532ecf7afb1d1ea475de0a..68900e2ee24177437f76b1438a4f6d75cf6398db 100644 (file)
@@ -30,21 +30,21 @@ import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.CollectionNodeBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 
 public class Bug5968MergeTest {
-    private static final String NS = "foo";
+    private static final String NS = "bug5968";
     private static final String REV = "2016-07-28";
     private static final QName ROOT = QName.create(NS, REV, "root");
     private static final QName MY_LIST = QName.create(NS, REV, "my-list");
     private static final QName LIST_ID = QName.create(NS, REV, "list-id");
     private static final QName MANDATORY_LEAF = QName.create(NS, REV, "mandatory-leaf");
     private static final QName COMMON_LEAF = QName.create(NS, REV, "common-leaf");
-    private static SchemaContext SCHEMA_CONTEXT;
+    private static EffectiveModelContext SCHEMA_CONTEXT;
 
     @BeforeClass
     public static void beforeClass() {
-        SCHEMA_CONTEXT = TestModel.createTestContext("/bug5968/foo.yang");
+        SCHEMA_CONTEXT = TestModel.createTestContext("/bug5968.yang");
     }
 
     @AfterClass
@@ -52,7 +52,7 @@ public class Bug5968MergeTest {
         SCHEMA_CONTEXT = null;
     }
 
-    private static DataTree initDataTree(final SchemaContext schemaContext, final boolean withMapNode)
+    private static DataTree initDataTree(final EffectiveModelContext schemaContext, final boolean withMapNode)
             throws DataValidationFailedException {
         final DataTree inMemoryDataTree = new InMemoryDataTreeFactory().create(
                 DataTreeConfiguration.DEFAULT_CONFIGURATION, schemaContext);
@@ -74,7 +74,7 @@ public class Bug5968MergeTest {
         return inMemoryDataTree;
     }
 
-    private static DataTree emptyDataTree(final SchemaContext schemaContext)
+    private static DataTree emptyDataTree(final EffectiveModelContext schemaContext)
             throws DataValidationFailedException {
         return new InMemoryDataTreeFactory().create(DataTreeConfiguration.DEFAULT_CONFIGURATION, schemaContext);
     }
@@ -97,9 +97,8 @@ public class Bug5968MergeTest {
             inMemoryDataTree.commit(prepare);
             fail("Should fail due to missing mandatory leaf.");
         } catch (final IllegalArgumentException e) {
-            assertEquals(
-                    "Node (foo?revision=2016-07-28)my-list[{(foo?revision=2016-07-28)list-id=1}] is missing mandatory "
-                            + "descendant /(foo?revision=2016-07-28)mandatory-leaf", e.getMessage());
+            assertEquals("Node (bug5968?revision=2016-07-28)my-list[{(bug5968?revision=2016-07-28)list-id=1}] is "
+                + "missing mandatory descendant /(bug5968?revision=2016-07-28)mandatory-leaf", e.getMessage());
         }
     }
 
@@ -116,9 +115,8 @@ public class Bug5968MergeTest {
             inMemoryDataTree.commit(prepare);
             fail("Should fail due to missing mandatory leaf.");
         } catch (final IllegalArgumentException e) {
-            assertEquals(
-                    "Node (foo?revision=2016-07-28)my-list[{(foo?revision=2016-07-28)list-id=1}] is missing mandatory "
-                            + "descendant /(foo?revision=2016-07-28)mandatory-leaf", e.getMessage());
+            assertEquals("Node (bug5968?revision=2016-07-28)my-list[{(bug5968?revision=2016-07-28)list-id=1}] is "
+                + "missing mandatory descendant /(bug5968?revision=2016-07-28)mandatory-leaf", e.getMessage());
         }
     }
 
@@ -136,9 +134,8 @@ public class Bug5968MergeTest {
             inMemoryDataTree.commit(prepare);
             fail("Should fail due to missing mandatory leaf.");
         } catch (final IllegalArgumentException e) {
-            assertEquals(
-                    "Node (foo?revision=2016-07-28)my-list[{(foo?revision=2016-07-28)list-id=1}] is missing mandatory "
-                            + "descendant /(foo?revision=2016-07-28)mandatory-leaf", e.getMessage());
+            assertEquals("Node (bug5968?revision=2016-07-28)my-list[{(bug5968?revision=2016-07-28)list-id=1}] is "
+                + "missing mandatory descendant /(bug5968?revision=2016-07-28)mandatory-leaf", e.getMessage());
         }
     }
 
@@ -164,14 +161,14 @@ public class Bug5968MergeTest {
 
         modificationTree.merge(
                 YangInstanceIdentifier.of(ROOT).node(MY_LIST)
-                        .node(new NodeIdentifierWithPredicates(MY_LIST, ImmutableMap.of(LIST_ID, listIdValue))),
+                        .node(NodeIdentifierWithPredicates.of(MY_LIST, ImmutableMap.of(LIST_ID, listIdValue))),
                 taskEntryNode);
     }
 
     private static MapEntryNode createMapEntry(final Object listIdValue, final Object mandatoryLeafValue,
             final Object commonLeafValue) throws DataValidationFailedException {
         return Builders.mapEntryBuilder()
-                .withNodeIdentifier(new NodeIdentifierWithPredicates(MY_LIST, ImmutableMap.of(LIST_ID, listIdValue)))
+                .withNodeIdentifier(NodeIdentifierWithPredicates.of(MY_LIST, ImmutableMap.of(LIST_ID, listIdValue)))
                 .withChild(ImmutableNodes.leafNode(LIST_ID, listIdValue))
                 .withChild(ImmutableNodes.leafNode(MANDATORY_LEAF, mandatoryLeafValue))
                 .withChild(ImmutableNodes.leafNode(COMMON_LEAF, commonLeafValue)).build();
@@ -180,7 +177,7 @@ public class Bug5968MergeTest {
     private static MapEntryNode createMapEntry(final Object listIdValue, final Object commonLeafValue)
             throws DataValidationFailedException {
         return Builders.mapEntryBuilder()
-                .withNodeIdentifier(new NodeIdentifierWithPredicates(MY_LIST, ImmutableMap.of(LIST_ID, listIdValue)))
+                .withNodeIdentifier(NodeIdentifierWithPredicates.of(MY_LIST, ImmutableMap.of(LIST_ID, listIdValue)))
                 .withChild(ImmutableNodes.leafNode(LIST_ID, listIdValue))
                 .withChild(ImmutableNodes.leafNode(COMMON_LEAF, commonLeafValue)).build();
     }
@@ -188,7 +185,7 @@ public class Bug5968MergeTest {
     private static MapEntryNode createMapEntryM(final Object listIdValue, final Object mandatoryLeafValue)
             throws DataValidationFailedException {
         return Builders.mapEntryBuilder()
-                .withNodeIdentifier(new NodeIdentifierWithPredicates(MY_LIST, ImmutableMap.of(LIST_ID, listIdValue)))
+                .withNodeIdentifier(NodeIdentifierWithPredicates.of(MY_LIST, ImmutableMap.of(LIST_ID, listIdValue)))
                 .withChild(ImmutableNodes.leafNode(LIST_ID, listIdValue))
                 .withChild(ImmutableNodes.leafNode(MANDATORY_LEAF, mandatoryLeafValue)).build();
     }
@@ -243,11 +240,11 @@ public class Bug5968MergeTest {
         modificationTree.merge(YangInstanceIdentifier.of(ROOT).node(MY_LIST), createMapBuilder().build());
         modificationTree.merge(
                 YangInstanceIdentifier.of(ROOT).node(MY_LIST)
-                        .node(new NodeIdentifierWithPredicates(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
+                        .node(NodeIdentifierWithPredicates.of(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
                 createEmptyMapEntryBuilder("1").build());
         modificationTree.merge(
                 YangInstanceIdentifier.of(ROOT).node(MY_LIST)
-                        .node(new NodeIdentifierWithPredicates(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
+                        .node(NodeIdentifierWithPredicates.of(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
                 createMapEntry("1", "mandatory-value", "common-value"));
 
         modificationTree.ready();
@@ -265,11 +262,11 @@ public class Bug5968MergeTest {
         modificationTree.merge(YangInstanceIdentifier.of(ROOT).node(MY_LIST), createMapBuilder().build());
         modificationTree.merge(
                 YangInstanceIdentifier.of(ROOT).node(MY_LIST)
-                        .node(new NodeIdentifierWithPredicates(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
+                        .node(NodeIdentifierWithPredicates.of(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
                 createEmptyMapEntryBuilder("1").build());
         modificationTree.merge(
                 YangInstanceIdentifier.of(ROOT).node(MY_LIST)
-                        .node(new NodeIdentifierWithPredicates(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
+                        .node(NodeIdentifierWithPredicates.of(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
                 createMapEntry("1", "common-value"));
 
         try {
@@ -279,16 +276,15 @@ public class Bug5968MergeTest {
             inMemoryDataTree.commit(prepare);
             fail("Should fail due to missing mandatory leaf.");
         } catch (final IllegalArgumentException e) {
-            assertEquals(
-                    "Node (foo?revision=2016-07-28)my-list[{(foo?revision=2016-07-28)list-id=1}] is missing mandatory "
-                            + "descendant /(foo?revision=2016-07-28)mandatory-leaf", e.getMessage());
+            assertEquals("Node (bug5968?revision=2016-07-28)my-list[{(bug5968?revision=2016-07-28)list-id=1}] is "
+                + "missing mandatory descendant /(bug5968?revision=2016-07-28)mandatory-leaf", e.getMessage());
         }
     }
 
     private static DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> createEmptyMapEntryBuilder(
             final Object listIdValue) throws DataValidationFailedException {
         return Builders.mapEntryBuilder()
-                .withNodeIdentifier(new NodeIdentifierWithPredicates(MY_LIST, ImmutableMap.of(LIST_ID, listIdValue)))
+                .withNodeIdentifier(NodeIdentifierWithPredicates.of(MY_LIST, ImmutableMap.of(LIST_ID, listIdValue)))
                 .withChild(ImmutableNodes.leafNode(LIST_ID, listIdValue));
     }
 
@@ -309,11 +305,11 @@ public class Bug5968MergeTest {
         modificationTree.merge(YangInstanceIdentifier.of(ROOT).node(MY_LIST), createMapBuilder().build());
         modificationTree.merge(
                 YangInstanceIdentifier.of(ROOT).node(MY_LIST)
-                        .node(new NodeIdentifierWithPredicates(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
+                        .node(NodeIdentifierWithPredicates.of(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
                 createEmptyMapEntryBuilder("1").build());
         modificationTree.merge(
                 YangInstanceIdentifier.of(ROOT).node(MY_LIST)
-                        .node(new NodeIdentifierWithPredicates(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
+                        .node(NodeIdentifierWithPredicates.of(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
                 createMapEntry("1", "mandatory-value", "common-value"));
 
         modificationTree.ready();
@@ -331,11 +327,11 @@ public class Bug5968MergeTest {
         modificationTree.merge(YangInstanceIdentifier.of(ROOT).node(MY_LIST), createMapBuilder().build());
         modificationTree.merge(
                 YangInstanceIdentifier.of(ROOT).node(MY_LIST)
-                        .node(new NodeIdentifierWithPredicates(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
+                        .node(NodeIdentifierWithPredicates.of(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
                 createEmptyMapEntryBuilder("1").build());
         modificationTree.merge(
                 YangInstanceIdentifier.of(ROOT).node(MY_LIST)
-                        .node(new NodeIdentifierWithPredicates(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
+                        .node(NodeIdentifierWithPredicates.of(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
                 createMapEntry("1", "common-value"));
 
         try {
@@ -345,9 +341,8 @@ public class Bug5968MergeTest {
             inMemoryDataTree.commit(prepare);
             fail("Should fail due to missing mandatory leaf.");
         } catch (final IllegalArgumentException e) {
-            assertEquals(
-                    "Node (foo?revision=2016-07-28)my-list[{(foo?revision=2016-07-28)list-id=1}] is missing mandatory "
-                            + "descendant /(foo?revision=2016-07-28)mandatory-leaf", e.getMessage());
+            assertEquals("Node (bug5968?revision=2016-07-28)my-list[{(bug5968?revision=2016-07-28)list-id=1}] is "
+                + "missing mandatory descendant /(bug5968?revision=2016-07-28)mandatory-leaf", e.getMessage());
         }
     }
 
@@ -360,11 +355,11 @@ public class Bug5968MergeTest {
         modificationTree.merge(YangInstanceIdentifier.of(ROOT).node(MY_LIST), createMapBuilder().build());
         modificationTree.merge(
                 YangInstanceIdentifier.of(ROOT).node(MY_LIST)
-                        .node(new NodeIdentifierWithPredicates(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
+                        .node(NodeIdentifierWithPredicates.of(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
                 createEmptyMapEntryBuilder("1").build());
         modificationTree.merge(
                 YangInstanceIdentifier.of(ROOT).node(MY_LIST)
-                        .node(new NodeIdentifierWithPredicates(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
+                        .node(NodeIdentifierWithPredicates.of(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
                 createMapEntryM("1", "mandatory-value"));
 
         modificationTree.ready();
@@ -375,7 +370,7 @@ public class Bug5968MergeTest {
         final DataTreeModification modificationTree2 = inMemoryDataTree.takeSnapshot().newModification();
         modificationTree2.merge(
                 YangInstanceIdentifier.of(ROOT).node(MY_LIST)
-                        .node(new NodeIdentifierWithPredicates(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
+                        .node(NodeIdentifierWithPredicates.of(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
                 createMapEntry("1", "common-value"));
         modificationTree2.ready();
         inMemoryDataTree.validate(modificationTree2);
@@ -392,11 +387,11 @@ public class Bug5968MergeTest {
         modificationTree.merge(YangInstanceIdentifier.of(ROOT).node(MY_LIST), createMapBuilder().build());
         modificationTree.merge(
                 YangInstanceIdentifier.of(ROOT).node(MY_LIST)
-                        .node(new NodeIdentifierWithPredicates(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
+                        .node(NodeIdentifierWithPredicates.of(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
                 createEmptyMapEntryBuilder("1").build());
         modificationTree.merge(
                 YangInstanceIdentifier.of(ROOT).node(MY_LIST)
-                        .node(new NodeIdentifierWithPredicates(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
+                        .node(NodeIdentifierWithPredicates.of(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
                 createMapEntryM("1", "mandatory-value"));
 
         modificationTree.ready();
@@ -407,15 +402,15 @@ public class Bug5968MergeTest {
         final DataTreeModification modificationTree2 = inMemoryDataTree.takeSnapshot().newModification();
         modificationTree2.write(
                 YangInstanceIdentifier.of(ROOT).node(MY_LIST)
-                        .node(new NodeIdentifierWithPredicates(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
+                        .node(NodeIdentifierWithPredicates.of(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
                 createMapEntry("1", "common-value"));
         modificationTree2.merge(
                 YangInstanceIdentifier.of(ROOT).node(MY_LIST)
-                        .node(new NodeIdentifierWithPredicates(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
+                        .node(NodeIdentifierWithPredicates.of(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
                 createMapEntryM("1", "mandatory-value"));
         modificationTree2.merge(
                 YangInstanceIdentifier.of(ROOT).node(MY_LIST)
-                        .node(new NodeIdentifierWithPredicates(MY_LIST, ImmutableMap.of(LIST_ID, "2"))),
+                        .node(NodeIdentifierWithPredicates.of(MY_LIST, ImmutableMap.of(LIST_ID, "2"))),
                 createMapEntry("2", "common-value"));
         try {
             modificationTree2.ready();
@@ -424,9 +419,8 @@ public class Bug5968MergeTest {
             inMemoryDataTree.commit(prepare2);
             fail("Should fail due to missing mandatory leaf.");
         } catch (final IllegalArgumentException e) {
-            assertEquals(
-                    "Node (foo?revision=2016-07-28)my-list[{(foo?revision=2016-07-28)list-id=2}] is missing mandatory "
-                            + "descendant /(foo?revision=2016-07-28)mandatory-leaf", e.getMessage());
+            assertEquals("Node (bug5968?revision=2016-07-28)my-list[{(bug5968?revision=2016-07-28)list-id=2}] is "
+                + "missing mandatory descendant /(bug5968?revision=2016-07-28)mandatory-leaf", e.getMessage());
         }
     }
 
@@ -445,11 +439,11 @@ public class Bug5968MergeTest {
         modificationTree.merge(YangInstanceIdentifier.of(ROOT).node(MY_LIST), createMapBuilder().build());
         modificationTree.merge(
                 YangInstanceIdentifier.of(ROOT).node(MY_LIST)
-                        .node(new NodeIdentifierWithPredicates(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
+                        .node(NodeIdentifierWithPredicates.of(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
                 createEmptyMapEntryBuilder("1").build());
         modificationTree.merge(
                 YangInstanceIdentifier.of(ROOT).node(MY_LIST)
-                        .node(new NodeIdentifierWithPredicates(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
+                        .node(NodeIdentifierWithPredicates.of(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
                 createMapEntryM("1", "mandatory-value"));
 
         modificationTree.ready();
@@ -459,7 +453,7 @@ public class Bug5968MergeTest {
 
         modificationTree2.merge(
                 YangInstanceIdentifier.of(ROOT).node(MY_LIST)
-                        .node(new NodeIdentifierWithPredicates(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
+                        .node(NodeIdentifierWithPredicates.of(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
                 createMapEntry("1", "common-value"));
         modificationTree2.ready();
         inMemoryDataTree.validate(modificationTree2);