public static GitRemoteBranch createRemoteBranch(final String name, final GitRemote remote) { GitRemoteBranch branch = mock(GitRemoteBranch.class); when(branch.getName()).thenReturn("refs/remotes/" + name); when(branch.getFullName()).thenReturn(name); when(branch.isRemote()).thenReturn(true); when(branch.getRemote()).thenReturn(remote); when(branch.getNameForLocalOperations()).thenReturn(name); when(branch.getNameForRemoteOperations()).thenReturn(name); return branch; }
@Before public void setUp() throws Exception { PowerMockito.mockStatic(VcsNotifier.class); when(VcsNotifier.getInstance(mockProject)).thenReturn(mockVcsNotifier); PowerMockito.mockStatic(GeneralGitHelper.class); when(GeneralGitHelper.getLastCommitHash(mockProject, mockGitRepository, mockRemoteMaster)).thenReturn("281e2d5f8ba36655570ba808055e81ff64ba14d8"); when(mockGitRepository.getRemotes()).thenReturn(ImmutableList.of(tfsRemoteBranch1, tfsRemoteBranch2, tfsRemoteMaster)); when(mockGitRepository.getInfo()).thenReturn(mockGitRepoInfo); when(mockRemoteMaster.getRemote()).thenReturn(tfsRemoteMaster); when(mockRemoteMaster.getName()).thenReturn("master"); when(mockRemoteBranch1.getRemote()).thenReturn(tfsRemoteBranch1); when(mockRemoteBranch1.getName()).thenReturn("branch1"); when(mockRemoteBranch2.getRemote()).thenReturn(tfsRemoteBranch2); when(mockRemoteBranch2.getName()).thenReturn("branch2"); when(mockVstsRepo.getId()).thenReturn(UUID.fromString("00000000-0000-0000-0000-000000000000")); when(mockTeamProjectReference.getId()).thenReturn(UUID.fromString("00000000-0000-0000-0000-000000000000")); when(mockGitRepoInfo.getRemoteBranches()).thenReturn(ImmutableList.of(mockRemoteMaster)); when(mockContext.getUri()).thenReturn(uri); when(mockContext.getGitRepository()).thenReturn(mockVstsRepo); when(mockContext.getTeamProjectReference()).thenReturn(mockTeamProjectReference); }