Search in sources :

Example 1 with ArticleCreatingEvent

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);
}
Also used : XWikiDocument(com.xpn.xwiki.doc.XWikiDocument) ArticleCreatingEvent(com.celements.blog.observation.event.ArticleCreatingEvent) DocumentReference(org.xwiki.model.reference.DocumentReference) Date(java.util.Date) BaseObject(com.xpn.xwiki.objects.BaseObject) Test(org.junit.Test)

Example 2 with ArticleCreatingEvent

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);
}
Also used : ArticleCreatingEvent(com.celements.blog.observation.event.ArticleCreatingEvent) ArticleCreatingEvent(com.celements.blog.observation.event.ArticleCreatingEvent) ArticleCreatedEvent(com.celements.blog.observation.event.ArticleCreatedEvent) ArticleUpdatingEvent(com.celements.blog.observation.event.ArticleUpdatingEvent) ArticleDeletingEvent(com.celements.blog.observation.event.ArticleDeletingEvent) Event(org.xwiki.observation.event.Event) ArticleUpdatedEvent(com.celements.blog.observation.event.ArticleUpdatedEvent) ArticleDeletedEvent(com.celements.blog.observation.event.ArticleDeletedEvent) Test(org.junit.Test)

Example 3 with ArticleCreatingEvent

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);
}
Also used : ArticleCreatingEvent(com.celements.blog.observation.event.ArticleCreatingEvent) ArticleCreatingEvent(com.celements.blog.observation.event.ArticleCreatingEvent) ArticleCreatedEvent(com.celements.blog.observation.event.ArticleCreatedEvent) Event(org.xwiki.observation.event.Event) Test(org.junit.Test)

Aggregations

ArticleCreatingEvent (com.celements.blog.observation.event.ArticleCreatingEvent)3 Test (org.junit.Test)3 ArticleCreatedEvent (com.celements.blog.observation.event.ArticleCreatedEvent)2 Event (org.xwiki.observation.event.Event)2 ArticleDeletedEvent (com.celements.blog.observation.event.ArticleDeletedEvent)1 ArticleDeletingEvent (com.celements.blog.observation.event.ArticleDeletingEvent)1 ArticleUpdatedEvent (com.celements.blog.observation.event.ArticleUpdatedEvent)1 ArticleUpdatingEvent (com.celements.blog.observation.event.ArticleUpdatingEvent)1 XWikiDocument (com.xpn.xwiki.doc.XWikiDocument)1 BaseObject (com.xpn.xwiki.objects.BaseObject)1 Date (java.util.Date)1 DocumentReference (org.xwiki.model.reference.DocumentReference)1