use of com.celements.blog.observation.event.ArticleCreatingEvent in project celements-blog by celements.
the class ArticleDatesListenerTest method testOnEvent.
@Test
public void testOnEvent() throws Exception {
DocumentReference articleDocRef = new DocumentReference("wiki", "space", "articleDoc");
XWikiDocument articleDoc = new XWikiDocument(articleDocRef);
BaseObject articleObj = new BaseObject();
articleObj.setXClassReference(listener.getBlogClasses().getArticleClassRef("wiki"));
articleDoc.addXObject(articleObj);
Date beforeDate = new Date();
replayDefault();
listener.onEvent(new ArticleCreatingEvent(), articleDoc, null);
verifyDefault();
Date afterDate = new Date();
Date publishDate = articleObj.getDateValue(BlogClasses.PROPERTY_ARTICLE_PUBLISH_DATE);
assertNotNull(publishDate);
assertTrue(beforeDate.equals(publishDate) || beforeDate.before(publishDate));
assertTrue(afterDate.equals(publishDate) || afterDate.after(publishDate));
Date archiveDate = articleObj.getDateValue(BlogClasses.PROPERTY_ARTICLE_ARCHIVE_DATE);
assertNotNull(archiveDate);
assertEquals(ILuceneSearchService.SDF.parse(ILuceneSearchService.DATE_HIGH), archiveDate);
}
use of com.celements.blog.observation.event.ArticleCreatingEvent in project celements-blog by celements.
the class ArticleUpdateListenerTest method testCreatingEvent.
@Test
public void testCreatingEvent() {
Event event = listener.getCreatingEvent(null);
assertNotNull(event);
assertSame(ArticleCreatingEvent.class, event.getClass());
assertTrue(event.matches(new ArticleCreatingEvent()));
assertNotSame(listener.getCreatingEvent(null), event);
}
use of com.celements.blog.observation.event.ArticleCreatingEvent in project celements-blog by celements.
the class ArticleCreateListenerTest method testCreatingEvent.
@Test
public void testCreatingEvent() {
Event event = listener.getCreatingEvent(null);
assertNotNull(event);
assertSame(ArticleCreatingEvent.class, event.getClass());
assertTrue(event.matches(new ArticleCreatingEvent()));
assertNotSame(listener.getCreatingEvent(null), event);
}
Aggregations