From 5403be2a94ce73b0a55d003ee376d84a7faba78b Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Thu, 6 Nov 2014 13:42:11 +0100 Subject: [PATCH] Add generic arguments to Answer Just use Object as the argument to get rid of the warnings. Change-Id: I17d2ee9c518ed53c27bd5e1c330e7c161a388194 Signed-off-by: Robert Varga --- ...kwardsCompatibleMountPointManagerTest.java | 6 ++-- .../BackwardsCompatibleMountPointTest.java | 6 ++-- .../connect/netconf/NetconfDeviceTest.java | 5 ++- .../NetconfClientSessionNegotiatorTest.java | 35 +++++++++++-------- 4 files changed, 28 insertions(+), 24 deletions(-) diff --git a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/sal/dom/broker/BackwardsCompatibleMountPointManagerTest.java b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/sal/dom/broker/BackwardsCompatibleMountPointManagerTest.java index 05c4793218..608fd72f4a 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/sal/dom/broker/BackwardsCompatibleMountPointManagerTest.java +++ b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/sal/dom/broker/BackwardsCompatibleMountPointManagerTest.java @@ -15,7 +15,7 @@ import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; - +import com.google.common.base.Optional; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; @@ -36,8 +36,6 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.google.common.base.Optional; - public class BackwardsCompatibleMountPointManagerTest { private static final Logger log = LoggerFactory.getLogger(BackwardsCompatibleMountPointManagerTest.class); @@ -106,7 +104,7 @@ public class BackwardsCompatibleMountPointManagerTest { private DOMMountPoint mockMountPoint() { final DOMMountPoint mock = mock(DOMMountPoint.class); - doAnswer(new Answer() { + doAnswer(new Answer() { @Override public Object answer(final InvocationOnMock invocation) throws Throwable { return Optional.of(mock(((Class) invocation.getArguments()[0]))); diff --git a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/sal/dom/broker/BackwardsCompatibleMountPointTest.java b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/sal/dom/broker/BackwardsCompatibleMountPointTest.java index 91ae0c24dd..cb1a99b4c0 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/sal/dom/broker/BackwardsCompatibleMountPointTest.java +++ b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/sal/dom/broker/BackwardsCompatibleMountPointTest.java @@ -8,15 +8,14 @@ package org.opendaylight.controller.sal.dom.broker; -import static junit.framework.Assert.fail; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; import static org.mockito.Matchers.any; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; - import com.google.common.base.Optional; import com.google.common.util.concurrent.ListenableFuture; import java.util.AbstractMap; @@ -38,6 +37,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +@Deprecated public class BackwardsCompatibleMountPointTest { private static final Logger log = LoggerFactory.getLogger(BackwardsCompatibleMountPointManagerTest.class); @@ -147,7 +147,7 @@ public class BackwardsCompatibleMountPointTest { } private NormalizedNode mockNormalizedNode() { - final NormalizedNode mock = mock(NormalizedNode.class); + final NormalizedNode mock = mock(NormalizedNode.class); doReturn("mockNormalizedNode").when(mock).toString(); return mock; } diff --git a/opendaylight/md-sal/sal-netconf-connector/src/test/java/org/opendaylight/controller/sal/connect/netconf/NetconfDeviceTest.java b/opendaylight/md-sal/sal-netconf-connector/src/test/java/org/opendaylight/controller/sal/connect/netconf/NetconfDeviceTest.java index 218ec0be8d..cbddac2caf 100644 --- a/opendaylight/md-sal/sal-netconf-connector/src/test/java/org/opendaylight/controller/sal/connect/netconf/NetconfDeviceTest.java +++ b/opendaylight/md-sal/sal-netconf-connector/src/test/java/org/opendaylight/controller/sal/connect/netconf/NetconfDeviceTest.java @@ -17,7 +17,6 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.timeout; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; - import com.google.common.base.Optional; import com.google.common.collect.HashMultimap; import com.google.common.collect.Lists; @@ -134,7 +133,7 @@ public class NetconfDeviceTest { // Make fallback attempt to fail due to empty resolved sources final MissingSchemaSourceException schemaResolutionException = new MissingSchemaSourceException("fail first", TEST_SID); - doAnswer(new Answer() { + doAnswer(new Answer() { @Override public Object answer(final InvocationOnMock invocation) throws Throwable { if(((Collection) invocation.getArguments()[0]).size() == 2) { @@ -158,7 +157,7 @@ public class NetconfDeviceTest { private SchemaSourceRegistry getSchemaRegistry() { final SchemaSourceRegistry mock = mock(SchemaSourceRegistry.class); - final SchemaSourceRegistration mockReg = mock(SchemaSourceRegistration.class); + final SchemaSourceRegistration mockReg = mock(SchemaSourceRegistration.class); doNothing().when(mockReg).close(); doReturn(mockReg).when(mock).registerSchemaSource(any(org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceProvider.class), any(PotentialSchemaSource.class)); return mock; diff --git a/opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/NetconfClientSessionNegotiatorTest.java b/opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/NetconfClientSessionNegotiatorTest.java index 333e9deae4..9993f48a4d 100644 --- a/opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/NetconfClientSessionNegotiatorTest.java +++ b/opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/NetconfClientSessionNegotiatorTest.java @@ -8,22 +8,35 @@ package org.opendaylight.controller.netconf.client; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyObject; +import static org.mockito.Matchers.anyString; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; import com.google.common.base.Optional; -import io.netty.channel.*; +import io.netty.channel.Channel; +import io.netty.channel.ChannelFuture; +import io.netty.channel.ChannelHandler; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelPipeline; +import io.netty.channel.ChannelProgressivePromise; import io.netty.handler.ssl.SslHandler; import io.netty.util.HashedWheelTimer; +import io.netty.util.Timer; import io.netty.util.concurrent.GenericFutureListener; import io.netty.util.concurrent.Promise; -import org.apache.mina.handler.demux.ExceptionHandler; +import java.util.Set; import org.junit.Before; import org.junit.Test; -import org.mockito.Mockito; import org.mockito.internal.util.collections.Sets; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; import org.opendaylight.controller.netconf.api.NetconfClientSessionPreferences; import org.opendaylight.controller.netconf.api.NetconfMessage; -import io.netty.util.Timer; import org.opendaylight.controller.netconf.nettyutil.handler.ChunkedFramingMechanismEncoder; import org.opendaylight.controller.netconf.nettyutil.handler.NetconfXMLToHelloMessageDecoder; import org.opendaylight.controller.netconf.nettyutil.handler.NetconfXMLToMessageDecoder; @@ -31,14 +44,8 @@ import org.opendaylight.controller.netconf.nettyutil.handler.exi.NetconfStartExi import org.opendaylight.controller.netconf.util.messages.NetconfHelloMessage; import org.opendaylight.controller.netconf.util.messages.NetconfHelloMessageAdditionalHeader; import org.opendaylight.controller.netconf.util.test.XmlFileLoader; -import org.opendaylight.controller.netconf.util.xml.XmlUtil; import org.openexi.proc.common.EXIOptions; import org.w3c.dom.Document; -import java.util.Set; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyObject; -import static org.mockito.Matchers.anyString; -import static org.mockito.Mockito.*; public class NetconfClientSessionNegotiatorTest { @@ -96,8 +103,8 @@ public class NetconfClientSessionNegotiatorTest { return pipeline; } - private NetconfClientSessionNegotiator createNetconfClientSessionNegotiator(Promise promise, - NetconfMessage startExi) { + private NetconfClientSessionNegotiator createNetconfClientSessionNegotiator(final Promise promise, + final NetconfMessage startExi) { ChannelProgressivePromise progressivePromise = mock(ChannelProgressivePromise.class); NetconfClientSessionPreferences preferences = new NetconfClientSessionPreferences(helloMessage, startExi); doReturn(progressivePromise).when(promise).setFailure(any(Throwable.class)); @@ -133,9 +140,9 @@ public class NetconfClientSessionNegotiatorTest { Set caps = Sets.newSet("exi:1.0"); NetconfHelloMessage helloMessage = NetconfHelloMessage.createServerHello(caps, 10); - doAnswer(new Answer() { + doAnswer(new Answer() { @Override - public Object answer(InvocationOnMock invocationOnMock) throws Throwable { + public Object answer(final InvocationOnMock invocationOnMock) throws Throwable { channelInboundHandlerAdapter = ((ChannelInboundHandlerAdapter) invocationOnMock.getArguments()[2]); return null; } -- 2.36.6