### Question:
Configuration { public long getCheckIntervalInMillis() { return checkInterval == null ? DISABLED_INTERVAL : checkInterval.toMilliSeconds(); } Configuration(); List<String> getOverrides(); boolean isEnabled(); ExecutionFrequency getMaxFrequency(); String getHeapDumpName(); File getHeapDumpFolder(); Logger.Severity getLogLevel(); long getCheckIntervalInMillis(); UsageThresholdConfiguration getHeapMemoryUsageThreshold(); UsageThresholdConfiguration getCodeCacheMemoryUsageThreshold(); UsageThresholdConfiguration getMetaspaceMemoryUsageThreshold(); UsageThresholdConfiguration getPermGenMemoryUsageThreshold(); UsageThresholdConfiguration getCompressedClassSpaceMemoryUsageThreshold(); UsageThresholdConfiguration getCodeHeapNonNMethodsMemoryUsageThreshold(); UsageThresholdConfiguration getCodeHeapNonProfiledNMethodsMemoryUsageThreshold(); UsageThresholdConfiguration getCodeHeapProfiledNMethodsMemoryUsageThreshold(); UsageThresholdConfiguration getEdenSpaceMemoryUsageThreshold(); UsageThresholdConfiguration getSurvivorSpaceMemoryUsageThreshold(); UsageThresholdConfiguration getOldGenSpaceMemoryUsageThreshold(); UsageThresholdConfiguration getTenuredGenSpaceMemoryUsageThreshold(); String getExecuteBefore(); String getExecuteAfter(); String getExecuteOnShutDown(); String getCommandInterpreter(); static final Logger.Severity DEFAULT_LOG_LEVEL; static final String DEFAULT_NAME_PATTERN; }### Answer:
@Test public void testLegacyPrefix() { temporarySystemProperties.set("hdagent.check_interval").to("4h"); final Configuration subject = Configuration.Builder.initializeFromSystemProperties(logger).build(); assertThat(subject.getCheckIntervalInMillis(), is(TimeUnit.HOURS.toMillis(4))); }
@Test public void testSystemPropertiesDoNotAffectConfiguration() { final Configuration configuration = Configuration.Builder.initializeFromSystemProperties(logger).build(); temporarySystemProperties .set(Property.CHECK_INTERVAL.getQualifiedName()).to("42"); assertThat(configuration.getCheckIntervalInMillis(), is(-1L)); }
@Test public void testInterval() throws Exception { final Configuration configuration = new Configuration(); Property.CHECK_INTERVAL.doApply(configuration, "42ms"); assertThat(configuration.getCheckIntervalInMillis(), is(42L)); Property.CHECK_INTERVAL.doApply(configuration, "42s"); assertThat(configuration.getCheckIntervalInMillis(), is(42000L)); Property.CHECK_INTERVAL.doApply(configuration, "2m"); assertThat(configuration.getCheckIntervalInMillis(), is(120000L)); Property.CHECK_INTERVAL.doApply(configuration, "3h"); assertThat(configuration.getCheckIntervalInMillis(), is(10800000L)); }