### Question:
OrientDBClient extends DB { @Override public Status scan(String table, String startkey, int recordcount, Set<String> fields, Vector<HashMap<String, ByteIterator>> result) { if (isRemote) { LOG.warn("OrientDB scan operation is not implemented for remote database connections."); return Status.NOT_IMPLEMENTED; } try { int entrycount = 0; final OIndexCursor entries = dictionary.getIndex().iterateEntriesMajor(startkey, true, true); while (entries.hasNext() && entrycount < recordcount) { final OIdentifiable entry = entries.next(); final ODocument document = entry.getRecord(); final HashMap<String, ByteIterator> map = new HashMap<String, ByteIterator>(); result.add(map); if (fields != null && !fields.isEmpty()) { for (String field : fields) { map.put(field, new StringByteIterator((String) document.field(field))); } } entrycount++; } return Status.OK; } catch (Exception e) { e.printStackTrace(); } return Status.ERROR; }  @Override void init(); @Override void cleanup(); @Override Status insert(String table, String key, HashMap<String, ByteIterator> values); @Override Status delete(String table, String key); @Override Status read(String table, String key, Set<String> fields, HashMap<String, ByteIterator> result); @Override Status update(String table, String key, HashMap<String, ByteIterator> values); @Override Status scan(String table, String startkey, int recordcount, Set<String> fields,
                     Vector<HashMap<String, ByteIterator>> result);  }### Answer:
@Test public void scanTest() { Map<String, Map<String, ByteIterator>> keyMap = new HashMap<>(); for (int i = 0; i < 5; i++) { String insertKey = KEY_PREFIX + i; keyMap.put(insertKey, insertRow(insertKey)); } Set<String> fieldSet = new HashSet<>(); fieldSet.add("FIELD0"); fieldSet.add("FIELD1"); int startIndex = 1; int resultRows = 3; Vector<HashMap<String, ByteIterator>> resultVector = new Vector<>(); orientDBClient.scan(CLASS, KEY_PREFIX + startIndex, resultRows, fieldSet, resultVector); assertEquals("Assert the correct number of results rows were returned", resultRows, resultVector.size()); int testIndex = startIndex; for (HashMap<String, ByteIterator> result: resultVector) { assertEquals("Assert that this row has the correct number of fields", fieldSet.size(), result.size()); for (String field: fieldSet) { assertEquals("Assert this field is correct in this row", keyMap.get(KEY_PREFIX + testIndex).get(field).toString(), result.get(field).toString()); } testIndex++; } }