private void verifyThrowsRegistryUnauthorizedException(int httpStatusCode)
      throws IOException, RegistryException {
    ResponseException responseException = mockResponseException(httpStatusCode);
    setUpRegistryResponse(responseException);

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

    } catch (RegistryUnauthorizedException ex) {
      Assert.assertEquals("serverUrl/imageName", ex.getImageReference());
      Assert.assertSame(responseException, ex.getCause());
    }
  }
Verifies that a response with {@code httpStatusCode} throws {@link
RegistryUnauthorizedException}.
jib-core/src/test/java/com/google/cloud/tools/jib/registry/RegistryEndpointCallerTest.java