@SuppressWarnings("unchecked")
@Test
public void testNginxGaugeTest() {

    String data1 = "Active connections: 5\n" +
            "server accepts handled requests request_time\n" +
            " 2009437 2009437 2003352 28635579\n" +
            "Reading: 0 Writing: 1 Waiting: 4\n";
    ManualClock clock = new ManualClock();
    TestNginxGaugeSet nginxGaugeSet = new TestNginxGaugeSet(clock);
    Map<MetricName, Metric> metrics = nginxGaugeSet.getMetrics();
    Assert.assertEquals(8, metrics.keySet().size());
    clock.addMillis(20);
    nginxGaugeSet.setData(data1);
    Gauge<Double> connAccepted = (Gauge<Double>)metrics.get(MetricName.build("conn.accepted"));
    Gauge<Double> connHandled = (Gauge<Double>)metrics.get(MetricName.build("conn.handled"));
    Gauge<Double> reqQps = (Gauge<Double>)metrics.get(MetricName.build("request.qps"));
    Gauge<Double> reqAvgRt = (Gauge<Double>)metrics.get(MetricName.build("request.avg_rt"));
    Gauge<Long> connActive = (Gauge<Long>)metrics.get(MetricName.build("conn.active"));
    Gauge<Long> connReading = (Gauge<Long>)metrics.get(MetricName.build("conn.reading"));
    Gauge<Long> connWriting = (Gauge<Long>)metrics.get(MetricName.build("conn.writing"));
    Gauge<Long> connWaiting = (Gauge<Long>)metrics.get(MetricName.build("conn.waiting"));
    Assert.assertEquals(0.0d, connAccepted.getValue(), 0.0001d);
    Assert.assertEquals(0.0d, connHandled.getValue(), 0.0001d);
    Assert.assertEquals(0.0d, reqQps.getValue(), 0.0001d);
    Assert.assertEquals(0.0d, reqAvgRt.getValue(), 0.0001d);
    Assert.assertEquals(5L, connActive.getValue().longValue());
    Assert.assertEquals(0L, connReading.getValue().longValue());
    Assert.assertEquals(1L, connWriting.getValue().longValue());
    Assert.assertEquals(4L, connWaiting.getValue().longValue());
    clock.addMillis(20);
    String data2 = "Active connections: 10\n" +
            "server accepts handled requests request_time\n" +
            " 2009637 2009617 2003502 28638579\n" +
            "Reading: 5 Writing: 3 Waiting: 2\n";
    nginxGaugeSet.setData(data2);
    Assert.assertEquals(10000.0d, connAccepted.getValue(), 0.0001d);
    Assert.assertEquals(1.0d * (2009617 - 2009437)/0.02, connHandled.getValue(), 0.0001d);
    Assert.assertEquals(1.0d * (2003502 - 2003352)/0.02, reqQps.getValue(), 0.0001d);
    Assert.assertEquals(1.0d * (28638579 - 28635579) / (2003502 - 2003352), reqAvgRt.getValue(), 0.0001d);
    Assert.assertEquals(10L, connActive.getValue().longValue());
    Assert.assertEquals(5L, connReading.getValue().longValue());
    Assert.assertEquals(3L, connWriting.getValue().longValue());
    Assert.assertEquals(2L, connWaiting.getValue().longValue());
}