package com.celements.navigation.listener;

import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Test;
import org.xwiki.observation.EventListener;

import com.celements.common.test.AbstractBridgedComponentTestCase;
import com.celements.navigation.listener.TreeNodeDocumentCreatedListener;
import com.xpn.xwiki.web.Utils;

public class TreeNodeDocumentCreatedListenerTest extends AbstractBridgedComponentTestCase {
  
  private TreeNodeDocumentCreatedListener eventListener;

  @Before
  public void setUp_TreeNodeDocumentCreatedListenerTest() throws Exception {
    eventListener = getTreeNodeDocumentCreatedListener();
  }

  @Test
  public void testComponentSingleton() {
    assertSame(eventListener, getTreeNodeDocumentCreatedListener());
  }

  private TreeNodeDocumentCreatedListener getTreeNodeDocumentCreatedListener() {
    return (TreeNodeDocumentCreatedListener) Utils.getComponent(
        EventListener.class, "TreeNodeDocumentCreatedListener");
  }

}

@@ -83,46 +83,147 @@
 ort 
-org.junit.Before;%0Aimport org.junit.Tes
+java.util.Arrays;%0Aimport java.util.List;%0A%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.xwiki.bridge.event.DocumentCreatedEven
 t;%0Ai
@@ -256,32 +256,74 @@
 n.EventListener;
+%0Aimport org.xwiki.observation.event.Event;
 %0A%0Aimport com.cel
@@ -379,82 +379,8 @@
 se;%0A
-import com.celements.navigation.listener.TreeNodeDocumentCreatedListener;%0A
 impo
@@ -834,16 +834,571 @@
 );%0A  %7D%0A%0A
+  @Test%0A  public void testGetEvents() %7B%0A    List%3CString%3E expectedEventClassList = Arrays.asList(new DocumentCreatedEvent(%0A        ).getClass().getName());%0A    replayDefault();%0A    List%3CEvent%3E actualEventList = eventListener.getEvents();%0A    assertEquals(expectedEventClassList.size(), actualEventList.size());%0A    for (Event actualEvent : actualEventList) %7B%0A      assertTrue(%22Unexpected Event %5B%22 + actualEvent.getClass().getName() + %22%5D found.%22,%0A          expectedEventClassList.contains(actualEvent.getClass().getName()));%0A    %7D%0A    verifyDefault();%0A  %7D%0A%0A
   privat

add unit test testGetEvents to TreeNodeDocumentCreatedListenerTest