PageRenderTime 3404ms CodeModel.GetById 20ms RepoModel.GetById 2ms app.codeStats 0ms

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

http://github.com/jclouds/jclouds
Java | 99 lines | 76 code | 7 blank | 16 comment | 0 complexity | a2f3c9ee129d9f4256ba313812b6844b 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 com.google.common.collect.ImmutableMap;
  19. import com.google.common.collect.ImmutableMultimap;
  20. import com.google.inject.Guice;
  21. import com.google.inject.Injector;
  22. import org.jclouds.date.internal.SimpleDateFormatDateService;
  23. import org.jclouds.json.BaseItemParserTest;
  24. import org.jclouds.json.config.GsonModule;
  25. import org.jclouds.openstack.nova.v2_0.config.NovaParserModule;
  26. import org.jclouds.openstack.nova.v2_0.domain.Address;
  27. import org.jclouds.openstack.nova.v2_0.domain.Server;
  28. import org.jclouds.openstack.nova.v2_0.domain.Server.Status;
  29. import org.jclouds.openstack.v2_0.domain.Link;
  30. import org.jclouds.openstack.v2_0.domain.Link.Relation;
  31. import org.jclouds.openstack.v2_0.domain.Resource;
  32. import org.jclouds.rest.annotations.SelectJson;
  33. import org.testng.annotations.Test;
  34. import javax.ws.rs.Consumes;
  35. import javax.ws.rs.core.MediaType;
  36. import java.net.URI;
  37. import static org.jclouds.openstack.nova.v2_0.domain.Address.createV4;
  38. import static org.jclouds.openstack.nova.v2_0.domain.Address.createV6;
  39. @Test(groups = "unit", testName = "ParseServerWithoutImageTest")
  40. public class ParseServerWithoutImageTest extends BaseItemParserTest<Server> {
  41. @Override
  42. public String resource() {
  43. return "/server_details_without_image.json";
  44. }
  45. @Override
  46. @SelectJson("server")
  47. @Consumes(MediaType.APPLICATION_JSON)
  48. public Server expected() {
  49. return Server
  50. .builder()
  51. .id("71752")
  52. .tenantId("1234")
  53. .userId("5678")
  54. .name("sample-f352")
  55. .updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2010-10-10T12:00:00Z"))
  56. .created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2010-08-10T12:00:00Z"))
  57. .hostId("e4d909c290d0fb1ca068ffaddf22cbd0")
  58. .accessIPv4("67.23.10.132")
  59. .accessIPv6("::babe:67.23.10.132")
  60. .status(Status.BUILD)
  61. .diskConfig(Server.DISK_CONFIG_AUTO)
  62. .flavor(
  63. Resource
  64. .builder()
  65. .id("52415800-8b69-11e0-9b19-734f216543fd")
  66. .name("null")
  67. .links(
  68. Link.create(
  69. Relation.SELF,
  70. URI.create("http://servers.api.openstack.org/v1.1/1234/flavors/52415800-8b69-11e0-9b19-734f216543fd")),
  71. Link.create(
  72. Relation.BOOKMARK,
  73. URI.create("http://servers.api.openstack.org/1234/flavors/52415800-8b69-11e0-9b19-734f216543fd")))
  74. .build())
  75. .metadata(
  76. new ImmutableMap.Builder<String, String>().put("Server Label", "Web Head 1")
  77. .put("Image Version", "2.1").build())
  78. .addresses(ImmutableMultimap.<String, Address>builder()
  79. .putAll("public", createV4("67.23.10.132"), createV6("::babe:67.23.10.132"), createV4("67.23.10.131"), createV6("::babe:4317:0A83"))
  80. .putAll("private", createV4("10.176.42.16"), createV6("::babe:10.176.42.16"))
  81. .build())
  82. .links(Link.create(
  83. Relation.SELF, URI.create("http://servers.api.openstack.org/v2/1234/servers/71752")),
  84. Link.create(
  85. Relation.BOOKMARK,
  86. URI.create("http://servers.api.openstack.org/1234/servers/71752")))
  87. .build();
  88. }
  89. protected Injector injector() {
  90. return Guice.createInjector(new NovaParserModule(), new GsonModule());
  91. }
  92. }