@Test public void testGetAll() { ReadWriteLockDataStore datastoreMock = createMock("datastore", ReadWriteLockDataStore.class); testedClass = new CombinedFeedService(datastoreMock, idGenerator, DEFAULT_REFRESH_PERIOD); CombinedFeed feed = new CombinedFeed.CombinedFeedBuilder("1", "http: .title("title").description("description").build(); List<Serializable> entities = Arrays.asList(feed, "fakeObject"); expect(datastoreMock.getAll()).andReturn(entities); replay(datastoreMock); List<CombinedFeed> actual = testedClass.getAll(); verify(datastoreMock); assertEquals(1, actual.size()); assertEquals(feed, actual.get(0)); }
@Override public List<CombinedFeed> getAll() { if (datastore instanceof ReadWriteLockDataStore) { ReadWriteLockDataStore rwDatastore = (ReadWriteLockDataStore) datastore; Collection<Serializable> entities = rwDatastore.getAll(); return entities.parallelStream() .filter(entity -> entity instanceof CombinedFeed) .map(CombinedFeed.class::cast) .collect(Collectors.toList()); } return new ArrayList<>(); }
CombinedFeedService implements CrudService<CombinedFeed> { @Override public List<CombinedFeed> getAll() { if (datastore instanceof ReadWriteLockDataStore) { ReadWriteLockDataStore rwDatastore = (ReadWriteLockDataStore) datastore; Collection<Serializable> entities = rwDatastore.getAll(); return entities.parallelStream() .filter(entity -> entity instanceof CombinedFeed) .map(CombinedFeed.class::cast) .collect(Collectors.toList()); } return new ArrayList<>(); } }
CombinedFeedService implements CrudService<CombinedFeed> { @Override public List<CombinedFeed> getAll() { if (datastore instanceof ReadWriteLockDataStore) { ReadWriteLockDataStore rwDatastore = (ReadWriteLockDataStore) datastore; Collection<Serializable> entities = rwDatastore.getAll(); return entities.parallelStream() .filter(entity -> entity instanceof CombinedFeed) .map(CombinedFeed.class::cast) .collect(Collectors.toList()); } return new ArrayList<>(); } @Inject  CombinedFeedService(InMemoryDataStore datastore, IdGenerator idGenerator,
                               @Named(DEFAULT_REFRESH_PERIOD) String defaultRefreshPeriod); }
CombinedFeedService implements CrudService<CombinedFeed> { @Override public List<CombinedFeed> getAll() { if (datastore instanceof ReadWriteLockDataStore) { ReadWriteLockDataStore rwDatastore = (ReadWriteLockDataStore) datastore; Collection<Serializable> entities = rwDatastore.getAll(); return entities.parallelStream() .filter(entity -> entity instanceof CombinedFeed) .map(CombinedFeed.class::cast) .collect(Collectors.toList()); } return new ArrayList<>(); } @Inject  CombinedFeedService(InMemoryDataStore datastore, IdGenerator idGenerator,
                               @Named(DEFAULT_REFRESH_PERIOD) String defaultRefreshPeriod); @Override CombinedFeed save(CombinedFeed insertedFeed); @Override Serializable delete(String feedId); @Override CombinedFeed update(CombinedFeed feed); @Override CombinedFeed get(String feedId); @Override List<CombinedFeed> getAll(); }
CombinedFeedService implements CrudService<CombinedFeed> { @Override public List<CombinedFeed> getAll() { if (datastore instanceof ReadWriteLockDataStore) { ReadWriteLockDataStore rwDatastore = (ReadWriteLockDataStore) datastore; Collection<Serializable> entities = rwDatastore.getAll(); return entities.parallelStream() .filter(entity -> entity instanceof CombinedFeed) .map(CombinedFeed.class::cast) .collect(Collectors.toList()); } return new ArrayList<>(); } @Inject  CombinedFeedService(InMemoryDataStore datastore, IdGenerator idGenerator,
                               @Named(DEFAULT_REFRESH_PERIOD) String defaultRefreshPeriod); @Override CombinedFeed save(CombinedFeed insertedFeed); @Override Serializable delete(String feedId); @Override CombinedFeed update(CombinedFeed feed); @Override CombinedFeed get(String feedId); @Override List<CombinedFeed> getAll();  }