use of com.oxygenxml.git.view.remotes.RemotesRepositoryDialog in project oxygen-git-client-addon by oxygenxml.
the class RemoteVisualTests method testManageBasicsRemote.
/**
* <p><b>Description:</b> Tests the action for manage remote from remote button of git staging toolbar.</p>
* <p><b>Bug ID:</b> EXM-40858</p>
*
* @author Alex_Smarandache
*
* @throws Exception
*/
public void testManageBasicsRemote() throws Exception {
gitAccess.setRepositorySynchronously(LOCAL_REPO);
gitAccess.createBranch(LOCAL_BRANCH);
gitAccess.fetch();
JFrame frame = new JFrame();
try {
// Init UI
GitController gitCtrl = new GitController();
GitActionsManager gitActionsManager = new GitActionsManager(gitCtrl, null, null, refreshSupport);
stagingPanel = new StagingPanel(refreshSupport, gitCtrl, null, gitActionsManager);
frame.getContentPane().add(stagingPanel);
frame.pack();
frame.setVisible(true);
flushAWT();
refreshSupport.call();
flushAWT();
SwingUtilities.invokeLater(() -> gitActionsManager.getManageRemoteRepositoriesAction().actionPerformed(null));
flushAWT();
// -----> TEST ADD REMOTE OPTION <----- //
RemotesRepositoryDialog[] manageRemoteDialog = new RemotesRepositoryDialog[1];
manageRemoteDialog[0] = (RemotesRepositoryDialog) findDialog(Tags.REMOTES_DIALOG_TITLE);
assertNotNull(manageRemoteDialog);
flushAWT();
RemotesTableModel model = manageRemoteDialog[0].getModel();
final String firstRemoteName = (String) model.getValueAt(0, 0);
final String firstRemoteURL = (String) model.getValueAt(0, 1);
assertEquals(1, model.getRowCount());
JButton doAddButton = findFirstButton(manageRemoteDialog[0], Tags.ADD + "...");
assertNotNull(doAddButton);
SwingUtilities.invokeLater(() -> doAddButton.doClick());
flushAWT();
OKCancelDialog addRemoteDialog = (OKCancelDialog) findDialog(Tags.ADD_REMOTE);
assertNotNull(addRemoteDialog);
flushAWT();
JTextField remoteNameTF = TestUtil.findFirstTextField(addRemoteDialog);
assertNotNull(remoteNameTF);
SwingUtilities.invokeLater(() -> remoteNameTF.setText("Custom remote"));
flushAWT();
JTextField[] remoteURLTF = new JTextField[1];
remoteURLTF[0] = TestUtil.findNthTextField(addRemoteDialog, 2);
assertNotNull(remoteURLTF[0]);
SwingUtilities.invokeLater(() -> remoteURLTF[0].setText("https/custom_link.ro"));
flushAWT();
sleep(500);
SwingUtilities.invokeLater(() -> addRemoteDialog.getOkButton().doClick());
flushAWT();
assertEquals(2, model.getRowCount());
assertEquals("Custom remote", (String) model.getValueAt(1, 0));
assertEquals("https/custom_link.ro", (String) model.getValueAt(1, 1));
flushAWT();
SwingUtilities.invokeLater(() -> manageRemoteDialog[0].getOkButton().doClick());
// Test if the remotes has been saved after confirmation.
SwingUtilities.invokeLater(() -> gitActionsManager.getManageRemoteRepositoriesAction().actionPerformed(null));
flushAWT();
manageRemoteDialog[0] = (RemotesRepositoryDialog) findDialog(Tags.REMOTES_DIALOG_TITLE);
assertNotNull(manageRemoteDialog);
flushAWT();
model = manageRemoteDialog[0].getModel();
assertEquals(2, model.getRowCount());
assertEquals("Custom remote", (String) model.getValueAt(0, 0));
assertEquals("https/custom_link.ro", (String) model.getValueAt(0, 1));
// -----> TEST EDIT REMOTE OPTION <----- //
JTable[] table = new JTable[1];
table[0] = manageRemoteDialog[0].getTable();
SwingUtilities.invokeLater(() -> table[0].addRowSelectionInterval(0, 0));
flushAWT();
JButton editButton = findFirstButton(manageRemoteDialog[0], Tags.EDIT);
assertNotNull(editButton);
SwingUtilities.invokeLater(() -> editButton.doClick());
flushAWT();
OKCancelDialog editRemoteDialog = (OKCancelDialog) findDialog(Tags.EDIT_REMOTE);
assertNotNull(editRemoteDialog);
flushAWT();
remoteURLTF[0] = TestUtil.findNthTextField(editRemoteDialog, 2);
assertNotNull(remoteURLTF[0]);
SwingUtilities.invokeLater(() -> remoteURLTF[0].setText("https/edit_link.ro"));
flushAWT();
sleep(500);
SwingUtilities.invokeLater(() -> editRemoteDialog.getOkButton().doClick());
flushAWT();
model = manageRemoteDialog[0].getModel();
assertEquals(2, model.getRowCount());
assertEquals("Custom remote", (String) model.getValueAt(0, 0));
assertEquals("https/edit_link.ro", (String) model.getValueAt(0, 1));
flushAWT();
SwingUtilities.invokeLater(() -> manageRemoteDialog[0].getOkButton().doClick());
// Test if the remotes has been saved after confirmation.
SwingUtilities.invokeLater(() -> gitActionsManager.getManageRemoteRepositoriesAction().actionPerformed(null));
flushAWT();
manageRemoteDialog[0] = (RemotesRepositoryDialog) findDialog(Tags.REMOTES_DIALOG_TITLE);
assertNotNull(manageRemoteDialog);
flushAWT();
model = manageRemoteDialog[0].getModel();
assertEquals(2, model.getRowCount());
assertEquals("Custom remote", (String) model.getValueAt(0, 0));
assertEquals("https/edit_link.ro", (String) model.getValueAt(0, 1));
// -----> TEST DELETE REMOTE OPTION <----- //
table[0] = manageRemoteDialog[0].getTable();
SwingUtilities.invokeLater(() -> table[0].addRowSelectionInterval(0, 0));
flushAWT();
JButton deleteButton = findFirstButton(manageRemoteDialog[0], Tags.DELETE);
assertNotNull(deleteButton);
SwingUtilities.invokeLater(() -> deleteButton.doClick());
flushAWT();
OKCancelDialog deleteRemoteDialog = (OKCancelDialog) findDialog(Tags.DELETE_REMOTE);
assertNotNull(deleteRemoteDialog);
flushAWT();
sleep(500);
SwingUtilities.invokeLater(() -> deleteRemoteDialog.getOkButton().doClick());
flushAWT();
model = manageRemoteDialog[0].getModel();
assertEquals(1, model.getRowCount());
assertEquals(firstRemoteName, (String) model.getValueAt(0, 0));
assertEquals(firstRemoteURL, (String) model.getValueAt(0, 1));
flushAWT();
SwingUtilities.invokeLater(() -> manageRemoteDialog[0].getOkButton().doClick());
// Test if the remotes has been saved after confirmation.
SwingUtilities.invokeLater(() -> gitActionsManager.getManageRemoteRepositoriesAction().actionPerformed(null));
flushAWT();
manageRemoteDialog[0] = (RemotesRepositoryDialog) findDialog(Tags.REMOTES_DIALOG_TITLE);
assertNotNull(manageRemoteDialog);
flushAWT();
model = manageRemoteDialog[0].getModel();
assertEquals(1, model.getRowCount());
assertEquals(firstRemoteName, (String) model.getValueAt(0, 0));
assertEquals(firstRemoteURL, (String) model.getValueAt(0, 1));
table[0] = manageRemoteDialog[0].getTable();
SwingUtilities.invokeLater(() -> table[0].addRowSelectionInterval(0, 0));
flushAWT();
JButton eButton = findFirstButton(manageRemoteDialog[0], Tags.EDIT);
assertNotNull(eButton);
SwingUtilities.invokeLater(() -> eButton.doClick());
flushAWT();
OKCancelDialog eRemoteDialog = (OKCancelDialog) findDialog(Tags.EDIT_REMOTE);
assertNotNull(eRemoteDialog);
flushAWT();
remoteURLTF[0] = TestUtil.findNthTextField(eRemoteDialog, 2);
assertNotNull(remoteURLTF[0]);
SwingUtilities.invokeLater(() -> remoteURLTF[0].setText("https/edit_link_test.ro"));
flushAWT();
sleep(500);
SwingUtilities.invokeLater(() -> eRemoteDialog.getOkButton().doClick());
flushAWT();
model = manageRemoteDialog[0].getModel();
assertEquals(1, model.getRowCount());
assertEquals(firstRemoteName, (String) model.getValueAt(0, 0));
assertEquals("https/edit_link_test.ro", (String) model.getValueAt(0, 1));
flushAWT();
SwingUtilities.invokeLater(() -> manageRemoteDialog[0].getCancelButton().doClick());
// Test if the remotes has not been saved after the user cancel dialog.
SwingUtilities.invokeLater(() -> gitActionsManager.getManageRemoteRepositoriesAction().actionPerformed(null));
flushAWT();
manageRemoteDialog[0] = (RemotesRepositoryDialog) findDialog(Tags.REMOTES_DIALOG_TITLE);
assertNotNull(manageRemoteDialog);
flushAWT();
model = manageRemoteDialog[0].getModel();
assertEquals(1, model.getRowCount());
assertEquals(firstRemoteName, (String) model.getValueAt(0, 0));
assertEquals(firstRemoteURL, (String) model.getValueAt(0, 1));
} finally {
frame.setVisible(false);
frame.dispose();
}
}
use of com.oxygenxml.git.view.remotes.RemotesRepositoryDialog in project oxygen-git-client-addon by oxygenxml.
the class RemoteVisualTests method testManageAdvancedRemote.
/**
* <p><b>Description:</b> Tests corner case when user tries to add an existing remote.</p>
* <p><b>Bug ID:</b> EXM-40858</p>
*
* @author Alex_Smarandache
*
* @throws Exception
*/
public void testManageAdvancedRemote() throws Exception {
gitAccess.setRepositorySynchronously(LOCAL_REPO);
gitAccess.createBranch(LOCAL_BRANCH);
gitAccess.fetch();
JFrame frame = new JFrame();
try {
// Init UI
GitController gitCtrl = new GitController();
GitActionsManager gitActionsManager = new GitActionsManager(gitCtrl, null, null, refreshSupport);
stagingPanel = new StagingPanel(refreshSupport, gitCtrl, null, gitActionsManager);
frame.getContentPane().add(stagingPanel);
frame.pack();
frame.setVisible(true);
flushAWT();
refreshSupport.call();
flushAWT();
SwingUtilities.invokeLater(() -> gitActionsManager.getManageRemoteRepositoriesAction().actionPerformed(null));
flushAWT();
RemotesRepositoryDialog[] manageRemoteDialog = new RemotesRepositoryDialog[1];
manageRemoteDialog[0] = (RemotesRepositoryDialog) findDialog(Tags.REMOTES_DIALOG_TITLE);
assertNotNull(manageRemoteDialog);
flushAWT();
RemotesTableModel model = manageRemoteDialog[0].getModel();
final String firstRemoteName = (String) model.getValueAt(0, 0);
assertEquals(1, model.getRowCount());
JButton doAddButton = findFirstButton(manageRemoteDialog[0], Tags.ADD + "...");
assertNotNull(doAddButton);
SwingUtilities.invokeLater(() -> doAddButton.doClick());
flushAWT();
OKCancelDialog addRemoteDialog = (OKCancelDialog) findDialog(Tags.ADD_REMOTE);
assertNotNull(addRemoteDialog);
flushAWT();
JTextField remoteNameTF = TestUtil.findFirstTextField(addRemoteDialog);
assertNotNull(remoteNameTF);
SwingUtilities.invokeLater(() -> remoteNameTF.setText(firstRemoteName));
flushAWT();
JTextField[] remoteURLTF = new JTextField[1];
remoteURLTF[0] = TestUtil.findNthTextField(addRemoteDialog, 2);
assertNotNull(remoteURLTF[0]);
SwingUtilities.invokeLater(() -> remoteURLTF[0].setText("https/custom_link.ro"));
flushAWT();
sleep(500);
SwingUtilities.invokeLater(() -> addRemoteDialog.getOkButton().doClick());
final OKCancelDialog confirmDialog = (OKCancelDialog) findDialog(Tags.ADD_REMOTE);
assertNotNull(confirmDialog);
SwingUtilities.invokeLater(() -> confirmDialog.getOkButton().doClick());
flushAWT();
assertEquals(1, model.getRowCount());
assertEquals(firstRemoteName, (String) model.getValueAt(0, 0));
assertEquals("https/custom_link.ro", (String) model.getValueAt(0, 1));
} finally {
frame.setVisible(false);
frame.dispose();
}
}
Aggregations