PageRenderTime 3333ms CodeModel.GetById 1ms RepoModel.GetById 1ms app.codeStats 0ms

/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseImageTest.java

http://github.com/jclouds/jclouds
Java | 95 lines | 71 code | 8 blank | 16 comment | 0 complexity | bf5aca890eea427bb359633eba6f0237 MD5 | raw file
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. package org.jclouds.openstack.nova.v2_0.parse;
  18. import java.net.URI;
  19. import javax.ws.rs.Consumes;
  20. import javax.ws.rs.core.MediaType;
  21. import org.jclouds.date.internal.SimpleDateFormatDateService;
  22. import org.jclouds.json.BaseItemParserTest;
  23. import org.jclouds.json.config.GsonModule;
  24. import org.jclouds.openstack.nova.v2_0.config.NovaParserModule;
  25. import org.jclouds.openstack.nova.v2_0.domain.Image;
  26. import org.jclouds.openstack.nova.v2_0.domain.Image.Status;
  27. import org.jclouds.openstack.v2_0.domain.Link;
  28. import org.jclouds.openstack.v2_0.domain.Link.Relation;
  29. import org.jclouds.openstack.v2_0.domain.Resource;
  30. import org.jclouds.rest.annotations.SelectJson;
  31. import org.testng.annotations.Test;
  32. import com.google.common.collect.ImmutableMap;
  33. import com.google.common.collect.ImmutableSet;
  34. import com.google.inject.Guice;
  35. import com.google.inject.Injector;
  36. @Test(groups = "unit", testName = "ParseImageTest")
  37. public class ParseImageTest extends BaseItemParserTest<Image> {
  38. @Override
  39. public String resource() {
  40. return "/image_details.json";
  41. }
  42. @Override
  43. @SelectJson("image")
  44. @Consumes(MediaType.APPLICATION_JSON)
  45. public Image expected() {
  46. return Image
  47. .builder()
  48. .id("52415800-8b69-11e0-9b19-734f5736d2a2")
  49. .name("My Server Backup")
  50. .updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2010-10-10T12:00:00Z"))
  51. .created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2010-08-10T12:00:00Z"))
  52. .tenantId("12345")
  53. .userId("joe")
  54. .status(Status.SAVING)
  55. .progress(80)
  56. .minDisk(5)
  57. .minRam(256)
  58. .metadata(
  59. new ImmutableMap.Builder<String, String>().put("ImageType", "Gold").put("ImageVersion", "1.5")
  60. .build())
  61. .server(
  62. Resource
  63. .builder()
  64. .id("52415800-8b69-11e0-9b19-734f335aa7b3")
  65. .name("null")
  66. .links(
  67. Link.create(
  68. Relation.SELF,
  69. URI.create("http://servers.api.openstack.org/v2/1234/servers/52415800-8b69-11e0-9b19-734f335aa7b3")),
  70. Link.create(
  71. Relation.BOOKMARK,
  72. URI.create("http://servers.api.openstack.org/1234/servers/52415800-8b69-11e0-9b19-734f335aa7b3")))
  73. .build())
  74. .links(
  75. ImmutableSet.of(
  76. Link.create(
  77. Relation.SELF,
  78. URI.create("http://servers.api.openstack.org/v2/1234/images/52415800-8b69-11e0-9b19-734f5736d2a2")),
  79. Link.create(
  80. Relation.BOOKMARK,
  81. URI.create("http://servers.api.openstack.org/1234/images/52415800-8b69-11e0-9b19-734f5736d2a2"))))
  82. .build();
  83. }
  84. protected Injector injector() {
  85. return Guice.createInjector(new NovaParserModule(), new GsonModule());
  86. }
  87. }