BUG-1014: clean up DatastoreContext.dataStoreType()
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / cluster / datastore / entityownership / DistributedEntityOwnershipServiceTest.java
index 9608b812e402fc419299e6804890ac0a26f0764b..63e576944b985b0d8272fd533cd8a02be95b5650 100644 (file)
@@ -26,9 +26,9 @@ import akka.actor.PoisonPill;
 import akka.actor.Props;
 import com.google.common.base.Function;
 import com.google.common.base.Optional;
+import com.google.common.collect.Sets;
 import com.google.common.util.concurrent.Uninterruptibles;
-import java.util.Collections;
-import java.util.Map;
+import java.util.Collection;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicReference;
@@ -42,8 +42,7 @@ import org.opendaylight.controller.cluster.datastore.DistributedDataStore;
 import org.opendaylight.controller.cluster.datastore.ShardDataTree;
 import org.opendaylight.controller.cluster.datastore.config.Configuration;
 import org.opendaylight.controller.cluster.datastore.config.ConfigurationImpl;
-import org.opendaylight.controller.cluster.datastore.config.ModuleConfig;
-import org.opendaylight.controller.cluster.datastore.config.ModuleShardConfigProvider;
+import org.opendaylight.controller.cluster.datastore.config.EmptyModuleShardConfigProvider;
 import org.opendaylight.controller.cluster.datastore.entityownership.messages.RegisterCandidateLocal;
 import org.opendaylight.controller.cluster.datastore.entityownership.messages.RegisterListenerLocal;
 import org.opendaylight.controller.cluster.datastore.entityownership.messages.UnregisterCandidateLocal;
@@ -62,6 +61,7 @@ import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 import scala.concurrent.Await;
 import scala.concurrent.Future;
@@ -78,26 +78,26 @@ public class DistributedEntityOwnershipServiceTest extends AbstractEntityOwnersh
     static int ID_COUNTER = 1;
     static final QName QNAME = QName.create("test", "2015-08-11", "foo");
 
-    private final String dataStoreType = "config" + ID_COUNTER++;
+    private final String dataStoreName = "config" + ID_COUNTER++;
     private DistributedDataStore dataStore;
 
     @Before
     public void setUp() {
-        DatastoreContext datastoreContext = DatastoreContext.newBuilder().dataStoreType(dataStoreType).
+        DatastoreContext datastoreContext = DatastoreContext.newBuilder().dataStoreName(dataStoreName).
                 shardInitializationTimeout(10, TimeUnit.SECONDS).build();
 
-        Configuration configuration = new ConfigurationImpl(new ModuleShardConfigProvider() {
+        Configuration configuration = new ConfigurationImpl(new EmptyModuleShardConfigProvider()) {
             @Override
-            public Map<String, ModuleConfig> retrieveModuleConfigs(Configuration configuration) {
-                return Collections.emptyMap();
+            public Collection<String> getUniqueMemberNamesForAllShards() {
+                return Sets.newHashSet("member-1");
             }
-        });
+        };
 
         DatastoreContextFactory mockContextFactory = Mockito.mock(DatastoreContextFactory.class);
         Mockito.doReturn(datastoreContext).when(mockContextFactory).getBaseDatastoreContext();
         Mockito.doReturn(datastoreContext).when(mockContextFactory).getShardDatastoreContext(Mockito.anyString());
 
-        dataStore = new DistributedDataStore(getSystem(), new MockClusterWrapper(), configuration, mockContextFactory);
+        dataStore = new DistributedDataStore(getSystem(), new MockClusterWrapper(), configuration, mockContextFactory, null);
 
         dataStore.onGlobalContextUpdated(SchemaContextHelper.entityOwners());
     }
@@ -264,7 +264,7 @@ public class DistributedEntityOwnershipServiceTest extends AbstractEntityOwnersh
 
         service.start();
 
-        ShardDataTree shardDataTree = new ShardDataTree(SchemaContextHelper.entityOwners());
+        ShardDataTree shardDataTree = new ShardDataTree(SchemaContextHelper.entityOwners(), TreeType.OPERATIONAL);
         shardBuilder.setDataTree(shardDataTree.getDataTree());
 
         Entity entity1 = new Entity(ENTITY_TYPE, "one");