@Test
  public void testMore() throws InterruptedException {
    final Element e1 = TestUtils.getElement("test1", Regexp.<AbstractStructuralNode>getMutable());
    final Element e2 = TestUtils.getElement("test2", Regexp.<AbstractStructuralNode>getMutable());
    final Element e3 = TestUtils.getElement("test3", Regexp.<AbstractStructuralNode>getMutable());
    final Element e4 = TestUtils.getElement("test4", Regexp.<AbstractStructuralNode>getMutable());

    e1.getSubnodes().setType(RegexpType.CONCATENATION);
    e1.getSubnodes().setInterval(RegexpInterval.getOnce());
    e2.getSubnodes().setType(RegexpType.CONCATENATION);
    e2.getSubnodes().setInterval(RegexpInterval.getOnce());
    e3.getSubnodes().setType(RegexpType.CONCATENATION);
    e3.getSubnodes().setInterval(RegexpInterval.getOnce());
    e4.getSubnodes().setType(RegexpType.CONCATENATION);
    e4.getSubnodes().setInterval(RegexpInterval.getOnce());

    e1.getSubnodes().addChild(Regexp.<AbstractStructuralNode>getToken(e2));
    e1.getSubnodes().addChild(Regexp.<AbstractStructuralNode>getToken(e3));
    e3.getSubnodes().addChild(Regexp.<AbstractStructuralNode>getToken(e4));

    final List<Element> elements = Arrays.asList(e1, e2);

    Collections.shuffle(elements);

    final TopologicalSort s = new TopologicalSort(elements);
    final List<Element> toposorted = s.sort();

    assertEquals(2, toposorted.size());
    assertTrue(toposorted.indexOf(e1) > toposorted.indexOf(e2));
    assertTrue(toposorted.indexOf(e1) > toposorted.indexOf(e3));
    assertTrue(toposorted.indexOf(e2) > toposorted.indexOf(e4));
  }
 @Test
 public void testOne() throws InterruptedException {
   final Element e = TestUtils.getElement("test", Regexp.<AbstractStructuralNode>getMutable());
   e.getSubnodes().setType(RegexpType.CONCATENATION);
   e.getSubnodes().setInterval(RegexpInterval.getOnce());
   final TopologicalSort s = new TopologicalSort(Arrays.asList(e));
   final List<Element> elements = s.sort();
   assertEquals(1, elements.size());
   assertEquals(e, elements.get(0));
 }