class DownloadManager {

  public int add(DownloadRequest request) {
    request = checkNotNull(request, "request == null");
    if (isDownloading(request.uri().toString())) {
      return -1;
    }

    request.context(context);
    request.downloader(downloader.copy());

    /* add download request into download request queue */
    return downloadRequestQueue.add(request) ? request.downloadId() : -1;
  }

}

class DownloadManagerTest {

  private MockWebServer mockWebServer;
  private DownloadManager downloadManager;
  private DownloadRequest request;

  @Test public void testDuplicate() throws Exception {

    int downloadId = downloadManager.add(request);
    assertEquals(1, downloadId);
    int downloadId2 = downloadManager.add(request);
    assertEquals(-1, downloadId2);
  }

}