/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseSecurityGroupTest.java

https://github.com/danikov/jclouds · Java · 71 lines · 40 code · 9 blank · 22 comment · 0 complexity · 763e3f73fd35f63f5a619fc469a99a62 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.v1_1.parse;
  20. import java.util.Set;
  21. import javax.ws.rs.Consumes;
  22. import javax.ws.rs.core.MediaType;
  23. import org.jclouds.json.BaseItemParserTest;
  24. import org.jclouds.json.config.GsonModule;
  25. import org.jclouds.openstack.nova.v1_1.config.NovaParserModule;
  26. import org.jclouds.openstack.nova.v1_1.domain.IpProtocol;
  27. import org.jclouds.openstack.nova.v1_1.domain.SecurityGroup;
  28. import org.jclouds.openstack.nova.v1_1.domain.SecurityGroupRule;
  29. import org.jclouds.openstack.nova.v1_1.domain.TenantIdAndName;
  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 Michael Arnold
  38. */
  39. @Test(groups = "unit", testName = "ParseSecurityGroupTest")
  40. public class ParseSecurityGroupTest extends BaseItemParserTest<SecurityGroup> {
  41. @Override
  42. public String resource() {
  43. return "/securitygroup_details.json";
  44. }
  45. @Override
  46. @SelectJson("security_group")
  47. @Consumes(MediaType.APPLICATION_JSON)
  48. public SecurityGroup expected() {
  49. Set<SecurityGroupRule> securityGroupRules = ImmutableSet.<SecurityGroupRule> of(
  50. SecurityGroupRule.builder().fromPort(22)
  51. .ipProtocol(IpProtocol.TCP).toPort(22).parentGroupId("28")
  52. .ipRange("10.2.6.0/24").id("108").build(),
  53. SecurityGroupRule.builder().fromPort(22).group(new TenantIdAndName("admin", "11111"))
  54. .ipProtocol(IpProtocol.TCP).toPort(22).parentGroupId("28")
  55. .id("109").build());
  56. return SecurityGroup.builder().description("description0").id("0").tenantId("tenant0").rules(securityGroupRules)
  57. .name("name0").build();
  58. }
  59. protected Injector injector() {
  60. return Guice.createInjector(new NovaParserModule(), new GsonModule());
  61. }
  62. }