### Question:
GitScannerPlugin extends AbstractScannerPlugin<FileResource, GitRepositoryDescriptor> { static void initGitDescriptor(final GitRepositoryDescriptor gitRepositoryDescriptor, final File file) throws IOException { final Path headPath = file.toPath().toAbsolutePath().normalize(); LOGGER.debug ("Full path to Git directory HEAD is '{}'", headPath); final Path gitPath = headPath.getParent(); final String pathToGitProject = gitPath.toFile().getAbsolutePath(); LOGGER.debug ("Full path to Git directory is '{}'", pathToGitProject); final Path projectPath = gitPath.getParent(); final String projectName = projectPath.toFile().getName(); LOGGER.debug ("Git Project name is '{}'", projectName); gitRepositoryDescriptor.setName(projectName); gitRepositoryDescriptor.setFileName(pathToGitProject); }  @Override /* * Check whether this is the start of a git repository. * * If the path is "/HEAD" and the file (behind item) lives in a directory called ".git" this must be a git * repository and the scanner may perform it's work on it (call to "scan" method). */ boolean accepts(final FileResource item, final String path, final Scope scope); @Override GitRepositoryDescriptor scan(final FileResource item, final String path, final Scope scope, final Scanner scanner);  }### Answer:
@Test public void testGitScannerInitGitDescriptorDefault () { GitRepositoryDescriptor gitRepositoryDescriptor = mock(GitRepositoryDescriptor.class); try { GitScannerPlugin.initGitDescriptor(gitRepositoryDescriptor, new File("/tmp/xxx/.git/HEAD")); if (!IS_WINDOWS) { verify(gitRepositoryDescriptor).setFileName("/tmp/xxx/.git"); } verify(gitRepositoryDescriptor).setName("xxx"); } catch (IOException e) { e.printStackTrace(); } }
@Test public void testGitScannerInitGitDescriptorMyOwnGit () { GitRepositoryDescriptor gitRepositoryDescriptor = mock(GitRepositoryDescriptor.class); try { GitScannerPlugin.initGitDescriptor(gitRepositoryDescriptor, new File("../.git/HEAD")); } catch (IOException e) { e.printStackTrace(); } }
@Test public void testGitScannerInitGitDescriptorRelativeDotGit () { GitRepositoryDescriptor gitRepositoryDescriptor = mock(GitRepositoryDescriptor.class); try { GitScannerPlugin.initGitDescriptor(gitRepositoryDescriptor, new File(".git/HEAD")); verify(gitRepositoryDescriptor).setName("git"); } catch (IOException e) { e.printStackTrace(); } }
@Test public void testGitScannerInitGitDescriptorRelativeDotDotGit () { GitRepositoryDescriptor gitRepositoryDescriptor = mock(GitRepositoryDescriptor.class); try { GitScannerPlugin.initGitDescriptor(gitRepositoryDescriptor, new File("./.git/HEAD")); verify(gitRepositoryDescriptor).setName("git"); } catch (IOException e) { e.printStackTrace(); } }