public static BytesInput from(InputStream in, int bytes) {
    return new StreamBytesInput(in, bytes);
  }
@Test
  public void testFromCapacityByteArrayOutputStreamOneSlab() throws IOException {
    byte[] data = new byte[1000];
    RANDOM.nextBytes(data);
    List<CapacityByteArrayOutputStream> toClose = new ArrayList<>();
    Supplier<BytesInput> factory = () -> {
      CapacityByteArrayOutputStream cbaos = new CapacityByteArrayOutputStream(10, 1000, allocator);
      toClose.add(cbaos);
      try {
        cbaos.write(data);
      } catch (IOException e) {
        throw new RuntimeException(e);
      }
      return BytesInput.from(cbaos);
    };

    try {
      validate(data, factory);

      validateToByteBufferIsInternal(factory);
    } finally {
      AutoCloseables.uncheckedClose(toClose);
    }
  }