public void testUpdateDomainWhenResponseIs2xx() {
    GlobalDomainClient client =
        requestSendsResponse(
            HttpRequest.builder()
                .method("GET")
                .endpoint(
                    URI.create(
                        "http://localhost:8080/client/api?response=json&"
                            + "command=updateDomain&id=10&name=test-2&apiKey=identity&signature=5t1eUf2Eyf%2FaB6qt%2BqIj%2BmcwFIo%3D"))
                .addHeader("Accept", "application/json")
                .build(),
            HttpResponse.builder()
                .statusCode(200)
                .payload(payloadFromResource("/updatedomainresponse.json"))
                .build());

    assertEquals(
        client.updateDomain("10", name("test-2")),
        Domain.builder()
            .id("10")
            .name("test-2")
            .level(1)
            .parentDomainId("1")
            .parentDomainName("ROOT")
            .hasChild(false)
            .build());
  }
  public void testCreateDomainWhenResponseIs2xx() {
    GlobalDomainClient client =
        requestSendsResponse(
            HttpRequest.builder()
                .method("GET")
                .endpoint(
                    URI.create(
                        "http://localhost:8080/client/api?response=json&command=createDomain&"
                            + "name=test&apiKey=identity&signature=6cxzEo7h63G0hgTTMLm4lGsSDK8%3D"))
                .addHeader("Accept", "application/json")
                .build(),
            HttpResponse.builder()
                .statusCode(200)
                .payload(payloadFromResource("/createdomainresponse.json"))
                .build());

    assertEquals(
        client.createDomain("test"),
        Domain.builder()
            .id("10")
            .name("test")
            .level(1)
            .parentDomainId("1")
            .parentDomainName("ROOT")
            .hasChild(false)
            .build());
  }
  public void testCreateDomainWhenResponseIs404() {
    GlobalDomainClient client =
        requestSendsResponse(
            HttpRequest.builder()
                .method("GET")
                .endpoint(
                    URI.create(
                        "http://localhost:8080/client/api?response=json&command=createDomain&"
                            + "name=test&apiKey=identity&signature=6cxzEo7h63G0hgTTMLm4lGsSDK8%3D"))
                .addHeader("Accept", "application/json")
                .build(),
            HttpResponse.builder().statusCode(404).build());

    assertNull(client.createDomain("test"));
  }
  public void testUpdateDomainWhenResponseIs404() {
    GlobalDomainClient client =
        requestSendsResponse(
            HttpRequest.builder()
                .method("GET")
                .endpoint(
                    URI.create(
                        "http://localhost:8080/client/api?response=json&"
                            + "command=updateDomain&id=10&name=test-2&apiKey=identity&signature=5t1eUf2Eyf%2FaB6qt%2BqIj%2BmcwFIo%3D"))
                .addHeader("Accept", "application/json")
                .build(),
            HttpResponse.builder().statusCode(404).build());

    assertNull(client.updateDomain("10", name("test-2")));
  }
  public void testDeleteDomainAndAttachedResources() {
    GlobalDomainClient client =
        requestSendsResponse(
            HttpRequest.builder()
                .method("GET")
                .endpoint(
                    URI.create(
                        "http://localhost:8080/client/api?response=json&"
                            + "command=deleteDomain&cleanup=true&id=1&apiKey=identity&signature=grL7JStvtYUT89Jr0D8FgwMyJpU%3D"))
                .build(),
            HttpResponse.builder()
                .statusCode(200)
                .payload(payloadFromResource("/deletedomainresponse.json"))
                .build());

    client.deleteDomainAndAttachedResources("1");
  }
  public void testDeleteOnlyDomain() {
    GlobalDomainClient client =
        requestSendsResponse(
            HttpRequest.builder()
                .method("GET")
                .endpoint(
                    URI.create(
                        "http://localhost:8080/client/api?response=json&"
                            + "command=deleteDomain&cleanup=false&id=1&apiKey=identity&signature=%2F5aLbigg612t9IrZi0JZO7CyiOU%3D"))
                .build(),
            HttpResponse.builder()
                .statusCode(200)
                .payload(payloadFromResource("/deletedomainresponse.json"))
                .build());

    client.deleteOnlyDomain("1");
  }