### Question:
UniqueId implements UniqueIdInterface { public List<String> suggest(final String search) throws HBaseException { final Scanner scanner = getSuggestScanner(search); final LinkedList<String> suggestions = new LinkedList<String>(); try { ArrayList<ArrayList<KeyValue>> rows; while ((short) suggestions.size() < MAX_SUGGESTIONS && (rows = scanner.nextRows().joinUninterruptibly()) != null) { for (final ArrayList<KeyValue> row : rows) { if (row.size() != 1) { LOG.error("WTF shouldn't happen! Scanner " + scanner + " returned" + " a row that doesn't have exactly 1 KeyValue: " + row); if (row.isEmpty()) { continue; } } final byte[] key = row.get(0).key(); final String name = fromBytes(key); final byte[] id = row.get(0).value(); final byte[] cached_id = nameCache.get(name); if (cached_id == null) { addIdToCache(name, id); addNameToCache(id, name); } else if (!Arrays.equals(id, cached_id)) { throw new IllegalStateException("WTF? For kind=" + kind() + " name=" + name + ", we have id=" + Arrays.toString(cached_id) + " in cache, but just scanned id=" + Arrays.toString(id)); } suggestions.add(name); } } } catch (HBaseException e) { throw e; } catch (Exception e) { throw new RuntimeException("Should never be here", e); } finally { scanner.close(); } return suggestions; } UniqueId(final HBaseClient client, final byte[] table, final String kind,
                    final int width); int cacheHits(); int cacheMisses(); int cacheSize(); String kind(); short width(); void dropCaches(); String getName(final byte[] id); byte[] getId(final String name); byte[] getOrCreateId(String name); List<String> suggest(final String search); void rename(final String oldname, final String newname); String toString();  }### Answer:
@PrepareForTest({HBaseClient.class, Scanner.class}) @Test public void suggestWithNoMatch() { uid = new UniqueId(client, table, kind, 3); final Scanner fake_scanner = mock(Scanner.class); when(client.newScanner(table)) .thenReturn(fake_scanner); when(fake_scanner.nextRows()) .thenReturn(Deferred.<ArrayList<ArrayList<KeyValue>>>fromResult(null)); final List<String> suggestions = uid.suggest("nomatch"); assertEquals(0, suggestions.size()); verify(fake_scanner).setStartKey("nomatch".getBytes()); verify(fake_scanner).setStopKey("nomatci".getBytes()); verify(fake_scanner).setFamily(ID); verify(fake_scanner).setQualifier(kind_array); }