Index: trunk/quest-core-tasktrees-test/src/test/java/de/ugoe/cs/quest/tasktrees/manager/TaskTreeManagerTest.java
===================================================================
--- trunk/quest-core-tasktrees-test/src/test/java/de/ugoe/cs/quest/tasktrees/manager/TaskTreeManagerTest.java	(revision 468)
+++ trunk/quest-core-tasktrees-test/src/test/java/de/ugoe/cs/quest/tasktrees/manager/TaskTreeManagerTest.java	(revision 557)
@@ -1,3 +1,2 @@
-//-------------------------------------------------------------------------------------------------
 // Module    : $RCSfile: TaskTreeManagerTest.java,v $
 // Version   : $Revision: 0.0 $  $Author: Patrick $  $Date: 08.11.2011 21:32:36 $
@@ -5,5 +4,4 @@
 // Creation  : 2011 by Patrick
 // Copyright : Patrick Harms, 2011
-//-------------------------------------------------------------------------------------------------
 
 package de.ugoe.cs.quest.tasktrees.manager;
@@ -15,7 +13,7 @@
 import org.junit.Test;
 
-import de.ugoe.cs.quest.eventcore.guimodel.GUIElement;
-import de.ugoe.cs.quest.eventcore.userinteraction.Interaction;
-import de.ugoe.cs.quest.eventcore.userinteraction.InteractionEvent;
+import de.ugoe.cs.quest.eventcore.Event;
+import de.ugoe.cs.quest.eventcore.IEventTarget;
+import de.ugoe.cs.quest.eventcore.IEventType;
 import de.ugoe.cs.quest.tasktrees.testutils.DummyGUIElement;
 import de.ugoe.cs.quest.tasktrees.testutils.DummyInteraction;
@@ -23,554 +21,456 @@
 import de.ugoe.cs.quest.tasktrees.testutils.TaskTreeChecker;
 
-//-------------------------------------------------------------------------------------------------
 /**
  * TODO comment
- *
+ * 
  * @version $Revision: $ $Date: $
- * @author  2011, last modified by $Author: $
+ * @author 2011, last modified by $Author: $
  */
