@Override
  public Map<String, Long> call() throws Exception {
    Map<String, Long> result = new LinkedHashMap<>();
    for (DownloadableItem item : items) {
      InputStreamWrapper stream = connectionProvider.getInputStreamForItem(jobId, item);
      long size = stream.getBytes();
      if (size <= 0) {
        size = computeSize(stream);
      }

      result.put(item.getIdempotentId(), size);
    }

    return result;
  }
@Test
  public void testAllSizesAreProvided() throws Exception {
    List<DownloadableItem> items = IntStream.range(1, 20)
        .mapToObj(i -> createItem(i + "-" + nextInt(100, 9999)))
        .collect(Collectors.toList());

    Map<String, Long> expected = new HashMap<>();
    for (DownloadableItem item : items) {
      long size = nextLong(1, 100000);
      when(connectionProvider.getInputStreamForItem(eq(jobId), eq(item)))
          .thenReturn(new InputStreamWrapper(null, size));
      expected.put(item.getIdempotentId(), size);
    }

    Map<String, Long> actual = new CallableSizeCalculator(jobId, connectionProvider,
        items).call();

    Truth.assertThat(actual).containsExactlyEntriesIn(expected);
  }