### Question:
RegistryEndpointCaller { @VisibleForTesting static boolean isBrokenPipe(IOException original) { Throwable exception = original; while (exception != null) { String message = exception.getMessage(); if (message != null && message.toLowerCase(Locale.US).contains("broken pipe")) { return true; } exception = exception.getCause(); if (exception == original) { return false; } } return false; } @VisibleForTesting  RegistryEndpointCaller(
      EventHandlers eventHandlers,
      @Nullable String userAgent,
      RegistryEndpointProvider<T> registryEndpointProvider,
      @Nullable Authorization authorization,
      RegistryEndpointRequestProperties registryEndpointRequestProperties,
      FailoverHttpClient httpClient);   }### Answer:
@Test public void testIsBrokenPipe_notBrokenPipe() { Assert.assertFalse(RegistryEndpointCaller.isBrokenPipe(new IOException())); Assert.assertFalse(RegistryEndpointCaller.isBrokenPipe(new SocketException())); Assert.assertFalse(RegistryEndpointCaller.isBrokenPipe(new SSLException("mock"))); }
@Test public void testIsBrokenPipe_brokenPipe() { Assert.assertTrue(RegistryEndpointCaller.isBrokenPipe(new IOException("cool broken pipe !"))); Assert.assertTrue(RegistryEndpointCaller.isBrokenPipe(new SocketException("BROKEN PIPE"))); Assert.assertTrue(RegistryEndpointCaller.isBrokenPipe(new SSLException("calm BrOkEn PiPe"))); }
@Test public void testIsBrokenPipe_nestedBrokenPipe() { IOException exception = new IOException(new SSLException(new SocketException("Broken pipe"))); Assert.assertTrue(RegistryEndpointCaller.isBrokenPipe(exception)); }
@Test public void testIsBrokenPipe_terminatesWhenCauseIsOriginal() { IOException exception = Mockito.mock(IOException.class); Mockito.when(exception.getCause()).thenReturn(exception); Assert.assertFalse(RegistryEndpointCaller.isBrokenPipe(exception)); }