use of com.enonic.xp.event.Event in project xp by enonic.
the class EventPublisherImplTest method testPublish_noListener.
@Test
public void testPublish_noListener() {
final Event event = Event.create("test").build();
this.publisher.publish(event);
}
use of com.enonic.xp.event.Event in project xp by enonic.
the class EventPublisherImplTest method testPublish_withListener.
@Test
public void testPublish_withListener() throws Exception {
final EventListener listener = mock(EventListener.class);
this.publisher.addListener(listener);
final Event event = Event.create("test").build();
for (int i = 0; i < 100; i++) {
this.publisher.publish(event);
}
verify(listener, times(100)).onEvent(Mockito.any());
}
use of com.enonic.xp.event.Event in project xp by enonic.
the class NodeEventsTest method testRenamed.
@Test
public void testRenamed() {
final Node sourceNode = createNode("before", NodePath.create("/mynode1/child1").build(), "myId");
final Node targetNode = createNode("after", NodePath.create("/mynode1/child1").build(), "myId");
Event event = NodeEvents.renamed(sourceNode.path(), targetNode);
assertNotNull(event);
assertTrue(event.isDistributed());
assertEquals(NodeEvents.NODE_RENAMED_EVENT, event.getType());
assertEquals("[{id=myId, path=/mynode1/child1/before, branch=draft, repo=com.enonic.cms.default, newPath=/mynode1/child1/after}]", event.getValue("nodes").get().toString());
}
use of com.enonic.xp.event.Event in project xp by enonic.
the class NodeEventsTest method testStateUpdated.
@Test
public void testStateUpdated() {
final Node pushed1 = createNode("state_updated1", NodePath.create("/mynode1/state_updated1").build(), "id1");
final Node pushed2 = createNode("state_updated2", NodePath.create("/mynode1/state_updated2").build(), "id2");
final Node pushed3 = createNode("state_updated3", NodePath.create("/mynode1/state_updated3").build(), "id3");
final Nodes nodes = Nodes.from(pushed1, pushed2, pushed3);
Event event = NodeEvents.stateUpdated(nodes);
assertNotNull(event);
assertTrue(event.isDistributed());
assertTrue(event.hasValue("nodes"));
assertTrue(event.hasValue("state"));
assertEquals(NodeEvents.NODE_STATE_UPDATED_EVENT, event.getType());
assertEquals(NodeState.DEFAULT.toString(), event.getValue("state").get());
assertEquals("[{id=id1, path=/mynode1/state_updated1/state_updated1, branch=draft, repo=com.enonic.cms.default}" + ", {id=id2, path=/mynode1/state_updated2/state_updated2, branch=draft, repo=com.enonic.cms.default}" + ", {id=id3, path=/mynode1/state_updated3/state_updated3, branch=draft, repo=com.enonic.cms.default}]", event.getValue("nodes").get().toString());
}
use of com.enonic.xp.event.Event in project xp by enonic.
the class NodeEventsTest method testMoved.
@Test
public void testMoved() {
final Node sourceNode = createNode("before", NodePath.create("/mynode1/child1").build(), "myId");
final Node targetNode = createNode("after", NodePath.create("/mynode1").build(), "myId");
Event event = NodeEvents.moved(MoveNodeResult.create().addMovedNode(MoveNodeResult.MovedNode.create().node(targetNode).previousPath(sourceNode.path()).build()).sourceNode(sourceNode).build());
assertNotNull(event);
assertTrue(event.isDistributed());
assertEquals(NodeEvents.NODE_MOVED_EVENT, event.getType());
assertEquals("[{id=myId, path=/mynode1/child1/before, branch=draft, repo=com.enonic.cms.default, newPath=/mynode1/after}]", event.getValue("nodes").get().toString());
}
Aggregations