@Test
    public void testGetUsage() {
        Map<String, String> config = new HashMap<>();
        config.put("datasource.jndi-location", DB_JNDI_LOC);
        JdbcMetricsAccessor accessor = new JdbcMetricsAccessor(config);
        DateTime from = ISODateTimeFormat.dateTimeNoMillis().withZone(DateTimeZone.UTC).parseDateTime("2016-02-01T00:00:00Z");
        DateTime to = ISODateTimeFormat.dateTimeNoMillis().withZone(DateTimeZone.UTC).parseDateTime("2016-03-01T00:00:00Z");
        
        UsageHistogramBean usage = accessor.getUsage("TestOrg", "TestApi", "1.0", HistogramIntervalType.day, from, to);
        Assert.assertNotNull(usage);
        UsageDataPoint dataPoint = usage.getData().get(9);
        Assert.assertNotNull(dataPoint);
        Assert.assertEquals(2, dataPoint.getCount());
        Assert.assertEquals("2016-02-10T00:00:00.000Z", dataPoint.getLabel());
        Assert.assertEquals(9, usage.getData().get(22).getCount());
        Assert.assertEquals(6, usage.getData().get(23).getCount());
        Assert.assertEquals(0, usage.getData().get(24).getCount());

        // No data for "UnknownApi"
        usage = accessor.getUsage("TestOrg", "UnknownApi", "1.0", HistogramIntervalType.day, from, to);
        Assert.assertNotNull(usage);
        for (UsageDataPoint dp : usage.getData()) {
            Assert.assertEquals(0, dp.getCount());
        }

        from = ISODateTimeFormat.dateTimeNoMillis().withZone(DateTimeZone.UTC).parseDateTime("2016-01-01T00:00:00Z");
        to = ISODateTimeFormat.dateTimeNoMillis().withZone(DateTimeZone.UTC).parseDateTime("2016-12-31T00:00:00Z");
        usage = accessor.getUsage("TestOrg", "TestApi", "1.0", HistogramIntervalType.month, from, to);
        Assert.assertNotNull(usage);
        Assert.assertEquals(18, usage.getData().get(1).getCount());
        Assert.assertEquals(0, usage.getData().get(2).getCount());

        from = ISODateTimeFormat.dateTimeNoMillis().withZone(DateTimeZone.UTC).parseDateTime("2016-02-10T00:00:00Z");
        to = ISODateTimeFormat.dateTimeNoMillis().withZone(DateTimeZone.UTC).parseDateTime("2016-02-12T00:00:00Z");
        usage = accessor.getUsage("TestOrg", "TestApi", "1.0", HistogramIntervalType.hour, from, to);
        Assert.assertNotNull(usage);
        Assert.assertEquals(2, usage.getData().get(8).getCount());
        Assert.assertEquals(1, usage.getData().get(36).getCount());

        from = ISODateTimeFormat.dateTimeNoMillis().withZone(DateTimeZone.UTC).parseDateTime("2016-02-10T07:00:00Z");
        to = ISODateTimeFormat.dateTimeNoMillis().withZone(DateTimeZone.UTC).parseDateTime("2016-02-11T00:00:00Z");
        usage = accessor.getUsage("TestOrg", "TestApi", "1.0", HistogramIntervalType.minute, from, to);
        Assert.assertNotNull(usage);
        for (UsageDataPoint dp : usage.getData()) {
            if ("2016-02-10T08:56:00.000Z".equals(dp.getLabel())) {
                Assert.assertEquals(2, dp.getCount());
            } else {
                Assert.assertEquals(0, dp.getCount());
            }
        }
    }
Test method for {@link io.apiman.manager.api.jdbc.JdbcMetricsAccessor#getUsage(java.lang.String, java.lang.String, java.lang.String, io.apiman.manager.api.beans.metrics.HistogramIntervalType, org.joda.time.DateTime, org.joda.time.DateTime)}.
manager/api/jdbc/src/test/java/io/apiman/manager/api/jdbc/JdbcMetricsAccessorTest.java