Package org.jclouds.openstack.marconi.v1.features

Examples of org.jclouds.openstack.marconi.v1.features.MessageApiLiveTest


   ParseMessagesCreated(ParseJson<MessagesCreated> json) {
      this.json = checkNotNull(json, "json");
   }

   public MessagesCreated apply(HttpResponse from) {
      MessagesCreated rawMessagesCreated = json.apply(from);
      List<String> messageIds = Lists.transform(rawMessagesCreated.getMessageIds(), TO_ID_FROM_HREF);

      MessagesCreated messagesCreated = MessagesCreated.builder()
            .messageIds(messageIds)
            .build();

      return messagesCreated;
   }
View Full Code Here


   ParseMessagesCreated(ParseJson<MessagesCreated> json) {
      this.json = checkNotNull(json, "json");
   }

   public MessagesCreated apply(HttpResponse from) {
      MessagesCreated rawMessagesCreated = json.apply(from);
      List<String> messageIds = Lists.transform(rawMessagesCreated.getMessageIds(), TO_ID_FROM_HREF);

      MessagesCreated messagesCreated = MessagesCreated.builder()
            .messageIds(messageIds)
            .build();

      return messagesCreated;
   }
View Full Code Here

         Aged newestWithHref = rawQueueStats.getMessagesStats().getNewest().get();
         Aged newestWithId = newestWithHref.toBuilder()
               .id(TO_ID_FROM_HREF.apply(newestWithHref.getId()))
               .build();

         MessagesStats messagesStatsWithIds = rawQueueStats.getMessagesStats().toBuilder()
               .oldest(oldestWithId)
               .newest(newestWithId)
               .build();

         QueueStats queueStatsWithIds = rawQueueStats.toBuilder().messageStats(messagesStatsWithIds).build();
View Full Code Here

         Aged newestWithHref = rawQueueStats.getMessagesStats().getNewest().get();
         Aged newestWithId = newestWithHref.toBuilder()
               .id(TO_ID_FROM_HREF.apply(newestWithHref.getId()))
               .build();

         MessagesStats messagesStatsWithIds = rawQueueStats.getMessagesStats().toBuilder()
               .oldest(oldestWithId)
               .newest(newestWithId)
               .build();

         QueueStats queueStatsWithIds = rawQueueStats.toBuilder().messageStats(messagesStatsWithIds).build();
View Full Code Here

      server.enqueue(new MockResponse().setResponseCode(200).setBody("{\"messages\":{\"claimed\":0,\"total\":0,\"free\":0}}"));

      try {
         MarconiApi api = api(server.getUrl("/").toString(), "openstack-marconi");
         QueueApi queueApi = api.getQueueApiForZoneAndClient("DFW", CLIENT_ID);
         QueueStats stats = queueApi.getStats("jclouds-test");

         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());

         assertEquals(server.getRequestCount(), 2);
         assertEquals(server.takeRequest().getRequestLine(), "POST /tokens HTTP/1.1");
         assertEquals(server.takeRequest().getRequestLine(), "GET /v1/123123/queues/jclouds-test/stats HTTP/1.1");
      }
