import io.netty.channel.EventLoop;
import io.netty.util.concurrent.GenericFutureListener;
import org.junit.Test;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
import org.opendaylight.controller.config.util.xml.DocumentedException;
import org.opendaylight.controller.config.util.xml.XmlElement;
import org.opendaylight.controller.config.util.xml.XmlUtil;
public class DefaultCloseSessionTest {
- private void mockEventLoop(final Channel channel) {
+ private static void mockEventLoop(final Channel channel) {
final EventLoop eventLoop = mock(EventLoop.class);
doReturn(eventLoop).when(channel).eventLoop();
- doAnswer(new Answer<Void>() {
- @Override
- public Void answer(InvocationOnMock invocation) throws Throwable {
- final Object[] args = invocation.getArguments();
- final Runnable runnable = (Runnable) args[0];
- runnable.run();
- return null;
- }
+ doAnswer(invocation -> {
+ final Object[] args = invocation.getArguments();
+ final Runnable runnable = (Runnable) args[0];
+ runnable.run();
+ return null;
}).when(eventLoop).execute(any(Runnable.class));
doReturn(true).when(eventLoop).inEventLoop();
}
doReturn(channelFuture).when(channelFuture).addListener(any(GenericFutureListener.class));
final ChannelFuture sendFuture = mock(ChannelFuture.class);
- doAnswer(new Answer<Object>() {
- @Override
- public Object answer(final InvocationOnMock invocation) throws Throwable {
- ((GenericFutureListener) invocation.getArguments()[0]).operationComplete(sendFuture);
- return null;
- }
+ doAnswer(invocation -> {
+ ((GenericFutureListener) invocation.getArguments()[0]).operationComplete(sendFuture);
+ return null;
}).when(sendFuture).addListener(any(GenericFutureListener.class));
doReturn(sendFuture).when(channel).writeAndFlush(anyObject());
doReturn(true).when(sendFuture).isSuccess();