Author: julien(a)jboss.com
Date: 2007-12-04 11:00:56 -0500 (Tue, 04 Dec 2007)
New Revision: 9284
Modified:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIObjectImpl.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/EventAssert.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/ModelTestCase.java
Log:
make child creation throw an event and test it
Modified:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIObjectImpl.java
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIObjectImpl.java 2007-12-04
15:45:20 UTC (rev 9283)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIObjectImpl.java 2007-12-04
16:00:56 UTC (rev 9284)
@@ -273,7 +273,16 @@
context.update(creation);
//
- return type.cast(context.getObject(creation.getChild().getId()));
+ StructuralObject child = creation.getChild();
+
+ // Eventing
+ StructuralStateModification mod = new StructuralStateModification.Creation(type,
name, EMPTY_STATE);
+ StateChange<StructuralStateModification> change = new
StateChange<StructuralStateModification>(child.getId(), mod);
+ StateChangeEvent event = new StateChangeEvent(change);
+ context.fireEvent(event);
+
+ //
+ return type.cast(context.getObject(child.getId()));
}
void update(StructuralObject object)
Modified:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/EventAssert.java
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/EventAssert.java 2007-12-04
15:45:20 UTC (rev 9283)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/EventAssert.java 2007-12-04
16:00:56 UTC (rev 9284)
@@ -69,6 +69,17 @@
Assert.assertEquals(sp.getChanges(), mod.getChanges());
}
+ public void next(String targetId, StructuralStateModification.Creation sp)
+ {
+ StateChangeEvent ste = next(StateChangeEvent.class);
+ StateChange change = ste.getChange();
+ Assert.assertEquals(targetId, change.getTargetId());
+ StructuralStateModification.Creation mod =
(StructuralStateModification.Creation)change.getModification();
+ Assert.assertEquals(sp.getName(), mod.getName());
+ Assert.assertEquals(sp.getType(), mod.getType());
+ Assert.assertEquals(sp.getProperties(), mod.getProperties());
+ }
+
public void next(String targetId, NavigationalStateModification ns)
{
StateChangeEvent ste = next(StateChangeEvent.class);
Modified:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/ModelTestCase.java
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/ModelTestCase.java 2007-12-04
15:45:20 UTC (rev 9283)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/ModelTestCase.java 2007-12-04
16:00:56 UTC (rev 9284)
@@ -40,6 +40,7 @@
import org.jboss.portal.presentation.test.model.state.structural.MockObject;
import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
/**
@@ -499,6 +500,8 @@
public void testCreateChild()
{
UIContext context = createContext();
+ EventAssert eventAssert = new EventAssert();
+ context.addModelListener(eventAssert);
assertNull(context.getChild("foo"));
@@ -509,5 +512,7 @@
assertSame(context, portal.getParent());
assertSame(portal, context.getChild("foo"));
+
+ eventAssert.next(portal.getId(), new
StructuralStateModification.Creation(UIPortal.class, "foo", new
HashMap<String, String>()));
}
}
Show replies by date