Fix warnings in tests 17/54617/7
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 10 Apr 2017 18:12:47 +0000 (20:12 +0200)
committerTom Pantelis <tompantelis@gmail.com>
Tue, 18 Apr 2017 11:12:50 +0000 (11:12 +0000)
This fixes up initialization failures and use of raw classes where
possible.

Change-Id: Icfa9bd0a08a6dd838d794c509612f711099ea0fe
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
22 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/AbstractEnvelopeTest.java
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/concepts/AbstractRequestTest.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/ShardManagerSnapshot.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/DistributedShardFrontend.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/ClientBackedReadTransactionTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/ClientBackedReadWriteTransactionTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/ClientBackedWriteTransactionTest.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/AbstractClientHistoryTest.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/ClientTransactionCommitCohortTest.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/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/persisted/AbstractIdentifiablePayloadTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/sharding/CDSShardAccessImplTest.java

index 2696767..1355829 100644 (file)
@@ -12,8 +12,8 @@ import org.junit.Assert;
 import org.junit.Test;
 import org.opendaylight.controller.cluster.access.ABIVersion;
 
-public abstract class AbstractLocalTransactionRequestTest<T extends AbstractLocalTransactionRequest>
-        extends AbstractTransactionRequestTest {
+public abstract class AbstractLocalTransactionRequestTest<T extends AbstractLocalTransactionRequest<?>>
+        extends AbstractTransactionRequestTest<T> {
     @Override
     protected abstract T object();
 
index 376e13f..c1c7db1 100644 (file)
@@ -12,8 +12,8 @@ import org.junit.Assert;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 
-public abstract class AbstractReadTransactionRequestTest<T extends AbstractReadTransactionRequest>
-        extends AbstractTransactionRequestTest {
+public abstract class AbstractReadTransactionRequestTest<T extends AbstractReadTransactionRequest<?>>
+        extends AbstractTransactionRequestTest<T> {
     protected static final YangInstanceIdentifier PATH = YangInstanceIdentifier.EMPTY;
     protected static final boolean SNAPSHOT_ONLY = true;
 
index 69c9ea2..9e3cf09 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;
 
-public abstract class AbstractRequestFailureTest<T extends RequestFailure> {
+public abstract class AbstractRequestFailureTest<T extends RequestFailure<?, ?>> {
     private static final FrontendIdentifier FRONTEND_IDENTIFIER = FrontendIdentifier.create(
             MemberName.forName("member"), FrontendType.forName("frontend"));
 
index f0bb6f3..34bd2cc 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;
 
-public abstract class AbstractRequestSuccessTest<T extends RequestSuccess> {
+public abstract class AbstractRequestSuccessTest<T extends RequestSuccess<?, ?>> {
 
     private static final FrontendIdentifier FRONTEND_IDENTIFIER = FrontendIdentifier.create(
             MemberName.forName("test"), FrontendType.forName("one"));
@@ -35,7 +35,7 @@ public abstract class AbstractRequestSuccessTest<T extends RequestSuccess> {
         Assert.assertEquals(object().getTarget(), ((T) deserialize).getTarget());
         Assert.assertEquals(object().getVersion(), ((T) deserialize).getVersion());
         Assert.assertEquals(object().getSequence(), ((T) deserialize).getSequence());
-        doAdditionalAssertions((T) deserialize);
+        doAdditionalAssertions(deserialize);
     }
 
     protected abstract void doAdditionalAssertions(final Object deserialize);
index 87a0af1..f53d11c 100644 (file)
@@ -19,8 +19,8 @@ import org.opendaylight.controller.cluster.access.concepts.RequestException;
 import org.opendaylight.controller.cluster.access.concepts.RuntimeRequestException;
 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
 
-public abstract class AbstractTransactionRequestTest<T extends TransactionRequest>
-        extends AbstractRequestTest {
+public abstract class AbstractTransactionRequestTest<T extends TransactionRequest<?>>
+        extends AbstractRequestTest<T> {
     private static final FrontendIdentifier FRONTEND_IDENTIFIER = FrontendIdentifier.create(
             MemberName.forName("test"), FrontendType.forName("one"));
     private static final ClientIdentifier CLIENT_IDENTIFIER = ClientIdentifier.create(FRONTEND_IDENTIFIER, 0);
index de9d9ff..149844b 100644 (file)
@@ -9,8 +9,8 @@ package org.opendaylight.controller.cluster.access.commands;
 
 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
 
-public abstract class AbstractTransactionSuccessTest<T extends TransactionSuccess>
-        extends AbstractRequestSuccessTest {
+public abstract class AbstractTransactionSuccessTest<T extends TransactionSuccess<?>>
+        extends AbstractRequestSuccessTest<T> {
 
     protected static final TransactionIdentifier TRANSACTION_IDENTIFIER = new TransactionIdentifier(
             HISTORY_IDENTIFIER, 0);
index 43746ce..f310549 100644 (file)
@@ -12,7 +12,7 @@ import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 
-public abstract class AbstractEnvelopeTest<E extends Envelope> {
+public abstract class AbstractEnvelopeTest<E extends Envelope<?>> {
     private static final FrontendIdentifier FRONTEND =
             new FrontendIdentifier(MemberName.forName("test"), FrontendIdentifierTest.ONE_FRONTEND_TYPE);
     private static final ClientIdentifier CLIENT = new ClientIdentifier(FRONTEND, 0);
@@ -36,8 +36,8 @@ public abstract class AbstractEnvelopeTest<E extends Envelope> {
     private void checkDeserialized(final E deserializedEnvelope) {
         Assert.assertEquals(envelope.getSessionId(), deserializedEnvelope.getSessionId());
         Assert.assertEquals(envelope.getTxSequence(), deserializedEnvelope.getTxSequence());
-        final Message expectedMessage = envelope.getMessage();
-        final Message actualMessage = deserializedEnvelope.getMessage();
+        final Message<?, ?> expectedMessage = envelope.getMessage();
+        final Message<?, ?> actualMessage = deserializedEnvelope.getMessage();
         Assert.assertEquals(expectedMessage.getSequence(), actualMessage.getSequence());
         Assert.assertEquals(expectedMessage.getTarget(), actualMessage.getTarget());
         Assert.assertEquals(expectedMessage.getVersion(), actualMessage.getVersion());
index 2229aff..31c19f4 100644 (file)
@@ -18,7 +18,7 @@ import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 
-public abstract class AbstractRequestTest<T extends Request> {
+public abstract class AbstractRequestTest<T extends Request<?, ?>> {
     private static final ActorSystem SYSTEM = ActorSystem.create("test");
     protected static final ActorRef ACTOR_REF = TestProbe.apply(SYSTEM).ref();
 
@@ -48,7 +48,7 @@ public abstract class AbstractRequestTest<T extends Request> {
         Assert.assertEquals(object().getTarget(), ((T) deserialize).getTarget());
         Assert.assertEquals(object().getVersion(), ((T) deserialize).getVersion());
         Assert.assertEquals(object().getSequence(), ((T) deserialize).getSequence());
-        doAdditionalAssertions((T) deserialize);
+        doAdditionalAssertions(deserialize);
     }
 
     protected abstract void doAdditionalAssertions(final Object deserialize);
index 9384675..9dc95c0 100644 (file)
@@ -47,21 +47,21 @@ public class ShardManagerSnapshot implements Serializable {
         }
 
         @Override
-        public void writeExternal(ObjectOutput out) throws IOException {
+        public void writeExternal(final ObjectOutput out) throws IOException {
             out.writeInt(snapshot.shardList.size());
             for (String shard: snapshot.shardList) {
                 out.writeObject(shard);
             }
 
             out.writeInt(snapshot.prefixShardConfiguration.size());
-            for (Map.Entry prefixShardConfigEntry : snapshot.prefixShardConfiguration.entrySet()) {
+            for (Map.Entry<?, ?> prefixShardConfigEntry : snapshot.prefixShardConfiguration.entrySet()) {
                 out.writeObject(prefixShardConfigEntry.getKey());
                 out.writeObject(prefixShardConfigEntry.getValue());
             }
         }
 
         @Override
-        public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+        public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
             int size = in.readInt();
             List<String> shardList = new ArrayList<>(size);
             for (int i = 0; i < size; i++) {
index f6060a8..b148b91 100644 (file)
@@ -137,7 +137,6 @@ class DistributedShardFrontend implements ReadableWriteableDOMDataTreeShard {
 
     @Nonnull
     @Override
-    @SuppressWarnings("unchecked")
     public <L extends DOMDataTreeChangeListener> ListenerRegistration<L> registerTreeChangeListener(
             final YangInstanceIdentifier treeId, final L listener) {
         return publisher.registerTreeChangeListener(treeId, listener);
index 92cd99d..ee8280f 100644 (file)
@@ -26,7 +26,7 @@ public class ClientBackedReadTransactionTest extends ClientBackedTransactionTest
     private ClientBackedReadTransaction object;
 
     @Mock
-    private NormalizedNode data;
+    private NormalizedNode<?, ?> data;
     @Mock
     private ClientActorContext clientContext;
     @Mock
@@ -38,7 +38,6 @@ public class ClientBackedReadTransactionTest extends ClientBackedTransactionTest
     }
 
     @Before
-    @SuppressWarnings("unchecked")
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
 
index 3dfaac5..6e9305a 100644 (file)
@@ -86,7 +86,7 @@ public abstract class AbstractClientHandleTest<T extends AbstractClientHandle<Ab
         final long sequence = 0L;
         contextProbe.reply(new ConnectClientSuccess(CLIENT_ID, sequence, backendProbe.ref(),
                 Collections.emptyList(), dataTree, 3));
-        final InternalCommand command = clientContextProbe.expectMsgClass(InternalCommand.class);
+        final InternalCommand<ShardBackendInfo> command = clientContextProbe.expectMsgClass(InternalCommand.class);
         command.execute(client);
         //data tree mock
         when(dataTree.takeSnapshot()).thenReturn(dataTreeSnapshot);
@@ -118,7 +118,7 @@ public abstract class AbstractClientHandleTest<T extends AbstractClientHandle<Ab
     public void testAbort() throws Exception {
         doHandleOperation(handle);
         handle.abort();
-        final Envelope envelope = backendProbe.expectMsgClass(Envelope.class);
+        final Envelope<?> envelope = backendProbe.expectMsgClass(Envelope.class);
         final AbortLocalTransactionRequest request = (AbortLocalTransactionRequest) envelope.getMessage();
         Assert.assertEquals(TRANSACTION_ID, request.getTarget());
         checkClosed();
@@ -128,7 +128,7 @@ public abstract class AbstractClientHandleTest<T extends AbstractClientHandle<Ab
     public void testLocalAbort() throws Exception {
         doHandleOperation(handle);
         handle.localAbort(new RuntimeException("fail"));
-        final Envelope envelope = backendProbe.expectMsgClass(Envelope.class);
+        final Envelope<?> envelope = backendProbe.expectMsgClass(Envelope.class);
         final AbortLocalTransactionRequest request = (AbortLocalTransactionRequest) envelope.getMessage();
         Assert.assertEquals(TRANSACTION_ID, request.getTarget());
         checkClosed();
@@ -170,8 +170,8 @@ public abstract class AbstractClientHandleTest<T extends AbstractClientHandle<Ab
      * @param <R>                  expected request type
      * @return request message
      */
-    protected <R extends Request> R backendRespondToRequest(final Class<R> expectedRequestClass,
-                                                            final Response response) {
+    protected <R extends Request<?, ?>> R backendRespondToRequest(final Class<R> expectedRequestClass,
+                                                            final Response<?, ?> response) {
         final RequestEnvelope envelope = backendProbe.expectMsgClass(RequestEnvelope.class);
         Assert.assertEquals(expectedRequestClass, envelope.getMessage().getClass());
         final AbstractClientConnection<ShardBackendInfo> connection = client.getConnection(0L);
@@ -187,7 +187,7 @@ public abstract class AbstractClientHandleTest<T extends AbstractClientHandle<Ab
             final FailureEnvelope responseEnvelope = new FailureEnvelope(fail, sessionId, txSequence, executionTime);
             AccessClientUtil.completeRequest(connection, responseEnvelope);
         }
-        return (R) envelope.getMessage();
+        return expectedRequestClass.cast(envelope.getMessage());
     }
 
     protected T getHandle() {
index bd170ee..45c0dbb 100644 (file)
@@ -144,7 +144,6 @@ public abstract class AbstractClientHistoryTest<T extends AbstractClientHistory>
     }
 
     @Test
-    @SuppressWarnings("unchecked")
     public void testStartReconnect() throws Exception {
         // cookie and shard are the same
         final Long cookie = 0L;
@@ -152,7 +151,7 @@ public abstract class AbstractClientHistoryTest<T extends AbstractClientHistory>
 
         final ShardBackendInfo info = new ShardBackendInfo(clientActorContext().self(), 0L, ABIVersion.current(),
                 SHARD_NAME, UnsignedLong.ZERO, Optional.of(tree), 10);
-        final ConnectedClientConnection newConn = AccessClientUtil.createConnectedConnection(
+        final ConnectedClientConnection<ShardBackendInfo> newConn = AccessClientUtil.createConnectedConnection(
                 clientActorContext(), cookie, info);
         object().createSnapshotProxy(TRANSACTION_ID, shard);
 
@@ -161,7 +160,6 @@ public abstract class AbstractClientHistoryTest<T extends AbstractClientHistory>
     }
 
     @Test
-    @SuppressWarnings("unchecked")
     public void testStartReconnectMissingOldProxy() throws Exception {
         // cookie and shard are different
         final Long cookie = 1L;
@@ -169,7 +167,7 @@ public abstract class AbstractClientHistoryTest<T extends AbstractClientHistory>
 
         final ShardBackendInfo info = new ShardBackendInfo(clientActorContext().self(), 0L, ABIVersion.current(),
                 SHARD_NAME, UnsignedLong.ZERO, Optional.of(tree), 10);
-        final ConnectedClientConnection newConn = AccessClientUtil.createConnectedConnection(
+        final ConnectedClientConnection<ShardBackendInfo> newConn = AccessClientUtil.createConnectedConnection(
                 clientActorContext(), cookie, info);
         object().createSnapshotProxy(TRANSACTION_ID, shard);
 
index 6b37bc0..6054eb3 100644 (file)
@@ -195,20 +195,20 @@ public abstract class AbstractProxyTransactionTest<T extends AbstractProxyTransa
         Assert.assertThat(modifications, hasItem(both(isA(TransactionDelete.class)).and((hasPath(PATH_3)))));
     }
 
-    protected void testRequestResponse(final Consumer<VotingFuture> consumer,
-                                       final Class<? extends TransactionRequest> expectedRequest,
-                                       final BiFunction<TransactionIdentifier, Long, TransactionSuccess> replySupplier)
+    protected void testRequestResponse(final Consumer<VotingFuture<Void>> consumer,
+            final Class<? extends TransactionRequest<?>> expectedRequest,
+                    final BiFunction<TransactionIdentifier, Long, TransactionSuccess<?>> replySupplier)
             throws Exception {
         final TransactionTester<T> tester = getTester();
-        final VotingFuture future = mock(VotingFuture.class);
+        final VotingFuture<Void> future = mock(VotingFuture.class);
         transaction.seal();
         consumer.accept(future);
-        final TransactionRequest req = tester.expectTransactionRequest(expectedRequest);
+        final TransactionRequest<?> req = tester.expectTransactionRequest(expectedRequest);
         tester.replySuccess(replySupplier.apply(TRANSACTION_ID, req.getSequence()));
         verify(future).voteYes();
     }
 
-    protected <T extends TransactionRequest> T testHandleForwardedRemoteRequest(final T request) throws Exception {
+    protected <T extends TransactionRequest<?>> T testHandleForwardedRemoteRequest(final T request) throws Exception {
         transaction.handleForwardedRemoteRequest(request, createCallbackMock());
         final RequestEnvelope envelope = backendProbe.expectMsgClass(RequestEnvelope.class);
         final T received = (T) envelope.getMessage();
@@ -218,7 +218,7 @@ public abstract class AbstractProxyTransactionTest<T extends AbstractProxyTransa
         return received;
     }
 
-    protected <T extends TransactionRequest> T testForwardToRemote(final TransactionRequest toForward,
+    protected <T extends TransactionRequest<?>> T testForwardToRemote(final TransactionRequest<?> toForward,
                                                                    final Class<T> expectedMessageClass) {
         final Consumer<Response<?, ?>> callback = createCallbackMock();
         final TransactionTester<RemoteProxyTransaction> transactionTester = createRemoteProxyTransactionTester();
@@ -232,8 +232,8 @@ public abstract class AbstractProxyTransactionTest<T extends AbstractProxyTransa
     }
 
     @SuppressWarnings("unchecked")
-    protected <T> Consumer<T> createCallbackMock() {
-        return (Consumer<T>) mock(Consumer.class);
+    protected static <T> Consumer<T> createCallbackMock() {
+        return mock(Consumer.class);
     }
 
     protected static BaseMatcher<TransactionModification> hasPath(final YangInstanceIdentifier path) {
index 294c62a..f9eb6ed 100644 (file)
@@ -56,7 +56,7 @@ public class ClientTransactionCommitCohortTest {
     @Mock
     private AbstractClientHistory history;
     private ActorSystem system;
-    private List<TransactionTester> transactions;
+    private List<TransactionTester<RemoteProxyTransaction>> transactions;
     private ClientTransactionCommitCohort cohort;
 
     @Before
@@ -130,43 +130,43 @@ public class ClientTransactionCommitCohortTest {
         Assert.assertEquals(PersistenceProtocol.THREE_PHASE, request.getPersistenceProtocol().get());
     }
 
-    void expectPreCommit(final TransactionTester tester) {
+    void expectPreCommit(final TransactionTester<?> tester) {
         tester.expectTransactionRequest(TransactionPreCommitRequest.class);
     }
 
-    void expectCommit(final TransactionTester tester) {
+    void expectCommit(final TransactionTester<?> tester) {
         tester.expectTransactionRequest(TransactionDoCommitRequest.class);
     }
 
-    void expectAbort(final TransactionTester tester) {
+    void expectAbort(final TransactionTester<?> tester) {
         tester.expectTransactionRequest(TransactionAbortRequest.class);
     }
 
-    void replyCanCommitSuccess(final TransactionTester tester) {
+    void replyCanCommitSuccess(final TransactionTester<?> tester) {
         final RequestSuccess<?, ?> success = new TransactionCanCommitSuccess(tester.getTransaction().getIdentifier(),
                 tester.getLastReceivedMessage().getSequence());
         tester.replySuccess(success);
     }
 
-    void replyPreCommitSuccess(final TransactionTester tester) {
+    void replyPreCommitSuccess(final TransactionTester<?> tester) {
         final RequestSuccess<?, ?> success = new TransactionPreCommitSuccess(tester.getTransaction().getIdentifier(),
                 tester.getLastReceivedMessage().getSequence());
         tester.replySuccess(success);
     }
 
-    void replyCommitSuccess(final TransactionTester tester) {
+    void replyCommitSuccess(final TransactionTester<?> tester) {
         final RequestSuccess<?, ?> success = new TransactionCommitSuccess(tester.getTransaction().getIdentifier(),
                 tester.getLastReceivedMessage().getSequence());
         tester.replySuccess(success);
     }
 
-    void replyAbortSuccess(final TransactionTester tester) {
+    void replyAbortSuccess(final TransactionTester<?> tester) {
         final RequestSuccess<?, ?> success = new TransactionAbortSuccess(tester.getTransaction().getIdentifier(),
                 tester.getLastReceivedMessage().getSequence());
         tester.replySuccess(success);
     }
 
-    private static TransactionTester createTransactionTester(final TestProbe backendProbe,
+    private static TransactionTester<RemoteProxyTransaction> createTransactionTester(final TestProbe backendProbe,
                                                              final ClientActorContext context,
                                                              final AbstractClientHistory history) {
         final ShardBackendInfo backend = new ShardBackendInfo(backendProbe.ref(), 0L, ABIVersion.BORON,
@@ -176,13 +176,12 @@ public class ClientTransactionCommitCohortTest {
         final ProxyHistory proxyHistory = ProxyHistory.createClient(history, connection, HISTORY_ID);
         final RemoteProxyTransaction transaction =
                 new RemoteProxyTransaction(proxyHistory, TRANSACTION_ID, false, false);
-        return new TransactionTester(transaction, connection, backendProbe);
+        return new TransactionTester<>(transaction, connection, backendProbe);
     }
 
-    private void replySuccess(final Collection<TransactionTester> transactions,
-                              final Consumer<TransactionTester> expect,
-                              final Consumer<TransactionTester> reply) {
-        for (final TransactionTester transaction : transactions) {
+    private static <T extends TransactionTester<?>> void replySuccess(final Collection<T> transactions,
+                              final Consumer<T> expect, final Consumer<T> reply) {
+        for (final T transaction : transactions) {
             expect.accept(transaction);
             reply.accept(transaction);
         }
@@ -201,8 +200,8 @@ public class ClientTransactionCommitCohortTest {
      * @throws Exception unexpected exception
      */
     private <T> void testOpSuccess(final Function<ClientTransactionCommitCohort, ListenableFuture<T>> operation,
-                                   final Consumer<TransactionTester> expectFunction,
-                                   final Consumer<TransactionTester> replyFunction,
+                                   final Consumer<TransactionTester<RemoteProxyTransaction>> expectFunction,
+                                   final Consumer<TransactionTester<RemoteProxyTransaction>> replyFunction,
                                    final T expectedResult) throws Exception {
         final ListenableFuture<T> result = operation.apply(cohort);
         replySuccess(transactions, expectFunction, replyFunction);
@@ -221,13 +220,13 @@ public class ClientTransactionCommitCohortTest {
      * @throws Exception unexpected exception
      */
     private <T> void testOpFail(final Function<ClientTransactionCommitCohort, ListenableFuture<T>> operation,
-                                final Consumer<TransactionTester> expectFunction,
-                                final Consumer<TransactionTester> replyFunction) throws Exception {
+            final Consumer<TransactionTester<RemoteProxyTransaction>> expectFunction,
+            final Consumer<TransactionTester<RemoteProxyTransaction>> replyFunction) throws Exception {
         final ListenableFuture<T> canCommit = operation.apply(cohort);
         //reply success to all except last transaction
         replySuccess(transactions.subList(0, transactions.size() - 1), expectFunction, replyFunction);
         //reply fail to last transaction
-        final TransactionTester last = transactions.get(transactions.size() - 1);
+        final TransactionTester<RemoteProxyTransaction> last = transactions.get(transactions.size() - 1);
         expectFunction.accept(last);
         final RuntimeRequestException cause = new RuntimeRequestException("fail", new RuntimeException());
         last.replyFailure(cause);
@@ -237,4 +236,4 @@ public class ClientTransactionCommitCohortTest {
         Assert.assertEquals(cause, exception.getCause());
     }
 
-}
\ No newline at end of file
+}
index 6f66b3e..7815a26 100644 (file)
@@ -66,7 +66,7 @@ public abstract class LocalProxyTransactionTest<T extends LocalProxyTransaction>
         transaction.handleForwardedRemoteRequest(request, callback);
         final ArgumentCaptor<Response> captor = ArgumentCaptor.forClass(Response.class);
         verify(callback).accept(captor.capture());
-        final Response value = captor.getValue();
+        final Response<?, ?> value = captor.getValue();
         Assert.assertTrue(value instanceof ReadTransactionSuccess);
         final ReadTransactionSuccess success = (ReadTransactionSuccess) value;
         Assert.assertTrue(success.getData().isPresent());
@@ -82,7 +82,7 @@ public abstract class LocalProxyTransactionTest<T extends LocalProxyTransaction>
         transaction.handleForwardedRemoteRequest(request, callback);
         final ArgumentCaptor<Response> captor = ArgumentCaptor.forClass(Response.class);
         verify(callback).accept(captor.capture());
-        final Response value = captor.getValue();
+        final Response<?, ?> value = captor.getValue();
         Assert.assertTrue(value instanceof ExistsTransactionSuccess);
         final ExistsTransactionSuccess success = (ExistsTransactionSuccess) value;
         Assert.assertTrue(success.getExists());
@@ -135,7 +135,7 @@ public abstract class LocalProxyTransactionTest<T extends LocalProxyTransaction>
         testForwardToLocal(request, TransactionPurgeRequest.class);
     }
 
-    protected <T extends TransactionRequest> T testForwardToLocal(final TransactionRequest toForward,
+    protected <T extends TransactionRequest<?>> T testForwardToLocal(final TransactionRequest<?> toForward,
                                                                   final Class<T> expectedMessageClass) {
         final Consumer<Response<?, ?>> callback = createCallbackMock();
         final TransactionTester<LocalReadWriteProxyTransaction> transactionTester = createLocalProxy();
@@ -151,7 +151,7 @@ public abstract class LocalProxyTransactionTest<T extends LocalProxyTransaction>
      * @param invocation invocation
      * @return void - always null
      */
-    protected Answer applyToCursorAnswer(final InvocationOnMock invocation) {
+    protected Answer<?> applyToCursorAnswer(final InvocationOnMock invocation) {
         final DataTreeModificationCursor cursor =
                 invocation.getArgumentAt(0, DataTreeModificationCursor.class);
         cursor.write(PATH_1.getLastPathArgument(), DATA_1);
index 1bcf556..2876c03 100644 (file)
@@ -17,7 +17,6 @@ import org.opendaylight.controller.cluster.access.commands.TransactionFailure;
 import org.opendaylight.controller.cluster.access.commands.TransactionRequest;
 import org.opendaylight.controller.cluster.access.concepts.AbstractRequestFailureProxy;
 import org.opendaylight.controller.cluster.access.concepts.FailureEnvelope;
-import org.opendaylight.controller.cluster.access.concepts.Request;
 import org.opendaylight.controller.cluster.access.concepts.RequestEnvelope;
 import org.opendaylight.controller.cluster.access.concepts.RequestException;
 import org.opendaylight.controller.cluster.access.concepts.RequestFailure;
@@ -47,16 +46,16 @@ class TransactionTester<T extends AbstractProxyTransaction> {
         return transaction;
     }
 
-    TransactionRequest getLastReceivedMessage() {
-        return (TransactionRequest) envelope.getMessage();
+    TransactionRequest<?> getLastReceivedMessage() {
+        return (TransactionRequest<?>) envelope.getMessage();
     }
 
-    <R extends TransactionRequest> R expectTransactionRequest(final Class<R> expected) {
+    <R extends TransactionRequest<?>> R expectTransactionRequest(final Class<R> expected) {
         envelope = backendProbe.expectMsgClass(RequestEnvelope.class);
-        final Class<? extends Request> actual = envelope.getMessage().getClass();
+        final Class<?> actual = envelope.getMessage().getClass();
         final String errorMsg = String.format("Expected instance of %s, received %s", expected, actual);
         Assert.assertTrue(errorMsg, expected.isAssignableFrom(actual));
-        return (R) envelope.getMessage();
+        return expected.cast(envelope.getMessage());
     }
 
     void replySuccess(final RequestSuccess<?, ?> success) {
@@ -78,6 +77,8 @@ class TransactionTester<T extends AbstractProxyTransaction> {
     }
 
     private static class MockFailure extends RequestFailure<TransactionIdentifier, TransactionFailure> {
+        private static final long serialVersionUID = 1L;
+
         private MockFailure(@Nonnull final TransactionIdentifier target, final long sequence,
                             @Nonnull final RequestException cause) {
             super(target, sequence, cause);
index 9570e0e..93c3e5b 100644 (file)
@@ -129,11 +129,11 @@ public class IntegrationTestKit extends ShardTestKit {
         Mockito.doReturn(datastoreContext).when(mockContextFactory).getBaseDatastoreContext();
         Mockito.doReturn(datastoreContext).when(mockContextFactory).getShardDatastoreContext(Mockito.anyString());
 
-        final Constructor constructor = implementation.getDeclaredConstructor(
+        final Constructor<? extends AbstractDataStore> constructor = implementation.getDeclaredConstructor(
                 ActorSystem.class, ClusterWrapper.class, Configuration.class,
                 DatastoreContextFactory.class, DatastoreSnapshot.class);
 
-        final AbstractDataStore dataStore = (AbstractDataStore) constructor.newInstance(
+        final AbstractDataStore dataStore = constructor.newInstance(
                 getSystem(), cluster, config, mockContextFactory, restoreFromSnapshot);
 
         dataStore.onGlobalContextUpdated(schemaContext);
index e53b026..a04c169 100644 (file)
@@ -12,7 +12,7 @@ import org.junit.Assert;
 import org.junit.Test;
 import org.opendaylight.controller.cluster.datastore.AbstractTest;
 
-public abstract class AbstractIdentifiablePayloadTest<T extends AbstractIdentifiablePayload> extends AbstractTest {
+public abstract class AbstractIdentifiablePayloadTest<T extends AbstractIdentifiablePayload<?>> extends AbstractTest {
 
     abstract T object();
 
index cbb0726..1ece862 100644 (file)
@@ -102,9 +102,9 @@ public class CDSShardAccessImplTest extends AbstractActorTest {
         final LeaderLocationListener listener3 = mock(LeaderLocationListener.class);
         doNothing().when(listener3).onLeaderLocationChanged(any());
 
-        final LeaderLocationListenerRegistration reg1 = shardAccess.registerLeaderLocationListener(listener1);
-        final LeaderLocationListenerRegistration reg2 = shardAccess.registerLeaderLocationListener(listener2);
-        final LeaderLocationListenerRegistration reg3 = shardAccess.registerLeaderLocationListener(listener3);
+        final LeaderLocationListenerRegistration<?> reg1 = shardAccess.registerLeaderLocationListener(listener1);
+        final LeaderLocationListenerRegistration<?> reg2 = shardAccess.registerLeaderLocationListener(listener2);
+        final LeaderLocationListenerRegistration<?> reg3 = shardAccess.registerLeaderLocationListener(listener3);
 
         // Error in listener1 should not affect dispatching change to other listeners
         shardAccess.onLeaderLocationChanged(LeaderLocation.LOCAL);

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.