@Test
  public void testTimedAverageMetricsTimeBound() {
    TimedAverageMetrics metrics;

    // Window 1
    metrics = generateTimedAverageMetrics(1, 10, 1, 100, 0, 0, 1);
    assertEquals("Window size 1", 100, metrics.value(100));

    // Window 1 with multiple data
    metrics = generateTimedAverageMetrics(1, 10, 50, 100, 0, 0, 1);
    assertEquals("Window size 1 with multiple data", 100, metrics.value(100));

    // Single point in the middle
    metrics = generateTimedAverageMetrics(10, 100, 1, 100, 0, 50, 1);
    assertEquals("Single point in the middle", 50, metrics.value(100));

    // Single point at 3/4
    metrics = generateTimedAverageMetrics(10, 100, 1, 100, 0, 75, 1);
    assertEquals("Single point at 3/4", 25, metrics.value(100));

    // Single point at 1/4
    metrics = generateTimedAverageMetrics(10, 100, 1, 100, 0, 25, 1);
    assertEquals("Single point at 1/4", 75, metrics.value(100));

    // Multiple points after 1/4
    metrics = generateTimedAverageMetrics(10, 100, 3, 100, 0, 25, 25);
    assertEquals("Multiple points after 1/4", 75, metrics.value(100));

    // More points with overflow
    metrics = generateTimedAverageMetrics(10, 100, 18, 100, 0, 25, 25);
    assertEquals("More points with overflow", 100, metrics.value(450));

    // Very old points
    metrics = generateTimedAverageMetrics(10, 100, 20, 100, 0, 25, 25);
    assertEquals("Very old points", 100, metrics.value(5000));
    metrics.add(1000, 10);
    assertEquals("Very old points but not that old", 10, metrics.value(5000));
  }
Test generated values for TimedAverageMetrics when the time window is smaller than the amount
of data we have stored.
llap-server/src/test/org/apache/hadoop/hive/llap/metrics/TestLlapDaemonExecutorMetrics.java