@Before public void setUp() throws Exception { projectMock = Mockito.mock(Project.class); gitRepoInfoMock = Mockito.mock(GitRepoInfo.class); gitRepositoryMock = Mockito.mock(GitRepository.class); diffProviderMock = Mockito.mock(DiffCompareInfoProvider.class); observerMock = Mockito.mock(Observer.class); applicationProviderMock = Mockito.mock(CreatePullRequestModel.ApplicationProvider.class); currentBranch = PRGitObjectMockHelper.createLocalBranch("local"); tfsRemote = new GitRemote("origin", Arrays.asList("https://mytest.visualstudio.com/DefaultCollection/_git/testrepo"), Arrays.asList("https://pushurl"), Collections.<String>emptyList(), Collections.<String>emptyList()); when(diffProviderMock.getEmptyDiff(gitRepositoryMock)).thenCallRealMethod(); when(gitRepositoryMock.getInfo()).thenReturn(gitRepoInfoMock); when(gitRepositoryMock.getRemotes()).thenReturn(Collections.singletonList(tfsRemote)); when(gitRepoInfoMock.getCurrentBranch()).thenReturn(currentBranch); }
@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); }