BigtableStorage implements Closeable { List<WorkflowInstanceExecutionData> executionData(WorkflowId workflowId, String offset, int limit) throws IOException { try (final Table eventsTable = connection.getTable(EVENTS_TABLE_NAME)) { final Scan scan = new Scan() .setRowPrefixFilter(Bytes.toBytes(workflowId.toKey() + '#')) .setFilter(new FirstKeyOnlyFilter()); if (!Strings.isNullOrEmpty(offset)) { final WorkflowInstance offsetInstance = WorkflowInstance.create(workflowId, offset); scan.setStartRow(Bytes.toBytes(offsetInstance.toKey() + '#')); } final Set<WorkflowInstance> workflowInstancesSet = Sets.newHashSet(); try (ResultScanner scanner = eventsTable.getScanner(scan)) { Result result = scanner.next(); while (result != null) { final String key = new String(result.getRow()); final int lastHash = key.lastIndexOf('#'); final WorkflowInstance wfi = WorkflowInstance.parseKey(key.substring(0, lastHash)); workflowInstancesSet.add(wfi); if (workflowInstancesSet.size() == limit) { break; } result = scanner.next(); } } return executionData(workflowInstancesSet); } } BigtableStorage(Connection connection); @VisibleForTesting  BigtableStorage(Connection connection,
                  ExecutorService executor,
                  WaitStrategy waitStrategy,
                  StopStrategy retryStopStrategy); @Override void close(); static final TableName EVENTS_TABLE_NAME; }
@Test public void shouldProduceResourceNotFoundExceptionWhenNoExecutionData() throws Exception { setUp(0); thrown.expect(ResourceNotFoundException.class); thrown.expectMessage(containsString("Workflow instance not found")); storage.executionData(WFI1); }