### Question:
ToolMain { @VisibleForTesting static @Nullable File getGlowrootJarFile(@Nullable CodeSource codeSource) throws URISyntaxException { if (codeSource == null) { return null; } File codeSourceFile = new File(codeSource.getLocation().toURI()); if (codeSourceFile.getName().endsWith(".jar")) { return codeSourceFile; } return null; } private  ToolMain(); static void main(String[] args, @Nullable File glowrootJarFile);  }### Answer:
@Test public void testNullCodeSource() throws URISyntaxException { assertThat(ToolMain.getGlowrootJarFile(null)).isNull(); }
@Test public void testWithGlowrootJar() throws Exception { File glowrootJar = new File("x/glowroot.jar").getAbsoluteFile(); CodeSource codeSource = new CodeSource(glowrootJar.toURI().toURL(), new Certificate[0]); assertThat(ToolMain.getGlowrootJarFile(codeSource)).isEqualTo(glowrootJar); }
@Test public void testWithNotGlowrootJar() throws Exception { File glowrootJar = new File("x/classes"); CodeSource codeSource = new CodeSource(glowrootJar.toURI().toURL(), new Certificate[0]); assertThat(ToolMain.getGlowrootJarFile(codeSource)).isNull(); }