use of com.codahale.metrics.Gauge in project metrics by dropwizard.
the class MemoryUsageGaugeSetTest method hasAGaugeForNonHeapCommitted.
@Test
public void hasAGaugeForNonHeapCommitted() {
final Gauge gauge = (Gauge) gauges.getMetrics().get("non-heap.committed");
assertThat(gauge.getValue()).isEqualTo(1L);
}
use of com.codahale.metrics.Gauge in project metrics by dropwizard.
the class CollectdReporterTest method reportsGauges.
private <T extends Number> void reportsGauges(T value) throws Exception {
reporter.report(map("gauge", (Gauge) () -> value), map(), map(), map(), map());
ValueList data = receiver.next();
assertThat(data.getValues()).containsExactly(value.doubleValue());
}
use of com.codahale.metrics.Gauge in project verify-hub by alphagov.
the class IdpAssertionMetricsCollectorTest method shouldCollectNotOnOrAfterValueFromAssertion.
@Test
public void shouldCollectNotOnOrAfterValueFromAssertion() {
DateTimeFreezer.freezeTime();
MetricRegistry metricRegistry = new MetricRegistry();
IdpAssertionMetricsCollector idpAssertionMetricsCollector = new IdpAssertionMetricsCollector(metricRegistry);
DateTime notOnOrAfter = DateTime.now().plusMinutes(15);
Assertion anAssertion = anAssertion().withIssuer(anIssuer().withIssuerId("testIdP").build()).withSubject(aSubject().withSubjectConfirmation(aSubjectConfirmation().withSubjectConfirmationData(aSubjectConfirmationData().withNotOnOrAfter(notOnOrAfter).build()).build()).build()).buildUnencrypted();
idpAssertionMetricsCollector.update(anAssertion);
Gauge actual = metricRegistry.getGauges().get("notOnOrAfter.testIdP");
assertThat(actual.getValue()).isEqualTo(15L);
}
use of com.codahale.metrics.Gauge in project verify-hub by alphagov.
the class IdpAssertionMetricsCollectorTest method shouldNotRegisterIdpAlreadyExist.
@Test
public void shouldNotRegisterIdpAlreadyExist() {
MetricRegistry metricRegistry = mock(MetricRegistry.class);
SortedMap<String, Gauge> gaugeMock = mock(SortedMap.class);
when(gaugeMock.containsKey(any())).thenReturn(true);
when(metricRegistry.getGauges()).thenReturn(gaugeMock);
Assertion assertion = anAssertion().withIssuer(anIssuer().withIssuerId("testIdP").build()).buildUnencrypted();
IdpAssertionMetricsCollector idpAssertionMetricsCollector = new IdpAssertionMetricsCollector(metricRegistry);
idpAssertionMetricsCollector.update(assertion);
verify(metricRegistry, times(0)).register(any(), any());
}
Aggregations