@SuppressWarnings("unchecked")
  @Test
  public void testUpdateByPath() throws IOException, ServiceException {
    final BasePageEntry<?> parent = new WebPageEntry();
    parent.setPageName(new PageName("parent"));
    final BasePageEntry<?> newEntry = new WebPageEntry();
    newEntry.setPageName(new PageName("entry"));
    final List<BasePageEntry<?>> ancestors = Lists.newLinkedList();
    ancestors.add(parent);
    final BasePageEntry<?> oldEntry = new WebPageEntry();
    final String id = feedUrl.toExternalForm() + "/entry";
    oldEntry.setId(id);
    oldEntry.addLink(ILink.Rel.ENTRY_EDIT, ILink.Type.ATOM, id);
    final BaseContentEntry<?> returnedEntry = new WebPageEntry();

    context.checking(
        new Expectations() {
          {
            allowing(entryProvider).getEntries(with(any(ContentQuery.class)), with(sitesService));
            will(returnValue(Lists.newArrayList(oldEntry)));
            oneOf(entryUpdater).updateEntry(oldEntry, newEntry, sitesService);
            will(returnValue(returnedEntry));
          }
        });

    assertEquals(
        returnedEntry, entryUploader.uploadEntry(newEntry, ancestors, feedUrl, sitesService));
  }
  @Test
  public void testUpdateById() throws IOException, ServiceException {
    final String id = feedUrl.toExternalForm() + "/entry";
    final BaseContentEntry<?> newEntry = new WebPageEntry();
    newEntry.setId(id);
    final BaseContentEntry<?> oldEntry = new WebPageEntry();
    oldEntry.setId(id);
    oldEntry.addLink(ILink.Rel.ENTRY_EDIT, ILink.Type.ATOM, id);
    final BaseContentEntry<?> returnedEntry = new WebPageEntry();
    returnedEntry.setId(id);

    context.checking(
        new Expectations() {
          {
            oneOf(sitesService).getEntry(new URL(id), WebPageEntry.class);
            will(returnValue(oldEntry));
            oneOf(entryUpdater).updateEntry(oldEntry, newEntry, sitesService);
            will(returnValue(returnedEntry));
          }
        });

    assertEquals(
        returnedEntry,
        entryUploader.uploadEntry(
            newEntry, new LinkedList<BasePageEntry<?>>(), feedUrl, sitesService));
  }