@Test
  public void testFetchRequestSerialization() throws Exception {
    final String connectionId = UUID.randomUUID().toString();
    final int statementId = 12345;
    final long offset = 0L;

    for (int maxRowCount : Arrays.asList(-1, 0, 1, Integer.MAX_VALUE)) {
      Service.FetchRequest fetchReq =
          new Service.FetchRequest(connectionId, statementId, offset, maxRowCount);

      Requests.FetchRequest fetchProtoReq = fetchReq.serialize();
      assertEquals(maxRowCount, fetchProtoReq.getFetchMaxRowCount());
      assertEquals(maxRowCount, fetchProtoReq.getFrameMaxSize());

      assertEquals(fetchReq, fetchReq.deserialize(fetchProtoReq));
    }
  }
  @Test
  public void testFetchRequestDeserialization() throws Exception {
    final String connectionId = UUID.randomUUID().toString();
    final int statementId = 12345;
    final long offset = 0L;
    final int maxSize = 200;

    // The "current" serialization strategy.
    Requests.FetchRequest protoFetch =
        Requests.FetchRequest.newBuilder()
            .setConnectionId(connectionId)
            .setStatementId(statementId)
            .setOffset(offset)
            .setFrameMaxSize(maxSize)
            .build();

    Service.FetchRequest fetchReq = new Service.FetchRequest().deserialize(protoFetch);
    assertEquals(maxSize, fetchReq.fetchMaxRowCount);

    // The "old" serialization strategy.
    protoFetch =
        Requests.FetchRequest.newBuilder()
            .setConnectionId(connectionId)
            .setStatementId(statementId)
            .setOffset(offset)
            .setFetchMaxRowCount(maxSize)
            .build();

    fetchReq = new Service.FetchRequest().deserialize(protoFetch);
    assertEquals(maxSize, fetchReq.fetchMaxRowCount);

    // Both the new and old provided should default to the new
    protoFetch =
        Requests.FetchRequest.newBuilder()
            .setConnectionId(connectionId)
            .setStatementId(statementId)
            .setOffset(offset)
            .setFetchMaxRowCount(100)
            .setFrameMaxSize(maxSize)
            .build();

    fetchReq = new Service.FetchRequest().deserialize(protoFetch);
    assertEquals(maxSize, fetchReq.fetchMaxRowCount);
  }