PageRenderTime 5911ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/parse/ParseMachineListTest.java

http://github.com/jclouds/jclouds
Java | 92 lines | 59 code | 12 blank | 21 comment | 0 complexity | 60b2535dc0a4fc5e23e4ac3460f4e48a 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.joyent.cloudapi.v6_5.parse;
  20. import java.util.Set;
  21. import javax.ws.rs.Consumes;
  22. import javax.ws.rs.core.MediaType;
  23. import org.jclouds.date.internal.SimpleDateFormatDateService;
  24. import org.jclouds.domain.JsonBall;
  25. import org.jclouds.joyent.cloudapi.v6_5.domain.Machine;
  26. import org.jclouds.joyent.cloudapi.v6_5.domain.Machine.Type;
  27. import org.jclouds.json.BaseSetParserTest;
  28. import org.jclouds.json.config.GsonModule;
  29. import org.testng.annotations.Test;
  30. import com.google.common.collect.ImmutableMap;
  31. import com.google.common.collect.ImmutableSet;
  32. import com.google.inject.Guice;
  33. import com.google.inject.Injector;
  34. /**
  35. * @author Gerald Pereira
  36. */
  37. @Test(groups = "unit", testName = "ParseMachineListTest")
  38. public class ParseMachineListTest extends BaseSetParserTest<Machine> {
  39. @Override
  40. public String resource() {
  41. return "/machine_list.json";
  42. }
  43. @Override
  44. @Consumes(MediaType.APPLICATION_JSON)
  45. public Set<Machine> expected() {
  46. return ImmutableSet.of(
  47. Machine.builder().id("d73cb0b0-7d1f-44ef-8c40-e040eef0f726").name("sample-e922").type(Type.SMARTMACHINE)
  48. .state(Machine.State.RUNNING).dataset("sdc:sdc:smartosplus:3.1.0")
  49. .ips(ImmutableSet.<String> builder().add("37.153.96.56").add("10.224.0.57").build())
  50. .memorySizeMb(1024).diskSizeGb(61440).metadata(ImmutableMap.<String, JsonBall> of())
  51. .created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2012-05-09T13:39:43+00:00"))
  52. .updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2012-05-09T13:43:45+00:00"))
  53. .build(),
  54. Machine.builder()
  55. .id("94eba336-ecb7-49f5-8a27-52f5e4dd57a1")
  56. .name("sample-e92")
  57. .type(Type.VIRTUALMACHINE)
  58. .state(Machine.State.RUNNING)
  59. .dataset("sdc:sdc:centos-5.7:1.2.1")
  60. .ips(ImmutableSet.<String> builder().add("37.153.96.62").add("10.224.0.63").build())
  61. .memorySizeMb(1024)
  62. .diskSizeGb(61440)
  63. .metadata(
  64. ImmutableMap.<String, JsonBall> builder()
  65. .put("root_authorized_keys", new JsonBall("ssh-rsa XXXXXX== test@xxxx.ovh.net\n")).build())
  66. .created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2012-05-09T13:32:46+00:00"))
  67. .updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2012-05-11T09:00:33+00:00"))
  68. .build()
  69. );
  70. }
  71. protected Injector injector() {
  72. return Guice.createInjector(new GsonModule() {
  73. @Override
  74. protected void configure() {
  75. bind(DateAdapter.class).to(Iso8601DateAdapter.class);
  76. super.configure();
  77. }
  78. });
  79. }
  80. }