@Test
  public void batchDelete() {
    mockRequest(
        InteractionContext.builder()
            .request(
                TestRequest.builder()
                    .method(POST)
                    .path("/oauth/clients/tx/delete")
                    .payload("fixtures/uaa/clients/POST_tx_delete_request.json")
                    .build())
            .response(
                TestResponse.builder()
                    .status(OK)
                    .payload("fixtures/uaa/clients/POST_tx_delete_response.json")
                    .build())
            .build());

    this.clients
        .batchDelete(BatchDeleteClientsRequest.builder().clientId("14pnUs", "qECLyr").build())
        .as(StepVerifier::create)
        .expectNext(
            BatchDeleteClientsResponse.builder()
                .client(
                    Client.builder()
                        .approvalsDeleted(true)
                        .allowedProvider("uaa", "ldap", "my-saml-provider")
                        .authority("clients.read", "clients.write")
                        .authorizedGrantType(CLIENT_CREDENTIALS)
                        .autoApprove("true")
                        .clientId("14pnUs")
                        .lastModified(1468364444461L)
                        .name("My Client Name")
                        .redirectUriPattern(
                            "http*://ant.path.wildcard/**/passback/*", "http://test1.com")
                        .resourceId("none")
                        .scope("clients.read", "clients.write")
                        .tokenSalt("erRsWH")
                        .build())
                .client(
                    Client.builder()
                        .approvalsDeleted(true)
                        .allowedProvider("uaa", "ldap", "my-saml-provider")
                        .authority("clients.read", "clients.write")
                        .authorizedGrantType(CLIENT_CREDENTIALS)
                        .autoApprove("true")
                        .clientId("qECLyr")
                        .lastModified(1468364444868L)
                        .name("My Client Name")
                        .redirectUriPattern(
                            "http*://ant.path.wildcard/**/passback/*", "http://test1.com")
                        .resourceId("none")
                        .scope("clients.read", "clients.write")
                        .tokenSalt("48TIsq")
                        .build())
                .build())
        .expectComplete()
        .verify(Duration.ofSeconds(5));
  }
  @Test
  public void deserialize() {
    mockRequest(
        InteractionContext.builder()
            .request(TestRequest.builder().method(GET).path("/oauth/clients").build())
            .response(
                TestResponse.builder()
                    .status(OK)
                    .payload("fixtures/uaa/clients/GET_response_deserialize.json")
                    .build())
            .build());

    this.clients
        .list(ListClientsRequest.builder().build())
        .as(StepVerifier::create)
        .expectNext(
            ListClientsResponse.builder()
                .resource(
                    Client.builder()
                        .action("none")
                        .authority("uaa.none")
                        .authorizedGrantType(AUTHORIZATION_CODE, REFRESH_TOKEN)
                        .autoApprove("true")
                        .clientId("ssh-proxy")
                        .lastModified(1469112324000L)
                        .redirectUriPattern("/login")
                        .resourceId("none")
                        .scope("openid", "cloud_controller.read", "cloud_controller.write")
                        .build())
                .resource(
                    Client.builder()
                        .action("none")
                        .authority("routing.routes.write", "routing.routes.read")
                        .authorizedGrantType(CLIENT_CREDENTIALS, REFRESH_TOKEN)
                        .autoApprove("routing.routes.write", "routing.routes.read")
                        .clientId("tcp_emitter")
                        .lastModified(1469112324000L)
                        .resourceId("none")
                        .scope("uaa.none")
                        .build())
                .startIndex(1)
                .itemsPerPage(2)
                .totalResults(2)
                .schema("http://cloudfoundry.org/schema/scim/oauth-clients-1.0")
                .build())
        .expectComplete()
        .verify(Duration.ofSeconds(5));
  }
  @Test
  public void list() {
    mockRequest(
        InteractionContext.builder()
            .request(
                TestRequest.builder()
                    .method(GET)
                    .path(
                        "/oauth/clients?count=10&filter=client_id%2Beq%2B%22EGgNW3%22&sortBy=client_id&sortOrder=descending&startIndex=1")
                    .build())
            .response(
                TestResponse.builder()
                    .status(OK)
                    .payload("fixtures/uaa/clients/GET_response.json")
                    .build())
            .build());

    this.clients
        .list(
            ListClientsRequest.builder()
                .count(10)
                .filter("client_id+eq+\"EGgNW3\"")
                .sortBy("client_id")
                .sortOrder(SortOrder.DESCENDING)
                .startIndex(1)
                .build())
        .as(StepVerifier::create)
        .expectNext(
            ListClientsResponse.builder()
                .resource(
                    Client.builder()
                        .allowedProvider("uaa", "ldap", "my-saml-provider")
                        .authority("clients.read", "clients.write")
                        .authorizedGrantType(CLIENT_CREDENTIALS)
                        .autoApprove("true")
                        .clientId("EGgNW3")
                        .lastModified(1468364445334L)
                        .name("My Client Name")
                        .redirectUriPattern(
                            "http*://ant.path.wildcard/**/passback/*", "http://test1.com")
                        .resourceId("none")
                        .scope("clients.read", "clients.write")
                        .tokenSalt("7uDPJX")
                        .build())
                .startIndex(1)
                .itemsPerPage(1)
                .totalResults(1)
                .schema("http://cloudfoundry.org/schema/scim/oauth-clients-1.0")
                .build())
        .expectComplete()
        .verify(Duration.ofSeconds(5));
  }
  @Test
  public void batchChangeSecret() {
    mockRequest(
        InteractionContext.builder()
            .request(
                TestRequest.builder()
                    .method(POST)
                    .path("/oauth/clients/tx/secret")
                    .payload("fixtures/uaa/clients/POST_tx_secret_request.json")
                    .build())
            .response(
                TestResponse.builder()
                    .status(CREATED)
                    .payload("fixtures/uaa/clients/POST_tx_secret_response.json")
                    .build())
            .build());

    this.clients
        .batchChangeSecret(
            BatchChangeSecretRequest.builder()
                .changeSecret(
                    ChangeSecret.builder().clientId("Zkgt1Y").secret("new_secret").build())
                .changeSecret(
                    ChangeSecret.builder().clientId("Xm43aH").secret("new_secret").build())
                .build())
        .as(StepVerifier::create)
        .expectNext(
            BatchChangeSecretResponse.builder()
                .client(
                    Client.builder()
                        .accessTokenValidity(2700L)
                        .allowedProvider("uaa", "ldap", "my-saml-provider")
                        .approvalsDeleted(true)
                        .authority("clients.read", "clients.write")
                        .authorizedGrantType(CLIENT_CREDENTIALS)
                        .autoApprove("true")
                        .clientId("Zkgt1Y")
                        .lastModified(1474923482301L)
                        .name("My Client Name")
                        .redirectUriPattern(
                            "http*://ant.path.wildcard/**/passback/*", "http://test1.com")
                        .refreshTokenValidity(7000L)
                        .resourceId("none")
                        .scope("clients.read", "clients.write")
                        .tokenSalt("uHICvG")
                        .build())
                .client(
                    Client.builder()
                        .accessTokenValidity(2700L)
                        .allowedProvider("uaa", "ldap", "my-saml-provider")
                        .approvalsDeleted(true)
                        .authority("clients.read", "new.authority", "clients.write")
                        .authorizedGrantType(CLIENT_CREDENTIALS)
                        .autoApprove("true")
                        .clientId("Xm43aH")
                        .lastModified(1474923482302L)
                        .name("My Client Name")
                        .redirectUriPattern(
                            "http*://ant.path.wildcard/**/passback/*", "http://test1.com")
                        .refreshTokenValidity(7000L)
                        .resourceId("none")
                        .scope("clients.read", "clients.write")
                        .tokenSalt("WjlWvu")
                        .build())
                .build())
        .expectComplete()
        .verify(Duration.ofSeconds(5));
  }