RedisCommandResult implements CommandResult { @Override public int getInt() throws ConnectionException, IOException { final RedisStreamReader streamReader = getStreamReader(); checkMessageType(streamReader, RedisBytes.COLON_BYTE); return streamReader.readInt(); } RedisCommandResult(final Connection connection); @Override byte[] getBytes(); @Override String getStatus(); @Override int getInt();  }
@Test public void getInt() throws ConnectionException, IOException { int value = 10; doReturn(value).when(streamReader).readInt(); doReturn(RedisBytes.COLON_BYTE).when(streamReader).readByte(); int actualValue = commandResult.getInt(); assertEquals(value, actualValue); }
@Test(expected = ConnectionException.class) public void getIntThrowsConnectionException() throws ConnectionException, IOException { int value = 10; doReturn(value).when(streamReader).readInt(); doReturn(RedisBytes.ASTERISK_BYTE).when(streamReader).readByte(); commandResult.getInt(); }