BUG-5280: switch transactionIdentifier
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / cluster / datastore / utils / ActorContextTest.java
index 093f0fa6df046ba333858117e385a2a971e12fe6..405fe5221b64255e086db7b37eb1af1679e4da18 100644 (file)
@@ -35,6 +35,7 @@ import com.typesafe.config.ConfigFactory;
 import java.util.Arrays;
 import java.util.Map;
 import java.util.concurrent.TimeUnit;
+import java.util.function.Function;
 import org.junit.Assert;
 import org.junit.Test;
 import org.mockito.Mockito;
@@ -56,6 +57,7 @@ import org.opendaylight.controller.cluster.datastore.messages.PrimaryShardInfo;
 import org.opendaylight.controller.cluster.datastore.messages.RemotePrimaryShardFound;
 import org.opendaylight.controller.cluster.raft.utils.EchoActor;
 import org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -291,53 +293,6 @@ public class ActorContextTest extends AbstractActorTest{
         assertEquals(false, actorContext.isPathLocal("akka.tcp://system@127.0.0.1:2551/"));
     }
 
-    @Test
-    public void testResolvePathForRemoteActor() {
-        ActorContext actorContext =
-                new ActorContext(getSystem(), mock(ActorRef.class), mock(
-                        ClusterWrapper.class),
-                        mock(Configuration.class));
-
-        String actual = actorContext.resolvePath(
-                "akka.tcp://system@127.0.0.1:2550/user/shardmanager/shard",
-                "akka://system/user/shardmanager/shard/transaction");
-
-        String expected = "akka.tcp://system@127.0.0.1:2550/user/shardmanager/shard/transaction";
-
-        assertEquals(expected, actual);
-    }
-
-    @Test
-    public void testResolvePathForLocalActor() {
-        ActorContext actorContext =
-                new ActorContext(getSystem(), mock(ActorRef.class), mock(ClusterWrapper.class),
-                        mock(Configuration.class));
-
-        String actual = actorContext.resolvePath(
-                "akka://system/user/shardmanager/shard",
-                "akka://system/user/shardmanager/shard/transaction");
-
-        String expected = "akka://system/user/shardmanager/shard/transaction";
-
-        assertEquals(expected, actual);
-    }
-
-    @Test
-    public void testResolvePathForRemoteActorWithProperRemoteAddress() {
-        ActorContext actorContext =
-                new ActorContext(getSystem(), mock(ActorRef.class), mock(ClusterWrapper.class),
-                        mock(Configuration.class));
-
-        String actual = actorContext.resolvePath(
-                "akka.tcp://system@7.0.0.1:2550/user/shardmanager/shard",
-                "akka.tcp://system@7.0.0.1:2550/user/shardmanager/shard/transaction");
-
-        String expected = "akka.tcp://system@7.0.0.1:2550/user/shardmanager/shard/transaction";
-
-        assertEquals(expected, actual);
-    }
-
-
     @Test
     public void testClientDispatcherIsGlobalDispatcher(){
         ActorContext actorContext =
@@ -397,7 +352,8 @@ public class ActorContextTest extends AbstractActorTest{
             TestActorRef<MessageCollectorActor> shardManager =
                     TestActorRef.create(getSystem(), Props.create(MessageCollectorActor.class));
 
-            DatastoreContext dataStoreContext = DatastoreContext.newBuilder().dataStoreType("config").
+            DatastoreContext dataStoreContext = DatastoreContext.newBuilder().
+                    logicalStoreType(LogicalDatastoreType.CONFIGURATION).
                     shardLeaderElectionTimeout(100, TimeUnit.MILLISECONDS).build();
 
             final String expPrimaryPath = "akka://test-system/find-primary-shard";
@@ -439,7 +395,8 @@ public class ActorContextTest extends AbstractActorTest{
             TestActorRef<MessageCollectorActor> shardManager =
                     TestActorRef.create(getSystem(), Props.create(MessageCollectorActor.class));
 
-            DatastoreContext dataStoreContext = DatastoreContext.newBuilder().dataStoreType("config").
+            DatastoreContext dataStoreContext = DatastoreContext.newBuilder().
+                    logicalStoreType(LogicalDatastoreType.CONFIGURATION).
                     shardLeaderElectionTimeout(100, TimeUnit.MILLISECONDS).build();
 
             final DataTree mockDataTree = Mockito.mock(DataTree.class);
@@ -490,7 +447,8 @@ public class ActorContextTest extends AbstractActorTest{
         TestActorRef<MessageCollectorActor> shardManager =
             TestActorRef.create(getSystem(), Props.create(MessageCollectorActor.class));
 
-        DatastoreContext dataStoreContext = DatastoreContext.newBuilder().dataStoreType("config").
+        DatastoreContext dataStoreContext = DatastoreContext.newBuilder().
+            logicalStoreType(LogicalDatastoreType.CONFIGURATION).
             shardLeaderElectionTimeout(100, TimeUnit.MILLISECONDS).build();
 
         ActorContext actorContext =
@@ -540,7 +498,12 @@ public class ActorContextTest extends AbstractActorTest{
                     mock(ClusterWrapper.class), mockConfig,
                     DatastoreContext.newBuilder().shardInitializationTimeout(200, TimeUnit.MILLISECONDS).build(), new PrimaryShardInfoFutureCache());
 
-            actorContext.broadcast(new TestMessage());
+            actorContext.broadcast(new Function<Short, Object>() {
+                @Override
+                public Object apply(Short v) {
+                    return new TestMessage();
+                }
+            });
 
             MessageCollectorActor.expectFirstMatching(shardActorRef1, TestMessage.class);
             MessageCollectorActor.expectFirstMatching(shardActorRef2, TestMessage.class);