Package com.bluesoft.util.metrics.core

Examples of com.bluesoft.util.metrics.core.TimingMetric


  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 ) );
View Full Code Here


    verify( mock );
  }

  @Test
  public void testGetMean() {
    TimingMetric mock = createMock( TimingMetric.class );
    UnitRoundingTimingMetric rounder = new UnitRoundingTimingMetric( TimeUnit.MINUTES, TimeUnit.MILLISECONDS, mock );
    expect( mock.getMean() ).andReturn( new TimingImpl( BigDecimal.valueOf( 1500000000L, 0 ), TimeUnit.NANOSECONDS ) );
    replay( mock );
    Timing timing = rounder.getMean();
    assertEquals( timing.getUnit(), TimeUnit.MILLISECONDS );
    assertEquals( timing.getValue(), BigDecimal.valueOf( 1500000000000L, 9 ) );
    verify( mock );

    reset( mock );
    expect( mock.getMean() ).andReturn( new TimingImpl( BigDecimal.valueOf( 1500000000L, 0 ), TimeUnit.MILLISECONDS ) );
    replay( mock );
    timing = rounder.getMean();
    assertEquals( timing.getUnit(), TimeUnit.MILLISECONDS );
    assertEquals( timing.getValue(), BigDecimal.valueOf( 1500000000L, 0 ) );
    verify( mock );
View Full Code Here

    verify( mock );
  }

  @Test
  public void testGetStandardDeviation() {
    TimingMetric mock = createMock( TimingMetric.class );
    UnitRoundingTimingMetric rounder = new UnitRoundingTimingMetric( TimeUnit.MINUTES, TimeUnit.MILLISECONDS, mock );
    expect( mock.getStandardDeviation() ).andReturn( new TimingImpl( BigDecimal.valueOf( 1500000000L, 0 ), TimeUnit.NANOSECONDS ) );
    replay( mock );
    Timing timing = rounder.getStandardDeviation();
    assertEquals( timing.getUnit(), TimeUnit.MILLISECONDS );
    assertEquals( timing.getValue(), BigDecimal.valueOf( 1500000000000L, 9 ) );
    verify( mock );

    reset( mock );
    expect( mock.getStandardDeviation() ).andReturn( new TimingImpl( BigDecimal.valueOf( 1500000000L, 0 ), TimeUnit.MILLISECONDS ) );
    replay( mock );
    timing = rounder.getStandardDeviation();
    assertEquals( timing.getUnit(), TimeUnit.MILLISECONDS );
    assertEquals( timing.getValue(), BigDecimal.valueOf( 1500000000L, 0 ) );
    verify( mock );
View Full Code Here

    verify( mock );
  }

  @Test
  public void testGetTotal() {
    TimingMetric mock = createMock( TimingMetric.class );
    UnitRoundingTimingMetric rounder = new UnitRoundingTimingMetric( TimeUnit.MINUTES, TimeUnit.MILLISECONDS, mock );
    expect( mock.getTotal() ).andReturn( new TimingImpl( BigDecimal.valueOf( 1500000000L, 0 ), TimeUnit.NANOSECONDS ) );
    replay( mock );
    Timing timing = rounder.getTotal();
    assertEquals( timing.getUnit(), TimeUnit.MILLISECONDS );
    assertEquals( timing.getValue(), BigDecimal.valueOf( 1500000000000L, 9 ) );
    verify( mock );

    reset( mock );
    expect( mock.getTotal() ).andReturn( new TimingImpl( BigDecimal.valueOf( 1500000000L, 0 ), TimeUnit.MILLISECONDS ) );
    replay( mock );
    timing = rounder.getTotal();
    assertEquals( timing.getUnit(), TimeUnit.MILLISECONDS );
    assertEquals( timing.getValue(), BigDecimal.valueOf( 1500000000L, 0 ) );
    verify( mock );
View Full Code Here

    verify( mock );
  }

  @Test
  public void testGetRate() {
    TimingMetric mock = createMock( TimingMetric.class );
    UnitRoundingTimingMetric rounder = new UnitRoundingTimingMetric( TimeUnit.MINUTES, TimeUnit.MILLISECONDS, mock );
    expect( mock.getRate() ).andReturn( new RateImpl( BigDecimal.valueOf( 15L, 0 ), TimeUnit.SECONDS ) );
    replay( mock );
    Rate rate = rounder.getRate();
    assertEquals( rate.getUnit(), TimeUnit.MINUTES );
    assertEquals( rate.getValue(), BigDecimal.valueOf( 900000000000L, 9 ) );
    verify( mock );

    reset( mock );
    expect( mock.getRate() ).andReturn( new RateImpl( BigDecimal.valueOf( 15L, 0 ), TimeUnit.MINUTES ) );
    replay( mock );
    rate = rounder.getRate();
    assertEquals( rate.getUnit(), TimeUnit.MINUTES );
    assertEquals( rate.getValue(), BigDecimal.valueOf( 15L, 0 ) );
    verify( mock );
View Full Code Here

    verify( mock );
  }

  @Test
  public void testGetCount() {
    TimingMetric mock = createMock( TimingMetric.class );
    UnitRoundingTimingMetric rounder = new UnitRoundingTimingMetric( TimeUnit.MINUTES, TimeUnit.MILLISECONDS, mock );
    expect( mock.getCount() ).andReturn( BigInteger.valueOf( 15L ) );
    replay( mock );
    assertEquals( rounder.getCount(), BigInteger.valueOf( 15L ) );
    verify( mock );
  }
