PublishingEventHelper { public NodeRef getPublishingEventNode(String id) { if (id != null && NodeRef.isNodeRef(id)) { NodeRef eventNode = new NodeRef(id); if (nodeService.exists(eventNode) && TYPE_PUBLISHING_EVENT.equals(nodeService.getType(eventNode))) { return eventNode; } } return null; }  void setNodeService(NodeService nodeService); void setContentService(ContentService contentService); void setTransferManifestNodeFactory(TransferManifestNodeFactory transferManifestNodeFactory); void setVersionService(VersionService versionService); void setWorkflowService(WorkflowService workflowService); void setWorkflowEngineId(String workflowEngineId); void setSerializer(NodeSnapshotSerializer serializer); void setPermissionService(PermissionService permissionService); PublishingEvent getPublishingEvent(NodeRef eventNode); List<PublishingEvent> getPublishingEvents(List<NodeRef> eventNodes); NodeRef createNode(NodeRef queueNode, PublishingDetails details); List<NodeRef> findPublishingEventNodes(final NodeRef queue, PublishingEventFilter filter); List<NodeRef> getEventNodesForPublishedNodes(final NodeRef queue, NodeRef... publishedNodes); List<NodeRef> getEventNodesForPublishedNodes(final NodeRef queue, Collection<NodeRef> publishedNodes); List<NodeRef> getEventNodesForUnpublishedNodes(final NodeRef queue, Collection<NodeRef> unpublishedNodes); List<NodeRef> getEventNodesForPublishedNode(final NodeRef queue, NodeRef publishedNode); List<NodeRef> getEventNodesForUnpublishedNode(final NodeRef queue, NodeRef unpublishedNode); List<PublishingEvent> findPublishingEvents(NodeRef queue, PublishingEventFilter filter); PublishingEvent getPublishingEvent(String id); NodeRef getPublishingEventNode(String id); String startPublishingWorkflow(NodeRef eventNode, Calendar scheduledTime); Calendar getScheduledTime(NodeRef eventNode); Calendar getScheduledTime(Map<QName, Serializable> eventProperties); NodeRef getLastPublishEvent(NodeRef source, NodeRef channelNode); void cancelEvent(String id); AssociationRef linkToLastEvent(NodeRef publishedNode, NodeRef eventNode); PublishingDetails createPublishingDetails(); static final String WORKFLOW_DEFINITION_NAME; }
@Test public void testGetPublishingEventNode() throws Exception { NodeRef eventNode= helper.getPublishingEventNode(null); assertNull("If id is null event shoudl be null!", eventNode); eventNode= helper.getPublishingEventNode("foo"); assertNull("If id is invalid event shoudl be null!", eventNode); String nonExistantId = "foo: eventNode= helper.getPublishingEventNode(nonExistantId); assertNull("If event node does not exist event shoudl be null!", eventNode); String nonPublishingEventId = "foo: NodeRef nonPublishingEventNode = new NodeRef(nonPublishingEventId); when(nodeService.exists(nonPublishingEventNode)).thenReturn(true); eventNode= helper.getPublishingEventNode(nonPublishingEventId); assertNull("Event shoudl exist!", eventNode); String publishingEventId = "foo: NodeRef publishingEventNode = new NodeRef(publishingEventId); when(nodeService.exists(publishingEventNode)).thenReturn(true); when(nodeService.getType(publishingEventNode)).thenReturn(TYPE_PUBLISHING_EVENT); eventNode= helper.getPublishingEventNode(publishingEventId); assertNotNull("Event shoudl exist!", eventNode); }