public void testRevokeIngressRule() throws SecurityException, NoSuchMethodException, IOException {
    Invokable<?, ?> method =
        Invokable.from(
            SecurityGroupAsyncClient.class.getMethod(
                "revokeIngressRule", String.class, AccountInDomainOptions[].class));
    GeneratedHttpRequest httpRequest =
        processor.createRequest(
            method,
            ImmutableList.<Object>of(
                5, AccountInDomainOptions.Builder.accountInDomain("adrian", "1")));

    assertRequestLineEquals(
        httpRequest,
        "GET http://localhost:8080/client/api?response=json&command=revokeSecurityGroupIngress&id=5&account=adrian&domainid=1 HTTP/1.1");
    assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
    assertPayloadEquals(httpRequest, null, null, false);

    assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
    assertSaxResponseParserClassEquals(method, null);
    assertFallbackClassEquals(method, VoidOnNotFoundOr404.class);

    checkFilters(httpRequest);
  }
  @Test(dependsOnMethods = "testCreateDestroySecurityGroup")
  public void testCreateIngress() throws Exception {
    if (!securityGroupsSupported) return;
    String cidr = getCurrentCIDR();
    ImmutableSet<String> cidrs = ImmutableSet.of(cidr);
    assert jobComplete.apply(
            client.getSecurityGroupClient().authorizeIngressICMPToCIDRs(group.getId(), 0, 8, cidrs))
        : group;
    assert jobComplete.apply(
            client
                .getSecurityGroupClient()
                .authorizeIngressPortsToCIDRs(group.getId(), "TCP", 22, 22, cidrs))
        : group;

    AccountInDomainOptions.Builder.accountInDomain(group.getAccount(), group.getDomainId());

    // replace with get once bug is fixed where getGroup returns only one
    // ingress rule
    group =
        Iterables.find(
            client.getSecurityGroupClient().listSecurityGroups(),
            new Predicate<SecurityGroup>() {

              @Override
              public boolean apply(SecurityGroup input) {
                return input.getId() == group.getId();
              }
            });

    IngressRule ICMPPingRule =
        Iterables.find(
            group.getIngressRules(),
            new Predicate<IngressRule>() {

              @Override
              public boolean apply(IngressRule input) {
                return "icmp".equals(input.getProtocol());
              }
            });

    assert ICMPPingRule.getId() > 0 : ICMPPingRule;
    assert "icmp".equals(ICMPPingRule.getProtocol()) : ICMPPingRule;
    assert ICMPPingRule.getStartPort() == -1 : ICMPPingRule;
    assert ICMPPingRule.getEndPort() == -1 : ICMPPingRule;
    assert ICMPPingRule.getICMPCode() == 0 : ICMPPingRule;
    assert ICMPPingRule.getICMPType() == 8 : ICMPPingRule;
    assert ICMPPingRule.getAccount() == null : ICMPPingRule;
    assert ICMPPingRule.getSecurityGroupName() == null : ICMPPingRule;
    assert cidr.equals(ICMPPingRule.getCIDR()) : ICMPPingRule;

    IngressRule SSHRule =
        Iterables.find(
            group.getIngressRules(),
            new Predicate<IngressRule>() {

              @Override
              public boolean apply(IngressRule input) {
                return "tcp".equals(input.getProtocol());
              }
            });

    assert SSHRule.getId() > 0 : SSHRule;
    assert "tcp".equals(SSHRule.getProtocol()) : SSHRule;
    assert SSHRule.getStartPort() == 22 : SSHRule;
    assert SSHRule.getEndPort() == 22 : SSHRule;
    assert SSHRule.getICMPCode() == -1 : SSHRule;
    assert SSHRule.getICMPType() == -1 : SSHRule;
    assert SSHRule.getAccount() == null : SSHRule;
    assert SSHRule.getSecurityGroupName() == null : SSHRule;
    assert cidr.equals(SSHRule.getCIDR()) : SSHRule;
  }