private void verifyThrowsRegistryErrorException(int httpStatusCode)
      throws IOException, RegistryException {
    ResponseException errorResponse = mockResponseException(httpStatusCode);
    Mockito.when(errorResponse.getContent())
        .thenReturn("{\"errors\":[{\"code\":\"code\",\"message\":\"message\"}]}");
    setUpRegistryResponse(errorResponse);

    try {
      endpointCaller.call();
      Assert.fail("Call should have failed");

    } catch (RegistryErrorException ex) {
      MatcherAssert.assertThat(
          ex.getMessage(),
          CoreMatchers.startsWith(
              "Tried to actionDescription but failed because: unknown error code: code (message)"));
    }
  }
Verifies that a response with {@code httpStatusCode} throws {@link
RegistryUnauthorizedException}.
jib-core/src/test/java/com/google/cloud/tools/jib/registry/RegistryEndpointCallerTest.java