@Test
public void branchChangedFiles_should_return_null_if_repo_exactref_is_null() throws IOException {

  Repository repository = mock(Repository.class);
  RefDatabase refDatabase = mock(RefDatabase.class);
  when(repository.getRefDatabase()).thenReturn(refDatabase);
  when(refDatabase.findRef("branch")).thenReturn(null);
  GitScmProvider provider = new GitScmProvider(mockCommand(), analysisWarnings, gitIgnoreCommand, system2) {
    @Override
    Repository buildRepo(Path basedir) {
      return repository;
    }
  };
  assertThat(provider.branchChangedFiles("branch", worktree)).isNull();
  String warning = "Could not find ref 'branch' in refs/heads, refs/remotes/upstream or refs/remotes/origin."
    + " You may see unexpected issues and changes. Please make sure to fetch this ref before pull request analysis.";
  verify(analysisWarnings).addUnique(warning);
}