StatisticsClockFactory { public static StatisticsClock clock() { return clock(Boolean.getBoolean(ENABLE_CLOCK_STATS_PROPERTY)); }  @Deprecated static long getTimeIfEnabled(); static long getTime(); static StatisticsClock clock(); static StatisticsClock clock(boolean enabled); static StatisticsClock enabledClock(); static StatisticsClock enabledClock(LongSupplier time); static StatisticsClock disabledClock(); static StatisticsClock clock(LongSupplier time, BooleanSupplier isEnabled); @Immutable
  static final String ENABLE_CLOCK_STATS_PROPERTY; @Immutable
  static final boolean enableClockStats; }
@Test public void clock_createsEnabledClockIfPropertyIsTrue() { System.setProperty(ENABLE_CLOCK_STATS_PROPERTY, "true"); StatisticsClock clock = StatisticsClockFactory.clock(); assertThat(clock.isEnabled()).isTrue(); }
@Test public void clock_createsDisabledClockIfPropertyIsFalse() { System.setProperty(ENABLE_CLOCK_STATS_PROPERTY, "false"); StatisticsClock clock = StatisticsClockFactory.clock(); assertThat(clock.isEnabled()).isFalse(); }
@Test public void clock_boolean_createsEnabledClockIfParameterIsTrue() { StatisticsClock clock = StatisticsClockFactory.clock(true); assertThat(clock.isEnabled()).isTrue(); }
@Test public void clock_boolean_createsEnabledClockIfParameterIsFalse() { StatisticsClock clock = StatisticsClockFactory.clock(false); assertThat(clock.isEnabled()).isFalse(); }
@Test public void clock_usesProvidedBooleanSupplierForIsEnabled() { StatisticsClock clock = StatisticsClockFactory.clock(() -> 100, () -> true); assertThat(clock.isEnabled()).isTrue(); }
@Test public void clock_isEnabled_delegatesToBooleanSupplier() { BooleanSupplier isEnabled = mock(BooleanSupplier.class); StatisticsClock clock = StatisticsClockFactory.clock(mock(LongSupplier.class), isEnabled); clock.isEnabled(); verify(isEnabled).getAsBoolean(); }