use of com.oxygenxml.git.view.history.HistoryCommitTableModel in project oxygen-git-client-addon by oxygenxml.
the class HistoryPanel2Test method testMultipleSelectionHistoryActions.
/**
* Tests the actions presented for multiple selection in the history panel.
*
* EXM-44448
*
* @throws Exception If it fails.
*/
@Test
public void testMultipleSelectionHistoryActions() throws Exception {
generateRepositoryAndLoad(getClass().getClassLoader().getResource("scripts/file_content_script.txt"), new File("target/gen/HistoryPanelTest/testMultipleSelectionHistoryActions"));
List<CommitCharacteristics> commitsCharacteristics = GitAccess.getInstance().getCommitsCharacteristics(HistoryStrategy.CURRENT_BRANCH, null, null);
String dump = dumpHistory(commitsCharacteristics, true);
String expected = "[ Third. , {date} , Alex <alex_jitianu@sync.ro> , 1 , AlexJitianu , [2] ]\n" + "[ Second. , {date} , Alex <alex_jitianu@sync.ro> , 2 , AlexJitianu , [3] ]\n" + "[ First commit. , {date} , Alex <alex_jitianu@sync.ro> , 3 , 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);
// ---------------
// Invoke the Diff action to see if the built URLs are O.K.
// ---------------
CommitCharacteristics cc1 = model.getAllCommits().get(0);
CommitCharacteristics cc3 = model.getAllCommits().get(2);
FileStatus fileStatus = new FileStatus(GitChangeType.CHANGED, "file1.txt");
Action action = getCompareWithEachOther(fileStatus, cc1, cc3);
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://" + cc1.getCommitId() + "/file1.txt", left.toString());
assertEquals("git://" + cc3.getCommitId() + "/file1.txt", right.toString());
// ///////////////
// Test the open multiple files
// ////////////////
CommitCharacteristics cc2 = model.getAllCommits().get(1);
Action open = getOpenFileAction(fileStatus, cc1, cc2, cc3);
open.actionPerformed(null);
assertEquals("[" + "git://" + cc1.getCommitId() + "/file1.txt" + ", " + "git://" + cc2.getCommitId() + "/file1.txt" + ", " + "git://" + cc3.getCommitId() + "/file1.txt" + "]", toOpen.toString());
}
use of com.oxygenxml.git.view.history.HistoryCommitTableModel in project oxygen-git-client-addon by oxygenxml.
the class HistoryPanel4RevertTest method testRevertCommit.
/**
* <p><b>Description:</b> create new branch starting from a commit from the history table.</p>
*
* @author Tudosie Razvan
*
* @throws Exception
*/
@Test
public void testRevertCommit() 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().revertCommit(commitCharacteristics.getCommitId());
waitForScheduler();
sleep(400);
// Check the history of the new branch
commitsCharacteristics = GitAccess.getInstance().getCommitsCharacteristics(HistoryStrategy.CURRENT_BRANCH, null, null);
dump = dumpHistory(commitsCharacteristics);
expected = "[ Revert \"Changes.\"\n" + "\n" + "This reverts commit " + commitCharacteristics.getCommitId() + ".\n" + " , {date} , AlexJitianu <alex_jitianu@sync.ro> , 5 , AlexJitianu , [1] ]\n" + "[ 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);
assertEquals(1, noOfRefreshes);
} 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 testSearchAuthorAndMessage.
/**
* Tests when we search with the author name and the message of the commit
*
* @throws Exception If it fails.
*/
@Test
public void testSearchAuthorAndMessage() throws Exception {
generateRepositoryAndLoad(getClass().getClassLoader().getResource("scripts/history_script_rename.txt"), new File("target/gen/HistoryPanelTest/testAffectedFiles_ShowRenames"));
historyPanel.showRepositoryHistory();
waitForScheduler();
flushAWT();
sleep(300);
JTable historyTable = historyPanel.getHistoryTable();
HistoryCommitTableModel model = (HistoryCommitTableModel) historyTable.getModel();
model.filterChanged("alex rename");
sleep(700);
String dump = dumpHistory(model.getAllCommits(), true);
String expected = "[ Rename. , {date} , Alex <alex_jitianu@sync.ro> , 1 , AlexJitianu , [2] ]\n";
assertEquals(expected, dump);
}
use of com.oxygenxml.git.view.history.HistoryCommitTableModel in project oxygen-git-client-addon by oxygenxml.
the class HistoryPanelTest method testChangeBranchEvent.
/**
* TODO - pare sa fie ceva din resetarea cach-ului.
* com.oxygenxml.git.service.GitAccess.getCommitsCharacteristics(HistoryStrategy, String, RenameTracker)
* daca adaugam un resetCache
*
* if (filePath == null && statusCache.getStatus().hasUncommittedChanges()) {
* revisions.add(UNCOMMITED_CHANGES);
* }
*
* pare sa mearga
*
* Changing branches fires notification.
*
* @throws Exception If it fails.
*/
public void testChangeBranchEvent() throws Exception {
URL script = getClass().getClassLoader().getResource("scripts/git_branch_events.txt");
File wcTree = new File("target/gen/GitHistoryTest_testChangeBranchEvent");
generateRepositoryAndLoad(script, wcTree);
List<CommitCharacteristics> commitsCharacteristics = GitAccess.getInstance().getCommitsCharacteristics(HistoryStrategy.CURRENT_BRANCH, null, null);
String dump = dumpHistory(commitsCharacteristics);
String expected = "[ New branch , {date} , Alex <alex_jitianu@sync.ro> , 1 , AlexJitianu , [2] ]\n" + "[ First commit. , {date} , Alex <alex_jitianu@sync.ro> , 2 , AlexJitianu , null ]\n" + "";
expected = expected.replaceAll("\\{date\\}", DATE_FORMAT.format(new Date()));
expected = replaceDate(expected);
assertEquals(expected, dump);
historyPanel.showRepositoryHistory();
waitForScheduler();
flushAWT();
sleep(300);
JTable historyTable = historyPanel.getHistoryTable();
HistoryCommitTableModel model = (HistoryCommitTableModel) historyTable.getModel();
dump = dumpHistory(model.getAllCommits());
assertEquals(expected, dump);
// =======================
// Change branch.
// =======================
GitAccess.getInstance().setBranch(GitAccess.DEFAULT_BRANCH_NAME);
// History panel uses the scheduler to perform the change.
ScheduledFuture<?> schedule = GitOperationScheduler.getInstance().schedule(() -> {
});
schedule.get();
waitForScheduler();
model = (HistoryCommitTableModel) historyTable.getModel();
dump = dumpHistory(model.getAllCommits());
expected = "[ First commit. , {date} , Alex <alex_jitianu@sync.ro> , 2 , AlexJitianu , null ]\n";
expected = expected.replaceAll("\\{date\\}", DATE_FORMAT.format(new Date()));
assertEquals(expected, dump);
}
use of com.oxygenxml.git.view.history.HistoryCommitTableModel in project oxygen-git-client-addon by oxygenxml.
the class HistoryPanelTestBase method selectAndAssertRevision.
/**
* Selects a specific revision in the history table and asserts its description.
*
* @param historyTable History table.
* @param affectedTable The table that present the affected files from the commit selected in the history view.
* @param row Which row to select.
* @param expected The expected revision description.
*/
protected void selectAndAssertRevision(JTable historyTable, JTable affectedTable, int row, String expected) {
HistoryCommitTableModel model = (HistoryCommitTableModel) historyTable.getModel();
historyTable.getSelectionModel().clearSelection();
Semaphore s = new Semaphore(0);
TableModelListener l = new TableModelListener() {
@Override
public void tableChanged(TableModelEvent e) {
if (e.getType() == TableModelEvent.INSERT) {
s.release();
}
}
};
affectedTable.getModel().addTableModelListener(l);
historyTable.getSelectionModel().setSelectionInterval(row, row);
// There is a timer involved.
try {
s.tryAcquire(3, TimeUnit.SECONDS);
} catch (InterruptedException e1) {
e1.printStackTrace();
} finally {
affectedTable.getModel().removeTableModelListener(l);
}
flushAWT();
CommitCharacteristics selectedObject = (CommitCharacteristics) model.getValueAt(historyTable.getSelectedRow(), 1);
assertEquals(replaceDate(expected), toString(selectedObject));
}
Aggregations