This fixes most raw type warnings.
Change-Id: Iaec02aa9f40df6d04b9f1bfa7045c84b6cc40a53
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
20 files changed:
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();
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;
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"));
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"));
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"));
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(
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();
}
@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
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;
}
*/
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.
return new ConnectionEntryMatcher(request);
}
return new ConnectionEntryMatcher(request);
}
- private ConnectionEntryMatcher(final Request request) {
+ private ConnectionEntryMatcher(final Request<?, ?> request) {
this.request = request;
}
this.request = request;
}
@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);
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 =
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);
}
});
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) {
- 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();
* @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());
-}
\ No newline at end of file
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();
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();
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());
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();
* @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);
-}
\ No newline at end of file
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());
if (!e.getClass().equals(expectedException)) {
throw e;
}
if (!e.getClass().equals(expectedException)) {
throw e;
}
+ return expectedException.cast(e);
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);
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;
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);
- 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)) {
}
@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) {
- 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());
- 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) {
- 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());