ICategory category1 = fFactory.createCategory(null, feedRef.resolve());
category1.setName("Category");
ICategory category2 = fFactory.createCategory(null, newsRef.resolve());
category2.setName("Category");
final boolean categoryEvents[] = new boolean[6];
final CategoryReference categoryReference[] = new CategoryReference[2];
categoryListener = new CategoryListener() {
public void entitiesAdded(Set<CategoryEvent> events) {
for (CategoryEvent event : events) {
assertTrue("Expected this Event to be Root Event", event.isRoot());
if (categoryEvents[0])
categoryEvents[1] = true;
categoryEvents[0] = true;
}
}
public void entitiesDeleted(Set<CategoryEvent> events) {
for (CategoryEvent event : events) {
assertTrue("Expected this Event to be Root Event", event.isRoot());
if (categoryReference[0].references(event.getEntity()))
categoryEvents[2] = true;
else if (categoryReference[1].references(event.getEntity()))
categoryEvents[3] = true;
}
}
public void entitiesUpdated(Set<CategoryEvent> events) {
for (CategoryEvent event : events) {
assertTrue("Expected this Event to be Root Event", event.isRoot());
if (categoryReference[0].references(event.getEntity()))
categoryEvents[4] = true;
else if (categoryReference[1].references(event.getEntity()))
categoryEvents[5] = true;
}
}
};
DynamicDAO.addEntityListener(ICategory.class, categoryListener);
categoryReference[0] = new CategoryReference(DynamicDAO.save(category1).getId());
categoryReference[1] = new CategoryReference(DynamicDAO.save(category2).getId());
/* Update */
category1 = categoryReference[0].resolve();
category1.setName("Category Updated");
category2 = categoryReference[1].resolve();