@Test public void testMoveHeadIndexByOne() { MockClock clock = MockClock.at(2019, 8, 4, 12, 0, 0, ZoneId.of("UTC")); SlidingTimeWindowMetrics metrics = new SlidingTimeWindowMetrics(3, clock); assertThat(metrics.headIndex).isEqualTo(0); metrics.moveHeadIndexByOne(); assertThat(metrics.headIndex).isEqualTo(1); metrics.moveHeadIndexByOne(); assertThat(metrics.headIndex).isEqualTo(2); metrics.moveHeadIndexByOne(); assertThat(metrics.headIndex).isEqualTo(0); metrics.moveHeadIndexByOne(); assertThat(metrics.headIndex).isEqualTo(1); }
void moveHeadIndexByOne() { this.headIndex = (headIndex + 1) % timeWindowSizeInSeconds; }
SlidingTimeWindowMetrics implements Metrics { void moveHeadIndexByOne() { this.headIndex = (headIndex + 1) % timeWindowSizeInSeconds; } }
SlidingTimeWindowMetrics implements Metrics { void moveHeadIndexByOne() { this.headIndex = (headIndex + 1) % timeWindowSizeInSeconds; } SlidingTimeWindowMetrics(int timeWindowSizeInSeconds, Clock clock); }
SlidingTimeWindowMetrics implements Metrics { void moveHeadIndexByOne() { this.headIndex = (headIndex + 1) % timeWindowSizeInSeconds; } SlidingTimeWindowMetrics(int timeWindowSizeInSeconds, Clock clock); @Override synchronized Snapshot record(long duration, TimeUnit durationUnit, Outcome outcome); synchronized Snapshot getSnapshot(); }
SlidingTimeWindowMetrics implements Metrics { void moveHeadIndexByOne() { this.headIndex = (headIndex + 1) % timeWindowSizeInSeconds; } SlidingTimeWindowMetrics(int timeWindowSizeInSeconds, Clock clock); @Override synchronized Snapshot record(long duration, TimeUnit durationUnit, Outcome outcome); synchronized Snapshot getSnapshot();  }