@Test
public void shouldTestServiceAccountUsageAuthorization() throws Exception {

  final String serviceAccount = "foo@bar.iam.gserviceaccount.com";
  final String principal = "baz@example.com";
  final TestServiceAccountUsageAuthorizationResponse expectedResponse = TestServiceAccountUsageAuthorizationResponse
      .builder()
      .message("foo")
      .serviceAccount(serviceAccount)
      .principal(principal)
      .build();
  when(client.send(any())).thenReturn(CompletableFuture.completedFuture(response(HTTP_OK, expectedResponse)));
  final TestServiceAccountUsageAuthorizationResponse response =
      styx.testServiceAccountUsageAuthorization(serviceAccount, principal).toCompletableFuture().get(30, SECONDS);
  verify(client).send(requestCaptor.capture());
  final Request request = requestCaptor.getValue();
  assertThat(request.url().toString(), is(API_URL + "/status/testServiceAccountUsageAuthorization"));
  assertThat(request.method(), is("POST"));
  final TestServiceAccountUsageAuthorizationRequest requestPayload =
      Json.deserialize(bytesOfRequestBody(request), TestServiceAccountUsageAuthorizationRequest.class);
  assertThat(requestPayload.serviceAccount(), is(serviceAccount));
  assertThat(requestPayload.principal(), is(principal));
  assertThat(response, is(expectedResponse));
}