CategoryListener categoryListener = null;
try {
categoryListener = new CategoryAdapter() {
@Override
public void categoryAdded(Set<CategoryEvent> events) {
CategoryEvent event = events.iterator().next();
try {
categoryAddedCalled[0] = true;
Category dbCategory = (Category) event.getEntity();
initialCategory[0].setId(dbCategory.getId());
assertTrue(initialCategory[0].isIdentical(dbCategory));
dbCategory.setDomain("newDomain/newDomain");
updatedCategory[0] = dbCategory;
fModelDAO.saveCategory(dbCategory);
} catch (PersistenceException e) {
fail(e.getMessage());
}
}
@Override
public void categoryUpdated(Set<CategoryEvent> events) {
CategoryEvent event = events.iterator().next();
categoryUpdatedCalled[0] = true;
Category dbCategory = (Category) event.getEntity();
assertTrue(updatedCategory[0].isIdentical(dbCategory));
}
};
NewsModel.getDefault().addCategoryListener(categoryListener);
fModelDAO.saveCategory(initialCategory[0]);