private static ByteString generatePayload(ByteString dataBuffer, int offset, int size) {
        ByteString payload = ByteString.EMPTY;
        // This offset would never pass the array boundary.
        int begin = offset;
        int end = 0;
        int bytesLeft = size;
        while (bytesLeft > 0) {
            end = Math.min(begin + bytesLeft, dataBuffer.size());
            // ByteString.substring returns the substring from begin, inclusive, to end, exclusive.
            payload = payload.concat(dataBuffer.substring(begin, end));
            bytesLeft -= end - begin;
            begin = end % dataBuffer.size();
        }
        return payload;
    }
Generates a payload of desired type and size. Reads compressableBuffer or
uncompressableBuffer as a circular buffer.
grpc/src/test/java/com/linecorp/armeria/internal/common/grpc/TestServiceImpl.java