Examples of Rate


Examples of com.avaje.tests.model.ivo.Rate

    public BigDecimal unwrapValue(Rate beanType) {
        return beanType.getValue();
    }

    public Rate wrapValue(BigDecimal scalarType) {       
        return new Rate(scalarType);
    }
View Full Code Here

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

  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

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

    Timing mean = tm.getMean();
    Timing median = tm.getCentile( new BigDecimal( 50L ) );
    BigDecimal stddev = tm.getStandardDeviation().getValue();
    Timing total = tm.getTotal();
    Rate rate = tm.getRate();

    try {
      tm.getCentile( BigDecimal.valueOf( 105.0 ) );
      fail( "failed to trigger expected exception: IllegalArgumentException" );
    } catch ( IllegalArgumentException ex ) {
      // Expected
    }
    try {
      tm.getCentile( BigDecimal.valueOf( -1.0 ) );
      fail( "failed to trigger expected exception: IllegalArgumentException" );
    } catch ( IllegalArgumentException ex ) {
      // Expected
    }
    assertEquals( tm.getCentile( BigDecimal.valueOf( 100L ) ).getValue(), BigDecimal.valueOf( 10L ) );
    assertNotNull( mean );
    assertNotNull( median );
    assertNotNull( stddev );
    assertNotNull( total );
    assertNotNull( rate );
    assertBigDecimalEquals( mean.getValue(), BigDecimal.valueOf( 48333333333L, 10 ) );
    assertBigDecimalEquals( median.getValue(), new BigDecimal( 4 ) );
    assertBigDecimalEquals( stddev, BigDecimal.valueOf( 2786873996L, 9 ) );
    assertBigDecimalEquals( total.getValue(), new BigDecimal( 29 ) );
    assertBigDecimalEquals( rate.getValue(), new BigDecimal( 6 ) );

    TimingMetric<TimingMetric, TimingEvent> snapshot = tm.getSnapshot();
    mean = snapshot.getMean();
    median = snapshot.getCentile( new BigDecimal( 50L ) );
    stddev = snapshot.getStandardDeviation().getValue();
    total = snapshot.getTotal();
    rate = snapshot.getRate();

    assertNotNull( mean );
    assertNotNull( median );
    assertNotNull( stddev );
    assertNotNull( total );
    assertNotNull( rate );
    assertBigDecimalEquals( mean.getValue(), BigDecimal.valueOf( 48333333333L, 10 ) );
    assertBigDecimalEquals( median.getValue(), new BigDecimal( 4 ) );
    assertBigDecimalEquals( stddev, BigDecimal.valueOf( 2786873996L, 9 ) );
    assertBigDecimalEquals( total.getValue(), new BigDecimal( 29 ) );
    assertBigDecimalEquals( rate.getValue(), new BigDecimal( 6 ) );

    snapshot = tm.reset();
    mean = snapshot.getMean();
    median = snapshot.getCentile( new BigDecimal( 50L ) );
    stddev = snapshot.getStandardDeviation().getValue();
    total = snapshot.getTotal();
    rate = snapshot.getRate();

    assertNotNull( mean );
    assertNotNull( median );
    assertNotNull( stddev );
    assertNotNull( total );
    assertNotNull( rate );
    assertBigDecimalEquals( mean.getValue(), BigDecimal.valueOf( 48333333333L, 10 ) );
    assertBigDecimalEquals( median.getValue(), new BigDecimal( 4 ) );
    assertBigDecimalEquals( stddev, BigDecimal.valueOf( 2786873996L, 9 ) );
    assertBigDecimalEquals( total.getValue(), new BigDecimal( 29 ) );
    assertBigDecimalEquals( rate.getValue(), new BigDecimal( 6 ) );

    mean = tm.getMean();
    median = tm.getCentile( new BigDecimal( 50L ) );
    stddev = tm.getStandardDeviation().getValue();
    total = tm.getTotal();
View Full Code Here

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

    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();
    assertTrue( r.getValue().compareTo( BigDecimal.valueOf( 10L ) ) == 0, ": expected 10 but found " + r.getValue() );
    assertEquals( r.getUnit(), TimeUnit.SECONDS );

    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 );

    snapshot = (MeteringMetric)mm.getSnapshot();

    r = snapshot.getRate();
    assertTrue( r.getValue().compareTo( BigDecimal.valueOf( 4L ) ) == 0, ": expected 4 but found " + r.getValue() );
    assertEquals( r.getUnit(), TimeUnit.SECONDS );

    snapshot = (MeteringMetric)mm.getSnapshot();

    r = snapshot.getRate();
    assertTrue( r.getValue().compareTo( BigDecimal.valueOf( 33333333333L, 10 ) ) == 0, ": expected 3.3333333333 but found " + r.getValue() );
    assertEquals( r.getUnit(), TimeUnit.SECONDS );

    snapshot = (MeteringMetric)mm.reset();

    assertNull( mm.getRate() );
    r = snapshot.getRate();
    assertNotNull( r );
    assertTrue( r.getValue().compareTo( BigDecimal.valueOf( 33333333333L, 10 ) ) == 0, ": expected 3.3333333333 but found " + r.getValue() );
    assertEquals( r.getUnit(), TimeUnit.SECONDS );
    verify( clock );
  }
View Full Code Here

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

   * <p>
   * @return the rate events are occurring.
   */
  @Override
  public Rate getRate() {
    Rate r = delegate.getRate();
    if ( r.getUnit() != getRateUnit() ) {
      return r.convertTo( getRateUnit() );
    }
    return r;
  }
View Full Code Here

Examples of com.dodo.blog.model.Rate

            // rate article
            article.incrementRate( rate );
            save( article );

            // create Rate entity that holds info whether user already voted for this article or not
            save( new Rate( articleId, accountId ) );
        }

        return article;
    }
View Full Code Here

Examples of com.projectlibre.core.time.Rate

public class OpenprojRateConverter extends FieldTypeConverter {

  @Override
  public Object from(Object o) {
    com.projity.datatype.Rate r=(com.projity.datatype.Rate)o;
    return new Rate(r.getValue() * com.projity.datatype.Duration.timeUnitFactor(r.getTimeUnit()),TimeUnit.getInstance(r.getTimeUnit()));
  }
 
View Full Code Here

Examples of com.projectlibre.core.time.Rate

    return new Rate(r.getValue() * com.projity.datatype.Duration.timeUnitFactor(r.getTimeUnit()),TimeUnit.getInstance(r.getTimeUnit()));
  }

  @Override
  public Object to(Object o) {
    Rate r=(Rate)o;
    return new com.projity.datatype.Rate(r.getValue() / com.projity.datatype.Duration.timeUnitFactor(r.getUnit().getId()), r.getUnit().getId());
  }
View Full Code Here

Examples of com.projectlibre.core.time.Rate

public class MpxRateConverter extends FieldTypeConverter {

  @Override
  public Object from(Object o) {
    net.sf.mpxj.Rate r=(net.sf.mpxj.Rate)o;
    return new Rate(r.getAmount(),TimeUnit.getInstance(r.getUnits().getValue()));
  }
View Full Code Here

Examples of com.projectlibre.core.time.Rate

    return new Rate(r.getAmount(),TimeUnit.getInstance(r.getUnits().getValue()));
  }

  @Override
  public Object to(Object o) {
    Rate r=(Rate)o;
    return new net.sf.mpxj.Rate(r.getValue(),net.sf.mpxj.TimeUnit.getInstance(r.getUnit().getId()));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.