-//-------------------------------------------------------------------------------------------------
-
-public class TaskTreeManagerTest
-{
-  /** */
-  TaskTreeManager mManager;
-  
-  //-----------------------------------------------------------------------------------------------
-  /**
-   *
-   */
-  //-----------------------------------------------------------------------------------------------
-  @Before
-  public void setUp()
-  {
-    Logger.getLogger("").getHandlers()[0].setFormatter(new SimpleLogFormatter());
+public class TaskTreeManagerTest {
     
-    mManager = new TaskTreeManager();
-  }
-
-  //-----------------------------------------------------------------------------------------------
-  /**
-   *
-   */
-  //-----------------------------------------------------------------------------------------------
-  @After
-  public void tearDown()
-  {
-    mManager = null;
-    ComponentManager.clearInstance();
-  }
-
-  //-----------------------------------------------------------------------------------------------
-  /**
-   *
-   */
-  //-----------------------------------------------------------------------------------------------
-  @Test
-  public void testOneInteractionOnOneElement()
-  {
-    simulateInteraction(new DummyGUIElement("elem1"), new DummyInteraction("bla", 1));
-    new TaskTreeChecker().assertTaskTree
-      ("Sequence sequence {" +
-       "  Interaction bla {}" +
-       "}", mManager.getTaskTree());
-  }
-  
-  //-----------------------------------------------------------------------------------------------
-  /**
-   *
-   */
-  //-----------------------------------------------------------------------------------------------
-  @Test
-  public void testManyInteractionsOnOneElement()
-  {
-    GUIElement element = new DummyGUIElement("elem1");
-    simulateInteraction(element, new DummyInteraction("bla", 1));
-    simulateInteraction(element, new DummyInteraction("bli", 1));
-    simulateInteraction(element, new DummyInteraction("blo", 1));
-    simulateInteraction(element, new DummyInteraction("blu", 1));
-    simulateInteraction(element, new DummyInteraction("bla", 1));
-
-    new TaskTreeChecker().assertTaskTree
-      ("Sequence sequence {" +
-       "  Interaction bla {}" +
-       "  Interaction bli {}" +
-       "  Interaction blo {}" +
-       "  Interaction blu {}" +
-       "  Interaction bla {}" +
-       "}", mManager.getTaskTree());
-  }
-  
-  //-----------------------------------------------------------------------------------------------
-  /**
-   *
-   */
-  //-----------------------------------------------------------------------------------------------
-  @Test
-  public void testOneInteractionOnManyElements()
-  {
-    GUIElement element1 = new DummyGUIElement("elem1");
-    GUIElement element2 = new DummyGUIElement("elem2");
-    GUIElement element3 = new DummyGUIElement("elem3");
-    GUIElement element4 = new DummyGUIElement("elem4");
-    GUIElement element5 = new DummyGUIElement("elem5");
-    GUIElement element6 = new DummyGUIElement("elem6");
-    simulateInteraction(element1, new DummyInteraction("bla", 1));
-    simulateInteraction(element2, new DummyInteraction("bli", 1));
-    simulateInteraction(element3, new DummyInteraction("bla", 1));
-    simulateInteraction(element4, new DummyInteraction("bli", 1));
-    simulateInteraction(element5, new DummyInteraction("blo", 1));
-    simulateInteraction(element6, new DummyInteraction("bla", 1));
-    
-    new TaskTreeChecker().assertTaskTree
-      ("Sequence sequence0 {" +
-       "  Sequence sequence1 {" +
-       "    Interaction bla {}" +
-       "  }" +
-       "  Sequence sequence2 {" +
-       "    Interaction bli {}" +
-       "  }" +
-       "  Sequence sequence3 {" +
-       "    Interaction bla {}" +
-       "  }" +
-       "  Sequence sequence4 {" +
-       "    Interaction bli {}" +
-       "  }" +
-       "  Sequence sequence5 {" +
-       "    Interaction blo {}" +
-       "  }" +
-       "  Sequence sequence6 {" +
-       "    Interaction bla {}" +
-       "  }" +
-       "}", mManager.getTaskTree());
-  }
-
-  //-----------------------------------------------------------------------------------------------
-  /**
-   *
-   */
-  //-----------------------------------------------------------------------------------------------
-  @Test
-  public void testManyInteractionsOnManyElements()
-  {
-    GUIElement element1 = new DummyGUIElement("elem1");
-    GUIElement element2 = new DummyGUIElement("elem2");
-    GUIElement element3 = new DummyGUIElement("elem3");
-    GUIElement element4 = new DummyGUIElement("elem4");
-    GUIElement element5 = new DummyGUIElement("elem5");
-    GUIElement element6 = new DummyGUIElement("elem6");
-    simulateInteraction(element1, new DummyInteraction("bla", 1));
-    simulateInteraction(element1, new DummyInteraction("bli", 1));
-    simulateInteraction(element1, new DummyInteraction("bla", 1));
-    simulateInteraction(element2, new DummyInteraction("bli", 1));
-    simulateInteraction(element2, new DummyInteraction("blo", 1));
-    simulateInteraction(element3, new DummyInteraction("bla", 1));
-    simulateInteraction(element4, new DummyInteraction("bli", 1));
-    simulateInteraction(element4, new DummyInteraction("bla", 1));
-    simulateInteraction(element4, new DummyInteraction("bli", 1));
-    simulateInteraction(element4, new DummyInteraction("blo", 1));
-    simulateInteraction(element5, new DummyInteraction("bla", 1));
-    simulateInteraction(element6, new DummyInteraction("bli", 1));
-    simulateInteraction(element6, new DummyInteraction("bla", 1));
-    simulateInteraction(element6, new DummyInteraction("bli", 1));
-    simulateInteraction(element6, new DummyInteraction("blo", 1));
-
-    new TaskTreeChecker().assertTaskTree
-      ("Sequence sequence0 {" +
-       "  Sequence sequence1 {" +
-       "    Interaction bla {}" +
-       "    Interaction bli {}" +
-       "    Interaction bla {}" +
-       "  }" +
-       "  Sequence sequence2 {" +
-       "    Interaction bli {}" +
-       "    Interaction blo {}" +
-       "  }" +
-       "  Sequence sequence3 {" +
-       "    Interaction bla {}" +
-       "  }" +
-       "  Sequence sequence4 {" +
-       "    Interaction bli {}" +
-       "    Interaction bla {}" +
-       "    Interaction bli {}" +
-       "    Interaction blo {}" +
-       "  }" +
-       "  Sequence sequence5 {" +
-       "    Interaction bla {}" +
-       "  }" +
-       "  Sequence sequence6 {" +
-       "    Interaction bli {}" +
-       "    Interaction bla {}" +
-       "    Interaction bli {}" +
-       "    Interaction blo {}" +
-       "  }" +
-       "}", mManager.getTaskTree());
-  }
-
-  //-----------------------------------------------------------------------------------------------
-  /**
-   *
-   */
-  //-----------------------------------------------------------------------------------------------
-  @Test
-  public void testInteractionIterationDetection() throws Exception
-  {
-    GUIElement element1 = new DummyGUIElement("elem1");
-    Interaction interaction1 = new DummyInteraction("bla", 1);
-    simulateInteraction(element1, interaction1);
-    new TaskTreeChecker().assertTaskTree
-      ("Sequence sequence1 {" +
-       "  Interaction bla {}" +
-       "}", mManager.getTaskTree());    
-
-    simulateInteraction(element1, interaction1);
-    new TaskTreeChecker().assertTaskTree
-      ("Sequence sequence1 {" +
-       "  Iteration iteration1 {" +
-       "    Interaction bla {}" +
-       "  }" +
-       "}", mManager.getTaskTree());    
-
-    simulateInteraction(element1, interaction1);
-    new TaskTreeChecker().assertTaskTree
-      ("Sequence sequence1 {" +
-       "  Iteration iteration1 {" +
-       "    Interaction bla {}" +
-       "  }" +
-       "}", mManager.getTaskTree());    
-
-    for (int i = 0; i < 10; i++)
-    {
-      simulateInteraction(element1, interaction1);
-    }
-    
-    new TaskTreeChecker().assertTaskTree
-      ("Sequence sequence1 {" +
-       "  Iteration iteration1 {" +
-       "    Interaction bla {}" +
-       "  }" +
-       "}", mManager.getTaskTree());    
-    
-    // now test with preceding and trailing other interactions
-    Interaction interaction2 = new DummyInteraction("bli", 1);
-    Interaction interaction3 = new DummyInteraction("blup", 1);
-
-    simulateInteraction(element1, interaction2);
-    simulateInteraction(element1, interaction3);
-    for (int i = 0; i < 10; i++)
-    {
-      simulateInteraction(element1, interaction1);
-    }
-    simulateInteraction(element1, interaction3);
-    simulateInteraction(element1, interaction2);
-    
-    new TaskTreeChecker().assertTaskTree
-      ("Sequence sequence1 {" +
-       "  Iteration iteration1 {" +
-       "    Interaction bla {}" +
-       "  }" +
-       "  Interaction bli {}" +
-       "  Interaction blup {}" +
-       "  Iteration iteration2 {" +
-       "    Interaction bla {}" +
-       "  }" +
-       "  Interaction blup {}" +
-       "  Interaction bli {}" +
-       "}", mManager.getTaskTree());    
-  
-    // now test with iterations of iterations
-
-    for (int i = 0; i < 10; i++)
-    {
-      for (int j = 0; j < 5; j++)
-      {
-        simulateInteraction(element1, interaction1);
-      }
-      for (int j = 0; j < 5; j++)
-      {
-        simulateInteraction(element1, interaction2);
-      }
-      for (int j = 0; j < 5; j++)
-      {
-        simulateInteraction(element1, interaction3);
-      }
-    }
-    
-    new TaskTreeChecker().assertTaskTree
-      ("Sequence sequence0 {" +
-       "  Iteration iteration0 {" +
-       "    Interaction bla {}" +
-       "  }" +
-       "  Interaction bli {}" +
-       "  Interaction blup {}" +
-       "  Iteration iteration1 {" +
-       "    Interaction bla {}" +
-       "  }" +
-       "  Interaction blup {}" +
-       "  Interaction bli {}" +
-       "  Iteration iteration2 {" +
-       "    Sequence sequence1 {" +
-       "      Iteration iteration3 {" +
-       "        Interaction bla {}" +
-       "      }" +
-       "      Iteration iteration4 {" +
-       "        Interaction bli {}" +
-       "      }" +
-       "      Iteration iteration5 {" +
-       "        Interaction blup {}" +
-       "      }" +
-       "    }" +
-       "  }" +
-       "}", mManager.getTaskTree());    
-  
-  }
-  
-  //-----------------------------------------------------------------------------------------------
-  /**
-   *
-   */
-  //-----------------------------------------------------------------------------------------------
-  @Test
-  public void testSequenceIterationDetection() throws Exception
-  {
-    GUIElement element1 = new DummyGUIElement("elem1");
-    Interaction interaction1 = new DummyInteraction("bla", 1);
-    Interaction interaction2 = new DummyInteraction("bli", 1);
-    Interaction interaction3 = new DummyInteraction("blup", 1);
-    simulateInteraction(element1, interaction1);
-    simulateInteraction(element1, interaction2);
-    simulateInteraction(element1, interaction3);
-    new TaskTreeChecker().assertTaskTree
-      ("Sequence sequence1 {" +
-       "  Interaction bla {}" +
-       "  Interaction bli {}" +
-       "  Interaction blup {}" +
-       "}", mManager.getTaskTree());    
-
-    simulateInteraction(element1, interaction1);
-    simulateInteraction(element1, interaction2);
-    simulateInteraction(element1, interaction3);
-    new TaskTreeChecker().assertTaskTree
-      ("Sequence sequence1 {" +
-       "  Iteration iteration1 {" +
-       "    Sequence sequence2 {" +
-       "      Interaction bla {}" +
-       "      Interaction bli {}" +
-       "      Interaction blup {}" +
-       "    }" +
-       "  }" +
-       "}", mManager.getTaskTree());    
-
-    simulateInteraction(element1, interaction1);
-    simulateInteraction(element1, interaction2);
-    simulateInteraction(element1, interaction3);
-    new TaskTreeChecker().assertTaskTree
-      ("Sequence sequence1 {" +
-       "  Iteration iteration1 {" +
-       "    Sequence sequence2 {" +
-       "      Interaction bla {}" +
-       "      Interaction bli {}" +
-       "      Interaction blup {}" +
-       "    }" +
-       "  }" +
-       "}", mManager.getTaskTree());    
-
-    for (int i = 0; i < 10; i++)
-    {
-      simulateInteraction(element1, interaction1);
-      simulateInteraction(element1, interaction2);
-      simulateInteraction(element1, interaction3);
-    }
-    
-    new TaskTreeChecker().assertTaskTree
-      ("Sequence sequence1 {" +
-       "  Iteration iteration1 {" +
-       "    Sequence sequence2 {" +
-       "      Interaction bla {}" +
-       "      Interaction bli {}" +
-       "      Interaction blup {}" +
-       "    }" +
-       "  }" +
-       "}", mManager.getTaskTree());    
-    
-    // now test with preceding and trailing other interactions
-    Interaction interaction4 = new DummyInteraction("ble", 1);
-    Interaction interaction5 = new DummyInteraction("blo", 1);
-    Interaction interaction6 = new DummyInteraction("blu", 1);
-    simulateInteraction(element1, interaction4);
-    simulateInteraction(element1, interaction5);
-    simulateInteraction(element1, interaction6);
-    for (int i = 0; i < 10; i++)
-    {
-      simulateInteraction(element1, interaction1);
-      simulateInteraction(element1, interaction2);
-      simulateInteraction(element1, interaction3);
-    }
-    simulateInteraction(element1, interaction6);
-    simulateInteraction(element1, interaction5);
-    simulateInteraction(element1, interaction4);
-    
-    new TaskTreeChecker().assertTaskTree
-    ("Sequence sequence1 {" +
-     "  Iteration iteration1 {" +
-     "    Sequence sequence2 {" +
-     "      Interaction bla {}" +
-     "      Interaction bli {}" +
-     "      Interaction blup {}" +
-     "    }" +
-     "  }" +
-     "  Interaction ble {}" +
-     "  Interaction blo {}" +
-     "  Interaction blu {}" +
-     "  Iteration iteration2 {" +
-     "    Sequence sequence3 {" +
-     "      Interaction bla {}" +
-     "      Interaction bli {}" +
-     "      Interaction blup {}" +
-     "    }" +
-     "  }" +
-     "  Interaction blu {}" +
-     "  Interaction blo {}" +
-     "  Interaction ble {}" +
-     "}", mManager.getTaskTree());    
-  
-    // now test with iterations of iterations
-    for (int i = 0; i < 10; i++)
-    {
-      for (int j = 0; j < 5; j++)
-      {
-        simulateInteraction(element1, interaction1);
-        simulateInteraction(element1, interaction2);
-        simulateInteraction(element1, interaction3);
-      }
-      for (int j = 0; j < 5; j++)
-      {
-        simulateInteraction(element1, interaction2);
-        simulateInteraction(element1, interaction1);
-        simulateInteraction(element1, interaction3);
-      }
-      for (int j = 0; j < 5; j++)
-      {
-        simulateInteraction(element1, interaction1);
-        simulateInteraction(element1, interaction2);
-        simulateInteraction(element1, interaction3);
-      }
-    }
-    
-    new TaskTreeChecker().assertTaskTree
-      ("Sequence sequence1 {" +
-       "  Iteration iteration1 {" +
-       "    Sequence sequence2 {" +
-       "      Interaction bla {}" +
-       "      Interaction bli {}" +
-       "      Interaction blup {}" +
-       "    }" +
-       "  }" +
-       "  Interaction ble {}" +
-       "  Interaction blo {}" +
-       "  Interaction blu {}" +
-       "  Iteration iteration2 {" +
-       "    Sequence sequence3 {" +
-       "      Interaction bla {}" +
-       "      Interaction bli {}" +
-       "      Interaction blup {}" +
-       "    }" +
-       "  }" +
-       "  Interaction blu {}" +
-       "  Interaction blo {}" +
-       "  Interaction ble {}" +
-       "  Iteration iteration3 {" +
-       "    Sequence sequence4 {" +
-       "      Iteration iteration4 {" +
-       "        Sequence sequence4 {" +
-       "          Interaction bla {}" +
-       "          Interaction bli {}" +
-       "          Interaction blup {}" +
-       "        }" +
-       "      }" +
-       "      Iteration iteration5 {" +
-       "        Sequence sequence5 {" +
-       "          Interaction bli {}" +
-       "          Interaction bla {}" +
-       "          Interaction blup {}" +
-       "        }" +
-       "      }" +
-       "      Iteration iteration6 {" +
-       "        Sequence sequence6 {" +
-       "          Interaction bla {}" +
-       "          Interaction bli {}" +
-       "          Interaction blup {}" +
-       "        }" +
-       "      }" +
-       "    }" +
-       "  }" +
-       "}", mManager.getTaskTree());    
-  }
-  
-  //-----------------------------------------------------------------------------------------------
-  /**
-   *
-   */
-  //-----------------------------------------------------------------------------------------------
-  @Test
-  public void testGUIElementHierarchyChanges() throws Exception
-  {
-    GUIElement element1 = new DummyGUIElement("elem1");
-    GUIElement element2 = new DummyGUIElement("elem2");
-    GUIElement element3 = new DummyGUIElement("elem3");
-    GUIElement parent1 = new DummyGUIElement("parent1");
-    GUIElement parent2 = new DummyGUIElement("parent2");
-    GUIElement parent3 = new DummyGUIElement("parent3");
-    
-    element1.setParent(parent1);
-    element2.setParent(parent2);
-    element3.setParent(parent3);
-    
-    parent1.setParent(parent2);
-    parent2.setParent(parent3);
-    
-    Interaction interaction1 = new DummyInteraction("bla", 1);
-    simulateInteraction(element1, interaction1);
-    simulateInteraction(element2, interaction1);
-    simulateInteraction(element3, interaction1);
-    simulateInteraction(element2, interaction1);
-    simulateInteraction(element3, interaction1);
-    simulateInteraction(element2, interaction1);
-    simulateInteraction(element1, interaction1);
-   
-    new TaskTreeChecker().assertTaskTree
-      ("Sequence sequence0 {" +
-       "  Sequence sequence1 {" +
-       "    Interaction bla {}" +
-       "  }" +
-       "  Sequence sequence2 {" +
-       "    Interaction bla {}" +
-       "  }" +
-       "  Iteration iteration0 {" +
-       "    Sequence sequence3 {" +
-       "      Sequence sequence4 {" +
-       "        Interaction bla {}" +
-       "      }" +
-       "      Sequence sequence5 {" +
-       "        Interaction bla {}" +
-       "      }" +
-       "    }" +
-       "  }" +
-       "  Sequence sequence6 {" +
-       "    Interaction bla {}" +
-       "  }" +
-       "}", mManager.getTaskTree());    
-
-  }
-  
-  //-----------------------------------------------------------------------------------------------
-  /**
-   * @param interactionsDoNotOverwriteElement
-   */
-  //-----------------------------------------------------------------------------------------------
-  private void simulateInteraction(GUIElement GUIElement, Interaction interaction)
-  {
-    mManager.handleNewInteractionEvent(new InteractionEvent(GUIElement, interaction));
-  }
+    /** */
+    TaskTreeManager manager;
+
+    /**
+     *
+     */
+    @Before
+    public void setUp() {
+        Logger.getLogger("").getHandlers()[0].setFormatter(new SimpleLogFormatter());
+
+        manager = new TaskTreeManager();
+    }
+
+    /**
+     *
+     */
+    @After
+    public void tearDown() {
+        manager = null;
+        ComponentManager.clearInstance();
+    }
+
+    /**
+     *
+     */
+    @Test
+    public void testOneEventOnOneElement() {
+        simulateEvent(new DummyInteraction("bla", 1), new DummyGUIElement("elem1"));
+        new TaskTreeChecker().assertTaskTree
+            ("Sequence sequence {" +
+             "  Event bla {}" +
+             "}", manager.getTaskTree());
+    }
+
+    /**
+     *
+     */
+    @Test
+    public void testManyEventsOnOneElement() {
+        IEventTarget eventTarget = new DummyGUIElement("elem1");
+        simulateEvent(new DummyInteraction("bla", 1), eventTarget);
+        simulateEvent(new DummyInteraction("bli", 1), eventTarget);
+        simulateEvent(new DummyInteraction("blo", 1), eventTarget);
+        simulateEvent(new DummyInteraction("blu", 1), eventTarget);
+        simulateEvent(new DummyInteraction("bla", 1), eventTarget);
+
+        new TaskTreeChecker().assertTaskTree
+            ("Sequence sequence {" +
+             "  Event bla {}" +
+             "  Event bli {}" +
+             "  Event blo {}" +
+             "  Event blu {}" +
+             "  Event bla {}" +
+             "}", manager.getTaskTree());
+    }
+
+    /**
+     *
+     */
+    @Test
+    public void testOneEventOnManyElements() {
+        IEventTarget eventTarget1 = new DummyGUIElement("elem1");
+        IEventTarget eventTarget2 = new DummyGUIElement("elem2");
+        IEventTarget eventTarget3 = new DummyGUIElement("elem3");
+        IEventTarget eventTarget4 = new DummyGUIElement("elem4");
+        IEventTarget eventTarget5 = new DummyGUIElement("elem5");
+        IEventTarget eventTarget6 = new DummyGUIElement("elem6");
+        simulateEvent(new DummyInteraction("bla", 1), eventTarget1);
+        simulateEvent(new DummyInteraction("bli", 1), eventTarget2);
+        simulateEvent(new DummyInteraction("bla", 1), eventTarget3);
+        simulateEvent(new DummyInteraction("bli", 1), eventTarget4);
+        simulateEvent(new DummyInteraction("blo", 1), eventTarget5);
+        simulateEvent(new DummyInteraction("bla", 1), eventTarget6);
+
+        new TaskTreeChecker().assertTaskTree
+            ("Sequence sequence0 {" +
+             "  Sequence sequence1 {" +
+             "    Event bla {}" +
+             "  }" +
+             "  Sequence sequence2 {" +
+             "    Event bli {}" +
+             "  }" +
+             "  Sequence sequence3 {" +
+             "    Event bla {}" +
+             "  }" +
+             "  Sequence sequence4 {" +
+             "    Event bli {}" +
+             "  }" +
+             "  Sequence sequence5 {" +
+             "    Event blo {}" +
+             "  }" +
+             "  Sequence sequence6 {" +
+             "    Event bla {}" +
+             "  }" +
+             "}", manager.getTaskTree());
+    }
+
+    /**
+     *
+     */
+    @Test
+    public void testManyEventsOnManyElements() {
+        IEventTarget eventTarget1 = new DummyGUIElement("elem1");
+        IEventTarget eventTarget2 = new DummyGUIElement("elem2");
+        IEventTarget eventTarget3 = new DummyGUIElement("elem3");
+        IEventTarget eventTarget4 = new DummyGUIElement("elem4");
+        IEventTarget eventTarget5 = new DummyGUIElement("elem5");
+        IEventTarget eventTarget6 = new DummyGUIElement("elem6");
+        simulateEvent(new DummyInteraction("bla", 1), eventTarget1);
+        simulateEvent(new DummyInteraction("bli", 1), eventTarget1);
+        simulateEvent(new DummyInteraction("bla", 1), eventTarget1);
+        simulateEvent(new DummyInteraction("bli", 1), eventTarget2);
+        simulateEvent(new DummyInteraction("blo", 1), eventTarget2);
+        simulateEvent(new DummyInteraction("bla", 1), eventTarget3);
+        simulateEvent(new DummyInteraction("bli", 1), eventTarget4);
+        simulateEvent(new DummyInteraction("bla", 1), eventTarget4);
+        simulateEvent(new DummyInteraction("bli", 1), eventTarget4);
+        simulateEvent(new DummyInteraction("blo", 1), eventTarget4);
+        simulateEvent(new DummyInteraction("bla", 1), eventTarget5);
+        simulateEvent(new DummyInteraction("bli", 1), eventTarget6);
+        simulateEvent(new DummyInteraction("bla", 1), eventTarget6);
+        simulateEvent(new DummyInteraction("bli", 1), eventTarget6);
+        simulateEvent(new DummyInteraction("blo", 1), eventTarget6);
+
+        new TaskTreeChecker().assertTaskTree
+            ("Sequence sequence0 {" +
+             "  Sequence sequence1 {" +
+             "    Event bla {}" +
+             "    Event bli {}" +
+             "    Event bla {}" +
+             "  }" +
+             "  Sequence sequence2 {" +
+             "    Event bli {}" +
+             "    Event blo {}" +
+             "  }" +
+             "  Sequence sequence3 {" +
+             "    Event bla {}" +
+             "  }" +
+             "  Sequence sequence4 {" +
+             "    Event bli {}" +
+             "    Event bla {}" +
+             "    Event bli {}" +
+             "    Event blo {}" +
+             "  }" +
+             "  Sequence sequence5 {" +
+             "    Event bla {}" +
+             "  }" +
+             "  Sequence sequence6 {" +
+             "    Event bli {}" +
+             "    Event bla {}" +
+             "    Event bli {}" +
+             "    Event blo {}" +
+             "  }" +
+             "}", manager.getTaskTree());
+    }
+
+    /**
+     *
+     */
+    @Test
+    public void testEventIterationDetection() throws Exception {
+        IEventTarget eventTarget1 = new DummyGUIElement("elem1");
+        IEventType event1 = new DummyInteraction("bla", 1);
+        simulateEvent(event1, eventTarget1);
+        new TaskTreeChecker().assertTaskTree
+            ("Sequence sequence1 {" +
+             "  Event bla {}" +
+             "}", manager.getTaskTree());
+
+        simulateEvent(event1, eventTarget1);
+        new TaskTreeChecker().assertTaskTree
+            ("Sequence sequence1 {" +
+             "  Iteration iteration1 {" +
+             "    Event bla {}" +
+             "  }" +
+             "}", manager.getTaskTree());
+
+        simulateEvent(event1, eventTarget1);
+        new TaskTreeChecker().assertTaskTree
+            ("Sequence sequence1 {" +
+             "  Iteration iteration1 {" +
+             "    Event bla {}" +
+             "  }" +
+             "}", manager.getTaskTree());
+
+        for (int i = 0; i < 10; i++) {
+            simulateEvent(event1, eventTarget1);
+        }
+
+        new TaskTreeChecker().assertTaskTree
+            ("Sequence sequence1 {" +
+             "  Iteration iteration1 {" +
+             "    Event bla {}" +
+             "  }" +
+             "}", manager.getTaskTree());
+
+        // now test with preceding and trailing other interactions
+        IEventType event2 = new DummyInteraction("bli", 1);
+        IEventType event3 = new DummyInteraction("blup", 1);
+
+        simulateEvent(event2, eventTarget1);
+        simulateEvent(event3, eventTarget1);
+        for (int i = 0; i < 10; i++) {
+            simulateEvent(event1, eventTarget1);
+        }
+        simulateEvent(event3, eventTarget1);
+        simulateEvent(event2, eventTarget1);
+
+        new TaskTreeChecker().assertTaskTree
+            ("Sequence sequence1 {" +
+             "  Iteration iteration1 {" +
+             "    Event bla {}" +
+             "  }" +
+             "  Event bli {}" +
+             "  Event blup {}" +
+             "  Iteration iteration2 {" +
+             "    Event bla {}" +
+             "  }" +
+             "  Event blup {}" +
+             "  Event bli {}" +
+             "}", manager.getTaskTree());
+
+        // now test with iterations of iterations
+
+        for (int i = 0; i < 10; i++) {
+            for (int j = 0; j < 5; j++) {
+                simulateEvent(event1, eventTarget1);
+            }
+            for (int j = 0; j < 5; j++) {
+                simulateEvent(event2, eventTarget1);
+            }
+            for (int j = 0; j < 5; j++) {
+                simulateEvent(event3, eventTarget1);
+            }
+        }
+
+        new TaskTreeChecker().assertTaskTree
+            ("Sequence sequence0 {" +
+             "  Iteration iteration0 {" +
+             "    Event bla {}" +
+             "  }" +
+             "  Event bli {}" +
+             "  Event blup {}" +
+             "  Iteration iteration1 {" +
+             "    Event bla {}" +
+             "  }" +
+             "  Event blup {}" +
+             "  Event bli {}" +
+             "  Iteration iteration2 {" +
+             "    Sequence sequence1 {" +
+             "      Iteration iteration3 {" +
+             "        Event bla {}" +
+             "      }" +
+             "      Iteration iteration4 {" +
+             "        Event bli {}" +
+             "      }" +
+             "      Iteration iteration5 {" +
+             "        Event blup {}" +
+             "      }" +
+             "    }" +
+             "  }" +
+             "}", manager.getTaskTree());
+
+    }
+
+    /**
+     *
+     */
+    @Test
+    public void testSequenceIterationDetection() throws Exception {
+        IEventTarget eventTarget1 = new DummyGUIElement("elem1");
+        IEventType event1 = new DummyInteraction("bla", 1);
+        IEventType event2 = new DummyInteraction("bli", 1);
+        IEventType event3 = new DummyInteraction("blup", 1);
+        simulateEvent(event1, eventTarget1);
+        simulateEvent(event2, eventTarget1);
+        simulateEvent(event3, eventTarget1);
+        new TaskTreeChecker().assertTaskTree
+            ("Sequence sequence1 {" +
+             "  Event bla {}" +
+             "  Event bli {}" +
+             "  Event blup {}" +
+             "}", manager.getTaskTree());
+
+        simulateEvent(event1, eventTarget1);
+        simulateEvent(event2, eventTarget1);
+        simulateEvent(event3, eventTarget1);
+        new TaskTreeChecker().assertTaskTree
+            ("Sequence sequence1 {" +
+             "  Iteration iteration1 {" +
+             "    Sequence sequence2 {" +
+             "      Event bla {}" +
+             "      Event bli {}" +
+             "      Event blup {}" +
+             "    }" +
+             "  }" +
+             "}", manager.getTaskTree());
+
+        simulateEvent(event1, eventTarget1);
+        simulateEvent(event2, eventTarget1);
+        simulateEvent(event3, eventTarget1);
+        new TaskTreeChecker().assertTaskTree
+            ("Sequence sequence1 {" +
+             "  Iteration iteration1 {" +
+             "    Sequence sequence2 {" +
+             "      Event bla {}" +
+             "      Event bli {}" +
+             "      Event blup {}" +
+             "    }" +
+             "  }" +
+             "}", manager.getTaskTree());
+
+        for (int i = 0; i < 10; i++) {
+            simulateEvent(event1, eventTarget1);
+            simulateEvent(event2, eventTarget1);
+            simulateEvent(event3, eventTarget1);
+        }
+
+        new TaskTreeChecker().assertTaskTree
+            ("Sequence sequence1 {" +
+             "  Iteration iteration1 {" +
+             "    Sequence sequence2 {" +
+             "      Event bla {}" +
+             "      Event bli {}" +
+             "      Event blup {}" +
+             "    }" +
+             "  }" +
+             "}", manager.getTaskTree());
+
+        // now test with preceding and trailing other interactions
+        IEventType event4 = new DummyInteraction("ble", 1);
+        IEventType event5 = new DummyInteraction("blo", 1);
+        IEventType event6 = new DummyInteraction("blu", 1);
+        simulateEvent(event4, eventTarget1);
+        simulateEvent(event5, eventTarget1);
+        simulateEvent(event6, eventTarget1);
+        for (int i = 0; i < 10; i++) {
+            simulateEvent(event1, eventTarget1);
+            simulateEvent(event2, eventTarget1);
+            simulateEvent(event3, eventTarget1);
+        }
+        simulateEvent(event6, eventTarget1);
+        simulateEvent(event5, eventTarget1);
+        simulateEvent(event4, eventTarget1);
+
+        new TaskTreeChecker().assertTaskTree
+            ("Sequence sequence1 {" +
+             "  Iteration iteration1 {" +
+             "    Sequence sequence2 {" +
+             "      Event bla {}" +
+             "      Event bli {}" +
+             "      Event blup {}" +
+             "    }" +
+             "  }" +
+             "  Event ble {}" +
+             "  Event blo {}" +
+             "  Event blu {}" +
+             "  Iteration iteration2 {" +
+             "    Sequence sequence3 {" +
+             "      Event bla {}" +
+             "      Event bli {}" +
+             "      Event blup {}" +
+             "    }" +
+             "  }" +
+             "  Event blu {}" +
+             "  Event blo {}" +
+             "  Event ble {}" +
+             "}", manager.getTaskTree());
+
+        // now test with iterations of iterations
+        for (int i = 0; i < 10; i++) {
+            for (int j = 0; j < 5; j++) {
+                simulateEvent(event1, eventTarget1);
+                simulateEvent(event2, eventTarget1);
+                simulateEvent(event3, eventTarget1);
+            }
+            for (int j = 0; j < 5; j++) {
+                simulateEvent(event2, eventTarget1);
+                simulateEvent(event1, eventTarget1);
+                simulateEvent(event3, eventTarget1);
+            }
+            for (int j = 0; j < 5; j++) {
+                simulateEvent(event1, eventTarget1);
+                simulateEvent(event2, eventTarget1);
+                simulateEvent(event3, eventTarget1);
+            }
+        }
+
+        new TaskTreeChecker().assertTaskTree
+            ("Sequence sequence1 {" +
+             "  Iteration iteration1 {" +
+             "    Sequence sequence2 {" +
+             "      Event bla {}" +
+             "      Event bli {}" +
+             "      Event blup {}" +
+             "    }" +
+             "  }" +
+             "  Event ble {}" +
+             "  Event blo {}" +
+             "  Event blu {}" +
+             "  Iteration iteration2 {" +
+             "    Sequence sequence3 {" +
+             "      Event bla {}" +
+             "      Event bli {}" +
+             "      Event blup {}" +
+             "    }" +
+             "  }" +
+             "  Event blu {}" +
+             "  Event blo {}" +
+             "  Event ble {}" +
+             "  Iteration iteration3 {" +
+             "    Sequence sequence4 {" +
+             "      Iteration iteration4 {" +
+             "        Sequence sequence4 {" +
+             "          Event bla {}" +
+             "          Event bli {}" +
+             "          Event blup {}" +
+             "        }" +
+             "      }" +
+             "      Iteration iteration5 {" +
+             "        Sequence sequence5 {" +
+             "          Event bli {}" +
+             "          Event bla {}" +
+             "          Event blup {}" +
+             "        }" +
+             "      }" +
+             "      Iteration iteration6 {" +
+             "        Sequence sequence6 {" +
+             "          Event bla {}" +
+             "          Event bli {}" +
+             "          Event blup {}" +
+             "        }" +
+             "      }" +
+             "    }" +
+             "  }" +
+             "}", manager.getTaskTree());
+    }
+
+    /**
+     *
+     */
+    private void simulateEvent(IEventType eventType, IEventTarget eventTarget) {
+        manager.handleNewEvent(new Event(eventType, eventTarget));
+    }
 
 }
