You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ds...@apache.org on 2020/04/25 21:01:34 UTC

[geode] 01/01: fixed unit test that could no longer mock enum

This is an automated email from the ASF dual-hosted git repository.

dschneider pushed a commit to branch RedisCommandType-refactor
in repository https://gitbox.apache.org/repos/asf/geode.git

commit d9d281a353496d7d3d71a648e80ed497c546288a
Author: Darrel Schneider <ds...@pivotal.io>
AuthorDate: Sat Apr 25 14:00:13 2020 -0700

    fixed unit test that could no longer mock enum
---
 .../redis/internal/ExecutionHandlerContextJUnitTest.java     | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/geode-redis/src/test/java/org/apache/geode/redis/internal/ExecutionHandlerContextJUnitTest.java b/geode-redis/src/test/java/org/apache/geode/redis/internal/ExecutionHandlerContextJUnitTest.java
index 90bacba..835bcc3 100644
--- a/geode-redis/src/test/java/org/apache/geode/redis/internal/ExecutionHandlerContextJUnitTest.java
+++ b/geode-redis/src/test/java/org/apache/geode/redis/internal/ExecutionHandlerContextJUnitTest.java
@@ -15,6 +15,8 @@
  */
 package org.apache.geode.redis.internal;
 
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufAllocator;
 import io.netty.channel.Channel;
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.channel.ChannelPipeline;
@@ -41,30 +43,30 @@ public class ExecutionHandlerContextJUnitTest {
     ChannelPipeline channelPipeline = Mockito.mock(ChannelPipeline.class);
     EventExecutor eventExecutor = Mockito.mock(EventExecutor.class);
     ChannelHandlerContext channelHandlerContext = Mockito.mock(ChannelHandlerContext.class);
+    ByteBufAllocator alloc = Mockito.mock(ByteBufAllocator.class);
+    ByteBuf byteBuf = Mockito.mock(ByteBuf.class);
     @SuppressWarnings("deprecation")
     org.apache.geode.LogWriter logWriter = Mockito.mock(org.apache.geode.LogWriter.class);
     Command msg = Mockito.mock(Command.class);
     RegionProvider regionProvider = Mockito.mock(RegionProvider.class);
     GeodeRedisServer server = Mockito.mock(GeodeRedisServer.class);
-    RedisCommandType redisCommandType = Mockito.mock(RedisCommandType.class);
     KeyRegistrar keyRegistrar = Mockito.mock(KeyRegistrar.class);
     PubSub pubSub = Mockito.mock(PubSub.class);
     RedisLockService lockService = Mockito.mock(RedisLockService.class);
 
     Mockito.when(cache.getLogger()).thenReturn(logWriter);
+    Mockito.when(ch.alloc()).thenReturn(alloc);
+    Mockito.when(alloc.buffer(Mockito.anyInt())).thenReturn(byteBuf);
     Mockito.when(ch.pipeline()).thenReturn(channelPipeline);
     Mockito.when(channelPipeline.lastContext()).thenReturn(channelHandlerContext);
     Mockito.when(channelHandlerContext.executor()).thenReturn(eventExecutor);
+    Mockito.when(msg.getCommandType()).thenReturn(RedisCommandType.UNKNOWN);
 
     byte[] pwd = null;
     ExecutionHandlerContext handler =
         new ExecutionHandlerContext(ch, cache, regionProvider, server, pwd, keyRegistrar, pubSub,
             lockService);
 
-    Mockito.when(msg.getCommandType()).thenReturn(redisCommandType);
-    Executor exec = Mockito.mock(Executor.class);
-    Mockito.when(redisCommandType.getExecutor()).thenReturn(exec);
-
     ChannelHandlerContext ctx = null;
     handler.channelRead(ctx, msg);