@Test
public void testCopyFromHostConnectionRejected() throws Exception {

  when(connection.getResponseCode())
      .thenReturn(Fetcher.TOO_MANY_REQ_STATUS_CODE);
  Fetcher<Text, Text> fetcher = new FakeFetcher<>(job, id, ss, mm, r, metrics,
      except, key, connection);
  fetcher.copyFromHost(host);
  assertThat(ss.hostFailureCount(host.getHostName()))
      .withFailMessage("No host failure is expected.").isEqualTo(0);
  assertThat(ss.fetchFailureCount(map1ID))
      .withFailMessage("No fetch failure is expected.").isEqualTo(0);
  assertThat(ss.fetchFailureCount(map2ID))
      .withFailMessage("No fetch failure is expected.").isEqualTo(0);
  verify(ss).penalize(eq(host), anyLong());
  verify(ss).putBackKnownMapOutput(any(MapHost.class), eq(map1ID));
  verify(ss).putBackKnownMapOutput(any(MapHost.class), eq(map2ID));
}