Remove unused exceptions
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / cluster / databroker / actors / dds / AbstractDataStoreClientBehaviorTest.java
index 7ababb8ca894cc50c9f4b93e9a72b46b08bbad6d..b6a11561b0b946ce06e9ceaa2d2cd41f2d65e333 100644 (file)
@@ -10,14 +10,16 @@ package org.opendaylight.controller.cluster.databroker.actors.dds;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
+import static org.opendaylight.controller.cluster.databroker.actors.dds.TestUtils.CLIENT_ID;
 
 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;
@@ -28,10 +30,6 @@ import org.opendaylight.controller.cluster.access.client.ClientActorContext;
 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.access.concepts.ClientIdentifier;
-import org.opendaylight.controller.cluster.access.concepts.FrontendIdentifier;
-import org.opendaylight.controller.cluster.access.concepts.FrontendType;
-import org.opendaylight.controller.cluster.access.concepts.MemberName;
 import org.opendaylight.controller.cluster.datastore.messages.PrimaryShardInfo;
 import org.opendaylight.controller.cluster.datastore.utils.ActorContext;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
@@ -43,10 +41,6 @@ import scala.concurrent.Promise;
 public abstract class AbstractDataStoreClientBehaviorTest {
 
     protected static final String SHARD = "default";
-    private static final MemberName MEMBER_NAME = MemberName.forName("member-1");
-    private static final FrontendType FRONTEND_TYPE = FrontendType.forName("type-1");
-    private static final FrontendIdentifier FRONTEND_ID = FrontendIdentifier.create(MEMBER_NAME, FRONTEND_TYPE);
-    private static final ClientIdentifier CLIENT_ID = ClientIdentifier.create(FRONTEND_ID, 0);
     private static final String PERSISTENCE_ID = "per-1";
 
     private ActorSystem system;
@@ -56,7 +50,7 @@ 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");
@@ -66,26 +60,27 @@ public abstract class AbstractDataStoreClientBehaviorTest {
         behavior = createBehavior(clientContext, context);
     }
 
+    @SuppressWarnings("checkstyle:hiddenField")
     protected abstract AbstractDataStoreClientBehavior createBehavior(ClientActorContext clientContext,
                                                                       ActorContext context);
 
     @After
-    public void tearDown() throws Exception {
-        JavaTestKit.shutdownActorSystem(system);
+    public void tearDown() {
+        TestKit.shutdownActorSystem(system);
     }
 
     @Test
-    public void testResolveShardForPath() throws Exception {
+    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);
@@ -95,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);
@@ -133,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);
@@ -178,4 +173,4 @@ public abstract class AbstractDataStoreClientBehaviorTest {
         return mock;
     }
 
-}
\ No newline at end of file
+}