use of com.oxygenxml.git.view.history.HistoryCommitTableModel in project oxygen-git-client-addon by oxygenxml.
the class HistoryPanel2Test method testActionsOnRenamedFile.
/**
* Test the contextual actions presented for revisions preceding a rename.
* EXM-44300
*
* @throws Exception If it fails.
*/
@Test
public void testActionsOnRenamedFile() throws Exception {
generateRepositoryAndLoad(getClass().getClassLoader().getResource("scripts/EXM-44300/script.txt"), new File("target/gen/HistoryPanelTest/testActionsOnRenamedFile"));
List<CommitCharacteristics> commitsCharacteristics = GitAccess.getInstance().getCommitsCharacteristics(HistoryStrategy.CURRENT_BRANCH, null, null);
String dump = dumpHistory(commitsCharacteristics, true);
String expected = "[ Fourth , {date} , Alex <alex_jitianu@sync.ro> , 1 , AlexJitianu , [2] ]\n" + "[ Third (Rename) , {date} , Alex <alex_jitianu@sync.ro> , 2 , AlexJitianu , [3] ]\n" + "[ Second , {date} , Alex <alex_jitianu@sync.ro> , 3 , AlexJitianu , [4] ]\n" + "[ First , {date} , Alex <alex_jitianu@sync.ro> , 4 , AlexJitianu , null ]\n" + "";
assertEquals(expected, dump);
historyPanel.showRepositoryHistory();
waitForScheduler();
flushAWT();
sleep(300);
JTable historyTable = historyPanel.getHistoryTable();
HistoryCommitTableModel model = (HistoryCommitTableModel) historyTable.getModel();
dump = dumpHistory(model.getAllCommits(), true);
assertEquals(expected, dump);
// ---------------
// Assert the available actions.
// ---------------
CommitCharacteristics cc = commitsCharacteristics.get(2);
assertEquals("Second", cc.getCommitMessage());
List<Action> actions = getAllActions(new FileStatus(GitChangeType.MODIFIED, "file_renamed.txt"), cc);
List<Object> collect = actions.stream().map(t -> t.getValue(Action.NAME)).collect(Collectors.toList());
assertEquals("[Compare_file_with_previous_version, " + "Compare_file_with_working_tree_version, Open_this_version_of_filename, " + "Open_the_working_copy_version_of, Create_branch..., " + "Create_Tag..., Checkout..., Revert_Commit, Reset_branch_to_this_commit...]", collect.toString());
}
use of com.oxygenxml.git.view.history.HistoryCommitTableModel in project oxygen-git-client-addon by oxygenxml.
the class HistoryPanel2Test method testAffectedFiles_ShowCopyRenames.
/**
* Tests the affected files presented when a revision is selected inside the history panel.
*
* @throws Exception If it fails.
*/
@Test
public void testAffectedFiles_ShowCopyRenames() throws Exception {
generateRepositoryAndLoad(getClass().getClassLoader().getResource("scripts/history_script_follow_move.txt"), new File("target/gen/HistoryPanelTest/testAffectedFiles_ShowCopyRenames"));
List<CommitCharacteristics> commitsCharacteristics = GitAccess.getInstance().getCommitsCharacteristics(HistoryStrategy.CURRENT_BRANCH, null, null);
String dump = dumpHistory(commitsCharacteristics, true);
String expected = "[ Move , {date} , Alex <alex_jitianu@sync.ro> , 1 , AlexJitianu , [2] ]\n" + "[ Initial , {date} , Alex <alex_jitianu@sync.ro> , 2 , AlexJitianu , null ]\n" + "";
assertEquals(expected, dump);
historyPanel.showRepositoryHistory();
waitForScheduler();
flushAWT();
sleep(500);
JTable historyTable = historyPanel.getHistoryTable();
HistoryCommitTableModel model = (HistoryCommitTableModel) historyTable.getModel();
dump = dumpHistory(model.getAllCommits(), true);
assertEquals(expected, dump);
// -----------
// Select an entry in the revision table.
// -----------
expected = "[ Move , {date} , Alex <alex_jitianu@sync.ro> , 1 , AlexJitianu , [2] ]";
expected = replaceDate(expected);
selectAndAssertRevision(historyTable, historyPanel.getAffectedFilesTable(), 0, expected);
// -----------
// Assert the affected files
// -----------
assertAffectedFiles(historyPanel, "(changeType=RENAME, fileLocation=child/file.txt)\n");
// ---------------
// Invoke the Diff action to see if the built URLs are O.K.
// ---------------
HistoryTableAffectedFilesModel affectedFilesModel = (HistoryTableAffectedFilesModel) historyPanel.getAffectedFilesTable().getModel();
FileStatus fileStatus = affectedFilesModel.getFilesStatuses().get(0);
CommitCharacteristics cc = model.getAllCommits().get(0);
Action action = getCompareWithPreviousAction(fileStatus, cc);
action.actionPerformed(null);
assertEquals("Unexpected number of URLs intercepted in the comparison support:" + urls2compare.toString(), 2, urls2compare.size());
URL left = urls2compare.get(0);
URL right = urls2compare.get(1);
assertEquals("git://" + model.getAllCommits().get(0).getCommitId() + "/child/file.txt", left.toString());
assertEquals("git://" + model.getAllCommits().get(1).getCommitId() + "/file.txt", right.toString());
}
use of com.oxygenxml.git.view.history.HistoryCommitTableModel in project oxygen-git-client-addon by oxygenxml.
the class HistoryPanel2Test method testAffectedFiles_ShowRenames.
/**
* Tests the affected files presented when a revision is selected inside the history panel.
*
* @throws Exception If it fails.
*/
@Test
public void testAffectedFiles_ShowRenames() throws Exception {
generateRepositoryAndLoad(getClass().getClassLoader().getResource("scripts/history_script_rename.txt"), new File("target/gen/HistoryPanelTest/testAffectedFiles_ShowRenames"));
List<CommitCharacteristics> commitsCharacteristics = GitAccess.getInstance().getCommitsCharacteristics(HistoryStrategy.CURRENT_BRANCH, null, null);
String dump = dumpHistory(commitsCharacteristics, true);
String expected = "[ Rename. , {date} , Alex <alex_jitianu@sync.ro> , 1 , AlexJitianu , [2] ]\n" + "[ First commit. , {date} , Alex <alex_jitianu@sync.ro> , 2 , AlexJitianu , null ]\n" + "";
assertEquals(expected, dump);
historyPanel.showRepositoryHistory();
waitForScheduler();
flushAWT();
sleep(300);
JTable historyTable = historyPanel.getHistoryTable();
HistoryCommitTableModel model = (HistoryCommitTableModel) historyTable.getModel();
dump = dumpHistory(model.getAllCommits(), true);
assertEquals(expected, dump);
// -----------
// Select an entry in the revision table.
// -----------
expected = "[ Rename. , {date} , Alex <alex_jitianu@sync.ro> , 1 , AlexJitianu , [2] ]";
expected = replaceDate(expected);
selectAndAssertRevision(historyTable, historyPanel.getAffectedFilesTable(), 0, expected);
// -----------
// Assert the affected files
// -----------
assertAffectedFiles(historyPanel, "(changeType=RENAME, fileLocation=file_renamed.txt)\n");
// ---------------
// Invoke the Diff action to see if the built URLs are O.K.
// ---------------
HistoryTableAffectedFilesModel affectedFilesModel = (HistoryTableAffectedFilesModel) historyPanel.getAffectedFilesTable().getModel();
FileStatus fileStatus = affectedFilesModel.getFilesStatuses().get(0);
CommitCharacteristics cc = model.getAllCommits().get(0);
Action action = getCompareWithPreviousAction(fileStatus, cc);
action.actionPerformed(null);
assertEquals("Unexpected number of URLs intercepted in the comparison support:" + urls2compare.toString(), 2, urls2compare.size());
URL left = urls2compare.get(0);
URL right = urls2compare.get(1);
assertEquals("git://" + model.getAllCommits().get(0).getCommitId() + "/file_renamed.txt", left.toString());
assertEquals("git://" + model.getAllCommits().get(1).getCommitId() + "/file.txt", right.toString());
}
use of com.oxygenxml.git.view.history.HistoryCommitTableModel in project oxygen-git-client-addon by oxygenxml.
the class HistoryPanel3Test method testCreateBranchFromCommit.
/**
* <p><b>Description:</b> create new branch starting from a commit from the history table.</p>
* <p><b>Bug ID:</b> EXM-45710-</p>
*
* @author sorin_carbunaru
*
* @throws Exception
*/
@Test
public void testCreateBranchFromCommit() throws Exception {
URL script = getClass().getClassLoader().getResource("scripts/history_script.txt");
File wcTree = new File("target/gen/HistoryPanelTest/testAffectedFiles");
RepoGenerationScript.generateRepository(script, wcTree);
try {
GitAccess.getInstance().setRepositorySynchronously(wcTree.getAbsolutePath());
List<CommitCharacteristics> commitsCharacteristics = GitAccess.getInstance().getCommitsCharacteristics(HistoryStrategy.CURRENT_BRANCH, null, null);
String dump = dumpHistory(commitsCharacteristics);
String expected = "[ Root file changed. , {date} , Alex <alex_jitianu@sync.ro> , 1 , AlexJitianu , [2] ]\n" + "[ Root file. , {date} , Alex <alex_jitianu@sync.ro> , 2 , AlexJitianu , [3] ]\n" + "[ Changes. , {date} , Alex <alex_jitianu@sync.ro> , 3 , AlexJitianu , [4] ]\n" + "[ First commit. , {date} , Alex <alex_jitianu@sync.ro> , 4 , AlexJitianu , null ]\n";
expected = replaceDate(expected);
assertEquals(expected, dump);
historyPanel.showRepositoryHistory();
flushAWT();
JTable historyTable = historyPanel.getHistoryTable();
HistoryCommitTableModel model = (HistoryCommitTableModel) historyTable.getModel();
dump = dumpHistory(model.getAllCommits());
assertEquals(expected, dump);
// Checkout commit as new branch
CommitCharacteristics commitCharacteristics = model.getAllCommits().get(2);
dump = dumpHistory(Arrays.asList(commitCharacteristics));
expected = replaceDate("[ Changes. , {date} , Alex <alex_jitianu@sync.ro> , 3 , AlexJitianu , [4] ]\n");
assertEquals(expected, dump);
GitAccess.getInstance().checkoutCommitAndCreateBranch("new_branch", commitCharacteristics.getCommitId());
waitForScheduler();
sleep(400);
assertEquals("new_branch", GitAccess.getInstance().getBranchInfo().getBranchName());
// Check the history of the new branch
commitsCharacteristics = GitAccess.getInstance().getCommitsCharacteristics(HistoryStrategy.CURRENT_BRANCH, null, null);
dump = dumpHistory(commitsCharacteristics);
expected = "[ Changes. , {date} , Alex <alex_jitianu@sync.ro> , 3 , AlexJitianu , [4] ]\n" + "[ First commit. , {date} , Alex <alex_jitianu@sync.ro> , 4 , AlexJitianu , null ]\n";
expected = replaceDate(expected);
assertEquals(expected, dump);
} finally {
GitAccess.getInstance().closeRepo();
FileUtils.deleteDirectory(wcTree);
}
}
use of com.oxygenxml.git.view.history.HistoryCommitTableModel in project oxygen-git-client-addon by oxygenxml.
the class HistoryPanelQuickSearchTest method testSearchNoMatch.
/**
* Tests search with a word that could not be found in the history list
*
* @throws Exception If it fails.
*/
@Test
public void testSearchNoMatch() throws Exception {
generateRepositoryAndLoad(getClass().getClassLoader().getResource("scripts/history_script_rename.txt"), new File("target/gen/HistoryPanelTest/testAffectedFiles_ShowRenames"));
historyPanel.showRepositoryHistory();
flushAWT();
JTable historyTable = historyPanel.getHistoryTable();
HistoryCommitTableModel model = (HistoryCommitTableModel) historyTable.getModel();
model.filterChanged("nimic");
sleep(300);
String dump = dumpHistory(model.getAllCommits(), true);
assertEquals("", dump);
}
Aggregations