### Question:
DownloadBazelTask extends DefaultTask { public static DownloadBazelTask injectDownloadTask(Project project, String pathToBazelBin) { Project rootProject = project.getRootProject(); if (rootProject.getTasks().findByName(DOWNLOAD_TASK_NAME) == null) { final Object urlPropertyName; switch (SystemEnvironment.getOsType()) { case macOs: urlPropertyName = rootProject.getProperties().get("bazel.bin.url.macos"); break; case Windows: urlPropertyName = rootProject.getProperties().get("bazel.bin.url.windows"); break; default: urlPropertyName = rootProject.getProperties().get("bazel.bin.url.linux"); } return injectTask(rootProject, urlPropertyName, pathToBazelBin); } return null; }  static DownloadBazelTask injectDownloadTask(Project project, String pathToBazelBin); @Input File getTargetFile(); void setTargetFile(File targetFile); @Input String getDownloadUrl(); void setDownloadUrl(String downloadUrl); @TaskAction void download();  }### Answer:
@Test public void testDownloadUrlDoesntExistsForOs() throws Exception { Project project = TestUtils.createConfiguredAppliedProject(); System.setProperty("os.name", "mac"); project.getExtensions().getExtraProperties().set("bazel.bin.url.macos", null); Exception caughtException = null; try { DownloadBazelTask.injectDownloadTask(project, "bazelBin"); } catch (Exception e) { caughtException = e; } assertNotNull(caughtException); assertTrue(caughtException instanceof IllegalArgumentException); assertTrue(caughtException.getMessage().contains("The URL property to download Bazel is invalid")); }