### Question:
DownloadBazelTask extends DefaultTask { @TaskAction public void download() throws IOException { if (mTargetFile == null) { throw new NullPointerException("targetFile needs to be set!"); } if (mDownloadUrl == null) { throw new NullPointerException("downloadUrl needs to be set!"); } File canonicalFileTargetFile = mTargetFile.getCanonicalFile(); if (canonicalFileTargetFile.getParentFile() == null || ( !canonicalFileTargetFile.getParentFile().exists() && !canonicalFileTargetFile .getParentFile().mkdirs())) { throw new IOException( "Failed to create parent folder for " + canonicalFileTargetFile.getAbsolutePath()); } try { final Download downloader = new Download( new DownloadProgressLogger(mDownloadUrl, canonicalFileTargetFile.getAbsolutePath()), "bazel-leaf", "0.0.1"); downloader.download(URI.create(mDownloadUrl), canonicalFileTargetFile); getAnt().invokeMethod("chmod", map( "file", canonicalFileTargetFile, "perm", "+x")); } catch (Exception e) { throw new RuntimeException("Failed to download Bazel to " + canonicalFileTargetFile + "! This could be a target path issue.", e); } }  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 testMissingTargetFileArgument() throws Exception { Project project = TestUtils.createConfiguredAppliedProject(); DownloadBazelTask downloadBazel = project.getTasks().create("downloadBazel", DownloadBazelTask.class); try { downloadBazel.download(); fail(); } catch (NullPointerException e) { assertThat(e.getMessage(), IsEqual.equalTo("targetFile needs to be set!")); } }