@Test
    public void testGetUsagePerPlan() throws Exception {
        EsMetricsAccessor metrics = new EsMetricsAccessor(client);

        // data exists - all data for JBossOverlord/s-ramp-api:1.0
        UsagePerPlanBean usagePerPlan = metrics.getUsagePerPlan("JBossOverlord", "s-ramp-api", "1.0",
                parseDate("2015-01-01"), new DateTime().withZone(DateTimeZone.UTC));
        Assert.assertNotNull(usagePerPlan);
        Map<String, Long> expectedData = new HashMap<>();
        expectedData.put("Platinum", 17L);
        expectedData.put("Silver", 16L);
        expectedData.put("Gold", 12L);
        Assert.assertEquals(expectedData, usagePerPlan.getData());

        // data exists - all data for Test/echo:1.0
        usagePerPlan = metrics.getUsagePerPlan("Test", "echo", "1.0",
                parseDate("2015-01-01"), new DateTime().withZone(DateTimeZone.UTC));
        Assert.assertNotNull(usagePerPlan);
        expectedData.clear();
        expectedData.put("Platinum", 31L);
        expectedData.put("Silver", 73L);
        expectedData.put("Gold", 67L);
        expectedData.put("Bronze", 43L);
        Assert.assertEquals(expectedData, usagePerPlan.getData());

        // Test/echo:1.0 bounded by a different date range
        usagePerPlan = metrics.getUsagePerPlan("Test", "echo", "1.0",
                parseDate("2015-06-18"), new DateTime().withZone(DateTimeZone.UTC));
        Assert.assertNotNull(usagePerPlan);
        expectedData.clear();
        Assert.assertEquals(expectedData, usagePerPlan.getData());

        // data exists - all data for Test/echo:1.0 (alt timeframe)
        usagePerPlan = metrics.getUsagePerPlan("Test", "echo", "1.0",
                parseDate("2015-06-01"),
                parseDate("2015-06-17"));
        Assert.assertNotNull(usagePerPlan);
        expectedData.clear();
        expectedData.put("Platinum", 31L);
        expectedData.put("Silver", 73L);
        expectedData.put("Gold", 67L);
        expectedData.put("Bronze", 43L);
        Assert.assertEquals(expectedData, usagePerPlan.getData());

    }
Test method for {@link EsMetricsAccessor#getUsagePerPlan(java.lang.String, java.lang.String, java.lang.String, java.util.Date, java.util.Date)}.
manager/test/api/src/test/java/io/apiman/manager/test/es/EsMetricsAccessorTest.java