package com.netflix.dyno.jedis.utils;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

public class MockedResponseHandler extends SimpleChannelInboundHandler<String> {

    private static volatile int requestsReceived = 0;

    private final String response;

    public MockedResponseHandler(final String response) {
        this.response = response;
    }

    @Override
    protected void channelRead0(final ChannelHandlerContext ctx, final String msg) throws Exception {

        if (requestsReceived == 0) {
            ctx.writeAndFlush("$" + response.length() + "\r\n");
            ctx.writeAndFlush(response + "\r\n");
        } else {
            ctx.writeAndFlush("+OK\r\n");
        }

        requestsReceived++;
    }
}

package com.netflix.dyno.jedis.utils;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

public class MockedResponseHandler extends SimpleChannelInboundHandler<String> {

    private final String response;

    public MockedResponseHandler(final String response) {
        this.response = response;
    }

    @Override
    protected void channelRead0(final ChannelHandlerContext ctx, final String msg) throws Exception {
        
        ctx.writeAndFlush("$" + response.length() + "\r\n");
        ctx.writeAndFlush(response + "\r\n");
    }
}

remove unused requestsReceived