@Test
  public void testSimple() throws InterruptedException, ExecutionException {
    Callable<String> mainJob =
        new Callable<String>() {
          public String call() {
            log.info("main job - " + Tasks.current());
            messages.add("main");
            DynamicTasks.queue(sayTask("world"));
            return "bye";
          }
        };
    DynamicSequentialTask<String> t = new DynamicSequentialTask<String>(mainJob);
    // this should be added before anything added when the task is invoked
    t.queue(sayTask("hello"));

    Assert.assertEquals(messages, Lists.newArrayList());
    Assert.assertEquals(t.isBegun(), false);
    Assert.assertEquals(Iterables.size(t.getChildren()), 1);

    ec.submit(t);
    Assert.assertEquals(t.isSubmitted(), true);
    Assert.assertEquals(t.getUnchecked(Duration.ONE_SECOND), "bye");
    long elapsed = t.getEndTimeUtc() - t.getSubmitTimeUtc();
    Assert.assertTrue(
        elapsed < 1000,
        "elapsed time should have been less than 1s but was " + Time.makeTimeString(elapsed, true));
    Assert.assertEquals(Iterables.size(t.getChildren()), 2);
    Assert.assertEquals(messages.size(), 3, "expected 3 entries, but had " + messages);
    // either main or hello can be first, but world should be last
    Assert.assertEquals(messages.get(2), "world");
  }