mm.setClock( clock );
assertNull( mm.getRate() );
assertEquals( mm.getRateUnit(), TimeUnit.SECONDS );
mm.addEvent( new BasicMetricEvent() );
Rate r = mm.getRate();
assertTrue( r.getValue().compareTo( BigDecimal.valueOf( 1L ) ) == 0, ": expected 1 but found " + r.getValue() );
assertEquals( r.getUnit(), TimeUnit.SECONDS );
mm.addEvent( new BasicMetricEvent() );
mm.addEvent( new BasicMetricEvent() );
mm.addEvent( new BasicMetricEvent() );
mm.addEvent( new BasicMetricEvent() );
r = mm.getRate();
assertTrue( r.getValue().compareTo( BigDecimal.valueOf( 5L ) ) == 0, ": expected 5 but found " + r.getValue() );
assertEquals( r.getUnit(), TimeUnit.SECONDS );
MeteringMetric snapshot = (MeteringMetric)mm.getSnapshot();
r = snapshot.getRate();
assertTrue( r.getValue().compareTo( BigDecimal.valueOf( 5L ) ) == 0, ": expected 5 but found " + r.getValue() );
assertEquals( r.getUnit(), TimeUnit.SECONDS );
for ( int i = 0; i < 15; i++ ) {
mm.addEvent( new BasicMetricEvent() );
}
snapshot = (MeteringMetric)mm.getSnapshot();
r = snapshot.getRate();