PageRenderTime 76ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListAccountsResponseTest.java

https://github.com/regularfry/jclouds
Java | 112 lines | 79 code | 11 blank | 22 comment | 0 complexity | f327ef614f7053efe75a179e222515f3 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.cloudstack.parse;
  20. import java.util.Set;
  21. import org.jclouds.cloudstack.config.CloudStackParserModule;
  22. import org.jclouds.cloudstack.domain.Account;
  23. import org.jclouds.cloudstack.domain.Account.State;
  24. import org.jclouds.cloudstack.domain.Account.Type;
  25. import org.jclouds.cloudstack.domain.User;
  26. import org.jclouds.date.internal.SimpleDateFormatDateService;
  27. import org.jclouds.json.BaseSetParserTest;
  28. import org.jclouds.json.config.GsonModule;
  29. import org.jclouds.rest.annotations.SelectJson;
  30. import org.testng.annotations.Test;
  31. import com.google.common.collect.ImmutableSet;
  32. import com.google.inject.Guice;
  33. import com.google.inject.Injector;
  34. /**
  35. *
  36. * @author Adrian Cole
  37. */
  38. @Test(groups = "unit")
  39. public class ListAccountsResponseTest extends BaseSetParserTest<Account> {
  40. @Override
  41. protected Injector injector() {
  42. return Guice.createInjector(new CloudStackParserModule(), new GsonModule() {
  43. @Override
  44. protected void configure() {
  45. bind(DateAdapter.class).to(Iso8601DateAdapter.class);
  46. super.configure();
  47. }
  48. });
  49. }
  50. @Override
  51. public String resource() {
  52. return "/listaccountsresponse.json";
  53. }
  54. @Override
  55. @SelectJson("account")
  56. public Set<Account> expected() {
  57. return ImmutableSet.<Account> of(Account
  58. .builder()
  59. .id(505)
  60. .name("jclouds")
  61. .type(Type.USER)
  62. .domainId(457)
  63. .domain("AA000062-jclouds-dev")
  64. .receivedBytes(318900216)
  65. .sentBytes(23189677)
  66. .VMLimit(15l)
  67. .VMs(1)
  68. .IPsAvailable(14l)
  69. .IPLimit(15l)
  70. .IPs(0)
  71. .IPsAvailable(15l)
  72. .volumeLimit(90l)
  73. .volumes(2)
  74. .volumesAvailable(88l)
  75. .snapshotLimit(250l)
  76. .snapshots(0)
  77. .snapshotsAvailable(250l)
  78. .templateLimit(15l)
  79. .templates(0)
  80. .templatesAvailable(15l)
  81. .VMsAvailable(14l)
  82. .VMsStopped(0)
  83. .VMsRunning(1)
  84. .state(State.ENABLED)
  85. .users(
  86. ImmutableSet.of(User.builder()
  87. .id(505)
  88. .name("jclouds")
  89. .firstName("Adrian")
  90. .lastName("Cole")
  91. .email("adrian@jclouds.org")
  92. .created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-04-19T01:57:24+0000"))
  93. .state("enabled")
  94. .account("jclouds")
  95. .accountType(Type.USER)
  96. .domainId(457)
  97. .domain("AA000062-jclouds-dev")
  98. .apiKey("APIKEY")
  99. .secretKey("SECRETKEY").build())).build());
  100. }
  101. }