// Path: src/main/java/org/lmdbjava/ByteBufferProxy.java
// public static final BufferProxy<ByteBuffer> PROXY_OPTIMAL;
// 
// Path: src/main/java/org/lmdbjava/Env.java
// public static Builder<ByteBuffer> create() {
//   return new Builder<>(PROXY_OPTIMAL);
// }
// 
// Path: src/test/java/org/lmdbjava/TestUtils.java
// public static final String DB_1 = "test-db-1";
// 
// Path: src/test/java/org/lmdbjava/TestUtils.java
// @SuppressWarnings("PMD.AvoidUsingOctalValues")
// public static final int POSIX_MODE = 0664;
// 
// Path: src/test/java/org/lmdbjava/TestUtils.java
// static ByteBuffer bb(final int value) {
//   final ByteBuffer bb = allocateDirect(BYTES);
//   bb.putInt(value).flip();
//   return bb;
// }
// 
// Path: src/main/java/org/lmdbjava/Cursor.java
// public static final class ClosedException extends LmdbException {
// 
//   private static final long serialVersionUID = 1L;
// 
//   /**
//    * Creates a new instance.
//    */
//   public ClosedException() {
//     super("Cursor has already been closed");
//   }
// }
// 
// Path: src/main/java/org/lmdbjava/Txn.java
// public static final class NotReadyException extends LmdbException {
// 
//   private static final long serialVersionUID = 1L;
// 
//   /**
//    * Creates a new instance.
//    */
//   public NotReadyException() {
//     super("Transaction is not in ready state");
//   }
// }
// 
// Path: src/main/java/org/lmdbjava/Txn.java
// public static class ReadOnlyRequiredException extends LmdbException {
// 
//   private static final long serialVersionUID = 1L;
// 
//   /**
//    * Creates a new instance.
//    */
//   public ReadOnlyRequiredException() {
//     super("Not a read-only transaction");
//   }
// }


