use of org.glassfish.jersey.examples.feedcombiner.model.CombinedFeed in project jersey by jersey.
the class ReadWriteLockDataStoreTest method testSaveEntity.
@Test
public void testSaveEntity() {
String id = "1";
CombinedFeed feed = new CombinedFeed.CombinedFeedBuilder(id, "http://localhost").title("title").description("description").refreshPeriod(5L).build();
observer.save(feed);
replayAll();
Serializable previousEntity = testedClass.put(id, feed);
verifyAll();
assertNull(previousEntity);
}
use of org.glassfish.jersey.examples.feedcombiner.model.CombinedFeed in project jersey by jersey.
the class ReadWriteLockDataStoreTest method testSaveEntityWithNullKey.
@Test(expected = NullPointerException.class)
public void testSaveEntityWithNullKey() {
String id = null;
CombinedFeed feed = getCombinedFeed(id);
observer.save(feed);
replayAll();
// save entity
testedClass.put(id, feed);
verifyAll();
}
use of org.glassfish.jersey.examples.feedcombiner.model.CombinedFeed in project jersey by jersey.
the class ReadWriteLockDataStoreTest method testGetNullEntity.
@Test
public void testGetNullEntity() {
CombinedFeed combinedFeed = testedClass.get("1", CombinedFeed.class);
assertNull(combinedFeed);
}
use of org.glassfish.jersey.examples.feedcombiner.model.CombinedFeed in project jersey by jersey.
the class ReadWriteLockDataStoreTest method testSaveDatastore.
@Test
public void testSaveDatastore() {
// Insert new combined Feed
String id = "1";
CombinedFeed feed = new CombinedFeed.CombinedFeedBuilder(id, "http://localhost").title("title").description("description").refreshPeriod(5L).build();
observer.save(feed);
replayAll();
testedClass.put(id, feed);
// Copy the datastore into the stream
try {
ByteArrayOutputStream output = new ByteArrayOutputStream();
testedClass.save(output);
// Deserialize the datastore
Map<String, Serializable> entities = SerializationUtils.<Map<String, Serializable>>deserialize(output.toByteArray());
// Check whether is the saved entity was deserialized successfully or not
Serializable serializableEntity = entities.get(id);
if (serializableEntity instanceof CombinedFeed) {
CombinedFeed fetchedFeed = (CombinedFeed) serializableEntity;
assertEquals(feed, fetchedFeed);
} else {
fail("Deserialized entity is not CombinedFeed Class");
}
} catch (IOException e) {
fail(e.getMessage());
}
verifyAll();
}
use of org.glassfish.jersey.examples.feedcombiner.model.CombinedFeed in project jersey by jersey.
the class ReadWriteLockDataStoreTest method testGetEntity.
@Test
public void testGetEntity() {
String id = "1";
CombinedFeed feed = getCombinedFeed(id);
observer.save(feed);
replayAll();
// save entity
testedClass.put(id, feed);
CombinedFeed fetchedFeed = testedClass.get(id, CombinedFeed.class);
verifyAll();
assertEquals(feed, fetchedFeed);
}
Aggregations