protected PublishEventTO createPublishEventTO(
     SubscriptionContext subsContext,
     Long dialogElementsResourceableId,
     Identity identity,
     DialogElement dialogElement,
     EventType eventType) {
   if (EventType.NO_PUBLISH.equals(eventType) || subsContext == null) {
     return PublishEventTO.getNoPublishInstance();
   }
   ContextInfo contextInfo =
       notificationSubscriptionContextFactory.createContextInfoFrom(subsContext);
   PublishEventTO publishEventTO =
       PublishEventTO.getValidInstance(
           contextInfo.getContextType(),
           contextInfo.contextId(),
           subsContext.getContextTitle(),
           contextInfo.subContextId(),
           DialogElementsNotificationTypeHandler.DIALOGELEMENTS_SOURCE_TYPE,
           dialogElementsResourceableId,
           subsContext.getSourceTitle(),
           dialogElement.getFilename(),
           identity,
           eventType);
   publishEventTO.setSourceEntryId(dialogElement.getFilename());
   return publishEventTO;
 }
  private void publishEvents() {
    for (ActionEntry action : actions.values()) {

      PublishEventTO publishEventTO =
          PublishEventTO.getValidInstance(
              publishers.get(action.publisherId).publisher.getContextType(),
              publishers.get(action.publisherId).publisher.getContextId(),
              publishers.get(action.publisherId).contextTitle,
              publishers.get(action.publisherId).publisher.getSubcontextId(),
              publishers.get(action.publisherId).publisher.getSourceType(),
              publishers.get(action.publisherId).publisher.getSourceId(),
              publishers.get(action.publisherId).sourceTitle,
              action.title,
              subscribers.get(action.subscriberId).subscriber.getIdentity(),
              getEventType(action.eventType));
      publishEventTO.setSourceEntryId(action.messageId);
      notificationServiceImpl.publishEvent(publishEventTO);
    }
  }
 /** Test method add */
 @Test
 public void testAdd() {
   final Item newEpisode = new Item();
   newEpisode.setGuid(CodeHelper.getGlobalForeverUniqueID());
   newEpisode.setTitle("This is my new Item");
   // Count episodes before
   final int initialCount = feed.getItems().size();
   feedManager.addItem(newEpisode, null, feed, PublishEventTO.getNoPublishInstance());
   // re-read feed and count episodes
   feed = feedManager.getFeed(feed);
   final int newCount = feed.getItems().size();
   // Compare
   assertEquals(initialCount + 1, newCount);
 }
  /** @see junit.framework.TestCase#setUp() */
  @Before
  public void setup() {
    setupMocking();

    // Create a feed that can be read, updated or deleted.
    final OLATResourceable podcastResource = feedManager.createPodcastResource();
    feed = feedManager.getFeed(podcastResource);
    feed.setTitle(PODCAST_TITLE);
    feedManager.updateFeedMetadata(feed);

    // Add an episode
    // A feed can only be edited when it is an internal feed (meaning that
    // it is made within OLAT). Obviously, external feeds cannot be changed.
    final Item item = new Item();
    item.setTitle("My Test Item");
    feed = feedManager.updateFeedMode(Boolean.FALSE, feed);
    feedManager.addItem(item, null, feed, PublishEventTO.getNoPublishInstance());
  }