*
* @throws Exception
*/
@Test
public void testReparentMark() throws Exception {
FolderListener folderListener = null;
BookMarkListener bookMarkListener = null;
SearchMarkListener searchMarkListener = null;
try {
/* Add */
final IFolder oldParent = fFactory.createFolder(null, null, "Old parent");
FeedReference feedRef = new FeedReference(Long.MAX_VALUE);
final IBookMark bookMark = fFactory.createBookMark(null, oldParent,
new URL("http://www.link.com"), feedRef, "bookmark");
final ISearchMark searchMark = fFactory.createSearchMark(null, oldParent, "searchmark");
fDao.saveFolder(oldParent);
final IFolder newParent = fFactory.createFolder(null, null, "New parent");
fFactory.createFolder(null, newParent, "New parent child");
fDao.saveFolder(newParent);
final boolean[] bookMarkUpdateEventOccurred = new boolean[1];
bookMarkListener = new BookMarkListener() {
public void bookMarkAdded(Set<BookMarkEvent> events) {
fail("Unexpected event");
}
public void bookMarkDeleted(Set<BookMarkEvent> events) {
fail("Unexpected event");
}
public void bookMarkUpdated(Set<BookMarkEvent> events) {
bookMarkUpdateEventOccurred[0] = true;
assertEquals(1, events.size());
BookMarkEvent event = events.iterator().next();
assertEquals(bookMark, event.getEntity());
assertTrue("Expected this Event to be Root Event", event.isRoot());
assertEquals(oldParent, event.getOldParent());
assertEquals(newParent, event.getEntity().getFolder());
}
};
final boolean[] searchMarkUpdateEventOccurred = new boolean[1];
searchMarkListener = new SearchMarkListener() {
public void searchMarkAdded(Set<SearchMarkEvent> events) {
fail("Unexpected event");
}
public void searchMarkDeleted(Set<SearchMarkEvent> events) {
fail("Unexpected event");
}
public void searchMarkUpdated(Set<SearchMarkEvent> events) {
searchMarkUpdateEventOccurred[0] = true;
assertEquals(1, events.size());
SearchMarkEvent event = events.iterator().next();
assertEquals(searchMark, event.getEntity());
assertTrue("Expected this Event to be Root Event", event.isRoot());
assertEquals(oldParent, event.getOldParent());
assertEquals(newParent, event.getEntity().getFolder());
}
};
final boolean[] folderUpdateEventOccurred = new boolean[1];
folderListener = new FolderListener() {
public void folderAdded(Set<FolderEvent> events) {
fail("Unexpected event");
}
public void folderDeleted(Set<FolderEvent> events) {