RuleDatabaseItemUpdateRunnable implements Runnable { boolean shouldDownload() { if (item.state == Configuration.Item.STATE_IGNORE) { return false; } if (item.location.startsWith("content:/")) { return true; } file = FileHelper.getItemFile(context, item); if (file == null || !item.isDownloadable()) { return false; } try { url = new URL(item.location); } catch (MalformedURLException e) { parentTask.addError(item, context.getString(R.string.invalid_url_s, item.location)); return false; } return true; } RuleDatabaseItemUpdateRunnable(@NonNull RuleDatabaseUpdateTask parentTask, @NonNull Context context, @NonNull Configuration.Item item); @Override void run();  }
@Test public void testShouldDownload() throws Exception { Configuration.Item item = new Configuration.Item(); item.state = Configuration.Item.STATE_DENY; item.location = "example.com"; item.title = "host-uri"; RuleDatabaseItemUpdateRunnable itemUpdateRunnable = new RuleDatabaseItemUpdateRunnable(mockTask, mockContext, item); assertFalse(itemUpdateRunnable.shouldDownload()); item.location = "content: assertTrue(itemUpdateRunnable.shouldDownload()); item.state = Configuration.Item.STATE_IGNORE; assertFalse(itemUpdateRunnable.shouldDownload()); item.state = Configuration.Item.STATE_DENY; item.location = "https: assertTrue(itemUpdateRunnable.shouldDownload()); item.location = "http: assertTrue(itemUpdateRunnable.shouldDownload()); }