PageRenderTime 98ms CodeModel.GetById 31ms RepoModel.GetById 0ms app.codeStats 0ms

/providers/hpcloud-objectstorage-lvs/src/test/java/org/jclouds/hpcloud/objectstorage/lvs/functions/ParseContainerCDNMetadataListFromJsonResponseTest.java

https://github.com/mattiasholmqvist/jclouds
Java | 69 lines | 36 code | 10 blank | 23 comment | 0 complexity | a6a57f2dc1162c6b6613d506c257664c MD5 | raw file
  1. /**
  2. * Licensed to jclouds, Inc. (jclouds) under one or more
  3. * contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. jclouds licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing,
  13. * software distributed under the License is distributed on an
  14. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. * KIND, either express or implied. See the License for the
  16. * specific language governing permissions and limitations
  17. * under the License.
  18. */
  19. package org.jclouds.hpcloud.objectstorage.lvs.functions;
  20. import static org.testng.Assert.assertEquals;
  21. import java.io.InputStream;
  22. import java.net.URI;
  23. import java.util.Set;
  24. import java.util.SortedSet;
  25. import org.jclouds.hpcloud.objectstorage.lvs.domain.ContainerCDNMetadata;
  26. import org.jclouds.http.HttpResponse;
  27. import org.jclouds.http.functions.ParseJson;
  28. import org.jclouds.io.Payloads;
  29. import org.jclouds.json.config.GsonModule;
  30. import org.testng.annotations.Test;
  31. import com.google.common.collect.ImmutableSortedSet;
  32. import com.google.inject.Guice;
  33. import com.google.inject.Injector;
  34. import com.google.inject.Key;
  35. import com.google.inject.TypeLiteral;
  36. /**
  37. * Tests behavior of {@code ParseContainerCDNMetadataListFromJsonResponse}
  38. *
  39. * @author Jeremy Daggett
  40. */
  41. @Test(groups = "unit")
  42. public class ParseContainerCDNMetadataListFromJsonResponseTest {
  43. Injector i = Guice.createInjector(new GsonModule());
  44. @Test
  45. public void testApplyInputStream() {
  46. InputStream is = getClass().getResourceAsStream("/test_list_cdn.json");
  47. Set<ContainerCDNMetadata> expects = ImmutableSortedSet.of(
  48. new ContainerCDNMetadata("hpcloud-blobstore.testCDNOperationsContainerWithCDN", false, 3600,
  49. URI.create("https://cdnmgmt.hpcloud.net:8080/v1/AUTH_test/")),
  50. new ContainerCDNMetadata("hpcloud-blobstore5", true, 28800,
  51. URI.create("https://cdnmgmt.hpcloud.net:8080/v1/AUTH_test/")),
  52. new ContainerCDNMetadata("hpcloud-cfcdnint.testCDNOperationsContainerWithCDN", false, 3600,
  53. URI.create("https://cdnmgmt.hpcloud.net:8080/v1/AUTH_test/")));
  54. ParseJson<SortedSet<ContainerCDNMetadata>> parser = i.getInstance(Key
  55. .get(new TypeLiteral<ParseJson<SortedSet<ContainerCDNMetadata>>>() {
  56. }));
  57. assertEquals(parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is))), expects);
  58. }
  59. }