use of com.oxygenxml.git.view.GitTreeNode in project oxygen-git-client-addon by oxygenxml.
the class BranchManagementTest method testBranchesTreeStructureRemoteMainOnly.
/**
* <p><b>Description:</b> Tests the structure of a tree with only main remote branch.</p>
* <p><b>Bug ID:</b> EXM-41701</p>
*
* @author bogdan_draghici
*
* @throws Exception
*/
public void testBranchesTreeStructureRemoteMainOnly() throws Exception {
gitAccess.setRepositorySynchronously(REMOTE_TEST_REPOSITORY);
File file = new File(REMOTE_TEST_REPOSITORY + "remote.txt");
file.createNewFile();
setFileContent(file, "remote content");
// Make the first commit for the remote repository and create a branch for it.
gitAccess.add(new FileStatus(GitChangeType.ADD, "remote.txt"));
gitAccess.commit("First remote commit.");
gitAccess.setRepositorySynchronously(LOCAL_TEST_REPOSITORY);
gitAccess.fetch();
BranchManagementPanel branchManagementPanel = new BranchManagementPanel(Mockito.mock(GitControllerBase.class));
branchManagementPanel.refreshBranches();
flushAWT();
JTree tree = branchManagementPanel.getTree();
GitTreeNode root = (GitTreeNode) tree.getModel().getRoot();
StringBuilder actualTree = new StringBuilder();
serializeTree(actualTree, root);
assertEquals("localRepository\n" + " refs/remotes/\n" + " refs/remotes/origin/\n" + " refs/remotes/origin/" + GitAccess.DEFAULT_BRANCH_NAME + "\n" + "", actualTree.toString());
}
use of com.oxygenxml.git.view.GitTreeNode in project oxygen-git-client-addon by oxygenxml.
the class BranchManagementTest method testBranchesTreeCustomRemote.
/**
* <p><b>Description:</b> Tests the filter for branches on a tree with both local and remote branches with more remotes.</p>
* <p><b>Bug ID:</b> EXM-49458</p>
*
* @author Alex_Smarandache
*
* @throws Exception
*/
@Test
public void testBranchesTreeCustomRemote() throws Exception {
bindLocalToRemote(localRepository, remoteRepository, "fork", "main");
File file = new File(LOCAL_TEST_REPOSITORY + "local.txt");
file.createNewFile();
setFileContent(file, "local content");
// Make the first commit for the local repository and create a branch for it.
gitAccess.add(new FileStatus(GitChangeType.ADD, "local.txt"));
gitAccess.commit("First local commit.");
gitAccess.createBranch(LOCAL_BRANCH_NAME1);
gitAccess.createBranch(LOCAL_BRANCH_NAME2);
gitAccess.setRepositorySynchronously(REMOTE_TEST_REPOSITORY);
file = new File(REMOTE_TEST_REPOSITORY + "remote1.txt");
file.createNewFile();
setFileContent(file, "remote content");
// Make the first commit for the remote repository and create a branch for it.
gitAccess.add(new FileStatus(GitChangeType.ADD, "remote1.txt"));
gitAccess.commit("First remote commit.");
gitAccess.createBranch(REMOTE_BRANCH_NAME1);
gitAccess.createBranch(REMOTE_BRANCH_NAME2);
gitAccess.setRepositorySynchronously(LOCAL_TEST_REPOSITORY);
gitAccess.fetch();
BranchManagementPanel branchManagementPanel = new BranchManagementPanel(Mockito.mock(GitControllerBase.class));
branchManagementPanel.refreshBranches();
flushAWT();
branchManagementPanel.filterTree("ewu82m");
flushAWT();
GitTreeNode root = (GitTreeNode) (branchManagementPanel.getTree().getModel().getRoot());
StringBuilder actualTree = new StringBuilder();
serializeTree(actualTree, root);
assertEquals("localRepository\n", actualTree.toString());
branchManagementPanel.filterTree("ai");
flushAWT();
root = (GitTreeNode) (branchManagementPanel.getTree().getModel().getRoot());
actualTree = new StringBuilder();
serializeTree(actualTree, root);
assertEquals("localRepository\n" + " refs/heads/\n" + " refs/heads/" + GitAccess.DEFAULT_BRANCH_NAME + "\n" + " refs/remotes/\n" + " refs/remotes/fork/\n" + " refs/remotes/fork/" + GitAccess.DEFAULT_BRANCH_NAME + "\n" + " refs/remotes/origin/\n" + " refs/remotes/origin/" + GitAccess.DEFAULT_BRANCH_NAME + "\n", actualTree.toString());
branchManagementPanel.filterTree("Branch");
flushAWT();
root = (GitTreeNode) (branchManagementPanel.getTree().getModel().getRoot());
actualTree = new StringBuilder();
serializeTree(actualTree, root);
assertEquals("localRepository\n" + " refs/heads/\n" + " refs/heads/LocalBranch\n" + " refs/heads/LocalBranch2\n" + " refs/remotes/\n" + " refs/remotes/fork/\n" + " refs/remotes/fork/RemoteBranch\n" + " refs/remotes/fork/RemoteBranch2\n" + " refs/remotes/origin/\n" + " refs/remotes/origin/RemoteBranch\n" + " refs/remotes/origin/RemoteBranch2\n", actualTree.toString());
branchManagementPanel.filterTree("2");
flushAWT();
root = (GitTreeNode) (branchManagementPanel.getTree().getModel().getRoot());
actualTree = new StringBuilder();
serializeTree(actualTree, root);
assertEquals("localRepository\n" + " refs/heads/\n" + " refs/heads/LocalBranch2\n" + " refs/remotes/\n" + " refs/remotes/fork/\n" + " refs/remotes/fork/RemoteBranch2\n" + " refs/remotes/origin/\n" + " refs/remotes/origin/RemoteBranch2\n" + "", actualTree.toString());
branchManagementPanel.filterTree("al");
flushAWT();
root = (GitTreeNode) (branchManagementPanel.getTree().getModel().getRoot());
actualTree = new StringBuilder();
serializeTree(actualTree, root);
assertEquals("localRepository\n" + " refs/heads/\n" + " refs/heads/LocalBranch\n" + " refs/heads/LocalBranch2\n" + "", actualTree.toString());
branchManagementPanel.filterTree("Rem");
flushAWT();
root = (GitTreeNode) (branchManagementPanel.getTree().getModel().getRoot());
actualTree = new StringBuilder();
serializeTree(actualTree, root);
assertEquals("localRepository\n" + " refs/remotes/\n" + " refs/remotes/fork/\n" + " refs/remotes/fork/RemoteBranch\n" + " refs/remotes/fork/RemoteBranch2\n" + " refs/remotes/origin/\n" + " refs/remotes/origin/RemoteBranch\n" + " refs/remotes/origin/RemoteBranch2\n" + "", actualTree.toString());
branchManagementPanel.filterTree("ai");
flushAWT();
root = (GitTreeNode) (branchManagementPanel.getTree().getModel().getRoot());
actualTree = new StringBuilder();
serializeTree(actualTree, root);
assertEquals("localRepository\n" + " refs/heads/\n" + " refs/heads/" + GitAccess.DEFAULT_BRANCH_NAME + "\n" + " refs/remotes/\n" + " refs/remotes/fork/\n" + " refs/remotes/fork/" + GitAccess.DEFAULT_BRANCH_NAME + "\n" + " refs/remotes/origin/\n" + " refs/remotes/origin/" + GitAccess.DEFAULT_BRANCH_NAME + "\n" + "", actualTree.toString());
branchManagementPanel.filterTree("a");
flushAWT();
root = (GitTreeNode) (branchManagementPanel.getTree().getModel().getRoot());
actualTree = new StringBuilder();
serializeTree(actualTree, root);
assertEquals("localRepository\n" + " refs/heads/\n" + " refs/heads/LocalBranch\n" + " refs/heads/LocalBranch2\n" + " refs/heads/" + GitAccess.DEFAULT_BRANCH_NAME + "\n" + " refs/remotes/\n" + " refs/remotes/fork/\n" + " refs/remotes/fork/" + GitAccess.DEFAULT_BRANCH_NAME + "\n" + " refs/remotes/fork/RemoteBranch\n" + " refs/remotes/fork/RemoteBranch2\n" + " refs/remotes/origin/\n" + " refs/remotes/origin/" + GitAccess.DEFAULT_BRANCH_NAME + "\n" + " refs/remotes/origin/RemoteBranch\n" + " refs/remotes/origin/RemoteBranch2\n" + "", actualTree.toString());
}
use of com.oxygenxml.git.view.GitTreeNode in project oxygen-git-client-addon by oxygenxml.
the class BranchManagementTest method testBranchesTreeFilterLocalBranchesOnly.
/**
* <p><b>Description:</b> Tests the filter for branches on a tree with only local branches.</p>
* <p><b>Bug ID:</b> EXM-41701</p>
*
* @author bogdan_draghici
*
* @throws Exception
*/
@Test
public void testBranchesTreeFilterLocalBranchesOnly() throws Exception {
File file = new File(LOCAL_TEST_REPOSITORY + "local.txt");
file.createNewFile();
setFileContent(file, "local content");
// Make the first commit for the local repository and create a branch for it.
gitAccess.add(new FileStatus(GitChangeType.ADD, "local.txt"));
gitAccess.commit("First local commit.");
gitAccess.createBranch(LOCAL_BRANCH_NAME1);
gitAccess.createBranch(LOCAL_BRANCH_NAME2);
gitAccess.fetch();
BranchManagementPanel branchManagementPanel = new BranchManagementPanel(Mockito.mock(GitControllerBase.class));
branchManagementPanel.refreshBranches();
flushAWT();
branchManagementPanel.filterTree("hedz");
flushAWT();
GitTreeNode root = (GitTreeNode) (branchManagementPanel.getTree().getModel().getRoot());
StringBuilder actualTree = new StringBuilder();
serializeTree(actualTree, root);
assertEquals("localRepository\n", actualTree.toString());
branchManagementPanel.filterTree("Local");
flushAWT();
root = (GitTreeNode) (branchManagementPanel.getTree().getModel().getRoot());
actualTree = new StringBuilder();
serializeTree(actualTree, root);
assertEquals("localRepository\n" + " refs/heads/\n" + " refs/heads/LocalBranch\n" + " refs/heads/LocalBranch2\n", actualTree.toString());
branchManagementPanel.filterTree("in");
flushAWT();
root = (GitTreeNode) (branchManagementPanel.getTree().getModel().getRoot());
actualTree = new StringBuilder();
serializeTree(actualTree, root);
assertEquals("localRepository\n" + " refs/heads/\n" + " refs/heads/" + GitAccess.DEFAULT_BRANCH_NAME + "\n", actualTree.toString());
branchManagementPanel.filterTree("h2");
flushAWT();
root = (GitTreeNode) (branchManagementPanel.getTree().getModel().getRoot());
actualTree = new StringBuilder();
serializeTree(actualTree, root);
assertEquals("localRepository\n" + " refs/heads/\n" + " refs/heads/LocalBranch2\n", actualTree.toString());
}
use of com.oxygenxml.git.view.GitTreeNode in project oxygen-git-client-addon by oxygenxml.
the class BranchManagementTest method testBranchesTreeToolTipsDeletedBranch.
/**
* <p><b>Description:</b> Tests the tool tips for deleted branches on a tree with both local and remote branches.</p>
* <p><b>Bug ID:</b> EXM-48768</p>
*
* @author Alex_Smarandache
*
* @throws Exception
*/
@Test
public void testBranchesTreeToolTipsDeletedBranch() throws Exception {
// Local repo
File file = new File(LOCAL_TEST_REPOSITORY + "local.txt");
file.createNewFile();
setFileContent(file, "local content");
gitAccess.add(new FileStatus(GitChangeType.ADD, "local.txt"));
gitAccess.commit("First local commit.");
gitAccess.createBranch(LOCAL_BRANCH_NAME1);
gitAccess.createBranch(LOCAL_BRANCH_NAME2);
// Remote repo
gitAccess.setRepositorySynchronously(REMOTE_TEST_REPOSITORY);
file = new File(REMOTE_TEST_REPOSITORY + "remote1.txt");
file.createNewFile();
setFileContent(file, "remote content");
gitAccess.add(new FileStatus(GitChangeType.ADD, "remote1.txt"));
gitAccess.commit("First remote commit.");
gitAccess.createBranch(REMOTE_BRANCH_NAME1);
gitAccess.createBranch(REMOTE_BRANCH_NAME2);
// Local repo again
gitAccess.setRepositorySynchronously(LOCAL_TEST_REPOSITORY);
gitAccess.fetch();
BranchManagementPanel branchManagementPanel = new BranchManagementPanel(Mockito.mock(GitControllerBase.class));
branchManagementPanel.refreshBranches();
flushAWT();
JTree tree = branchManagementPanel.getTree();
gitAccess.deleteBranch(LOCAL_BRANCH_NAME2);
GitTreeNode root = (GitTreeNode) (branchManagementPanel.getTree().getModel().getRoot());
DefaultMutableTreeNode leaf = root.getFirstLeaf();
JLabel rendererLabel = (JLabel) tree.getCellRenderer().getTreeCellRendererComponent(tree, leaf, false, true, true, 2, true);
assertEquals("<html><p>Local_branch LocalBranch<br><br>" + "Last_Commit_Details:<br>" + "- Author: AlexJitianu <alex_jitianu@sync.ro><br> " + "- Date: {date}</p></html>".replaceAll("\\{date\\}", DATE_FORMAT.format(new Date())), rendererLabel.getToolTipText());
leaf = leaf.getNextLeaf();
rendererLabel = (JLabel) tree.getCellRenderer().getTreeCellRendererComponent(tree, leaf, false, true, true, 3, true);
assertNull(rendererLabel.getToolTipText());
}
use of com.oxygenxml.git.view.GitTreeNode in project oxygen-git-client-addon by oxygenxml.
the class BranchManagementTest method testBranchesTreeToolTips.
/**
* <p><b>Description:</b> Tests the tool tips for branches on a tree with both local and remote branches.</p>
* <p><b>Bug ID:</b> EXM-46438</p>
*
* @author Alex_Smarandache
*
* @throws Exception
*/
@Test
public void testBranchesTreeToolTips() throws Exception {
// Local repo
File file = new File(LOCAL_TEST_REPOSITORY + "local.txt");
file.createNewFile();
setFileContent(file, "local content");
gitAccess.add(new FileStatus(GitChangeType.ADD, "local.txt"));
gitAccess.commit("First local commit.");
gitAccess.createBranch(LOCAL_BRANCH_NAME1);
gitAccess.createBranch(LOCAL_BRANCH_NAME2);
// Remote repo
gitAccess.setRepositorySynchronously(REMOTE_TEST_REPOSITORY);
file = new File(REMOTE_TEST_REPOSITORY + "remote1.txt");
file.createNewFile();
setFileContent(file, "remote content");
gitAccess.add(new FileStatus(GitChangeType.ADD, "remote1.txt"));
gitAccess.commit("First remote commit.");
gitAccess.createBranch(REMOTE_BRANCH_NAME1);
gitAccess.createBranch(REMOTE_BRANCH_NAME2);
// Local repo again
gitAccess.setRepositorySynchronously(LOCAL_TEST_REPOSITORY);
gitAccess.fetch();
BranchManagementPanel branchManagementPanel = new BranchManagementPanel(Mockito.mock(GitControllerBase.class));
branchManagementPanel.refreshBranches();
flushAWT();
JTree tree = branchManagementPanel.getTree();
GitTreeNode root = (GitTreeNode) (branchManagementPanel.getTree().getModel().getRoot());
DefaultMutableTreeNode leaf = root.getFirstLeaf();
JLabel rendererLabel = (JLabel) tree.getCellRenderer().getTreeCellRendererComponent(tree, leaf, false, true, true, 2, true);
assertEquals("<html><p>Local_branch LocalBranch<br><br>" + "Last_Commit_Details:<br>" + "- Author: AlexJitianu <alex_jitianu@sync.ro><br> " + "- Date: {date}</p></html>".replaceAll("\\{date\\}", DATE_FORMAT.format(new Date())), rendererLabel.getToolTipText());
leaf = leaf.getNextLeaf();
rendererLabel = (JLabel) tree.getCellRenderer().getTreeCellRendererComponent(tree, leaf, false, true, true, 3, true);
assertEquals("<html><p>Local_branch LocalBranch2<br><br>" + "Last_Commit_Details:<br>" + "- Author: AlexJitianu <alex_jitianu@sync.ro><br> " + "- Date: {date}</p></html>".replaceAll("\\{date\\}", DATE_FORMAT.format(new Date())), rendererLabel.getToolTipText());
leaf = leaf.getNextLeaf();
rendererLabel = (JLabel) tree.getCellRenderer().getTreeCellRendererComponent(tree, leaf, false, true, true, 4, true);
assertEquals("<html><p>Local_branch main<br>" + // Also has upstream
"Upstream_branch origin/main<br><br>" + "Last_Commit_Details:<br>" + "- Author: AlexJitianu <alex_jitianu@sync.ro><br> " + "- Date: {date}</p></html>".replaceAll("\\{date\\}", DATE_FORMAT.format(new Date())), rendererLabel.getToolTipText());
leaf = leaf.getNextLeaf();
rendererLabel = (JLabel) tree.getCellRenderer().getTreeCellRendererComponent(tree, leaf, false, true, true, 7, true);
String remoteURL = gitAccess.getRemoteURLFromConfig();
assertEquals("<html><p>Remote_branch origin/main<br>" + "Clone_Repository_Dialog_Url_Label: " + "<a href=\"" + remoteURL + "\">" + remoteURL + "</a><br><br>" + "Last_Commit_Details:<br>" + "- Author: AlexJitianu <alex_jitianu@sync.ro><br> " + "- Date: {date}</p></html>".replaceAll("\\{date\\}", DATE_FORMAT.format(new Date())), rendererLabel.getToolTipText());
leaf = leaf.getNextLeaf();
rendererLabel = (JLabel) tree.getCellRenderer().getTreeCellRendererComponent(tree, leaf, false, true, true, 8, true);
assertEquals("<html><p>Remote_branch origin/RemoteBranch<br>" + "Clone_Repository_Dialog_Url_Label: " + "<a href=\"" + remoteURL + "\">" + remoteURL + "</a><br><br>" + "Last_Commit_Details:<br>" + "- Author: AlexJitianu <alex_jitianu@sync.ro><br> " + "- Date: {date}</p></html>".replaceAll("\\{date\\}", DATE_FORMAT.format(new Date())), rendererLabel.getToolTipText());
leaf = leaf.getNextLeaf();
rendererLabel = (JLabel) tree.getCellRenderer().getTreeCellRendererComponent(tree, leaf, false, true, true, 9, true);
assertEquals("<html><p>Remote_branch origin/RemoteBranch2<br>" + "Clone_Repository_Dialog_Url_Label: " + "<a href=\"" + remoteURL + "\">" + remoteURL + "</a><br><br>" + "Last_Commit_Details:<br>" + "- Author: AlexJitianu <alex_jitianu@sync.ro><br> " + "- Date: {date}</p></html>".replaceAll("\\{date\\}", DATE_FORMAT.format(new Date())), rendererLabel.getToolTipText());
assertNull(leaf.getNextLeaf());
}
Aggregations