Adjust for Binding RPC codegen changes
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / cluster / datastore / DatastoreContextIntrospectorTest.java
index 2bd2e61296daec3f41d9264b78d8652d3159c762..5d5d2f8db23ede151123bd1be66ef722c009ea59 100644 (file)
@@ -14,10 +14,13 @@ import static org.opendaylight.controller.cluster.datastore.DatastoreContext.DEF
 import static org.opendaylight.controller.cluster.datastore.DatastoreContext.DEFAULT_SHARD_SNAPSHOT_DATA_THRESHOLD_PERCENTAGE;
 import static org.opendaylight.controller.cluster.datastore.DatastoreContext.DEFAULT_SHARD_TRANSACTION_IDLE_TIMEOUT;
 import static org.opendaylight.controller.cluster.datastore.DatastoreContext.DEFAULT_SHARD_TX_COMMIT_TIMEOUT_IN_SECONDS;
-import java.util.Dictionary;
+
+import java.util.HashMap;
 import java.util.Hashtable;
+import java.util.Map;
 import org.junit.Test;
-import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStoreConfigProperties;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.mdsal.dom.store.inmemory.InMemoryDOMDataStoreConfigProperties;
 
 /**
  * Unit tests for DatastoreContextIntrospector.
@@ -28,10 +31,11 @@ public class DatastoreContextIntrospectorTest {
 
     @Test
     public void testUpdate() {
-        DatastoreContext context = DatastoreContext.newBuilder().dataStoreType("operational").build();
-        DatastoreContextIntrospector introspector = new DatastoreContextIntrospector(context );
+        DatastoreContext context = DatastoreContext.newBuilder()
+                .logicalStoreType(LogicalDatastoreType.OPERATIONAL).build();
+        final DatastoreContextIntrospector introspector = new DatastoreContextIntrospector(context);
 
-        Dictionary<String, Object> properties = new Hashtable<>();
+        final Map<String, Object> properties = new HashMap<>();
         properties.put("shard-transaction-idle-timeout-in-minutes", "31");
         properties.put("operation-timeout-in-seconds", "26");
         properties.put("shard-transaction-commit-timeout-in-seconds", "100");
@@ -110,17 +114,18 @@ public class DatastoreContextIntrospectorTest {
         updated = introspector.update(null);
         assertEquals("updated", false, updated);
 
-        updated = introspector.update(new Hashtable<String, Object>());
+        updated = introspector.update(new Hashtable<>());
         assertEquals("updated", false, updated);
     }
 
 
     @Test
     public void testUpdateWithInvalidValues() {
-        DatastoreContext context = DatastoreContext.newBuilder().dataStoreType("operational").build();
-        DatastoreContextIntrospector introspector = new DatastoreContextIntrospector(context );
+        DatastoreContext context = DatastoreContext.newBuilder()
+                .logicalStoreType(LogicalDatastoreType.OPERATIONAL).build();
+        final DatastoreContextIntrospector introspector = new DatastoreContextIntrospector(context);
 
-        Dictionary<String, Object> properties = new Hashtable<>();
+        final Map<String, Object> properties = new HashMap<>();
         properties.put("shard-transaction-idle-timeout-in-minutes", "0"); // bad - must be > 0
         properties.put("shard-journal-recovery-log-batch-size", "199");
         properties.put("shard-transaction-commit-timeout-in-seconds", "bogus"); // bad - NaN
@@ -133,7 +138,7 @@ public class DatastoreContextIntrospectorTest {
         properties.put("max-shard-data-change-executor-pool-size", "bogus"); // bad - NaN
         properties.put("unknownProperty", "1"); // bad - invalid property name
 
-        boolean updated = introspector.update(properties);
+        final boolean updated = introspector.update(properties);
         assertEquals("updated", true, updated);
         context = introspector.getContext();
 
@@ -142,7 +147,8 @@ public class DatastoreContextIntrospectorTest {
         assertEquals(DEFAULT_SHARD_TX_COMMIT_TIMEOUT_IN_SECONDS, context.getShardTransactionCommitTimeoutInSeconds());
         assertEquals(212, context.getShardRaftConfig().getSnapshotBatchCount());
         assertEquals(DEFAULT_OPERATION_TIMEOUT_IN_MS, context.getOperationTimeoutInMillis());
-        assertEquals(DEFAULT_HEARTBEAT_INTERVAL_IN_MILLIS, context.getShardRaftConfig().getHeartBeatInterval().length());
+        assertEquals(DEFAULT_HEARTBEAT_INTERVAL_IN_MILLIS,
+                context.getShardRaftConfig().getHeartBeatInterval().length());
         assertEquals(567, context.getShardTransactionCommitQueueCapacity());
         assertEquals(DEFAULT_SHARD_SNAPSHOT_DATA_THRESHOLD_PERCENTAGE,
                 context.getShardRaftConfig().getSnapshotDataThresholdPercentage());
@@ -153,7 +159,7 @@ public class DatastoreContextIntrospectorTest {
 
     @Test
     public void testUpdateWithDatastoreTypeSpecificProperties() {
-        Dictionary<String, Object> properties = new Hashtable<>();
+        final Map<String, Object> properties = new HashMap<>();
         properties.put("shard-transaction-idle-timeout-in-minutes", "22"); // global setting
         properties.put("operational.shard-transaction-idle-timeout-in-minutes", "33"); // operational override
         properties.put("config.shard-transaction-idle-timeout-in-minutes", "44"); // config override
@@ -165,8 +171,9 @@ public class DatastoreContextIntrospectorTest {
         properties.put("persistent", "false"); // global setting
         properties.put("operational.Persistent", "true"); // operational override
 
-        DatastoreContext operContext = DatastoreContext.newBuilder().dataStoreType("operational").build();
-        DatastoreContextIntrospector operIntrospector = new DatastoreContextIntrospector(operContext);
+        DatastoreContext operContext = DatastoreContext.newBuilder()
+                .logicalStoreType(LogicalDatastoreType.OPERATIONAL).build();
+        final DatastoreContextIntrospector operIntrospector = new DatastoreContextIntrospector(operContext);
         boolean updated = operIntrospector.update(properties);
         assertEquals("updated", true, updated);
         operContext = operIntrospector.getContext();
@@ -175,8 +182,9 @@ public class DatastoreContextIntrospectorTest {
         assertEquals(true, operContext.isPersistent());
         assertEquals(333, operContext.getDataStoreProperties().getMaxDataChangeExecutorPoolSize());
 
-        DatastoreContext configContext = DatastoreContext.newBuilder().dataStoreType("config").build();
-        DatastoreContextIntrospector configIntrospector = new DatastoreContextIntrospector(configContext);
+        DatastoreContext configContext = DatastoreContext.newBuilder()
+                .logicalStoreType(LogicalDatastoreType.CONFIGURATION).build();
+        final DatastoreContextIntrospector configIntrospector = new DatastoreContextIntrospector(configContext);
         updated = configIntrospector.update(properties);
         assertEquals("updated", true, updated);
         configContext = configIntrospector.getContext();
@@ -188,14 +196,15 @@ public class DatastoreContextIntrospectorTest {
 
     @Test
     public void testGetDatastoreContextForShard() {
-        Dictionary<String, Object> properties = new Hashtable<>();
+        final Map<String, Object> properties = new HashMap<>();
         properties.put("shard-transaction-idle-timeout-in-minutes", "22"); // global setting
         properties.put("operational.shard-transaction-idle-timeout-in-minutes", "33"); // operational override
         properties.put("config.shard-transaction-idle-timeout-in-minutes", "44"); // config override
         properties.put("topology.shard-transaction-idle-timeout-in-minutes", "55"); // global shard override
 
-        DatastoreContext operContext = DatastoreContext.newBuilder().dataStoreType("operational").build();
-        DatastoreContextIntrospector operIntrospector = new DatastoreContextIntrospector(operContext);
+        DatastoreContext operContext = DatastoreContext.newBuilder()
+                .logicalStoreType(LogicalDatastoreType.OPERATIONAL).build();
+        final DatastoreContextIntrospector operIntrospector = new DatastoreContextIntrospector(operContext);
 
         DatastoreContext shardContext = operIntrospector.newContextFactory().getShardDatastoreContext("topology");
         assertEquals(10, shardContext.getShardTransactionIdleTimeout().toMinutes());
@@ -207,8 +216,9 @@ public class DatastoreContextIntrospectorTest {
         shardContext = operIntrospector.newContextFactory().getShardDatastoreContext("topology");
         assertEquals(55, shardContext.getShardTransactionIdleTimeout().toMinutes());
 
-        DatastoreContext configContext = DatastoreContext.newBuilder().dataStoreType("config").build();
-        DatastoreContextIntrospector configIntrospector = new DatastoreContextIntrospector(configContext);
+        DatastoreContext configContext = DatastoreContext.newBuilder()
+                .logicalStoreType(LogicalDatastoreType.CONFIGURATION).build();
+        final DatastoreContextIntrospector configIntrospector = new DatastoreContextIntrospector(configContext);
         configIntrospector.update(properties);
         configContext = configIntrospector.getContext();
         assertEquals(44, configContext.getShardTransactionIdleTimeout().toMinutes());
@@ -216,8 +226,10 @@ public class DatastoreContextIntrospectorTest {
         shardContext = configIntrospector.newContextFactory().getShardDatastoreContext("topology");
         assertEquals(55, shardContext.getShardTransactionIdleTimeout().toMinutes());
 
-        properties.put("operational.topology.shard-transaction-idle-timeout-in-minutes", "66"); // operational shard override
-        properties.put("config.topology.shard-transaction-idle-timeout-in-minutes", "77"); // config shard override
+        // operational shard override
+        properties.put("operational.topology.shard-transaction-idle-timeout-in-minutes", "66");
+        // config shard override
+        properties.put("config.topology.shard-transaction-idle-timeout-in-minutes", "77");
 
         operIntrospector.update(properties);
         shardContext = operIntrospector.newContextFactory().getShardDatastoreContext("topology");