View Full Code Here

      server.enqueue(new MockResponse().setResponseCode(200).setBody("{\"messages\": {\"claimed\": 0, \"oldest\": {\"age\": 0, \"href\": \"/v1/queues/jclouds-test/messages/526558b3f4919b655feba3a7\", \"created\": \"2013-10-21T16:39:15Z\"}, \"total\": 4, \"newest\": {\"age\": 0, \"href\": \"/v1/queues/jclouds-test/messages/526558b33ac24e663fc545e7\", \"created\": \"2013-10-21T16:39:15Z\"}, \"free\": 4}}"));

      try {
         MarconiApi api = api(server.getUrl("/").toString(), "openstack-marconi");
         QueueApi queueApi = api.getQueueApiForZoneAndClient("DFW", CLIENT_ID);
         QueueStats stats = queueApi.getStats("jclouds-test");

         assertEquals(stats.getMessagesStats().getClaimed(), 0);
         assertEquals(stats.getMessagesStats().getFree(), 4);
         assertEquals(stats.getMessagesStats().getTotal(), 4);
         assertTrue(stats.getMessagesStats().getOldest().isPresent());
         assertTrue(stats.getMessagesStats().getOldest().get().getCreated().before(new Date()));
         assertEquals(stats.getMessagesStats().getOldest().get().getAge(), 0);
         assertEquals(stats.getMessagesStats().getOldest().get().getId(), "526558b3f4919b655feba3a7");
         assertTrue(stats.getMessagesStats().getNewest().isPresent());
         assertTrue(stats.getMessagesStats().getNewest().get().getCreated().before(new Date()));
         assertEquals(stats.getMessagesStats().getNewest().get().getAge(), 0);
         assertEquals(stats.getMessagesStats().getNewest().get().getId(), "526558b33ac24e663fc545e7");

         assertEquals(server.getRequestCount(), 2);
         assertEquals(server.takeRequest().getRequestLine(), "POST /tokens HTTP/1.1");
         assertEquals(server.takeRequest().getRequestLine(), "GET /v1/123123/queues/jclouds-test/stats HTTP/1.1");
      }
View Full Code Here

   @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());
      }
   }
View Full Code Here

         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());
      }
   }
View Full Code Here

   ParseQueueStats(ParseJson<QueueStats> json) {
      this.json = checkNotNull(json, "json");
   }

   public QueueStats apply(HttpResponse from) {
      QueueStats rawQueueStats = json.apply(from);

      if (rawQueueStats.getMessagesStats().getTotal() == 0) {
         return rawQueueStats;
      }
      else {
         // change the hrefs to ids
         Aged oldestWithHref = rawQueueStats.getMessagesStats().getOldest().get();
         Aged oldestWithId = oldestWithHref.toBuilder()
               .id(TO_ID_FROM_HREF.apply(oldestWithHref.getId()))
               .build();
         Aged newestWithHref = rawQueueStats.getMessagesStats().getNewest().get();
         Aged newestWithId = newestWithHref.toBuilder()
               .id(TO_ID_FROM_HREF.apply(newestWithHref.getId()))
               .build();

         MessagesStats messagesStatsWithIds = rawQueueStats.getMessagesStats().toBuilder()
               .oldest(oldestWithId)
               .newest(newestWithId)
               .build();

         QueueStats queueStatsWithIds = rawQueueStats.toBuilder().messageStats(messagesStatsWithIds).build();

         return queueStatsWithIds;
      }
   }
View Full Code Here

   ParseQueueStats(ParseJson<QueueStats> json) {
      this.json = checkNotNull(json, "json");
   }

   public QueueStats apply(HttpResponse from) {
      QueueStats rawQueueStats = json.apply(from);

      if (rawQueueStats.getMessagesStats().getTotal() == 0) {
         return rawQueueStats;
      }
      else {
         // change the hrefs to ids
         Aged oldestWithHref = rawQueueStats.getMessagesStats().getOldest().get();
         Aged oldestWithId = oldestWithHref.toBuilder()
               .id(TO_ID_FROM_HREF.apply(oldestWithHref.getId()))
               .build();
         Aged newestWithHref = rawQueueStats.getMessagesStats().getNewest().get();
         Aged newestWithId = newestWithHref.toBuilder()
               .id(TO_ID_FROM_HREF.apply(newestWithHref.getId()))
               .build();

         MessagesStats messagesStatsWithIds = rawQueueStats.getMessagesStats().toBuilder()
               .oldest(oldestWithId)
               .newest(newestWithId)
               .build();

         QueueStats queueStatsWithIds = rawQueueStats.toBuilder().messageStats(messagesStatsWithIds).build();

         return queueStatsWithIds;
      }
   }
View Full Code Here

TOP

Related Classes of org.jclouds.openstack.marconi.v1.features.MessageApiLiveTest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.