use of org.glassfish.jersey.examples.feedcombiner.store.ReadWriteLockDataStore in project jersey by jersey.
the class CombinedFeedService method getAll.
@Override
public List<CombinedFeed> getAll() {
//TODO ugly, for purposes of CRUD controller
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<>();
}
use of org.glassfish.jersey.examples.feedcombiner.store.ReadWriteLockDataStore in project jersey by jersey.
the class CombinedFeedControllerTest method configure.
@Override
protected Application configure() {
enable(TestProperties.LOG_TRAFFIC);
enable(TestProperties.DUMP_ENTITY);
datastore = new ReadWriteLockDataStore();
return new MyApplication(datastore, false);
}
use of org.glassfish.jersey.examples.feedcombiner.store.ReadWriteLockDataStore in project jersey by jersey.
the class CombinedFeedResourceTest method configure.
@Override
protected Application configure() {
enable(TestProperties.LOG_TRAFFIC);
enable(TestProperties.DUMP_ENTITY);
datastore = new ReadWriteLockDataStore();
return new MyApplication(datastore, false);
}
use of org.glassfish.jersey.examples.feedcombiner.store.ReadWriteLockDataStore in project jersey by jersey.
the class CombinedFeedServiceTest method testGetAll.
@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://localhost").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));
}
Aggregations