IPerson person1 = fFactory.createPerson(null, feedRef.resolve());
person1.setName("Person1");
IPerson person2 = fFactory.createPerson(null, newsRef.resolve());
person2.setName("Person2");
final boolean personEvents[] = new boolean[6];
final PersonReference personReference[] = new PersonReference[2];
personListener = new PersonListener() {
public void entitiesAdded(Set<PersonEvent> events) {
for (PersonEvent event : events) {
assertTrue("Expected this Event to be Root Event", event.isRoot());
if (personEvents[0])
personEvents[1] = true;
personEvents[0] = true;
}
}
public void entitiesDeleted(Set<PersonEvent> events) {
for (PersonEvent event : events) {
assertTrue("Expected this Event to be Root Event", event.isRoot());
if (personReference[0].references(event.getEntity()))
personEvents[2] = true;
else if (personReference[1].references(event.getEntity()))
personEvents[3] = true;
}
}
public void entitiesUpdated(Set<PersonEvent> events) {
for (PersonEvent event : events) {
assertTrue("Expected this Event to be Root Event", event.isRoot());
if (personReference[0].references(event.getEntity()))
personEvents[4] = true;
else if (personReference[1].references(event.getEntity()))
personEvents[5] = true;
}
}
};
DynamicDAO.addEntityListener(IPerson.class, personListener);
personReference[0] = new PersonReference(DynamicDAO.save(person1).getId());
personReference[1] = new PersonReference(DynamicDAO.save(person2).getId());
/* Update */
person1 = personReference[0].resolve();
person1.setName("Person Updated");
person2 = personReference[1].resolve();