OrderedMap { public abstract AbstractRecord delete(AbstractKey key) throws IOException, InterruptedException, DeadlockException, TransactionRolledBackException;  abstract void ensurePresent(AbstractRecord record); abstract AbstractRecord put(AbstractRecord record); abstract void ensureAbsent(AbstractKey key); abstract AbstractRecord delete(AbstractKey key); abstract void lock(AbstractKey key); abstract AbstractRecord find(AbstractKey key); abstract Cursor cursor(AbstractKey key); abstract Cursor first(); abstract Cursor last();  }
@Test public void testDelete() throws IOException, InterruptedException, DeadlockException, TransactionRolledBackException { Database db = new DisklessTestDatabase(FACTORY); OrderedMap map = db.createMap(MAP_NAME, RecordFactory.simpleRecordFactory(TestKey.class, TestRecord.class)); for (int i = 0; i < N; i++) { AbstractRecord replaced = map.put(TestRecord.createRecord(i, "first")); assertNull(replaced); } for (int i = 0; i < N; i++) { { AbstractRecord replaced = map.delete(new TestKey(i)); assertNotNull(replaced); assertEquals(i, ((TestKey) replaced.key()).key()); assertEquals("first", ((TestRecord) replaced).stringValue()); } { AbstractRecord replaced = map.delete(new TestKey(-i)); assertNull(replaced); } } assertNull(map.first().next()); db.close(); }