@Test public void handlesDivideByZeroIssues() throws Exception { final RatioGauge divByZero = new RatioGauge() { @Override protected Ratio getRatio() { return Ratio.of(100, 0); } }; assertThat(divByZero.getValue()) .isNaN(); }
public Double getValue() { try { Ratio r = getRatio(); if (r == null) { return (double)NOT_AVAILABLE; } double result = r.getValue(); lastUpdated = System.currentTimeMillis(); return result; } catch (Exception e) { return (double)NOT_AVAILABLE; } }
RatioGauge implements Gauge<Double> { public Double getValue() { try { Ratio r = getRatio(); if (r == null) { return (double)NOT_AVAILABLE; } double result = r.getValue(); lastUpdated = System.currentTimeMillis(); return result; } catch (Exception e) { return (double)NOT_AVAILABLE; } } }
RatioGauge implements Gauge<Double> { public Double getValue() { try { Ratio r = getRatio(); if (r == null) { return (double)NOT_AVAILABLE; } double result = r.getValue(); lastUpdated = System.currentTimeMillis(); return result; } catch (Exception e) { return (double)NOT_AVAILABLE; } }  }
RatioGauge implements Gauge<Double> { public Double getValue() { try { Ratio r = getRatio(); if (r == null) { return (double)NOT_AVAILABLE; } double result = r.getValue(); lastUpdated = System.currentTimeMillis(); return result; } catch (Exception e) { return (double)NOT_AVAILABLE; } }  Double getValue(); @Override long lastUpdateTime(); }
RatioGauge implements Gauge<Double> { public Double getValue() { try { Ratio r = getRatio(); if (r == null) { return (double)NOT_AVAILABLE; } double result = r.getValue(); lastUpdated = System.currentTimeMillis(); return result; } catch (Exception e) { return (double)NOT_AVAILABLE; } }  Double getValue(); @Override long lastUpdateTime();  }