Migrate from YangInstanceIdentifier.EMPTY
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / cluster / databroker / actors / dds / AbstractDataStoreClientBehaviorTest.java
index 1961792a96961b6279fceae91748a92811639b2c..6528c6ba7c91df095d0962797586e5ceb6566b5e 100644 (file)
@@ -16,9 +16,10 @@ import akka.actor.ActorRef;
 import akka.actor.ActorSelection;
 import akka.actor.ActorSystem;
 import akka.actor.Status;
-import akka.testkit.JavaTestKit;
 import akka.testkit.TestProbe;
+import akka.testkit.javadsl.TestKit;
 import java.util.Collections;
+import java.util.Optional;
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
@@ -30,7 +31,7 @@ import org.opendaylight.controller.cluster.access.client.InternalCommand;
 import org.opendaylight.controller.cluster.access.commands.ConnectClientRequest;
 import org.opendaylight.controller.cluster.access.commands.ConnectClientSuccess;
 import org.opendaylight.controller.cluster.datastore.messages.PrimaryShardInfo;
-import org.opendaylight.controller.cluster.datastore.utils.ActorContext;
+import org.opendaylight.controller.cluster.datastore.utils.ActorUtils;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.CursorAwareDataTreeModification;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
@@ -49,11 +50,11 @@ public abstract class AbstractDataStoreClientBehaviorTest {
     private AbstractDataStoreClientBehavior behavior;
 
     @Before
-    public void setUp() throws Exception {
+    public void setUp() {
         system = ActorSystem.apply();
         clientActorProbe = new TestProbe(system, "client");
         actorContextProbe = new TestProbe(system, "actor-context");
-        final ActorContext context = createActorContextMock(system, actorContextProbe.ref());
+        final ActorUtils context = createActorContextMock(system, actorContextProbe.ref());
         clientContext =
                 AccessClientUtil.createClientActorContext(system, clientActorProbe.ref(), CLIENT_ID, PERSISTENCE_ID);
         behavior = createBehavior(clientContext, context);
@@ -61,25 +62,25 @@ public abstract class AbstractDataStoreClientBehaviorTest {
 
     @SuppressWarnings("checkstyle:hiddenField")
     protected abstract AbstractDataStoreClientBehavior createBehavior(ClientActorContext clientContext,
-                                                                      ActorContext context);
+                                                                      ActorUtils context);
 
     @After
-    public void tearDown() throws Exception {
-        JavaTestKit.shutdownActorSystem(system);
+    public void tearDown() {
+        TestKit.shutdownActorSystem(system);
     }
 
     @Test
-    public void testResolveShardForPath() throws Exception {
-        Assert.assertEquals(0L, behavior.resolveShardForPath(YangInstanceIdentifier.EMPTY).longValue());
+    public void testResolveShardForPath() {
+        Assert.assertEquals(0L, behavior.resolveShardForPath(YangInstanceIdentifier.empty()).longValue());
     }
 
     @Test
-    public void testHaltClient() throws Exception {
+    public void testHaltClient() {
         behavior.haltClient(new RuntimeException());
     }
 
     @Test
-    public void testOnCommand() throws Exception {
+    public void testOnCommand() {
         final TestProbe probe = new TestProbe(system);
         final GetClientRequest request = new GetClientRequest(probe.ref());
         final AbstractDataStoreClientBehavior nextBehavior = behavior.onCommand(request);
@@ -89,31 +90,31 @@ public abstract class AbstractDataStoreClientBehaviorTest {
     }
 
     @Test
-    public void testOnCommandUnhandled() throws Exception {
+    public void testOnCommandUnhandled() {
         final AbstractDataStoreClientBehavior nextBehavior = behavior.onCommand("unhandled");
         Assert.assertSame(behavior, nextBehavior);
     }
 
     @Test
-    public void testCreateLocalHistory() throws Exception {
+    public void testCreateLocalHistory() {
         final ClientLocalHistory history = behavior.createLocalHistory();
         Assert.assertEquals(behavior.getIdentifier(), history.getIdentifier().getClientId());
     }
 
     @Test
-    public void testCreateTransaction() throws Exception {
+    public void testCreateTransaction() {
         final ClientTransaction transaction = behavior.createTransaction();
         Assert.assertEquals(behavior.getIdentifier(), transaction.getIdentifier().getHistoryId().getClientId());
     }
 
     @Test
-    public void testCreateSnapshot() throws Exception {
+    public void testCreateSnapshot() {
         final ClientSnapshot snapshot = behavior.createSnapshot();
         Assert.assertEquals(behavior.getIdentifier(), snapshot.getIdentifier().getHistoryId().getClientId());
     }
 
     @Test
-    public void testClose() throws Exception {
+    public void testClose() {
         behavior.close();
         final InternalCommand<ShardBackendInfo> internalCommand =
                 clientActorProbe.expectMsgClass(InternalCommand.class);
@@ -127,15 +128,15 @@ public abstract class AbstractDataStoreClientBehaviorTest {
     }
 
     @Test
-    public void testGetIdentifier() throws Exception {
+    public void testGetIdentifier() {
         Assert.assertEquals(CLIENT_ID, behavior.getIdentifier());
     }
 
     @Test
-    public void testGetConnection() throws Exception {
+    public void testGetConnection() {
         //set up data tree mock
         final CursorAwareDataTreeModification modification = mock(CursorAwareDataTreeModification.class);
-        when(modification.readNode(YangInstanceIdentifier.EMPTY)).thenReturn(com.google.common.base.Optional.absent());
+        when(modification.readNode(YangInstanceIdentifier.empty())).thenReturn(Optional.empty());
         final DataTreeSnapshot snapshot = mock(DataTreeSnapshot.class);
         when(snapshot.newModification()).thenReturn(modification);
         final DataTree dataTree = mock(DataTree.class);
@@ -143,7 +144,7 @@ public abstract class AbstractDataStoreClientBehaviorTest {
 
         final TestProbe backendProbe = new TestProbe(system, "backend");
         final long shard = 0L;
-        behavior.createTransaction().read(YangInstanceIdentifier.EMPTY);
+        behavior.createTransaction().read(YangInstanceIdentifier.empty());
         final AbstractClientConnection<ShardBackendInfo> connection = behavior.getConnection(shard);
         //check cached connection for same shard
         Assert.assertSame(connection, behavior.getConnection(shard));
@@ -159,11 +160,11 @@ public abstract class AbstractDataStoreClientBehaviorTest {
         final InternalCommand<ShardBackendInfo> command = clientActorProbe.expectMsgClass(InternalCommand.class);
         command.execute(behavior);
         //check, whether command was reaplayed
-        verify(modification).readNode(YangInstanceIdentifier.EMPTY);
+        verify(modification).readNode(YangInstanceIdentifier.empty());
     }
 
-    private static ActorContext createActorContextMock(final ActorSystem system, final ActorRef actor) {
-        final ActorContext mock = mock(ActorContext.class);
+    private static ActorUtils createActorContextMock(final ActorSystem system, final ActorRef actor) {
+        final ActorUtils mock = mock(ActorUtils.class);
         final Promise<PrimaryShardInfo> promise = new scala.concurrent.impl.Promise.DefaultPromise<>();
         final ActorSelection selection = system.actorSelection(actor.path());
         final PrimaryShardInfo shardInfo = new PrimaryShardInfo(selection, (short) 0);