@PrepareForTest({HBaseClient.class, Scanner.class})
@Test
public void suggestWithMatches() {
uid = new UniqueId(client, table, kind, 3);
final Scanner fake_scanner = mock(Scanner.class);
when(client.newScanner(table))
.thenReturn(fake_scanner);
final ArrayList<ArrayList<KeyValue>> rows = new ArrayList<ArrayList<KeyValue>>(2);
final byte[] foo_bar_id = { 0, 0, 1 };
{
ArrayList<KeyValue> row = new ArrayList<KeyValue>(1);
row.add(new KeyValue("foo.bar".getBytes(), ID, kind_array, foo_bar_id));
rows.add(row);
row = new ArrayList<KeyValue>(1);
row.add(new KeyValue("foo.baz".getBytes(), ID, kind_array,
new byte[] { 0, 0, 2 }));
rows.add(row);
}
when(fake_scanner.nextRows())
.thenReturn(Deferred.<ArrayList<ArrayList<KeyValue>>>fromResult(rows))
.thenReturn(Deferred.<ArrayList<ArrayList<KeyValue>>>fromResult(null));
// Watch this! ______,^ I'm writing C++ in Java!
final List<String> suggestions = uid.suggest("foo");