private static final org.slf4j.Logger LOG = org.slf4j.LoggerFactory.getLogger( UnitRoundingTimingMetricTest.class );
@Test
public void testCentile() {
TimingMetric mock = createMock( TimingMetric.class );
UnitRoundingTimingMetric rounder = new UnitRoundingTimingMetric( TimeUnit.MINUTES, TimeUnit.MILLISECONDS, mock );
expect( mock.getCentile( eq( BigDecimal.valueOf( 95.0 ) ) ) )
.andReturn( new TimingImpl( BigDecimal.valueOf( 1500000000L, 0 ), TimeUnit.NANOSECONDS ) );
replay( mock );
Timing timing = rounder.getCentile( BigDecimal.valueOf( 95.0 ) );
assertEquals( timing.getUnit(), TimeUnit.MILLISECONDS );
assertEquals( timing.getValue(), BigDecimal.valueOf( 1500000000000L, 9 ) );
verify( mock );
reset( mock );
expect( mock.getCentile( eq( BigDecimal.valueOf( 95.0 ) ) ) )
.andReturn( new TimingImpl( BigDecimal.valueOf( 1500000000L, 0 ), TimeUnit.MILLISECONDS ) );
replay( mock );
timing = rounder.getCentile( BigDecimal.valueOf( 95.0 ) );
assertEquals( timing.getUnit(), TimeUnit.MILLISECONDS );
assertEquals( timing.getValue(), BigDecimal.valueOf( 1500000000L, 0 ) );