@Test
  public void testCreateDestroySecurityGroup() {
    try {
      zone =
          Iterables.find(
              client.getZoneClient().listZones(),
              new Predicate<Zone>() {

                @Override
                public boolean apply(Zone arg0) {
                  return arg0.isSecurityGroupsEnabled();
                }
              });
      securityGroupsSupported = true;
      for (SecurityGroup securityGroup :
          client
              .getSecurityGroupClient()
              .listSecurityGroups(ListSecurityGroupsOptions.Builder.named(prefix))) {
        for (IngressRule rule : securityGroup.getIngressRules())
          assert this.jobComplete.apply(
                  client.getSecurityGroupClient().revokeIngressRule(rule.getId()))
              : rule;
        client.getSecurityGroupClient().deleteSecurityGroup(securityGroup.getId());
      }
      group = client.getSecurityGroupClient().createSecurityGroup(prefix);
      assertEquals(group.getName(), prefix);
      checkGroup(group);
      try {
        client.getSecurityGroupClient().createSecurityGroup(prefix);
        assert false;
      } catch (IllegalStateException e) {

      }
    } catch (NoSuchElementException e) {
      e.printStackTrace();
    }
  }
  public void testListSecurityGroupsOptions()
      throws SecurityException, NoSuchMethodException, IOException {
    Invokable<?, ?> method =
        Invokable.from(
            SecurityGroupAsyncClient.class.getMethod(
                "listSecurityGroups", ListSecurityGroupsOptions[].class));
    GeneratedHttpRequest httpRequest =
        processor.createRequest(
            method,
            ImmutableList.<Object>of(
                ListSecurityGroupsOptions.Builder.virtualMachineId("4").domainId("5").id("6")));

    assertRequestLineEquals(
        httpRequest,
        "GET http://localhost:8080/client/api?response=json&command=listSecurityGroups&listAll=true&virtualmachineid=4&domainid=5&id=6 HTTP/1.1");
    assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
    assertPayloadEquals(httpRequest, null, null, false);

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

    checkFilters(httpRequest);
  }