PublishDelegate { public int publishEvent(PublishEventTO publishEventTO) { Publisher publisher = getPublisher(publishEventTO); if (publisher == null) { log.info("found no publisher for context-type=" + publishEventTO.getContextType() + " context-id=" + publishEventTO.getContextId() + " source-type=" + publishEventTO.getSourceType() + " source-id=" + publishEventTO.getSourceId()); } else { log.debug("publishEvent: create NotificationEvents for ContextTitle=" + publishEventTO.getContextTitle() + " SourceTitle=" + publishEventTO.getSourceTitle()); List<NotificationEvent> notificationEvents = notificationEventDao.createAndSaveNotificationEvents(publisher, createAttributesFrom(publishEventTO)); return notificationEvents.size(); } return 0; }  int publishEvent(PublishEventTO publishEventTO);  }
@Test(expected = IllegalArgumentException.class) public void publishEvent() { PublishEventTO invalidPublishEventTO = PublishEventTO.getValidInstance(contextType, null, contextTitle, subcontextId, sourceType, sourceId, sourceTitle, sourceEntryTitle, creatorIdentity, EventType.NEW); invalidPublishEventTO.setSourceEntryId(sourceEntryId.toString()); publishDelegateTestObject.publishEvent(invalidPublishEventTO); }
@Test public void publishEvent_noPublisherExists() { when(publishDelegateTestObject.publisherDao.findPublisher(contextId, contextType, sourceId, sourceType)).thenReturn(null); PublishEventTO invalidPublishEventTO = PublishEventTO.getValidInstance(ContextType.COURSE, contextId, contextTitle, subcontextId, ForumNotificationTypeHandler.FORUM_SOURCE_TYPE, sourceId, sourceTitle, sourceEntryTitle, creatorIdentity, EventType.NEW); invalidPublishEventTO.setSourceEntryId("4"); assertEquals("", 0, publishDelegateTestObject.publishEvent(invalidPublishEventTO)); }