Fix test warnings 23/57623/4
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 22 May 2017 11:14:05 +0000 (13:14 +0200)
committerStephen Kitt <skitt@redhat.com>
Mon, 22 May 2017 15:49:30 +0000 (15:49 +0000)
This fixes most raw type warnings.

Change-Id: Iaec02aa9f40df6d04b9f1bfa7045c84b6cc40a53
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
20 files changed:
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/AbstractLocalTransactionRequestTest.java
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/AbstractReadTransactionRequestTest.java
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/AbstractRequestFailureTest.java
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/AbstractRequestSuccessTest.java
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/AbstractTransactionRequestTest.java
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/AbstractTransactionSuccessTest.java
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/concepts/AbstractRequestTest.java
opendaylight/md-sal/cds-access-client/src/test/java/org/opendaylight/controller/cluster/access/client/ActorBehaviorTest.java
opendaylight/md-sal/cds-access-client/src/test/java/org/opendaylight/controller/cluster/access/client/ConnectionEntryMatcher.java
opendaylight/md-sal/cds-access-client/src/test/java/org/opendaylight/controller/cluster/access/client/HaltedTransmitQueueTest.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/DistributedShardedDOMDataTree.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/PrefixedShardConfigWriter.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/actors/dds/AbstractClientHandleTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/actors/dds/AbstractProxyTransactionTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/actors/dds/LocalProxyTransactionTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/actors/dds/LocalReadWriteProxyTransactionTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/actors/dds/TestUtils.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/actors/dds/TransactionTester.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/IntegrationTestKit.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/messages/DatastoreSnapshotListTest.java

index 1355829c7d70b76f47accbd5b14b8ec0e5105e6e..e40a39450b78c7b5462cae45b2cf9407c369a9cc 100644 (file)
@@ -12,7 +12,7 @@ import org.junit.Assert;
 import org.junit.Test;
 import org.opendaylight.controller.cluster.access.ABIVersion;
 
 import org.junit.Test;
 import org.opendaylight.controller.cluster.access.ABIVersion;
 
