public static void loadAndAssertStatusForRow(
      long downloadRowId, DownloadStatus status, boolean mockNetworkError) {
    FileDownloader loader = FileDownloader.newForDownloadRow(downloadRowId);
    if (mockNetworkError) {
      loader.connectionMock =
          new ConnectionTwitterGnuSocialMock(new ConnectionException("Mocked IO exception"));
    }
    CommandData commandData = CommandData.newCommand(CommandEnum.FETCH_AVATAR);
    loader.load(commandData);

    DownloadData data = DownloadData.fromId(downloadRowId);
    if (DownloadStatus.LOADED.equals(status)) {
      assertFalse("Loaded " + data.getUri() + "; " + data, commandData.getResult().hasError());
      assertEquals("Loaded " + data.getUri(), status, loader.getStatus());
    } else {
      assertTrue("Error loading " + data.getUri(), commandData.getResult().hasError());
    }

    if (DownloadStatus.LOADED.equals(status)) {
      assertTrue("File exists " + data.getUri(), data.getFile().exists());
    } else {
      assertFalse("File doesn't exist " + data.getUri(), data.getFile().exists());
    }

    assertEquals("Loaded " + data.getUri(), status, loader.getStatus());
  }
  private void testFileProvider(long downloadRowId) throws IOException {
    DownloadData data = DownloadData.fromId(downloadRowId);
    assertTrue(data.getFilename(), data.getFile().exists());

    Uri uri = FileProvider.downloadFilenameToUri(data.getFile().getFilename());
    InputStream in = MyContextHolder.get().context().getContentResolver().openInputStream(uri);
    byte[] buffer = new byte[100];
    int bytesRead = in.read(buffer);
    assertEquals(buffer.length, bytesRead);
    in.close();
  }