use of org.glassfish.jersey.examples.feedcombiner.model.CombinedFeed in project jersey by jersey.
the class CombinedFeedResourceTest method testDeleteNotFound.
@Test
public void testDeleteNotFound() {
// Saving entity
CombinedFeed feed = combinedFeed("1");
datastore.put(feed.getId(), feed);
// Deleting entity
Response deleteResp = target.path("wrong_id").request().delete();
assertEquals(Status.NOT_FOUND.getStatusCode(), deleteResp.getStatus());
}
use of org.glassfish.jersey.examples.feedcombiner.model.CombinedFeed in project jersey by jersey.
the class CombinedFeedResourceTest method testCreate.
@Test
public void testCreate() {
CombinedFeed feed = combinedFeed("1");
Entity<CombinedFeed> entity = Entity.entity(feed, APPLICATION_JSON_TYPE);
Response response = target.request(MediaType.APPLICATION_JSON).post(entity);
assertEquals(Status.CREATED.getStatusCode(), response.getStatus());
assertEquals(feed, response.readEntity(CombinedFeed.class));
}
use of org.glassfish.jersey.examples.feedcombiner.model.CombinedFeed 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));
}
use of org.glassfish.jersey.examples.feedcombiner.model.CombinedFeed in project jersey by jersey.
the class CombinedFeedServiceTest method testSaveWithoutRefreshPeriod.
@Test
public void testSaveWithoutRefreshPeriod() {
String id = "1";
CombinedFeed feed = new CombinedFeed.CombinedFeedBuilder(id, "http://localhost").title("title").description("description").build();
CombinedFeed expected = CombinedFeed.CombinedFeedBuilder.of(feed).refreshPeriod(Long.parseLong(DEFAULT_REFRESH_PERIOD)).build();
expect(idGenerator.getId()).andReturn(id);
expect(datastore.put(eq(id), eq(expected))).andReturn(null);
replayAll();
CombinedFeed actual = testedClass.save(feed);
verifyAll();
assertEquals(expected, actual);
}
use of org.glassfish.jersey.examples.feedcombiner.model.CombinedFeed in project jersey by jersey.
the class ReadWriteLockDataStoreTest method testUpdateEntity.
@Test
public void testUpdateEntity() {
String id = "1";
CombinedFeed feed = getCombinedFeed(id);
observer.save(feed);
replayAll();
// save entity
testedClass.put(id, feed);
CombinedFeed updatedFeed = CombinedFeed.CombinedFeedBuilder.of(feed).title("updated_title").description("updated_description").build();
// update entity
Serializable previousEntity = testedClass.put(id, updatedFeed);
verifyAll();
if (!(previousEntity instanceof CombinedFeed)) {
fail("The previous entity is not an instance of CombinedFeed");
}
assertEquals(feed, previousEntity);
}
Aggregations