PageRenderTime 44ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

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

https://github.com/richardcloudsoft/legacy-jclouds
Java | 87 lines | 56 code | 9 blank | 22 comment | 0 complexity | 29b533daee8d75277a0b2228bb53a563 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.openstack.nova.v2_0.parse;
  20. import java.net.URI;
  21. import java.util.Set;
  22. import javax.ws.rs.Consumes;
  23. import javax.ws.rs.core.MediaType;
  24. import org.jclouds.json.BaseSetParserTest;
  25. import org.jclouds.json.config.GsonModule;
  26. import org.jclouds.openstack.nova.v2_0.config.NovaParserModule;
  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.ImmutableSet;
  33. import com.google.inject.Guice;
  34. import com.google.inject.Injector;
  35. /**
  36. *
  37. * @author Adrian Cole
  38. */
  39. @Test(groups = "unit", testName = "ParseServerListTest")
  40. public class ParseServerListTest extends BaseSetParserTest<Resource> {
  41. @Override
  42. public String resource() {
  43. return "/server_list.json";
  44. }
  45. @Override
  46. @SelectJson("servers")
  47. @Consumes(MediaType.APPLICATION_JSON)
  48. public Set<Resource> expected() {
  49. return ImmutableSet
  50. .of(Resource
  51. .builder()
  52. .id("52415800-8b69-11e0-9b19-734f6af67565")
  53. .name("sample-server")
  54. .links(
  55. Link.create(
  56. Relation.SELF,
  57. URI.create("http://servers.api.openstack.org/v1.1/1234/servers/52415800-8b69-11e0-9b19-734f6af67565")),
  58. Link.create(
  59. Relation.BOOKMARK,
  60. URI.create("http://servers.api.openstack.org/1234/servers/52415800-8b69-11e0-9b19-734f6af67565")))
  61. .build(),
  62. Resource
  63. .builder()
  64. .id("52415800-8b69-11e0-9b19-734f1f1350e5")
  65. .name("sample-server2")
  66. .links(
  67. Link.create(
  68. Relation.SELF,
  69. URI.create("http://servers.api.openstack.org/v1.1/1234/servers/52415800-8b69-11e0-9b19-734f1f1350e5")),
  70. Link.create(
  71. Relation.BOOKMARK,
  72. URI.create("http://servers.api.openstack.org/1234/servers/52415800-8b69-11e0-9b19-734f1f1350e5")))
  73. .build());
  74. }
  75. protected Injector injector() {
  76. return Guice.createInjector(new NovaParserModule(), new GsonModule());
  77. }
  78. }