### Question:
AbstractMongoBackend implements MongoBackend { @Override public QueryResult handleGetMore(long cursorId, int numberToReturn) { Cursor cursor = cursorRegistry.getCursor(cursorId); List<Document> documents = cursor.takeDocuments(numberToReturn); if (cursor.isEmpty()) { log.debug("Removing empty {}", cursor); cursorRegistry.remove(cursor); } return new QueryResult(documents, cursor.isEmpty() ? EmptyCursor.get().getId() : cursorId); } protected  AbstractMongoBackend(); protected  AbstractMongoBackend(Clock clock); @Override MongoDatabase resolveDatabase(String databaseName); @Override Document getServerStatus(); @Override Document handleCommand(Channel channel, String databaseName, String command, Document query); @Override CompletionStage<Document> handleCommandAsync(Channel channel, String database,
                                                        String command, Document query); @Override Collection<Document> getCurrentOperations(MongoQuery query); @Override QueryResult handleQuery(MongoQuery query); @Override CompletionStage<QueryResult> handleQueryAsync(MongoQuery query); @Override QueryResult handleGetMore(long cursorId, int numberToReturn); @Override QueryResult handleGetMore(MongoGetMore getMore); @Override void handleInsert(MongoInsert insert); @Override CompletionStage<Void> handleInsertAsync(MongoInsert insert); @Override void handleDelete(MongoDelete delete); @Override CompletionStage<Void> handleDeleteAsync(MongoDelete delete); @Override void handleUpdate(MongoUpdate update); @Override CompletionStage<Void> handleUpdateAsync(MongoUpdate update); @Override void handleKillCursors(MongoKillCursors killCursors); @Override Document handleMessage(MongoMessage message); @Override void dropDatabase(String databaseName); @Override void handleClose(Channel channel); @Override void close(); @Override MongoBackend version(ServerVersion version); @Override Clock getClock(); @Override void disableOplog(); @Override void enableOplog();  }### Answer:
@Test void testGetMore_shouldDeleteCursorIfEmpty() { List<Document> documents = Arrays.asList( new Document("name", "Joe"), new Document("name", "Mary"), new Document("name", "Steve")); Cursor cursor = new InMemoryCursor(cursorRegistry.generateCursorId(), documents); cursorRegistry.add(cursor); MongoGetMore getMore = new MongoGetMore(null, null, "testcoll", 3, cursor.getId()); backend.handleGetMore(getMore.getCursorId(), getMore.getNumberToReturn()); assertThatExceptionOfType(CursorNotFoundException.class) .isThrownBy(() -> cursorRegistry.getCursor(cursor.getId())) .withMessage("[Error 43] Cursor id 1 does not exists"); }