Search in sources :

Example 1 with ReadWriteLockDataStore

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<>();
}
Also used : Serializable(java.io.Serializable) CombinedFeed(org.glassfish.jersey.examples.feedcombiner.model.CombinedFeed) ArrayList(java.util.ArrayList) ReadWriteLockDataStore(org.glassfish.jersey.examples.feedcombiner.store.ReadWriteLockDataStore)

Example 2 with ReadWriteLockDataStore

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);
}
Also used : MyApplication(org.glassfish.jersey.examples.feedcombiner.MyApplication) ReadWriteLockDataStore(org.glassfish.jersey.examples.feedcombiner.store.ReadWriteLockDataStore)

Example 3 with ReadWriteLockDataStore

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);
}
Also used : MyApplication(org.glassfish.jersey.examples.feedcombiner.MyApplication) ReadWriteLockDataStore(org.glassfish.jersey.examples.feedcombiner.store.ReadWriteLockDataStore)

Example 4 with ReadWriteLockDataStore

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));
}
Also used : Serializable(java.io.Serializable) CombinedFeed(org.glassfish.jersey.examples.feedcombiner.model.CombinedFeed) ReadWriteLockDataStore(org.glassfish.jersey.examples.feedcombiner.store.ReadWriteLockDataStore) Test(org.junit.Test)

Aggregations

ReadWriteLockDataStore (org.glassfish.jersey.examples.feedcombiner.store.ReadWriteLockDataStore)4 Serializable (java.io.Serializable)2 MyApplication (org.glassfish.jersey.examples.feedcombiner.MyApplication)2 CombinedFeed (org.glassfish.jersey.examples.feedcombiner.model.CombinedFeed)2 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1