@Test(dependsOnMethods = {"getMetadata"}) public void getStatsWithoutTotal() throws Exception { for (String zoneId : zones) { QueueApi queueApi = api.getQueueApiForZoneAndClient(zoneId, CLIENT_ID); QueueStats stats = queueApi.getStats("jclouds-test-1"); assertEquals(stats.getMessagesStats().getClaimed(), 0); assertEquals(stats.getMessagesStats().getFree(), 0); assertEquals(stats.getMessagesStats().getTotal(), 0); assertFalse(stats.getMessagesStats().getOldest().isPresent()); assertFalse(stats.getMessagesStats().getNewest().isPresent()); } }
@Test(dependsOnMethods = {"getStatsWithoutTotal"}) public void getStatsWithTotal() throws Exception { for (String zoneId : zones) { MessageApi messageApi = api.getMessageApiForZoneAndClientAndQueue(zoneId, CLIENT_ID, "jclouds-test-1"); String json1 = "{\"event\":{\"type\":\"hockey\",\"players\":[\"bob\",\"jim\",\"sally\"]}}"; CreateMessage message1 = CreateMessage.builder().ttl(120).body(json1).build(); List<CreateMessage> message = ImmutableList.of(message1); messageApi.create(message); QueueApi queueApi = api.getQueueApiForZoneAndClient(zoneId, CLIENT_ID); QueueStats stats = queueApi.getStats("jclouds-test-1"); assertEquals(stats.getMessagesStats().getClaimed(), 0); assertEquals(stats.getMessagesStats().getFree(), 1); assertEquals(stats.getMessagesStats().getTotal(), 1); assertTrue(stats.getMessagesStats().getOldest().isPresent()); assertNotNull(stats.getMessagesStats().getOldest().get().getId()); assertTrue(stats.getMessagesStats().getNewest().isPresent()); assertNotNull(stats.getMessagesStats().getNewest().get().getId()); } }