test_class.declarator: connection
test_class.modifier: @Mock
test_class.original_string: @Mock
    Connection connection;
test_class.type: Connection
test_class.var_name: connection
test_class.declarator: outputStream
test_class.modifier: @Mock
test_class.original_string: @Mock
    OutputStream outputStream;
test_class.type: OutputStream
test_class.var_name: outputStream
test_class.declarator: streamWriter
test_class.original_string: RedisStreamWriter streamWriter;
test_class.type: RedisStreamWriter
test_class.var_name: streamWriter
test_class.declarator: commandExecutor
test_class.original_string: RedisCommandExecutor commandExecutor;
test_class.type: RedisCommandExecutor
test_class.var_name: commandExecutor
test_class.file: imcache-redis/src/test/java/com/cetsoft/imcache/redis/client/RedisCommandExecutorTest.java
test_class.identifier: RedisCommandExecutorTest
test_case.body: @Test
    @SuppressWarnings("rawtypes")
    public void execute() throws ConnectionException, IOException {
      byte[] key = {'1'};
      byte[] value = {'1'};
      byte[][] args = {key, value};
      String expectedRedisCommandString = "*3\r\n$3\r\nSET\r\n$1\r\n1\r\n$1\r\n1\r\n";
      final byte[] outputStreamBytes = new byte[100];
      doAnswer(new Answer() {
        int position = 0;
  
        public Object answer(InvocationOnMock invocation) {
          Object[] args = invocation.getArguments();
          byte[] bytes = (byte[]) args[0];
          int offset = (Integer) args[1];
          int length = (Integer) args[2];
          System.arraycopy(bytes, offset, outputStreamBytes, position, length);
          position += length;
          return null;
        }
      }).when(outputStream).write((byte[]) any(), anyInt(), anyInt());
  
      commandExecutor.execute(RedisCommands.SET, args);
  
      verify(streamWriter, times(7)).writeNewLine();
      verify(streamWriter).write(RedisBytes.ASTERISK_BYTE);
      verify(streamWriter, times(3)).write(RedisBytes.DOLLAR_BYTE);
      verify(streamWriter, times(4)).write(anyInt());
      verify(streamWriter).flush();
  
      String actualRedisCommandString = new String(outputStreamBytes).substring(0,
          expectedRedisCommandString.length());
      assertEquals(expectedRedisCommandString, actualRedisCommandString);
    }
test_case.class_method_signature: RedisCommandExecutorTest.execute()
test_case.full_signature: @Test @SuppressWarnings("rawtypes") public void execute()
test_case.identifier: execute
test_case.invocations: write when doAnswer getArguments arraycopy any anyInt anyInt execute writeNewLine verify times write verify write verify times write verify times anyInt flush verify substring length assertEquals
test_case.modifiers: @Test @SuppressWarnings("rawtypes") public
test_case.parameters: ()
test_case.return: void
test_case.signature: void execute()
focal_class.declarator: connection
focal_class.modifier: final
focal_class.original_string: final Connection connection;
focal_class.type: Connection
focal_class.var_name: connection
focal_class.file: imcache-redis/src/main/java/com/cetsoft/imcache/redis/client/RedisCommandExecutor.java
focal_class.identifier: RedisCommandExecutor
focal_class.interfaces: implements CommandExecutor
focal_class.class_method_signature: RedisCommandExecutor.RedisCommandExecutor(final Connection connection)
focal_class.full_signature: public  RedisCommandExecutor(final Connection connection)
focal_class.identifier: RedisCommandExecutor
focal_class.modifiers: public
focal_class.parameters: (final Connection connection)
focal_class.signature:  RedisCommandExecutor(final Connection connection)
focal_class.class_method_signature: RedisCommandExecutor.execute(final ByteCommand command, final byte[]... args)
focal_class.full_signature: public void execute(final ByteCommand command, final byte[]... args)
focal_class.identifier: execute
focal_class.modifiers: public
focal_class.parameters: (final ByteCommand command, final byte[]... args)
focal_class.return: void
focal_class.signature: void execute(final ByteCommand command, final byte[]... args)
focal_method.body: public void execute(final ByteCommand command, final byte[]... args)
        throws ConnectionException, IOException {
      connection.open();
      final RedisStreamWriter streamWriter = connection.getStreamWriter();
      streamWriter.write(RedisBytes.ASTERISK_BYTE);
      streamWriter.write(args.length + 1);// 1 comes from set
      streamWriter.writeNewLine();
      streamWriter.write(RedisBytes.DOLLAR_BYTE);
      streamWriter.write(command.getBytes().length);
      streamWriter.writeNewLine();
      streamWriter.write(command.getBytes());
      streamWriter.writeNewLine();
  
      for (final byte[] arg : args) {
        streamWriter.write(RedisBytes.DOLLAR_BYTE);
        streamWriter.write(arg.length);
        streamWriter.writeNewLine();
        streamWriter.write(arg);
        streamWriter.writeNewLine();
      }
      streamWriter.flush();
    }
focal_method.class_method_signature: RedisCommandExecutor.execute(final ByteCommand command, final byte[]... args)
focal_method.full_signature: public void execute(final ByteCommand command, final byte[]... args)
focal_method.identifier: execute
focal_method.invocations: open getStreamWriter write write writeNewLine write write getBytes writeNewLine write getBytes writeNewLine write write writeNewLine write writeNewLine flush
focal_method.modifiers: public
focal_method.parameters: (final ByteCommand command, final byte[]... args)
focal_method.return: void
focal_method.signature: void execute(final ByteCommand command, final byte[]... args)