View Full Code Here

    verify( mock );
  }

  @Test
  public void testGetSnapshot() {
    TimingMetric mock = createMock( TimingMetric.class );
    UnitRoundingTimingMetric rounder = new UnitRoundingTimingMetric( TimeUnit.MINUTES, TimeUnit.MILLISECONDS, mock );
    final BasicTimingMetric snapshot = new BasicTimingMetric( "test" );
    expect( mock.getSnapshot() ).andReturn( snapshot );
    replay( mock );
    assertTrue( rounder.getSnapshot().getClass().isAssignableFrom( UnitRoundingTimingMetric.class ) );
    verify( mock );
  }
View Full Code Here

    verify( mock );
  }

  @Test
  public void testGetChild() {
    TimingMetric mock = createMock( TimingMetric.class );
    UnitRoundingTimingMetric rounder = new UnitRoundingTimingMetric( TimeUnit.MINUTES, TimeUnit.MILLISECONDS, mock );
    final BasicTimingMetric child = new BasicTimingMetric( "test" );
    expect( mock.getChild( eq( "test" ) ) ).andStubReturn( child );
    replay( mock );
    assertTrue( rounder.getChild( "test" ).getClass().isAssignableFrom( UnitRoundingTimingMetric.class ) );
    assertTrue( rounder.getChild( "test" ).getClass().isAssignableFrom( UnitRoundingTimingMetric.class ) );
    verify( mock );
  }
View Full Code Here

    verify( mock );
  }

  @Test
  public void testGetChildMeteringWrappingTiming() {
    TimingMetric mock = createMock( TimingMetric.class );
    UnitRoundingMeteringMetric rounder = new UnitRoundingMeteringMetric( TimeUnit.MINUTES, mock );
    final BasicTimingMetric child = new BasicTimingMetric( "test" );
    expect( mock.getChild( eq( "test" ) ) ).andStubReturn( child );
    replay( mock );
    assertTrue( rounder.getChild( "test" ).getClass().isAssignableFrom( UnitRoundingTimingMetric.class ) );
    assertTrue( rounder.getChild( "test" ).getClass().isAssignableFrom( UnitRoundingTimingMetric.class ) );
    assertEquals( ((TimingMetric)rounder.getChild( "test" )).getTimeUnit(), TimeUnit.NANOSECONDS );
    verify( mock );
View Full Code Here

    verify( mock );
  }

  @Test
  public void testGetChildMeteringWrappingMetric() {
    TimingMetric mock = createMock( TimingMetric.class );
    UnitRoundingMeteringMetric rounder = new UnitRoundingMeteringMetric( TimeUnit.MINUTES, mock );
    final Metric child = new AbstractMetric( "test" ) {
    };
    expect( mock.getChild( eq( "test" ) ) ).andStubReturn( child );
    replay( mock );
    assertSame( rounder.getChild( "test" ), child );
    verify( mock );
  }
View Full Code Here

TOP

Related Classes of com.bluesoft.util.metrics.core.TimingMetric

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.