PersonStore { public Collection<StoreEntry> getAll() { Builder<StoreEntry> builder = ImmutableList.builder(); for (Entry<String, Person> entry : persons.entrySet()) { builder.add(new AutoValue_PersonStore_StoreEntry(entry.getKey(), entry.getValue())); } return builder.build(); } @Inject  PersonStore(StoreConfig config, Ticker ticker); @Flatten PersonStoreStats getStats(); Person get(String id); boolean put(String id, Person person); boolean delete(String id); Collection<StoreEntry> getAll();  }
@Test public void testStartsEmpty() { PersonStore store = new PersonStore(new StoreConfig(), ticker); assertThat(store.getAll()).isEmpty(); }
@Test public void testGetAll() { PersonStore store = new PersonStore(new StoreConfig(), ticker); store.put("foo", createPerson("foo@example.com", "Mr Foo")); store.put("bar", createPerson("bar@example.com", "Mr Bar")); Collection<StoreEntry> entries = store.getAll(); assertThat(entries).hasSize(2); assertThat(entries) .filteredOn("id", "foo") .extracting("person") .containsExactly(createPerson("foo@example.com", "Mr Foo")); assertThat(entries) .filteredOn("id", "bar") .extracting("person") .containsExactly(createPerson("bar@example.com", "Mr Bar")); }