-public abstract class AbstractLocalTransactionRequestTest<T extends AbstractLocalTransactionRequest<?>>
+public abstract class AbstractLocalTransactionRequestTest<T extends AbstractLocalTransactionRequest<T>>
         extends AbstractTransactionRequestTest<T> {
     @Override
     protected abstract T object();
         extends AbstractTransactionRequestTest<T> {
     @Override
     protected abstract T object();
index c1c7db1e8cf96b7763857866aa52efb33a2f85a9..d769cbf04e5db960d2fb1c05131dcdca5fe64e0b 100644 (file)
@@ -12,7 +12,7 @@ import org.junit.Assert;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 
-public abstract class AbstractReadTransactionRequestTest<T extends AbstractReadTransactionRequest<?>>
+public abstract class AbstractReadTransactionRequestTest<T extends AbstractReadTransactionRequest<T>>
         extends AbstractTransactionRequestTest<T> {
     protected static final YangInstanceIdentifier PATH = YangInstanceIdentifier.EMPTY;
     protected static final boolean SNAPSHOT_ONLY = true;
         extends AbstractTransactionRequestTest<T> {
     protected static final YangInstanceIdentifier PATH = YangInstanceIdentifier.EMPTY;
     protected static final boolean SNAPSHOT_ONLY = true;
index 9e3cf090032395589d57a45c61fb067f15fdd662..a91828bc3d69b7f9b11051e87d21e8c066f64430 100644 (file)
@@ -20,7 +20,7 @@ import org.opendaylight.controller.cluster.access.concepts.RequestFailure;
 import org.opendaylight.controller.cluster.access.concepts.RuntimeRequestException;
 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
 
 import org.opendaylight.controller.cluster.access.concepts.RuntimeRequestException;
 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
 
-public abstract class AbstractRequestFailureTest<T extends RequestFailure<?, ?>> {
+public abstract class AbstractRequestFailureTest<T extends RequestFailure<?, T>> {
     private static final FrontendIdentifier FRONTEND_IDENTIFIER = FrontendIdentifier.create(
             MemberName.forName("member"), FrontendType.forName("frontend"));
 
     private static final FrontendIdentifier FRONTEND_IDENTIFIER = FrontendIdentifier.create(
             MemberName.forName("member"), FrontendType.forName("frontend"));
 
index 8cafe9133a2934445dadcb912ad80e73ba3b2141..8a812522336588517faff0a1a490196a1c46c077 100644 (file)
@@ -17,7 +17,7 @@ import org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifie
 import org.opendaylight.controller.cluster.access.concepts.MemberName;
 import org.opendaylight.controller.cluster.access.concepts.RequestSuccess;
 
 import org.opendaylight.controller.cluster.access.concepts.MemberName;
 import org.opendaylight.controller.cluster.access.concepts.RequestSuccess;
 
-public abstract class AbstractRequestSuccessTest<T extends RequestSuccess<?, ?>> {
+public abstract class AbstractRequestSuccessTest<T extends RequestSuccess<?, T>> {
 
     private static final FrontendIdentifier FRONTEND_IDENTIFIER = FrontendIdentifier.create(
             MemberName.forName("test"), FrontendType.forName("one"));
 
     private static final FrontendIdentifier FRONTEND_IDENTIFIER = FrontendIdentifier.create(
             MemberName.forName("test"), FrontendType.forName("one"));
index f53d11cf555a40ae08885d0f8b18035b6b06af60..58d24e4e53838a2c19b674a9251d32fd86cfa245 100644 (file)
@@ -19,7 +19,7 @@ import org.opendaylight.controller.cluster.access.concepts.RequestException;
 import org.opendaylight.controller.cluster.access.concepts.RuntimeRequestException;
 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
 
 import org.opendaylight.controller.cluster.access.concepts.RuntimeRequestException;
 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
 
-public abstract class AbstractTransactionRequestTest<T extends TransactionRequest<?>>
+public abstract class AbstractTransactionRequestTest<T extends TransactionRequest<T>>
         extends AbstractRequestTest<T> {
     private static final FrontendIdentifier FRONTEND_IDENTIFIER = FrontendIdentifier.create(
             MemberName.forName("test"), FrontendType.forName("one"));
         extends AbstractRequestTest<T> {
     private static final FrontendIdentifier FRONTEND_IDENTIFIER = FrontendIdentifier.create(
             MemberName.forName("test"), FrontendType.forName("one"));
index 149844bd62870a73b69fd9e162ab1113664aa820..08c9abb3af1d6905b904c74e03be822bde2e0cfd 100644 (file)
@@ -9,7 +9,7 @@ package org.opendaylight.controller.cluster.access.commands;
 
 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
 
 
 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
 
-public abstract class AbstractTransactionSuccessTest<T extends TransactionSuccess<?>>
+public abstract class AbstractTransactionSuccessTest<T extends TransactionSuccess<T>>
         extends AbstractRequestSuccessTest<T> {
 
     protected static final TransactionIdentifier TRANSACTION_IDENTIFIER = new TransactionIdentifier(
         extends AbstractRequestSuccessTest<T> {
 
     protected static final TransactionIdentifier TRANSACTION_IDENTIFIER = new TransactionIdentifier(
index d4378e9fd6072825c14f1d57f8f7a61cf78a5af9..c65c1956c2a9ee1c12dae42760cbc41db6223665 100644 (file)
@@ -18,7 +18,7 @@ import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 
 import org.junit.Before;
 import org.junit.Test;
 
-public abstract class AbstractRequestTest<T extends Request<?, ?>> {
+public abstract class AbstractRequestTest<T extends Request<?, T>> {
     private static final ActorSystem SYSTEM = ActorSystem.create("test");
     protected static final ActorRef ACTOR_REF = TestProbe.apply(SYSTEM).ref();
 
     private static final ActorSystem SYSTEM = ActorSystem.create("test");
     protected static final ActorRef ACTOR_REF = TestProbe.apply(SYSTEM).ref();
 
index b0a6011222d147d7a4c380e6058112800079862d..7431813010bcf633f4002805882254fa0cfad21d 100644 (file)
@@ -144,7 +144,7 @@ public class ActorBehaviorTest {
     }
 
     @SuppressWarnings("unchecked")
     }
 
     @SuppressWarnings("unchecked")
-    private ClientActorBehavior<BackendInfo> createInitialBehaviorMock() throws Exception {
+    private static ClientActorBehavior<BackendInfo> createInitialBehaviorMock() throws Exception {
         final ClientActorBehavior<BackendInfo> initialBehavior = mock(ClientActorBehavior.class);
         //persistenceId() in AbstractClientActorBehavior is final and can't be mocked
         //use reflection to work around this
         final ClientActorBehavior<BackendInfo> initialBehavior = mock(ClientActorBehavior.class);
         //persistenceId() in AbstractClientActorBehavior is final and can't be mocked
         //use reflection to work around this
@@ -173,13 +173,13 @@ public class ActorBehaviorTest {
 
     private static class MockedActor extends AbstractClientActor {
 
 
     private static class MockedActor extends AbstractClientActor {
 
-        private final ClientActorBehavior initialBehavior;
+        private final ClientActorBehavior<?> initialBehavior;
 
 
-        private static Props props(final FrontendIdentifier frontendId, final ClientActorBehavior initialBehavior) {
+        private static Props props(final FrontendIdentifier frontendId, final ClientActorBehavior<?> initialBehavior) {
             return Props.create(MockedActor.class, () -> new MockedActor(frontendId, initialBehavior));
         }
 
             return Props.create(MockedActor.class, () -> new MockedActor(frontendId, initialBehavior));
         }
 
-        private MockedActor(final FrontendIdentifier frontendId, final ClientActorBehavior initialBehavior) {
+        private MockedActor(final FrontendIdentifier frontendId, final ClientActorBehavior<?> initialBehavior) {
             super(frontendId);
             this.initialBehavior = initialBehavior;
         }
             super(frontendId);
             this.initialBehavior = initialBehavior;
         }
index d2d2fd8bd9a4c9238f0fa9cdbe34562ce32d2343..7f40dc1b37d82c6a3b6e646d493450a7cba1307d 100644 (file)
@@ -16,7 +16,7 @@ import org.opendaylight.controller.cluster.access.concepts.Request;
  */
 class ConnectionEntryMatcher extends BaseMatcher<ConnectionEntry> {
 
  */
 class ConnectionEntryMatcher extends BaseMatcher<ConnectionEntry> {
 
-    private final Request request;
+    private final Request<?, ?> request;
 
     /**
      * Creates a matcher that matches if the examined {@link ConnectionEntry} contains specified request.
 
     /**
      * Creates a matcher that matches if the examined {@link ConnectionEntry} contains specified request.
@@ -28,7 +28,7 @@ class ConnectionEntryMatcher extends BaseMatcher<ConnectionEntry> {
         return new ConnectionEntryMatcher(request);
     }
 
         return new ConnectionEntryMatcher(request);
     }
 
-    private ConnectionEntryMatcher(final Request request) {
+    private ConnectionEntryMatcher(final Request<?, ?> request) {
         this.request = request;
     }
 
         this.request = request;
     }
 
index 80394001a87378c6103bc8afbfe8b61af7cfdb33..4251c87f595338f9427b34c7a4f3624beff9da6c 100644 (file)
@@ -36,7 +36,7 @@ public class HaltedTransmitQueueTest extends AbstractTransmitQueueTest<TransmitQ
     @Test(expected = UnsupportedOperationException.class)
     @Override
     public void testTransmit() throws Exception {
     @Test(expected = UnsupportedOperationException.class)
     @Override
     public void testTransmit() throws Exception {
-        final Request request = new TransactionPurgeRequest(TRANSACTION_IDENTIFIER, 0L, probe.ref());
+        final Request<?, ?> request = new TransactionPurgeRequest(TRANSACTION_IDENTIFIER, 0L, probe.ref());
         final Consumer<Response<?, ?>> callback = createConsumerMock();
         final long now = Ticker.systemTicker().read();
         final ConnectionEntry entry = new ConnectionEntry(request, callback, now);
         final Consumer<Response<?, ?>> callback = createConsumerMock();
         final long now = Ticker.systemTicker().read();
         final ConnectionEntry entry = new ConnectionEntry(request, callback, now);
index 4ffc575c1afcf08ec4d5c35101999b90c61af502..35f5e998825951829be49b5e57e36a0ce3615cd4 100644 (file)
@@ -161,7 +161,7 @@ public class DistributedShardedDOMDataTree implements DOMDataTreeService, DOMDat
         createPrefixConfigShard(distributedOperDatastore);
     }
 
         createPrefixConfigShard(distributedOperDatastore);
     }
 
-    private void createPrefixConfigShard(final AbstractDataStore dataStore) {
+    private static void createPrefixConfigShard(final AbstractDataStore dataStore) {
         Configuration configuration = dataStore.getActorContext().getConfiguration();
         Collection<MemberName> memberNames = configuration.getUniqueMemberNamesForAllShards();
         CreateShard createShardMessage =
         Configuration configuration = dataStore.getActorContext().getConfiguration();
         Collection<MemberName> memberNames = configuration.getUniqueMemberNamesForAllShards();
         CreateShard createShardMessage =
@@ -451,12 +451,12 @@ public class DistributedShardedDOMDataTree implements DOMDataTreeService, DOMDat
 
         Futures.addCallback(future, new FutureCallback<Void>() {
             @Override
 
         Futures.addCallback(future, new FutureCallback<Void>() {
             @Override
-            public void onSuccess(@Nullable Void result) {
+            public void onSuccess(@Nullable final Void result) {
                 LOG.debug("{} - Succesfuly removed shard for {}", memberName, prefix);
             }
 
             @Override
                 LOG.debug("{} - Succesfuly removed shard for {}", memberName, prefix);
             }
 
             @Override
-            public void onFailure(Throwable throwable) {
+            public void onFailure(final Throwable throwable) {
                 LOG.error("Removal of shard {} from configuration failed.", prefix, throwable);
             }
         });
                 LOG.error("Removal of shard {} from configuration failed.", prefix, throwable);
             }
         });
index b0507f6383da8e24b7c936432fa06f588a6e414e..f6e4d37857b859bd1c92a94117dec32f294b1589 100644 (file)
@@ -88,7 +88,7 @@ class PrefixedShardConfigWriter {
         submitBlocking(cohort);
     }
 
         submitBlocking(cohort);
     }
 
-    private void submitBlocking(final DOMStoreThreePhaseCommitCohort cohort) {
+    private static void submitBlocking(final DOMStoreThreePhaseCommitCohort cohort) {
         try {
             doSubmit(cohort).get();
         } catch (final InterruptedException | ExecutionException e) {
         try {
             doSubmit(cohort).get();
         } catch (final InterruptedException | ExecutionException e) {
@@ -96,7 +96,7 @@ class PrefixedShardConfigWriter {
         }
     }
 
         }
     }
 
-    private ListenableFuture<Void> doSubmit(final DOMStoreThreePhaseCommitCohort cohort) {
+    private static ListenableFuture<Void> doSubmit(final DOMStoreThreePhaseCommitCohort cohort) {
         final AsyncFunction<Boolean, Void> validateFunction = input -> cohort.preCommit();
         final AsyncFunction<Void, Void> prepareFunction = input -> cohort.commit();
 
         final AsyncFunction<Boolean, Void> validateFunction = input -> cohort.preCommit();
         final AsyncFunction<Void, Void> prepareFunction = input -> cohort.commit();
 
index 6e9305aba9f9ac2a1ab451061463e1b131f74b59..ade447eed8776e4c2c04927d7651be5bbe50000b 100644 (file)
@@ -170,7 +170,7 @@ public abstract class AbstractClientHandleTest<T extends AbstractClientHandle<Ab
      * @param <R>                  expected request type
      * @return request message
      */
      * @param <R>                  expected request type
      * @return request message
      */
-    protected <R extends Request<?, ?>> R backendRespondToRequest(final Class<R> expectedRequestClass,
+    protected <R extends Request<?, R>> R backendRespondToRequest(final Class<R> expectedRequestClass,
                                                             final Response<?, ?> response) {
         final RequestEnvelope envelope = backendProbe.expectMsgClass(RequestEnvelope.class);
         Assert.assertEquals(expectedRequestClass, envelope.getMessage().getClass());
                                                             final Response<?, ?> response) {
         final RequestEnvelope envelope = backendProbe.expectMsgClass(RequestEnvelope.class);
         Assert.assertEquals(expectedRequestClass, envelope.getMessage().getClass());
@@ -208,4 +208,4 @@ public abstract class AbstractClientHandleTest<T extends AbstractClientHandle<Ab
         return mock;
     }
 
         return mock;
     }
 
-}
\ No newline at end of file
+}
index 9db19077e776e8817c77a631b39c49eb25a62a16..dfbd11fc1e2d37cfbf213a2298de075d2d2ffbb4 100644 (file)
@@ -220,10 +220,9 @@ public abstract class AbstractProxyTransactionTest<T extends AbstractProxyTransa
         Assert.assertThat(modifications, hasItem(both(isA(TransactionDelete.class)).and(hasPath(PATH_3))));
     }
 
         Assert.assertThat(modifications, hasItem(both(isA(TransactionDelete.class)).and(hasPath(PATH_3))));
     }
 
-    protected void testRequestResponse(final Consumer<VotingFuture<Void>> consumer,
-            final Class<? extends TransactionRequest<?>> expectedRequest,
-                    final BiFunction<TransactionIdentifier, Long, TransactionSuccess<?>> replySupplier)
-            throws Exception {
+    protected <R extends TransactionRequest<R>> void testRequestResponse(final Consumer<VotingFuture<Void>> consumer,
+            final Class<R> expectedRequest,
+            final BiFunction<TransactionIdentifier, Long, TransactionSuccess<?>> replySupplier) throws Exception {
         final TransactionTester<T> tester = getTester();
         final VotingFuture<Void> future = mock(VotingFuture.class);
         transaction.seal();
         final TransactionTester<T> tester = getTester();
         final VotingFuture<Void> future = mock(VotingFuture.class);
         transaction.seal();
@@ -233,18 +232,18 @@ public abstract class AbstractProxyTransactionTest<T extends AbstractProxyTransa
         verify(future).voteYes();
     }
 
         verify(future).voteYes();
     }
 
-    protected <T extends TransactionRequest<?>> T testHandleForwardedRemoteRequest(final T request) throws Exception {
+    protected <R extends TransactionRequest<R>> R testHandleForwardedRemoteRequest(final R request) throws Exception {
         transaction.handleReplayedRemoteRequest(request, createCallbackMock(), Ticker.systemTicker().read());
         final RequestEnvelope envelope = backendProbe.expectMsgClass(RequestEnvelope.class);
         transaction.handleReplayedRemoteRequest(request, createCallbackMock(), Ticker.systemTicker().read());
         final RequestEnvelope envelope = backendProbe.expectMsgClass(RequestEnvelope.class);
-        final T received = (T) envelope.getMessage();
+        final R received = (R) envelope.getMessage();
         Assert.assertTrue(received.getClass().equals(request.getClass()));
         Assert.assertEquals(TRANSACTION_ID, received.getTarget());
         Assert.assertEquals(clientContextProbe.ref(), received.getReplyTo());
         return received;
     }
 
         Assert.assertTrue(received.getClass().equals(request.getClass()));
         Assert.assertEquals(TRANSACTION_ID, received.getTarget());
         Assert.assertEquals(clientContextProbe.ref(), received.getReplyTo());
         return received;
     }
 
-    protected <T extends TransactionRequest<?>> T testForwardToRemote(final TransactionRequest<?> toForward,
-                                                                   final Class<T> expectedMessageClass) {
+    protected <R extends TransactionRequest<R>> R testForwardToRemote(final TransactionRequest<?> toForward,
+            final Class<R> expectedMessageClass) {
         final Consumer<Response<?, ?>> callback = createCallbackMock();
         final TransactionTester<RemoteProxyTransaction> transactionTester = createRemoteProxyTransactionTester();
         final RemoteProxyTransaction successor = transactionTester.getTransaction();
         final Consumer<Response<?, ?>> callback = createCallbackMock();
         final TransactionTester<RemoteProxyTransaction> transactionTester = createRemoteProxyTransactionTester();
         final RemoteProxyTransaction successor = transactionTester.getTransaction();
index dccdf9ef704a4dc6cfde283bf3592e78476c3251..3cf1b03493b2085bdf501a38127bac08e602cf70 100644 (file)
@@ -114,7 +114,7 @@ public abstract class LocalProxyTransactionTest<T extends LocalProxyTransaction>
         final CursorAwareDataTreeModification modification = mock(CursorAwareDataTreeModification.class);
         final CommitLocalTransactionRequest request =
                 new CommitLocalTransactionRequest(TRANSACTION_ID, 0L, probe.ref(), modification, null, true);
         final CursorAwareDataTreeModification modification = mock(CursorAwareDataTreeModification.class);
         final CommitLocalTransactionRequest request =
                 new CommitLocalTransactionRequest(TRANSACTION_ID, 0L, probe.ref(), modification, null, true);
-        doAnswer(this::applyToCursorAnswer).when(modification).applyToCursor(any());
+        doAnswer(LocalProxyTransactionTest::applyToCursorAnswer).when(modification).applyToCursor(any());
         final ModifyTransactionRequest modifyRequest = testForwardToRemote(request, ModifyTransactionRequest.class);
         verify(modification).applyToCursor(any());
         Assert.assertTrue(modifyRequest.getPersistenceProtocol().isPresent());
         final ModifyTransactionRequest modifyRequest = testForwardToRemote(request, ModifyTransactionRequest.class);
         verify(modification).applyToCursor(any());
         Assert.assertTrue(modifyRequest.getPersistenceProtocol().isPresent());
@@ -136,8 +136,8 @@ public abstract class LocalProxyTransactionTest<T extends LocalProxyTransaction>
         testForwardToLocal(request, TransactionPurgeRequest.class);
     }
 
         testForwardToLocal(request, TransactionPurgeRequest.class);
     }
 
-    protected <T extends TransactionRequest<?>> T testForwardToLocal(final TransactionRequest<?> toForward,
-                                                                  final Class<T> expectedMessageClass) {
+    protected <R extends TransactionRequest<R>> R testForwardToLocal(final TransactionRequest<?> toForward,
+                                                                  final Class<R> expectedMessageClass) {
         final Consumer<Response<?, ?>> callback = createCallbackMock();
         final TransactionTester<LocalReadWriteProxyTransaction> transactionTester = createLocalProxy();
         final LocalReadWriteProxyTransaction successor = transactionTester.getTransaction();
         final Consumer<Response<?, ?>> callback = createCallbackMock();
         final TransactionTester<LocalReadWriteProxyTransaction> transactionTester = createLocalProxy();
         final LocalReadWriteProxyTransaction successor = transactionTester.getTransaction();
@@ -152,7 +152,7 @@ public abstract class LocalProxyTransactionTest<T extends LocalProxyTransaction>
      * @param invocation invocation
      * @return void - always null
      */
      * @param invocation invocation
      * @return void - always null
      */
-    protected Answer<?> applyToCursorAnswer(final InvocationOnMock invocation) {
+    protected static final <T> Answer<T> applyToCursorAnswer(final InvocationOnMock invocation) {
         final DataTreeModificationCursor cursor =
                 invocation.getArgumentAt(0, DataTreeModificationCursor.class);
         cursor.write(PATH_1.getLastPathArgument(), DATA_1);
         final DataTreeModificationCursor cursor =
                 invocation.getArgumentAt(0, DataTreeModificationCursor.class);
         cursor.write(PATH_1.getLastPathArgument(), DATA_1);
@@ -161,4 +161,4 @@ public abstract class LocalProxyTransactionTest<T extends LocalProxyTransaction>
         return null;
     }
 
         return null;
     }
 
-}
\ No newline at end of file
+}
index 7eebfe02cad234c588aa2b3e000cc8f10bf3de34..7f1508d4d4e347bca4fed333c04a62e595b9437e 100644 (file)
@@ -147,7 +147,7 @@ public class LocalReadWriteProxyTransactionTest extends LocalProxyTransactionTes
     public void testFlushState() throws Exception {
         final TransactionTester<RemoteProxyTransaction> transactionTester = createRemoteProxyTransactionTester();
         final RemoteProxyTransaction successor = transactionTester.getTransaction();
     public void testFlushState() throws Exception {
         final TransactionTester<RemoteProxyTransaction> transactionTester = createRemoteProxyTransactionTester();
         final RemoteProxyTransaction successor = transactionTester.getTransaction();
-        doAnswer(this::applyToCursorAnswer).when(modification).applyToCursor(any());
+        doAnswer(LocalProxyTransactionTest::applyToCursorAnswer).when(modification).applyToCursor(any());
         transaction.doSeal();
         transaction.flushState(successor);
         verify(modification).applyToCursor(any());
         transaction.doSeal();
         transaction.flushState(successor);
         verify(modification).applyToCursor(any());
index 4c82357d93cfb5ddc99bcc1e0c7ccca898737428..977ada54e63f7e47640d5a98e7d08b19676efb57 100644 (file)
@@ -79,7 +79,7 @@ class TestUtils {
             if (!e.getClass().equals(expectedException)) {
                 throw e;
             }
             if (!e.getClass().equals(expectedException)) {
                 throw e;
             }
-            return (T) e;
+            return expectedException.cast(e);
         }
     }
 
         }
     }
 
index b3fb51d4582e4ea6e76a4a224041508e756c1cbd..c0ce5391448813748628d97e741a45877c4c0a66 100644 (file)
@@ -55,7 +55,7 @@ class TransactionTester<T extends AbstractProxyTransaction> {
         return (TransactionRequest<?>) envelope.getMessage();
     }
 
         return (TransactionRequest<?>) envelope.getMessage();
     }
 
-    <R extends TransactionRequest<?>> R expectTransactionRequest(final Class<R> expected) {
+    <R extends TransactionRequest<R>> R expectTransactionRequest(final Class<R> expected) {
         envelope = backendProbe.expectMsgClass(RequestEnvelope.class);
         final Class<?> actual = envelope.getMessage().getClass();
         final String errorMsg = String.format("Expected instance of %s, received %s", expected, actual);
         envelope = backendProbe.expectMsgClass(RequestEnvelope.class);
         final Class<?> actual = envelope.getMessage().getClass();
         final String errorMsg = String.format("Expected instance of %s, received %s", expected, actual);
index 1c4bfcfbb23dcf2d23faccdb6492d7f328656bf3..a9179299f70366bd21c079d667d9881df83327c5 100644 (file)
@@ -64,7 +64,8 @@ public class IntegrationTestKit extends ShardTestKit {
         this(actorSystem, datastoreContextBuilder, 7);
     }
 
         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;
         super(actorSystem);
         this.datastoreContextBuilder = datastoreContextBuilder;
         this.commitTimeout = commitTimeout;
@@ -139,8 +140,8 @@ public class IntegrationTestKit extends ShardTestKit {
                 ActorSystem.class, ClusterWrapper.class, Configuration.class,
                 DatastoreContextFactory.class, DatastoreSnapshot.class);
 
                 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);
 
 
         dataStore.onGlobalContextUpdated(schemaContext);
 
@@ -152,7 +153,7 @@ public class IntegrationTestKit extends ShardTestKit {
         return dataStore;
     }
 
         return dataStore;
     }
 
-    private void setDataStoreName(String typeName) {
+    private void setDataStoreName(final String typeName) {
         if ("config".equals(typeName)) {
             datastoreContextBuilder.logicalStoreType(LogicalDatastoreType.CONFIGURATION);
         } else if ("operational".equals(typeName)) {
         if ("config".equals(typeName)) {
             datastoreContextBuilder.logicalStoreType(LogicalDatastoreType.CONFIGURATION);
         } else if ("operational".equals(typeName)) {
index 7ae0b1c4985c735411ac5fcf975d05a57185d9e2..021a60fbaf80411df0b94dde63c21395814b6297 100644 (file)
@@ -84,10 +84,10 @@ public class DatastoreSnapshotListTest {
     }
 
     @SuppressWarnings("unchecked")
     }
 
     @SuppressWarnings("unchecked")
-    private void assertDatastoreSnapshotEquals(DatastoreSnapshot legacy,
-            org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot actual,
-            org.opendaylight.controller.cluster.datastore.persisted.ShardManagerSnapshot expShardMgrSnapshot,
-            Optional<NormalizedNode<?, ?>>... shardRoots) throws IOException {
+    private static void assertDatastoreSnapshotEquals(final DatastoreSnapshot legacy,
+            final org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot actual,
+            final org.opendaylight.controller.cluster.datastore.persisted.ShardManagerSnapshot expShardMgrSnapshot,
+            final Optional<NormalizedNode<?, ?>>... shardRoots) throws IOException {
         assertEquals("Type", legacy.getType(), actual.getType());
 
         if (legacy.getShardManagerSnapshot() == null) {
         assertEquals("Type", legacy.getType(), actual.getType());
 
         if (legacy.getShardManagerSnapshot() == null) {
@@ -112,8 +112,8 @@ public class DatastoreSnapshotListTest {
         }
     }
 
         }
     }
 
-    private static void assertSnapshotEquals(Snapshot expected, Optional<NormalizedNode<?, ?>> expRoot,
-            org.opendaylight.controller.cluster.raft.persisted.Snapshot actual) throws IOException {
+    private static void assertSnapshotEquals(final Snapshot expected, final Optional<NormalizedNode<?, ?>> expRoot,
+            final org.opendaylight.controller.cluster.raft.persisted.Snapshot actual) throws IOException {
         assertEquals("lastIndex", expected.getLastIndex(), actual.getLastIndex());
         assertEquals("lastTerm", expected.getLastTerm(), actual.getLastTerm());
         assertEquals("lastAppliedIndex", expected.getLastAppliedIndex(), actual.getLastAppliedIndex());
         assertEquals("lastIndex", expected.getLastIndex(), actual.getLastIndex());
         assertEquals("lastTerm", expected.getLastTerm(), actual.getLastTerm());
         assertEquals("lastAppliedIndex", expected.getLastAppliedIndex(), actual.getLastAppliedIndex());
@@ -132,16 +132,16 @@ public class DatastoreSnapshotListTest {
         }
     }
 
         }
     }
 
-    private static ShardManagerSnapshot newLegacyShardManagerSnapshot(String... shards) {
+    private static ShardManagerSnapshot newLegacyShardManagerSnapshot(final String... shards) {
         return ShardManagerSnapshot.forShardList(Arrays.asList(shards));
     }
 
         return ShardManagerSnapshot.forShardList(Arrays.asList(shards));
     }
 
-    private static DatastoreSnapshot.ShardSnapshot newLegacyShardSnapshot(String name,
-            org.opendaylight.controller.cluster.raft.Snapshot snapshot) {
+    private static DatastoreSnapshot.ShardSnapshot newLegacyShardSnapshot(final String name,
+            final org.opendaylight.controller.cluster.raft.Snapshot snapshot) {
         return new DatastoreSnapshot.ShardSnapshot(name, SerializationUtils.serialize(snapshot));
     }
 
         return new DatastoreSnapshot.ShardSnapshot(name, SerializationUtils.serialize(snapshot));
     }
 
-    private static Snapshot newLegacySnapshot(NormalizedNode<?, ?> root)
+    private static Snapshot newLegacySnapshot(final NormalizedNode<?, ?> root)
             throws Exception {
         final ByteArrayOutputStream bos = new ByteArrayOutputStream();
         if (root != null) {
             throws Exception {
         final ByteArrayOutputStream bos = new ByteArrayOutputStream();
         if (root != null) {
@@ -158,7 +158,7 @@ public class DatastoreSnapshotListTest {
                 "member-1", null);
     }
 
                 "member-1", null);
     }
 
-    private static NormalizedNode<?, ?> toRootNode(YangInstanceIdentifier path, NormalizedNode<?, ?> node)
+    private static NormalizedNode<?, ?> toRootNode(final YangInstanceIdentifier path, final NormalizedNode<?, ?> node)
             throws DataValidationFailedException {
         DataTree dataTree = InMemoryDataTreeFactory.getInstance().create(TreeType.OPERATIONAL);
         dataTree.setSchemaContext(SchemaContextHelper.full());
             throws DataValidationFailedException {
         DataTree dataTree = InMemoryDataTreeFactory.getInstance().create(TreeType.OPERATIONAL);
         dataTree.setSchemaContext(SchemaContextHelper.full());