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

https://github.com/richardcloudsoft/legacy-jclouds · Java · 72 lines · 40 code · 10 blank · 22 comment · 0 complexity · d6b2bd9860695a16d1af9ea404bf5481 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.domain.FirewallRule;
  22. import org.jclouds.json.BaseSetParserTest;
  23. import org.jclouds.json.config.GsonModule;
  24. import org.jclouds.rest.annotations.SelectJson;
  25. import org.testng.annotations.Test;
  26. import com.google.common.collect.ImmutableSet;
  27. import com.google.inject.Guice;
  28. import com.google.inject.Injector;
  29. /**
  30. *
  31. * @author Andrei Savu
  32. */
  33. @Test(groups = "unit")
  34. public class ListFirewallRulesResponseTest extends BaseSetParserTest<FirewallRule> {
  35. @Override
  36. protected Injector injector() {
  37. return Guice.createInjector(new GsonModule() {
  38. @Override
  39. protected void configure() {
  40. bind(DateAdapter.class).to(Iso8601DateAdapter.class);
  41. super.configure();
  42. }
  43. });
  44. }
  45. @Override
  46. public String resource() {
  47. return "/listfirewallrulesresponse.json";
  48. }
  49. @Override
  50. @SelectJson("firewallrule")
  51. public Set<FirewallRule> expected() {
  52. Set<String> CIDRs = ImmutableSet.of("0.0.0.0/0");
  53. return ImmutableSet.of(
  54. FirewallRule.builder().id("2017").protocol(FirewallRule.Protocol.TCP).startPort(30)
  55. .endPort(35).ipAddressId("2").ipAddress("10.27.27.51").state(FirewallRule.State.ACTIVE).CIDRs(CIDRs).build(),
  56. FirewallRule.builder().id("2016").protocol(FirewallRule.Protocol.TCP).startPort(22)
  57. .endPort(22).ipAddressId("2").ipAddress("10.27.27.51").state(FirewallRule.State.ACTIVE).CIDRs(CIDRs).build(),
  58. FirewallRule.builder().id("10").protocol(FirewallRule.Protocol.TCP).startPort(22)
  59. .endPort(22).ipAddressId("8").ipAddress("10.27.27.57").state(FirewallRule.State.ACTIVE).CIDRs(CIDRs).build()
  60. );
  61. }
  62. }