import static com.jakewharton.byteunits.BinaryByteUnit.KIBIBYTES;
import static java.lang.Long.BYTES;
import static java.lang.Long.MIN_VALUE;
import static java.nio.ByteBuffer.allocateDirect;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.lmdbjava.ByteBufferProxy.PROXY_OPTIMAL;
import static org.lmdbjava.DbiFlags.MDB_CREATE;
import static org.lmdbjava.DbiFlags.MDB_DUPFIXED;
import static org.lmdbjava.DbiFlags.MDB_DUPSORT;
import static org.lmdbjava.Env.create;
import static org.lmdbjava.EnvFlags.MDB_NOSUBDIR;
import static org.lmdbjava.PutFlags.MDB_APPENDDUP;
import static org.lmdbjava.PutFlags.MDB_MULTIPLE;
import static org.lmdbjava.PutFlags.MDB_NODUPDATA;
import static org.lmdbjava.PutFlags.MDB_NOOVERWRITE;
import static org.lmdbjava.SeekOp.MDB_FIRST;
import static org.lmdbjava.SeekOp.MDB_GET_BOTH;
import static org.lmdbjava.TestUtils.DB_1;
import static org.lmdbjava.TestUtils.POSIX_MODE;
import static org.lmdbjava.TestUtils.bb;
import java.io.File;
import java.io.IOException;
import java.nio.ByteBuffer;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.lmdbjava.Cursor.ClosedException;
import org.lmdbjava.Txn.NotReadyException;
import org.lmdbjava.Txn.ReadOnlyRequiredException;
        c.put(bb(1), bb(4), MDB_APPENDDUP);
        assertThat(c.count(), is(2L));
        txn.commit();
      }
    }
  }

  @Test
  public void cursorFirstLastNextPrev() {
    final Dbi<ByteBuffer> db = env.openDbi(DB_1, MDB_CREATE);
    try (Txn<ByteBuffer> txn = env.txnWrite();
         Cursor<ByteBuffer> c = db.openCursor(txn)) {
      c.put(bb(1), bb(2), MDB_NOOVERWRITE);
      c.put(bb(3), bb(4));
      c.put(bb(5), bb(6));
      c.put(bb(7), bb(8));

      assertThat(c.first(), is(true));
      assertThat(c.key().getInt(0), is(1));
      assertThat(c.val().getInt(0), is(2));

      assertThat(c.last(), is(true));
      assertThat(c.key().getInt(0), is(7));
      assertThat(c.val().getInt(0), is(8));

      assertThat(c.prev(), is(true));
      assertThat(c.key().getInt(0), is(5));
      assertThat(c.val().getInt(0), is(6));

      assertThat(c.first(), is(true));
// Path: src/main/java/org/lmdbjava/ByteBufferProxy.java
// public static final BufferProxy<ByteBuffer> PROXY_OPTIMAL;
// 
// Path: src/main/java/org/lmdbjava/Env.java
// public static Builder<ByteBuffer> create() {
//   return new Builder<>(PROXY_OPTIMAL);
// }
// 
// Path: src/test/java/org/lmdbjava/TestUtils.java
// public static final String DB_1 = "test-db-1";
// 
// Path: src/test/java/org/lmdbjava/TestUtils.java
// @SuppressWarnings("PMD.AvoidUsingOctalValues")
// public static final int POSIX_MODE = 0664;
// 
// Path: src/test/java/org/lmdbjava/TestUtils.java
// static ByteBuffer bb(final int value) {
//   final ByteBuffer bb = allocateDirect(BYTES);
//   bb.putInt(value).flip();
//   return bb;
// }
// 
// Path: src/main/java/org/lmdbjava/Cursor.java
// public static final class ClosedException extends LmdbException {
// 
//   private static final long serialVersionUID = 1L;
// 
//   /**
//    * Creates a new instance.
//    */
//   public ClosedException() {
//     super("Cursor has already been closed");
//   }
// }
// 
// Path: src/main/java/org/lmdbjava/Txn.java
// public static final class NotReadyException extends LmdbException {
// 
//   private static final long serialVersionUID = 1L;
// 
//   /**
//    * Creates a new instance.
//    */
//   public NotReadyException() {
//     super("Transaction is not in ready state");
//   }
// }
// 
// Path: src/main/java/org/lmdbjava/Txn.java
// public static class ReadOnlyRequiredException extends LmdbException {
// 
//   private static final long serialVersionUID = 1L;
// 
//   /**
//    * Creates a new instance.
//    */
//   public ReadOnlyRequiredException() {
//     super("Not a read-only transaction");
//   }
// }


// Path: src/test/java/org/lmdbjava/CursorTest.java
import static com.jakewharton.byteunits.BinaryByteUnit.KIBIBYTES;
import static java.lang.Long.BYTES;
import static java.lang.Long.MIN_VALUE;
import static java.nio.ByteBuffer.allocateDirect;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.lmdbjava.ByteBufferProxy.PROXY_OPTIMAL;
import static org.lmdbjava.DbiFlags.MDB_CREATE;
import static org.lmdbjava.DbiFlags.MDB_DUPFIXED;
import static org.lmdbjava.DbiFlags.MDB_DUPSORT;
import static org.lmdbjava.Env.create;
import static org.lmdbjava.EnvFlags.MDB_NOSUBDIR;
import static org.lmdbjava.PutFlags.MDB_APPENDDUP;
import static org.lmdbjava.PutFlags.MDB_MULTIPLE;
import static org.lmdbjava.PutFlags.MDB_NODUPDATA;
import static org.lmdbjava.PutFlags.MDB_NOOVERWRITE;
import static org.lmdbjava.SeekOp.MDB_FIRST;
import static org.lmdbjava.SeekOp.MDB_GET_BOTH;
import static org.lmdbjava.TestUtils.DB_1;
import static org.lmdbjava.TestUtils.POSIX_MODE;
import static org.lmdbjava.TestUtils.bb;
import java.io.File;
import java.io.IOException;
import java.nio.ByteBuffer;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.lmdbjava.Cursor.ClosedException;
import org.lmdbjava.Txn.NotReadyException;
import org.lmdbjava.Txn.ReadOnlyRequiredException;

        c.put(bb(1), bb(4), MDB_APPENDDUP);
        assertThat(c.count(), is(2L));
        txn.commit();
      }
    }
  }

  @Test
  public void cursorFirstLastNextPrev() {
    final Dbi<ByteBuffer> db = env.openDbi(DB_1, MDB_CREATE);
    try (Txn<ByteBuffer> txn = env.txnWrite();
         Cursor<ByteBuffer> c = db.openCursor(txn)) {
      c.put(bb(1), bb(2), MDB_NOOVERWRITE);
      c.put(bb(3), bb(4));
      c.put(bb(5), bb(6));
      c.put(bb(7), bb(8));

      assertThat(c.first(), is(true));
      assertThat(c.key().getInt(0), is(1));
      assertThat(c.val().getInt(0), is(2));

      assertThat(c.last(), is(true));
      assertThat(c.key().getInt(0), is(7));
      assertThat(c.val().getInt(0), is(8));

      assertThat(c.prev(), is(true));
      assertThat(c.key().getInt(0), is(5));
      assertThat(c.val().getInt(0), is(6));

      assertThat(c.first(), is(true));
      assertThat(c.next(), is(true));