private void assertShallowTraceMatches(final Task<?> task, final Trace trace)
  {
    assertEquals(task.getName(), trace.getName());
    assertEquals(ResultType.fromTask(task), trace.getResultType());
    assertEquals(task.getShallowTrace().getStartNanos(), trace.getStartNanos());

    // If the task has not been started then we expect the endNanos to be null.
    // If the task has started but has not been finished then endNanos is set
    // to the time that the trace was taken. If the task was finished then the
    // task end time and trace end time should match.
    if (trace.getResultType().equals(ResultType.UNFINISHED))
    {
      if (trace.getStartNanos() == null)
      {
        assertNull(trace.getEndNanos());
      }
      else
      {
        // Trace will have the end time set to the time the trace was taken
        assertTrue(trace.getEndNanos() <= System.nanoTime());

        // We assume that the end time will always be at least one nanosecond
        // greater than the start time.
        assertTrue(trace.getEndNanos() > trace.getStartNanos());
      }
    }
    else
    {
      assertEquals(task.getShallowTrace().getEndNanos(), trace.getEndNanos());
    }

    switch (ResultType.fromTask(task))
    {
      case SUCCESS:
        Object value = task.get();
        assertEquals(value == null ? null : value.toString(), trace.getValue());
        break;
      case ERROR:
        assertTrue(trace.getValue().contains(task.getError().toString()));
        break;
      case UNFINISHED:
        assertNull(trace.getValue());
        break;
      case EARLY_FINISH:
        assertNull(trace.getValue());
        break;
    }
  }