@SuppressWarnings("unchecked")
@Test
public void runtimeExceptionThrownForIoExceptionDuringHttpCommunication() throws Exception {

  // Arrange
  OkHttpClient mockHttpClient = mock(OkHttpClient.class);
  RangeReceiver mockReceiver = mock(RangeReceiver.class);
  RangeTransferListener listener = mock(RangeTransferListener.class);
  when(listener.newTransfer(any(List.class))).thenReturn(mock(HttpTransferListener.class));
  List<ContentRange> ranges = this.createSomeRanges(1);
  URI url = new URI("http://host/someurl");
  IOException expected = new IOException("IO");
  Call mockCall = mock(Call.class);
  when(mockCall.execute()).thenThrow(expected);
  when(mockHttpClient.newCall(any(Request.class))).thenReturn(mockCall);
  // Act
  try {
    new HttpClient(mockHttpClient).partialGet(url, ranges, Collections.<String, Credentials>emptyMap(), mockReceiver,
        listener);
  } catch (IOException exception) {
    // Assert
    assertEquals("IO", exception.getMessage());
  }
}