Fix test warnings
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / cluster / datastore / IntegrationTestKit.java
index 01678ad74e90141ef238845ce6202fd922f35836..a9179299f70366bd21c079d667d9881df83327c5 100644 (file)
@@ -64,7 +64,8 @@ public class IntegrationTestKit extends ShardTestKit {
         this(actorSystem, datastoreContextBuilder, 7);
     }
 
-    public IntegrationTestKit(final ActorSystem actorSystem, final Builder datastoreContextBuilder, int commitTimeout) {
+    public IntegrationTestKit(final ActorSystem actorSystem, final Builder datastoreContextBuilder,
+            final int commitTimeout) {
         super(actorSystem);
         this.datastoreContextBuilder = datastoreContextBuilder;
         this.commitTimeout = commitTimeout;
@@ -128,7 +129,7 @@ public class IntegrationTestKit extends ShardTestKit {
         final ClusterWrapper cluster = new ClusterWrapperImpl(getSystem());
         final Configuration config = new ConfigurationImpl(moduleShardsConfig, modulesConfig);
 
-        datastoreContextBuilder.dataStoreName(typeName);
+        setDataStoreName(typeName);
 
         final DatastoreContext datastoreContext = datastoreContextBuilder.build();
         final DatastoreContextFactory mockContextFactory = Mockito.mock(DatastoreContextFactory.class);
@@ -139,8 +140,8 @@ public class IntegrationTestKit extends ShardTestKit {
                 ActorSystem.class, ClusterWrapper.class, Configuration.class,
                 DatastoreContextFactory.class, DatastoreSnapshot.class);
 
-        final AbstractDataStore dataStore = constructor.newInstance(
-                getSystem(), cluster, config, mockContextFactory, restoreFromSnapshot);
+        final AbstractDataStore dataStore = constructor.newInstance(getSystem(), cluster, config, mockContextFactory,
+            restoreFromSnapshot);
 
         dataStore.onGlobalContextUpdated(schemaContext);
 
@@ -152,12 +153,22 @@ public class IntegrationTestKit extends ShardTestKit {
         return dataStore;
     }
 
+    private void setDataStoreName(final String typeName) {
+        if ("config".equals(typeName)) {
+            datastoreContextBuilder.logicalStoreType(LogicalDatastoreType.CONFIGURATION);
+        } else if ("operational".equals(typeName)) {
+            datastoreContextBuilder.logicalStoreType(LogicalDatastoreType.OPERATIONAL);
+        } else {
+            datastoreContextBuilder.dataStoreName(typeName);
+        }
+    }
+
     public DistributedDataStore setupDistributedDataStoreWithoutConfig(final String typeName,
                                                                        final SchemaContext schemaContext) {
         final ClusterWrapper cluster = new ClusterWrapperImpl(getSystem());
         final ConfigurationImpl configuration = new ConfigurationImpl(new EmptyModuleShardConfigProvider());
 
-        getDatastoreContextBuilder().dataStoreName(typeName);
+        setDataStoreName(typeName);
 
         final DatastoreContext datastoreContext = getDatastoreContextBuilder().build();
 
@@ -180,7 +191,7 @@ public class IntegrationTestKit extends ShardTestKit {
         final ClusterWrapper cluster = new ClusterWrapperImpl(getSystem());
         final ConfigurationImpl configuration = new ConfigurationImpl(new EmptyModuleShardConfigProvider());
 
-        getDatastoreContextBuilder().dataStoreName(typeName);
+        setDataStoreName(typeName);
 
         final DatastoreContext datastoreContext =
                 getDatastoreContextBuilder().logicalStoreType(storeType).build();