Search in sources :

Example 1 with StatsImpl

use of com.newrelic.agent.stats.StatsImpl in project newrelic-java-agent by newrelic.

the class J2EEStatsAttributeTest method processStatistic_count.

@Test
public void processStatistic_count() {
    CountStatistic statistic = Mockito.mock(CountStatistic.class);
    Mockito.when(statistic.getName()).thenReturn("CoolCount");
    Mockito.when(statistic.getCount()).thenReturn(66L);
    StatsImpl stat = new StatsImpl(0, 0, 0, 0, 0);
    StatsEngine statsEngine = Mockito.mock(StatsEngine.class);
    Mockito.when(statsEngine.getStats("Test/Metric/CoolCount")).thenReturn(stat);
    J2EEStatsAttributeProcessor.processStatistic(statsEngine, "Test/Metric", new Attribute("CoolCount", -32), statistic);
    Mockito.verify(statsEngine, times(1)).getStats("Test/Metric/CoolCount");
    Assert.assertEquals(66, stat.getTotal(), .0001);
}
Also used : StatsImpl(com.newrelic.agent.stats.StatsImpl) Attribute(javax.management.Attribute) StatsEngine(com.newrelic.agent.stats.StatsEngine) CountStatistic(javax.management.j2ee.statistics.CountStatistic) Test(org.junit.Test)

Example 2 with StatsImpl

use of com.newrelic.agent.stats.StatsImpl in project newrelic-java-agent by newrelic.

the class TokenTimeoutTest method assertMetricCount.

private void assertMetricCount(String metric, int count) {
    StatsImpl statsForMetric = (StatsImpl) stats.get(0).getUnscopedStats().getStats(metric);
    Assert.assertNotNull(statsForMetric);
    assertEquals(count, statsForMetric.getCallCount());
}
Also used : StatsImpl(com.newrelic.agent.stats.StatsImpl)

Example 3 with StatsImpl

use of com.newrelic.agent.stats.StatsImpl in project newrelic-java-agent by newrelic.

the class TransactionAsyncTimeoutTest method assertMetricCount.

private void assertMetricCount(String metric, int count) {
    StatsImpl statsForMetric = (StatsImpl) stats.getUnscopedStats().getStats(metric);
    Assert.assertNotNull(statsForMetric);
    Assert.assertEquals(count, statsForMetric.getCallCount());
}
Also used : StatsImpl(com.newrelic.agent.stats.StatsImpl)

Aggregations

StatsImpl (com.newrelic.agent.stats.StatsImpl)3 StatsEngine (com.newrelic.agent.stats.StatsEngine)1 Attribute (javax.management.Attribute)1 CountStatistic (javax.management.j2ee.statistics.CountStatistic)1 Test (org.junit.Test)1