ThreadStatesGaugeSet extends CachedMetricSet { @Override public Map<MetricName, Metric> getMetrics() { return Collections.unmodifiableMap(gauges); } ThreadStatesGaugeSet();  ThreadStatesGaugeSet(long dataTTL, TimeUnit unit);  ThreadStatesGaugeSet(ThreadMXBean threads, long dataTTL, TimeUnit unit, Clock clock); @Override Map<MetricName, Metric> getMetrics();  }
@Test public void hasASetOfGauges() throws Exception { assertThat(gauges.getMetrics().keySet()) .containsOnly(TERMINATED_COUNT, NEW_COUNT, COUNT, TIMED_WAITING_COUNT, BLOCKED_COUNT, WAITING_COUNT, DAEMON_COUNT, RUNNABLE_COUNT, DEADLOCK_COUNT); }
@Test public void hasAGaugeForEachThreadState() throws Exception { clock.addSeconds(61); assertThat(((Gauge) gauges.getMetrics().get(NEW_COUNT)).getValue()) .isEqualTo(1); assertThat(((Gauge) gauges.getMetrics().get(RUNNABLE_COUNT)).getValue()) .isEqualTo(1); assertThat(((Gauge) gauges.getMetrics().get(BLOCKED_COUNT)).getValue()) .isEqualTo(1); assertThat(((Gauge) gauges.getMetrics().get(WAITING_COUNT)).getValue()) .isEqualTo(1); assertThat(((Gauge) gauges.getMetrics().get(TIMED_WAITING_COUNT)).getValue()) .isEqualTo(1); assertThat(((Gauge) gauges.getMetrics().get(TERMINATED_COUNT)).getValue()) .isEqualTo(1); }
@Test public void hasAGaugeForTheNumberOfThreads() throws Exception { clock.addSeconds(61); assertThat(((Gauge) gauges.getMetrics().get(COUNT)).getValue()) .isEqualTo(12); }
@Test public void hasAGaugeForTheNumberOfDaemonThreads() throws Exception { clock.addSeconds(61); assertThat(((Gauge) gauges.getMetrics().get(DAEMON_COUNT)).getValue()) .isEqualTo(13); }
@Test public void hasAGaugeForAnyDeadlockCount() throws Exception { clock.addSeconds(61); assertThat(((Gauge) gauges.getMetrics().get(DEADLOCK_COUNT)).getValue()) .isEqualTo(1); }
@Test public void autoDiscoversTheMXBeans() throws Exception { final ThreadStatesGaugeSet set = new ThreadStatesGaugeSet(); assertThat(((Gauge) set.getMetrics().get(COUNT)).getValue()).isNotNull(); }