use of com.oxygenxml.git.service.SubmoduleAccess in project oxygen-git-client-addon by oxygenxml.
the class RefreshProjectTest method testRefreshProjectOnDiscard_3.
/**
* Refresh on submodule discard.
*
* @throws Exception
*/
@PrepareForTest({ GitAccess.class })
public void testRefreshProjectOnDiscard_3() throws Exception {
File repoDir = new File(localTestRepoPath);
repoDir.mkdirs();
File subModule = new File(localTestRepoPath, "subModule");
subModule.mkdir();
try {
GitAccess gitAccessMock = PowerMockito.mock(GitAccess.class);
Whitebox.setInternalState(GitAccess.class, "instance", gitAccessMock);
SubmoduleAccess submoduleAccess = Mockito.mock(SubmoduleAccess.class);
Mockito.doNothing().when(submoduleAccess).discardSubmodule();
PowerMockito.when(gitAccessMock.getSubmoduleAccess()).thenReturn(submoduleAccess);
DiscardAction discardAction = new DiscardAction(new SelectedResourcesProvider() {
@Override
public List<FileStatus> getOnlySelectedLeaves() {
return null;
}
@Override
public List<FileStatus> getAllSelectedResources() {
return Arrays.asList(new FileStatus(GitChangeType.SUBMODULE, "subModule"));
}
}, // A mock that does nothing.
Mockito.mock(GitControllerBase.class));
discardAction.actionPerformed(null);
assertEquals(subModule.getCanonicalFile().getAbsolutePath(), refreshedFolder.getAbsolutePath());
} finally {
FileUtils.deleteDirectory(repoDir);
}
}
Aggregations