final PersonReference personRef = new PersonReference(fDao.loadNews(newsRef.getId()).getAuthor().getId());
final AttachmentReference attachmentRef1 = new AttachmentReference(fDao.loadNews(newsRef.getId()).getAttachments().get(0).getId());
final AttachmentReference attachmentRef2 = new AttachmentReference(fDao.loadNews(newsRef.getId()).getAttachments().get(1).getId());
final AttachmentReference attachmentRef3 = new AttachmentReference(fDao.loadNews(newsRef.getId()).getAttachments().get(2).getId());
final CategoryReference categoryRef = new CategoryReference(fDao.loadNews(newsRef.getId()).getCategories().get(0).getId());
/* Check News Deleted */
final boolean newsDeleted[] = new boolean[1];
newsListener = new NewsAdapter() {
@Override
public void newsDeleted(Set<NewsEvent> events) {
for (NewsEvent event : events) {
assertTrue("Expected this Event to be Root Event", event.isRoot());
if (newsRef.references(event.getEntity()))
newsDeleted[0] = true;
try {
assertEquals(new URL("http://www.foobar.com").toString(),
event.getEntity().getFeedReference().getLink().toString());
} catch (MalformedURLException e) {
fail(e.getMessage());
}
}
}
};
fModel.addNewsListener(newsListener);
/* Check Author Deleted */
final boolean personDeleted[] = new boolean[1];
personListener = new PersonAdapter() {
@Override
public void personDeleted(Set<PersonEvent> events) {
for (PersonEvent event : events) {
assertFalse("Expected this Event to be no Root Event", event.isRoot());
if (personRef.references(event.getEntity()))
personDeleted[0] = true;
}
}
};
fModel.addPersonListener(personListener);
/* Check Attachments Deleted */
final boolean attachmentDeleted[] = new boolean[3];
attachmentListener = new AttachmentAdapter() {
@Override
public void attachmentDeleted(Set<AttachmentEvent> events) {
for (AttachmentEvent event : events) {
assertFalse("Expected this Event to be no Root Event", event.isRoot());
IAttachment attachment = event.getEntity();
if (attachmentRef1.references(attachment))
attachmentDeleted[0] = true;
else if (attachmentRef2.references(attachment))
attachmentDeleted[1] = true;
else if (attachmentRef3.references(attachment))
attachmentDeleted[2] = true;
}
}
};
fModel.addAttachmentListener(attachmentListener);
/* Check Category Deleted */
final boolean categoryDeleted[] = new boolean[1];
categoryListener = new CategoryAdapter() {
@Override
public void categoryDeleted(Set<CategoryEvent> events) {
for (CategoryEvent event : events) {
assertFalse("Expected this Event to be no Root Event", event.isRoot());
if (categoryRef.references(event.getEntity()))
categoryDeleted[0] = true;
}
}
};
fModel.addCategoryListener(categoryListener);