use of com.oxygenxml.git.view.staging.ChangesPanel.SelectedResourcesProvider in project oxygen-git-client-addon by oxygenxml.
the class GitViewResourceContextualMenuActionsTest method testActionsEnablingState_10.
/**
* <p><b>Description:</b> test the enabling state of the actions
* from the contextual menu of the unstaged resources.</p>
* <p><b>Bug ID:</b> EXM-40615</p>
*
* @author sorin_carbunaru
*
* @throws Exception
*/
public void testActionsEnablingState_10() throws Exception {
GitResourceContextualMenu menu = new GitResourceContextualMenu(new SelectedResourcesProvider() {
@Override
public List<FileStatus> getOnlySelectedLeaves() {
return getAllSelectedResources();
}
@Override
public List<FileStatus> getAllSelectedResources() {
List<FileStatus> fileStatuses = new ArrayList<>();
fileStatuses.add(new FileStatus(GitChangeType.MISSING, "test.xml"));
fileStatuses.add(new FileStatus(GitChangeType.UNTRACKED, "test2.xml"));
return fileStatuses;
}
}, gitCtrl, null, // For unstaged resources
false, Optional.of(RepositoryState.SAFE));
assertEquals("\n" + "Open_In_Compare [DISABLED]\n" + "Open [DISABLED]\n" + "----\n" + "Stage [ENABLED]\n" + "Resolve_Conflict [DISABLED]\n" + " Open_In_Compare [DISABLED]\n" + " ----\n" + " Resolve_Using_Mine [DISABLED]\n" + " Resolve_Using_Theirs [DISABLED]\n" + " Mark_Resolved [DISABLED]\n" + " ----\n" + " Restart_Merge [DISABLED]\n" + "Discard [ENABLED]\n" + "----\n" + "Show_history [DISABLED]\n" + "Show_blame [DISABLED]", PopupMenuSerializer.serializePopupStructure(menu, true, true));
}
use of com.oxygenxml.git.view.staging.ChangesPanel.SelectedResourcesProvider in project oxygen-git-client-addon by oxygenxml.
the class GitViewResourceContextualMenuActionsTest method testActionsEnablingState_20.
/**
* <p><b>Description:</b> test the enabling state of the actions
* from the contextual menu of the submodules.</p>
* <p><b>Bug ID:</b> EXM-40615</p>
*
* @author sorin_carbunaru
*
* @throws Exception
*/
public void testActionsEnablingState_20() throws Exception {
GitResourceContextualMenu menu = new GitResourceContextualMenu(new SelectedResourcesProvider() {
@Override
public List<FileStatus> getOnlySelectedLeaves() {
return getAllSelectedResources();
}
@Override
public List<FileStatus> getAllSelectedResources() {
List<FileStatus> fileStatuses = new ArrayList<>();
fileStatuses.add(new FileStatus(GitChangeType.SUBMODULE, "test.xml"));
return fileStatuses;
}
}, gitCtrl, null, // For staged resources
true, Optional.of(RepositoryState.SAFE));
assertEquals("\n" + "Open_In_Compare [ENABLED]\n" + "Open [ENABLED]\n" + "----\n" + "Unstage [ENABLED]\n" + "Resolve_Conflict [DISABLED]\n" + " Open_In_Compare [ENABLED]\n" + " ----\n" + " Resolve_Using_Mine [DISABLED]\n" + " Resolve_Using_Theirs [DISABLED]\n" + " Mark_Resolved [DISABLED]\n" + " ----\n" + " Restart_Merge [DISABLED]\n" + "Discard [ENABLED]", PopupMenuSerializer.serializePopupStructure(menu, true, true));
}
use of com.oxygenxml.git.view.staging.ChangesPanel.SelectedResourcesProvider in project oxygen-git-client-addon by oxygenxml.
the class RefreshProjectTest method testRefreshProjectOnDiscard_2.
/**
* Refresh on discard. Multiple "untracked" resources discarded
*
* @throws Exception
*/
public void testRefreshProjectOnDiscard_2() throws Exception {
File repoDir = new File(localTestRepoPath);
repoDir.mkdirs();
File file = new File(localTestRepoPath, "test.txt");
file.createNewFile();
file.deleteOnExit();
new File(localTestRepoPath + "/subFolder").mkdir();
File file2 = new File(localTestRepoPath, "subFolder/test2.txt");
file2.createNewFile();
file2.deleteOnExit();
try {
DiscardAction discardAction = new DiscardAction(new SelectedResourcesProvider() {
@Override
public List<FileStatus> getOnlySelectedLeaves() {
return null;
}
@Override
public List<FileStatus> getAllSelectedResources() {
return Arrays.asList(new FileStatus(GitChangeType.UNTRACKED, "test.txt"), new FileStatus(GitChangeType.UNTRACKED, "subFolder/test2.txt"));
}
}, // A mock that does nothing.
Mockito.mock(GitControllerBase.class));
discardAction.actionPerformed(null);
assertEquals(repoDir.getCanonicalFile().getAbsolutePath(), refreshedFolder.getAbsolutePath());
} finally {
FileUtils.deleteDirectory(repoDir);
}
}
use of com.oxygenxml.git.view.staging.ChangesPanel.SelectedResourcesProvider 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);
}
}
use of com.oxygenxml.git.view.staging.ChangesPanel.SelectedResourcesProvider in project oxygen-git-client-addon by oxygenxml.
the class RefreshProjectTest method testRefreshProjectOnDiscard_1.
/**
* Refresh on discard. Only one "added" resource discarded.
*
* @throws Exception
*/
public void testRefreshProjectOnDiscard_1() throws Exception {
File repoDir = new File(localTestRepoPath);
repoDir.mkdirs();
File file = new File(localTestRepoPath, "test.txt");
file.createNewFile();
file.deleteOnExit();
try {
DiscardAction discardAction = new DiscardAction(new SelectedResourcesProvider() {
@Override
public List<FileStatus> getOnlySelectedLeaves() {
return null;
}
@Override
public List<FileStatus> getAllSelectedResources() {
return Arrays.asList(new FileStatus(GitChangeType.ADD, "test.txt"));
}
}, // A mock that does nothing.
Mockito.mock(GitControllerBase.class));
discardAction.actionPerformed(null);
assertEquals(repoDir.getCanonicalFile().getAbsolutePath(), refreshedFolder.getAbsolutePath());
} finally {
FileUtils.deleteDirectory(repoDir);
}
}
Aggregations