RedisCommandResult implements CommandResult { @Override public byte[] getBytes() throws ConnectionException, IOException { final RedisStreamReader streamReader = getStreamReader(); checkMessageType(streamReader, RedisBytes.DOLLAR_BYTE); final int length = streamReader.readInt(); return streamReader.read(length); } RedisCommandResult(final Connection connection); @Override byte[] getBytes(); @Override String getStatus(); @Override int getInt();  }
@Test public void getBytes() throws ConnectionException, IOException { int length = 3; byte[] bytes = {1, 2, 3}; doReturn(RedisBytes.DOLLAR_BYTE).when(streamReader).readByte(); doReturn(length).when(streamReader).readInt(); doReturn(bytes).when(streamReader).read(length); byte[] actualBytes = commandResult.getBytes(); assertArrayEquals(bytes, actualBytes); }