### Question:
UscJsonRpcHandler extends SimpleChannelInboundHandler<ByteBufHolder> implements UscJsonRpcRequestVisitor { @Override public JsonRpcResultOrError visit(EthUnsubscribeRequest request, ChannelHandlerContext ctx) { boolean unsubscribed = emitter.unsubscribe(request.getParams().getSubscriptionId()); return new JsonRpcBooleanResult(unsubscribed); } UscJsonRpcHandler(EthSubscriptionNotificationEmitter emitter, JsonRpcSerializer serializer); @Override void channelInactive(ChannelHandlerContext ctx); @Override JsonRpcResultOrError visit(EthUnsubscribeRequest request, ChannelHandlerContext ctx); @Override JsonRpcResultOrError visit(EthSubscribeRequest request, ChannelHandlerContext ctx);  }### Answer:
@Test public void visitUnsubscribe() { EthUnsubscribeRequest unsubscribe = new EthUnsubscribeRequest( JsonRpcVersion.V2_0, UscJsonRpcMethod.ETH_UNSUBSCRIBE, 35, new EthUnsubscribeParams(SAMPLE_SUBSCRIPTION_ID) ); when(emitter.unsubscribe(SAMPLE_SUBSCRIPTION_ID)) .thenReturn(true); assertThat( handler.visit(unsubscribe, null), is(new JsonRpcBooleanResult(true)) ); }
@Test public void visitSubscribe() { Channel channel = mock(Channel.class); ChannelHandlerContext ctx = mock(ChannelHandlerContext.class); when(ctx.channel()) .thenReturn(channel); when(emitter.subscribe(channel)) .thenReturn(SAMPLE_SUBSCRIPTION_ID); assertThat( handler.visit(SAMPLE_SUBSCRIBE_REQUEST, ctx), is(SAMPLE_SUBSCRIPTION_ID) ); }