* Tests for onModifiedAdded.
*/
@Test
public final void testOnModifiedAdded() {
final PerceptionToObject pto = new PerceptionToObject();
final RPObject object = new RPObject();
object.setID(new RPObject.ID(1, "zone"));
final String attribute = "modifiedadded";
final ObjectChangeListener listener = new ObjectChangeListenerAdapter() {
@Override
public void modifiedAdded(final RPObject changes) {
object.add(attribute, 1);
}
};
final RPObject changes = new RPObject();
changes.setID(new RPObject.ID(object.getID().getObjectID(), object.getID().getZoneID()));
final RPObject object2 = new RPObject();
object2.setID(new RPObject.ID(2, "zone"));
pto.register(object, listener);
pto.register(object2, listener);
assertTrue(pto.map.containsKey(object.getID()));
assertFalse(object.has(attribute));
assertTrue(pto.map.containsKey(object2.getID()));
assertFalse(object2.has(attribute));
pto.onModifiedAdded(object, changes);
assertTrue(pto.map.containsKey(object.getID()));
assertTrue(object.has(attribute));
assertTrue(pto.map.containsKey(object2.getID()));
assertFalse(object2.has(attribute));
}