Do not generate 'isFoo()' methods
[mdsal.git] / dom / mdsal-dom-broker / src / test / java / org / opendaylight / mdsal / dom / broker / ShardedDOMDataTreeTest.java
index 814b3ec3e6b39801007119083454aa9cac7086c3..771312c05c50b46b7f921a377fd4f98fcd051b48 100644 (file)
@@ -57,14 +57,11 @@ import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafNodeBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMapNodeBuilder;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
-public class ShardedDOMDataTreeTest {
-
-    private static final SchemaContext SCHEMA_CONTEXT = TestModel.createTestContext();
+public class ShardedDOMDataTreeTest extends AbstractDatastoreTest {
 
     private static final DOMDataTreeIdentifier ROOT_ID =
-            new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.EMPTY);
+            new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.empty());
     private static final DOMDataTreeIdentifier TEST_ID =
             new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH);
 
@@ -72,7 +69,7 @@ public class ShardedDOMDataTreeTest {
             new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, TestModel.INNER_CONTAINER_PATH);
 
     private static final YangInstanceIdentifier OUTER_LIST_YID = TestModel.OUTER_LIST_PATH.node(
-            new NodeIdentifierWithPredicates(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1));
+            NodeIdentifierWithPredicates.of(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1));
     private static final DOMDataTreeIdentifier OUTER_LIST_ID =
             new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, OUTER_LIST_YID);
 
@@ -95,7 +92,7 @@ public class ShardedDOMDataTreeTest {
         MockitoAnnotations.initMocks(this);
 
         rootShard = InMemoryDOMDataTreeShard.create(ROOT_ID, executor, 1);
-        rootShard.onGlobalContextUpdated(SCHEMA_CONTEXT);
+        rootShard.onModelContextUpdated(SCHEMA_CONTEXT);
 
         final ShardedDOMDataTree dataTree = new ShardedDOMDataTree();
         final DOMDataTreeProducer shardRegProducer = dataTree.createProducer(Collections.singletonList(ROOT_ID));
@@ -111,20 +108,26 @@ public class ShardedDOMDataTreeTest {
         dataTreeService.createProducer(Collections.singletonList(TEST_ID));
     }
 
+    @Test(expected = IllegalArgumentException.class)
+    public void testProducerPathContentionReverse() throws Exception {
+        dataTreeService.createProducer(Collections.singletonList(TEST_ID));
+        dataTreeService.createProducer(Collections.singletonList(ROOT_ID));
+    }
+
     @Test
     public void testShardRegistrationClose() throws Exception {
         rootShardReg.close();
 
         final InMemoryDOMDataTreeShard newRootShard = InMemoryDOMDataTreeShard.create(ROOT_ID, executor, 1);
-        newRootShard.onGlobalContextUpdated(SCHEMA_CONTEXT);
+        newRootShard.onModelContextUpdated(SCHEMA_CONTEXT);
         final DOMDataTreeProducer shardRegProducer = dataTreeService.createProducer(Collections.singletonList(ROOT_ID));
 
         final ListenerRegistration<InMemoryDOMDataTreeShard> newRootShardReg =
-                dataTreeService.registerDataTreeShard(ROOT_ID, rootShard, shardRegProducer);
+                dataTreeService.registerDataTreeShard(ROOT_ID, newRootShard, shardRegProducer);
         shardRegProducer.close();
 
         final InMemoryDOMDataTreeShard innerShard = InMemoryDOMDataTreeShard.create(INNER_CONTAINER_ID, executor, 1);
-        innerShard.onGlobalContextUpdated(SCHEMA_CONTEXT);
+        innerShard.onModelContextUpdated(SCHEMA_CONTEXT);
         final DOMDataTreeProducer shardRegProducer2 =
                 dataTreeService.createProducer(Collections.singletonList(INNER_CONTAINER_ID));
         ListenerRegistration<InMemoryDOMDataTreeShard> innerShardReg =
@@ -207,7 +210,7 @@ public class ShardedDOMDataTreeTest {
         doNothing().when(mockedDataTreeListener).onDataTreeChanged(anyCollection(), anyMap());
 
         InMemoryDOMDataTreeShard testShard = InMemoryDOMDataTreeShard.create(TEST_ID, executor, 1);
-        testShard.onGlobalContextUpdated(SCHEMA_CONTEXT);
+        testShard.onModelContextUpdated(SCHEMA_CONTEXT);
 
         final DOMDataTreeProducer regProducer = dataTreeService.createProducer(Collections.singleton(TEST_ID));
         dataTreeService.registerDataTreeShard(TEST_ID, testShard, regProducer);
@@ -247,14 +250,14 @@ public class ShardedDOMDataTreeTest {
     @Test
     public void testMultipleWritesIntoSingleMapEntry() throws Exception {
 
-        final YangInstanceIdentifier oid1 = TestModel.OUTER_LIST_PATH.node(new NodeIdentifierWithPredicates(
+        final YangInstanceIdentifier oid1 = TestModel.OUTER_LIST_PATH.node(NodeIdentifierWithPredicates.of(
                 TestModel.OUTER_LIST_QNAME, QName.create(TestModel.OUTER_LIST_QNAME, "id"), 0));
         final DOMDataTreeIdentifier outerListPath = new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, oid1);
 
         final DOMDataTreeProducer shardProducer = dataTreeService.createProducer(
                 Collections.singletonList(outerListPath));
         final InMemoryDOMDataTreeShard outerListShard = InMemoryDOMDataTreeShard.create(outerListPath, executor, 1000);
-        outerListShard.onGlobalContextUpdated(SCHEMA_CONTEXT);
+        outerListShard.onModelContextUpdated(SCHEMA_CONTEXT);
 
         final ListenerRegistration<InMemoryDOMDataTreeShard> oid1ShardRegistration =
                 dataTreeService.registerDataTreeShard(outerListPath, outerListShard, shardProducer);
@@ -295,7 +298,7 @@ public class ShardedDOMDataTreeTest {
         final Collection<MapEntryNode> ret = new ArrayList<>();
         for (int i = 0; i < amount; i++) {
             ret.add(ImmutableNodes.mapEntryBuilder()
-                    .withNodeIdentifier(new NodeIdentifierWithPredicates(TestModel.INNER_LIST_QNAME,
+                    .withNodeIdentifier(NodeIdentifierWithPredicates.of(TestModel.INNER_LIST_QNAME,
                             QName.create(TestModel.OUTER_LIST_QNAME, "name"), Integer.toString(i)))
                     .withChild(ImmutableNodes
                             .leafNode(QName.create(TestModel.INNER_LIST_QNAME, "name"), Integer.toString(i)))
@@ -399,7 +402,7 @@ public class ShardedDOMDataTreeTest {
     public void testLargerSubshardSpace() throws Exception {
 
         final InMemoryDOMDataTreeShard outerListShard = InMemoryDOMDataTreeShard.create(OUTER_LIST_ID, executor, 1, 1);
-        outerListShard.onGlobalContextUpdated(SCHEMA_CONTEXT);
+        outerListShard.onModelContextUpdated(SCHEMA_CONTEXT);
 
         try (DOMDataTreeProducer producer =
                      dataTreeService.createProducer(Collections.singletonList(OUTER_LIST_ID))) {
@@ -420,7 +423,7 @@ public class ShardedDOMDataTreeTest {
         doNothing().when(listener).onDataTreeChanged(any(), any());
         dataTreeService.registerListener(listener,
                 Collections.singletonList(
-                        new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.EMPTY)),
+                        new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.empty())),
                 false, Collections.emptyList());
 
         verify(listener, times(2)).onDataTreeChanged(any(), any());