use of com.oxygenxml.git.view.staging.actions.DiscardAction in project oxygen-git-client-addon by oxygenxml.
the class FlatView3Test method testDiscard.
/**
* Discard changes. THose files must not appear in either stage/un-stage area.
*
* @throws Exception If it fails.
*/
public void testDiscard() throws Exception {
/**
* Local repository location.
*/
String localTestRepository = "target/test-resources/testDiscard_NewFile_local";
/**
* Remote repository location.
*/
String remoteTestRepository = "target/test-resources/testDiscard_NewFile_remote";
new File(localTestRepository).mkdirs();
File file = new File(localTestRepository + "/test.txt");
file.createNewFile();
setFileContent(file, "remote");
// Create repositories
Repository remoteRepo = createRepository(remoteTestRepository);
Repository localRepo = createRepository(localTestRepository);
// Bind the local repository to the remote one.
bindLocalToRemote(localRepo, remoteRepo);
// Add it to the index.
add(new FileStatus(GitChangeType.UNKNOWN, "test.txt"));
assertTableModels("", "ADD, test.txt");
GitAccess.getInstance().commit("First version.");
assertTableModels("", "");
// Change the file.
setFileContent(file, "index content");
assertTableModels("MODIFIED, test.txt", "");
add(new FileStatus(GitChangeType.MODIFIED, "test.txt"));
assertTableModels("", "CHANGED, test.txt");
// Change the file.
setFileContent(file, "modified content");
// The file is present in both areas.
assertTableModels("MODIFIED, test.txt", "CHANGED, test.txt");
// Discard.
DiscardAction discardAction = new DiscardAction(new SelectedResourcesProvider() {
@Override
public List<FileStatus> getOnlySelectedLeaves() {
return null;
}
@Override
public List<FileStatus> getAllSelectedResources() {
return Arrays.asList(new FileStatus(GitChangeType.MODIFIED, "test.txt"));
}
}, stagingPanel.getGitController());
discardAction.actionPerformed(null);
waitForScheduler();
assertTableModels("", "");
}
Aggregations