PageRenderTime 2829ms CodeModel.GetById 31ms RepoModel.GetById 0ms app.codeStats 0ms

/apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListDomainsResponseTest.java

http://github.com/jclouds/jclouds
Java | 60 lines | 36 code | 8 blank | 16 comment | 0 complexity | bc5d32abf4dcbb3d9445445683b89d5a 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.cloudstack.parse;
  18. import java.util.Set;
  19. import org.jclouds.cloudstack.domain.Domain;
  20. import org.jclouds.json.BaseSetParserTest;
  21. import org.jclouds.json.config.GsonModule;
  22. import org.jclouds.rest.annotations.SelectJson;
  23. import org.testng.annotations.Test;
  24. import com.google.common.collect.ImmutableSet;
  25. import com.google.inject.Guice;
  26. import com.google.inject.Injector;
  27. @Test(groups = "unit")
  28. public class ListDomainsResponseTest extends BaseSetParserTest<Domain> {
  29. @Override
  30. protected Injector injector() {
  31. return Guice.createInjector(new GsonModule() {
  32. @Override
  33. protected void configure() {
  34. bind(DateAdapter.class).to(Iso8601DateAdapter.class);
  35. super.configure();
  36. }
  37. });
  38. }
  39. @Override
  40. public String resource() {
  41. return "/listdomainsresponse.json";
  42. }
  43. @Override
  44. @SelectJson("domain")
  45. public Set<Domain> expected() {
  46. return ImmutableSet.of(
  47. Domain.builder().id("1").name("ROOT").level(0).hasChild(true).build(),
  48. Domain.builder().id("2").name("jclouds1").level(1).parentDomainId("1")
  49. .parentDomainName("ROOT").hasChild(false).build()
  50. );
  51. }
  52. }