*/
@Test
public void testAddUpdateAndGetSearchMark() {
SearchMarkListener searchMarkListener = null;
try {
final SearchMark initialSearchMark = (SearchMark) createSearchMark();
final SearchMark[] updatedSearchMark = new SearchMark[1];
final boolean[] searchMarkAddedCalled = new boolean[] { false };
final boolean[] searchMarkUpdatedCalled = new boolean[] { false };
searchMarkListener = new SearchMarkAdapter() {
@Override
public void entitiesAdded(Set<SearchMarkEvent> events) {
SearchMarkEvent event = events.iterator().next();
try {
searchMarkAddedCalled[0] = true;
SearchMark dbSearchMark = (SearchMark) event.getEntity();
initialSearchMark.setId(dbSearchMark.getId());
assertTrue(initialSearchMark.isIdentical(dbSearchMark));
dbSearchMark.setName("Another name");
updatedSearchMark[0] = dbSearchMark;
DynamicDAO.save(dbSearchMark);
} catch (PersistenceException e) {
fail(e.getMessage());
}
}
@Override
public void entitiesUpdated(Set<SearchMarkEvent> events) {
SearchMarkEvent event = events.iterator().next();
searchMarkUpdatedCalled[0] = true;
SearchMark dbSearchMark = (SearchMark) event.getEntity();
assertTrue(updatedSearchMark[0].isIdentical(dbSearchMark));
}
};
DynamicDAO.addEntityListener(ISearchMark.class, searchMarkListener);
DynamicDAO.save(initialSearchMark);