@Test public void findAll() { List<Item> items = createItems(); SelectResult result = createMock(SelectResult.class); Capture<SelectRequest> requestCapture = new Capture<SelectRequest>(); expect(domainFactory.createFromRing(RING_NAME)).andReturn(domain(RING_NAME)); expect(simpleDbClient.select(capture(requestCapture))).andReturn(result); expect(result.getItems()).andReturn(items); expect(result.getNextToken()).andReturn(null); replayAll(); Set<CassandraInstance> expected = transform(items); assertEquals(expected, dao.findAll(RING_NAME)); assertEquals(ALL_QUERY, requestCapture.getValue().getSelectExpression()); assertNull(requestCapture.getValue().getNextToken()); }
@Override public ImmutableSet<CassandraInstance> findAll(String ring) { List<CassandraInstance> instances = Lists.newArrayList(); String nextToken = null; do { SelectRequest request = new SelectRequest(String.format(ALL_QUERY, domain(ring))) .withNextToken(nextToken); SelectResult result = client.select(request); for (Item item : result.getItems()) { instances.add(transform(item)); } nextToken = result.getNextToken(); } while (nextToken != null); return ImmutableSet.copyOf(instances); }
SdbCassandraInstanceDao implements CassandraInstanceDao { @Override public ImmutableSet<CassandraInstance> findAll(String ring) { List<CassandraInstance> instances = Lists.newArrayList(); String nextToken = null; do { SelectRequest request = new SelectRequest(String.format(ALL_QUERY, domain(ring))) .withNextToken(nextToken); SelectResult result = client.select(request); for (Item item : result.getItems()) { instances.add(transform(item)); } nextToken = result.getNextToken(); } while (nextToken != null); return ImmutableSet.copyOf(instances); } }
SdbCassandraInstanceDao implements CassandraInstanceDao { @Override public ImmutableSet<CassandraInstance> findAll(String ring) { List<CassandraInstance> instances = Lists.newArrayList(); String nextToken = null; do { SelectRequest request = new SelectRequest(String.format(ALL_QUERY, domain(ring))) .withNextToken(nextToken); SelectResult result = client.select(request); for (Item item : result.getItems()) { instances.add(transform(item)); } nextToken = result.getNextToken(); } while (nextToken != null); return ImmutableSet.copyOf(instances); } @Inject  SdbCassandraInstanceDao(AmazonSimpleDBClient client, CassandraDomainFactory domainFactory); }
SdbCassandraInstanceDao implements CassandraInstanceDao { @Override public ImmutableSet<CassandraInstance> findAll(String ring) { List<CassandraInstance> instances = Lists.newArrayList(); String nextToken = null; do { SelectRequest request = new SelectRequest(String.format(ALL_QUERY, domain(ring))) .withNextToken(nextToken); SelectResult result = client.select(request); for (Item item : result.getItems()) { instances.add(transform(item)); } nextToken = result.getNextToken(); } while (nextToken != null); return ImmutableSet.copyOf(instances); } @Inject  SdbCassandraInstanceDao(AmazonSimpleDBClient client, CassandraDomainFactory domainFactory); @Override ImmutableSet<CassandraInstance> findAll(String ring); @Override @Nullable CassandraInstance findById(String ring, int id); @Override void save(String ring, CassandraInstance instance); @Override void delete(String ring, CassandraInstance instance); }
SdbCassandraInstanceDao implements CassandraInstanceDao { @Override public ImmutableSet<CassandraInstance> findAll(String ring) { List<CassandraInstance> instances = Lists.newArrayList(); String nextToken = null; do { SelectRequest request = new SelectRequest(String.format(ALL_QUERY, domain(ring))) .withNextToken(nextToken); SelectResult result = client.select(request); for (Item item : result.getItems()) { instances.add(transform(item)); } nextToken = result.getNextToken(); } while (nextToken != null); return ImmutableSet.copyOf(instances); } @Inject  SdbCassandraInstanceDao(AmazonSimpleDBClient client, CassandraDomainFactory domainFactory); @Override ImmutableSet<CassandraInstance> findAll(String ring); @Override @Nullable CassandraInstance findById(String ring, int id); @Override void save(String ring, CassandraInstance instance); @Override void delete(String ring, CassandraInstance instance);  }