* 'org.apache.lucene.gdata.storage.db4o.DB4oStorage.updateEntry(ServerBaseEntry)'
*/
public void testUpdateEntry() throws StorageException, InterruptedException {
storeServerBaseFeed();
Storage storage = this.controller.getStorage();
ServerBaseEntry exEntry = new ServerBaseEntry();
try {
storage.updateEntry(null);
fail("entry is null");
} catch (StorageException e) {
//
}
try {
storage.updateEntry(exEntry);
fail("entry id is null");
} catch (StorageException e) {
//
}
exEntry.setId("someID");
try {
storage.updateEntry(exEntry);
fail("feed id is null");
} catch (StorageException e) {
//
}
ServerBaseEntry e = createServerBaseEntry();
ServerBaseEntry e1 = createServerBaseEntry();
try {
storage.updateEntry(e);
fail("entry does not exist");
} catch (StorageException ex) {
ex.printStackTrace();
}
storage.storeEntry(e);
storage = this.controller.getStorage();
storage.storeEntry(e1);
ServerBaseEntry e2 = createServerBaseEntry();
e2.setId(e.getId());
e2.setTitle(new PlainTextConstruct("new"));
e2.setUpdated(DateTime.now());
storage.updateEntry(e2);
ObjectContainer container = getContainer();
Query query = container.query();
query.constrain(BaseEntry.class);
query.descend("id").constrain(e.getId());
ObjectSet resultSet = query.execute();
assertEquals(1, resultSet.size());
BaseEntry result = (BaseEntry) resultSet.next();
assertEquals("new", result.getTitle().getPlainText());
assertEquals("2", result.getVersionId());
ServerBaseFeed bFeed = new ServerBaseFeed();
bFeed.setItemsPerPage(25);
bFeed.setId(FEEDID);
bFeed.setStartIndex(1);
bFeed.setServiceType(SERVICENAME);
storage = this.controller.getStorage();
BaseFeed<BaseFeed, BaseEntry> feed = storage.getFeed(bFeed);
assertEquals(2, feed.getEntries().size());
assertEquals(e.getId(), feed.getEntries().get(0).getId());
assertEquals(feed.getUpdated(), feed.getEntries().get(0).getUpdated());
storage = this.controller.getStorage();
storage.storeEntry(e);
e2.setVersion(5);
try {
storage.updateEntry(e2);
fail("version does not match");
} catch (Exception ex) {
// TODO: handle exception