### Question:
GremlinServerStatementResult implements StatementResult { @Override public Record single() throws NoSuchRecordException { if (!iterator.hasNext()) { throw new NoSuchRecordException("Cannot retrieve a single record, because this result is empty."); } Record next = next(); if (iterator.hasNext()) { throw new NoSuchRecordException("Expected a result with a single record, but this result contains at least one more. " + "Ensure your query returns only one record, or use `first` instead of `single` if " + "you do not care about the number of records in the result."); } return next; } GremlinServerStatementResult(ServerInfo serverInfo,
                                 Statement statement,
                                 Iterator<Map<String, Object>> iterator,
                                 GremlinCypherValueConverter converter); @Override List<String> keys(); @Override boolean hasNext(); @Override Record next(); @Override Record single(); @Override Record peek(); @Override List<Record> list(); @Override List<T> list(Function<Record, T> mapFunction); @Override ResultSummary consume(); @Override ResultSummary summary();  }### Answer:
@Test public void single() { List<Map<String, Object>> results = singletonList(getRow(1)); StatementResult statementResult = new GremlinServerStatementResult(serverInfo, statement, results.iterator(), converter); assertThat(statementResult.single().get(KEY1).asInt()).isEqualTo(1); }
@Test(expected = NoSuchRecordException.class) public void singleMore() { List<Map<String, Object>> results = asList(getRow(1), getRow(2)); StatementResult statementResult = new GremlinServerStatementResult(serverInfo, statement, results.iterator(), converter); statementResult.single(); }
@Test(expected = NoSuchRecordException.class) public void singleZero() { StatementResult statementResult = new GremlinServerStatementResult(serverInfo, statement, new ArrayList<Map<String, Object>>().iterator(), converter); statementResult.single(); }