@SuppressWarnings("unchecked")
@Test
public void runtimeExceptionThrownForHttpResponsesOtherThan206() throws IOException, URISyntaxException {

  // Arrange
  List<Integer> responsesToTest = Lists.newArrayList(500, 413); // Add whatever other ones we want
  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");
  for (Integer responseToTest : responsesToTest) {
    // Arrange some more
    Call mockCall = mock(Call.class);
    Response fakeResponse = this.fakeResponse(responseToTest);
    when(mockHttpClient.newCall(any(Request.class))).thenReturn(mockCall);
    when(mockCall.execute()).thenReturn(fakeResponse);
    // Act
    try {
      new HttpClient(mockHttpClient).partialGet(url, ranges, Collections.<String, Credentials>emptyMap(),
          mockReceiver, listener);
    } catch (HttpError exception) {
      assertEquals(responseToTest.intValue(), exception.getCode());
    }
  }
}