Search in sources :

Example 6 with StagingPanel

use of com.oxygenxml.git.view.staging.StagingPanel in project oxygen-git-client-addon by oxygenxml.

the class StashVisualTests method testListStashApplyAndPopAction.

/**
 * <p><b>Description:</b> Tests the "List stashes" apply and pop actions</p>
 * <p><b>Bug ID:</b> EXM-45983</p>
 *
 * @author Alex_Smarandache
 *
 * @throws Exception
 */
public void testListStashApplyAndPopAction() throws Exception {
    // Init UI
    JFrame frame = new JFrame();
    GitController gitCtrl = new GitController();
    GitActionsManager gitActionsManager = new GitActionsManager(gitCtrl, null, null, refreshSupport);
    stagingPanel = new StagingPanel(refreshSupport, gitCtrl, null, gitActionsManager);
    ToolbarPanel toolbarPanel = stagingPanel.getToolbarPanel();
    frame.getContentPane().add(stagingPanel);
    frame.pack();
    frame.setVisible(true);
    flushAWT();
    toolbarPanel.updateButtonsStates();
    refreshSupport.call();
    flushAWT();
    // Make the first commit for the local repository
    File file = new File(LOCAL_REPO, "local.txt");
    file.createNewFile();
    setFileContent(file, "local content");
    gitAccess.add(new FileStatus(GitChangeType.ADD, "local.txt"));
    gitAccess.commit("First local commit.");
    // Make the first commit for the remote repository
    gitAccess.setRepositorySynchronously(REMOTE_REPO);
    file = new File(REMOTE_REPO, "remote1.txt");
    file.createNewFile();
    setFileContent(file, "remote content");
    gitAccess.add(new FileStatus(GitChangeType.ADD, "remote1.txt"));
    gitAccess.commit("First remote commit.");
    // Switch back to local repo and create local branch
    gitAccess.setRepositorySynchronously(LOCAL_REPO);
    gitAccess.createBranch(LOCAL_BRANCH);
    gitAccess.fetch();
    try {
        SplitMenuButton stashButton = toolbarPanel.getStashButton();
        makeLocalChange("some_modification");
        flushAWT();
        JMenuItem[] stashChangesItem = new JMenuItem[1];
        stashChangesItem[0] = stashButton.getItem(0);
        SwingUtilities.invokeLater(() -> stashChangesItem[0].getAction().actionPerformed(null));
        flushAWT();
        // Stash changes and test if the actions become disabled.
        JDialog stashChangesDialog = findDialog(Tags.STASH_CHANGES);
        flushAWT();
        assertNotNull(stashChangesDialog);
        JButton doStashButton = findFirstButton(stashChangesDialog, Tags.STASH);
        assertNotNull(doStashButton);
        doStashButton.doClick();
        refreshSupport.call();
        flushAWT();
        assertEquals("local content", getFileContent(LOCAL_REPO + "/local.txt"));
        JMenuItem[] listStashesItem = new JMenuItem[1];
        listStashesItem[0] = stashButton.getItem(1);
        SwingUtilities.invokeLater(() -> listStashesItem[0].getAction().actionPerformed(null));
        flushAWT();
        ListStashesDialog listStashesDialog = (ListStashesDialog) findDialog(Tags.STASHES);
        flushAWT();
        assertNotNull(listStashesDialog);
        JCheckBox[] popStashCheckBox = new JCheckBox[1];
        flushAWT();
        popStashCheckBox[0] = findCheckBox(listStashesDialog, Tags.DELETE_STASH_AFTER_APPLIED);
        assertNotNull(popStashCheckBox[0]);
        SwingUtilities.invokeLater(() -> popStashCheckBox[0].setSelected(true));
        flushAWT();
        List<RevCommit> stashes = new ArrayList<>(gitAccess.listStashes());
        assertFalse(stashes.isEmpty());
        assertEquals(1, listStashesDialog.getStashesTable().getRowCount());
        JButton[] applyButton = new JButton[1];
        flushAWT();
        applyButton[0] = findFirstButton(listStashesDialog, Tags.APPLY);
        assertNotNull(applyButton[0]);
        SwingUtilities.invokeLater(() -> applyButton[0].doClick());
        flushAWT();
        // Check if the stash was been deleted and applied
        stashes = new ArrayList<>(gitAccess.listStashes());
        assertTrue(stashes.isEmpty());
        assertEquals(0, listStashesDialog.getStashesTable().getRowCount());
        assertEquals("some_modification", getFileContent(LOCAL_REPO + "/local.txt"));
        JButton cancelButton = findFirstButton(listStashesDialog, Tags.CLOSE);
        assertNotNull(cancelButton);
        cancelButton.doClick();
        stashChangesItem[0] = stashButton.getItem(0);
        SwingUtilities.invokeLater(() -> stashChangesItem[0].getAction().actionPerformed(null));
        flushAWT();
        stashChangesDialog = findDialog(Tags.STASH_CHANGES);
        assertNotNull(stashChangesDialog);
        doStashButton = findFirstButton(stashChangesDialog, Tags.STASH);
        assertNotNull(doStashButton);
        doStashButton.doClick();
        refreshSupport.call();
        flushAWT();
        assertEquals("local content", getFileContent(LOCAL_REPO + "/local.txt"));
        listStashesItem[0] = stashButton.getItem(1);
        SwingUtilities.invokeLater(() -> listStashesItem[0].getAction().actionPerformed(null));
        listStashesDialog = (ListStashesDialog) findDialog(Tags.STASHES);
        assertNotNull(listStashesDialog);
        popStashCheckBox[0] = findCheckBox(listStashesDialog, Tags.DELETE_STASH_AFTER_APPLIED);
        assertNotNull(popStashCheckBox[0]);
        SwingUtilities.invokeLater(() -> popStashCheckBox[0].setSelected(false));
        flushAWT();
        applyButton[0] = findFirstButton(listStashesDialog, Tags.APPLY);
        assertNotNull(applyButton[0]);
        SwingUtilities.invokeLater(() -> applyButton[0].doClick());
        flushAWT();
        stashes = new ArrayList<>(gitAccess.listStashes());
        assertFalse(stashes.isEmpty());
        assertEquals(1, listStashesDialog.getStashesTable().getRowCount());
        assertEquals("some_modification", getFileContent(LOCAL_REPO + "/local.txt"));
        cancelButton = findFirstButton(listStashesDialog, Tags.CLOSE);
        assertNotNull(cancelButton);
        cancelButton.doClick();
    } finally {
        frame.setVisible(false);
        frame.dispose();
    }
}
Also used : FileStatus(com.oxygenxml.git.service.entities.FileStatus) SplitMenuButton(ro.sync.exml.workspace.api.standalone.ui.SplitMenuButton) JButton(javax.swing.JButton) ArrayList(java.util.ArrayList) GitController(com.oxygenxml.git.view.event.GitController) ListStashesDialog(com.oxygenxml.git.view.stash.ListStashesDialog) GitActionsManager(com.oxygenxml.git.view.actions.GitActionsManager) JCheckBox(javax.swing.JCheckBox) JFrame(javax.swing.JFrame) JMenuItem(javax.swing.JMenuItem) File(java.io.File) StagingPanel(com.oxygenxml.git.view.staging.StagingPanel) ToolbarPanel(com.oxygenxml.git.view.staging.ToolbarPanel) JDialog(javax.swing.JDialog) RevCommit(org.eclipse.jgit.revwalk.RevCommit)

Example 7 with StagingPanel

use of com.oxygenxml.git.view.staging.StagingPanel in project oxygen-git-client-addon by oxygenxml.

the class ToolbarPanelTest method testButtonsWhenNoRepo.

/**
 * <p><b>Description:</b> when trying to switch to another branch from the branches menu
 * and the checkout fails, tests the dialog</p>
 * <p><b>Bug ID:</b> EXM-48502</p>
 *
 * @author Alex_Smarandache
 *
 * @throws Exception
 */
public void testButtonsWhenNoRepo() throws Exception {
    File testDir = new File(String.format("target/test-resources/ToolbarPanelTest/%s", this.getName()));
    try {
        GitController gitCtrl = new GitController();
        GitActionsManager gitActionsManager = new GitActionsManager(gitCtrl, null, null, refreshSupport);
        stagingPanel = new StagingPanel(refreshSupport, gitCtrl, null, gitActionsManager);
        refreshSupport.setStagingPanel(stagingPanel);
        ToolbarPanel toolbar = stagingPanel.getToolbarPanel();
        assertFalse("No repo, the button should be disabled.", toolbar.getPullMenuButton().isEnabled());
        assertFalse(toolbar.getPushButton().isEnabled());
        assertFalse(toolbar.getStashButton().isEnabled());
        // Creates repos
        String local = String.format("target/test-resources/ToolbarPanelTest/%s/localRepository", this.getName());
        String remote = String.format("target/test-resources/ToolbarPanelTest/%s/remoteRepository", this.getName());
        // Creates the remote repository.
        createRepo(remote, local);
        Repository remoteRepository = createRepository(remote);
        Repository localRepository = createRepository(local);
        bindLocalToRemote(localRepository, remoteRepository);
        flushAWT();
        assertTrue("Pull Merge action should be enabled.", gitActionsManager.getPullMergeAction().isEnabled());
        assertTrue("Pull Rebase action should be enabled.", gitActionsManager.getPullRebaseAction().isEnabled());
        assertTrue(toolbar.getPullMenuButton().isEnabled());
        assertTrue("Push action should be enabled.", gitActionsManager.getPushAction().isEnabled());
        assertTrue(toolbar.getPushButton().isEnabled());
        assertFalse(toolbar.getStashButton().isEnabled());
    } finally {
        FileSystemUtil.deleteRecursivelly(testDir);
    }
}
Also used : Repository(org.eclipse.jgit.lib.Repository) GitController(com.oxygenxml.git.view.event.GitController) File(java.io.File) StagingPanel(com.oxygenxml.git.view.staging.StagingPanel) ToolbarPanel(com.oxygenxml.git.view.staging.ToolbarPanel) GitActionsManager(com.oxygenxml.git.view.actions.GitActionsManager)

Example 8 with StagingPanel

use of com.oxygenxml.git.view.staging.StagingPanel 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();
    }
}
Also used : JButton(javax.swing.JButton) OKCancelDialog(ro.sync.exml.workspace.api.standalone.ui.OKCancelDialog) GitController(com.oxygenxml.git.view.event.GitController) RemotesTableModel(com.oxygenxml.git.view.remotes.RemotesTableModel) JTextField(javax.swing.JTextField) GitActionsManager(com.oxygenxml.git.view.actions.GitActionsManager) JFrame(javax.swing.JFrame) RemotesRepositoryDialog(com.oxygenxml.git.view.remotes.RemotesRepositoryDialog) JTable(javax.swing.JTable) StagingPanel(com.oxygenxml.git.view.staging.StagingPanel)

Example 9 with StagingPanel

use of com.oxygenxml.git.view.staging.StagingPanel in project oxygen-git-client-addon by oxygenxml.

the class RemoteVisualTests method testEditGitConfigFile.

/**
 * <p><b>Description:</b> Tests the "Edit config" action from remote button of git staging toolbar.</p>
 * <p><b>Bug ID:</b> EXM-40858</p>
 *
 * @author Alex_Smarandache
 *
 * @throws Exception
 */
public void testEditGitConfigFile() throws Exception {
    String[] urlString = new String[1];
    String[] textTypeString = new String[1];
    ColorTheme colorTheme = Mockito.mock(ColorTheme.class);
    Mockito.when(colorTheme.isDarkTheme()).thenReturn(false);
    StandalonePluginWorkspace pluginWSMock = Mockito.mock(StandalonePluginWorkspace.class);
    Mockito.when(pluginWSMock.open((URL) Mockito.any(), (String) Mockito.any(), (String) Mockito.any())).then(new Answer<Boolean>() {

        @Override
        public Boolean answer(InvocationOnMock invocation) throws Throwable {
            urlString[0] = ((URL) invocation.getArgument(0)).toURI().toString();
            textTypeString[0] = (String) invocation.getArgument(2);
            return true;
        }
    });
    Mockito.when(pluginWSMock.getColorTheme()).thenReturn(colorTheme);
    PluginWorkspaceProvider.setPluginWorkspace(pluginWSMock);
    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.getEditConfigAction().actionPerformed(null));
        flushAWT();
        assertTrue(urlString[0].endsWith("target/test-resources/GitAccessRemote/localRepository/.git/config"));
        assertEquals("text/plain", textTypeString[0]);
    } finally {
        frame.setVisible(false);
        frame.dispose();
        PluginWorkspaceProvider.setPluginWorkspace(null);
    }
}
Also used : GitController(com.oxygenxml.git.view.event.GitController) GitActionsManager(com.oxygenxml.git.view.actions.GitActionsManager) JFrame(javax.swing.JFrame) ColorTheme(ro.sync.exml.workspace.api.util.ColorTheme) InvocationOnMock(org.mockito.invocation.InvocationOnMock) StandalonePluginWorkspace(ro.sync.exml.workspace.api.standalone.StandalonePluginWorkspace) StagingPanel(com.oxygenxml.git.view.staging.StagingPanel)

Example 10 with StagingPanel

use of com.oxygenxml.git.view.staging.StagingPanel 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();
    }
}
Also used : JFrame(javax.swing.JFrame) RemotesRepositoryDialog(com.oxygenxml.git.view.remotes.RemotesRepositoryDialog) JButton(javax.swing.JButton) OKCancelDialog(ro.sync.exml.workspace.api.standalone.ui.OKCancelDialog) GitController(com.oxygenxml.git.view.event.GitController) RemotesTableModel(com.oxygenxml.git.view.remotes.RemotesTableModel) JTextField(javax.swing.JTextField) StagingPanel(com.oxygenxml.git.view.staging.StagingPanel) GitActionsManager(com.oxygenxml.git.view.actions.GitActionsManager)

Aggregations

StagingPanel (com.oxygenxml.git.view.staging.StagingPanel)15 GitActionsManager (com.oxygenxml.git.view.actions.GitActionsManager)14 GitController (com.oxygenxml.git.view.event.GitController)14 JFrame (javax.swing.JFrame)13 File (java.io.File)10 JButton (javax.swing.JButton)10 FileStatus (com.oxygenxml.git.service.entities.FileStatus)9 JDialog (javax.swing.JDialog)8 ToolbarPanel (com.oxygenxml.git.view.staging.ToolbarPanel)7 JMenuItem (javax.swing.JMenuItem)6 SplitMenuButton (ro.sync.exml.workspace.api.standalone.ui.SplitMenuButton)6 ListStashesDialog (com.oxygenxml.git.view.stash.ListStashesDialog)5 ArrayList (java.util.ArrayList)5 RevCommit (org.eclipse.jgit.revwalk.RevCommit)5 JTextField (javax.swing.JTextField)3 RemotesRepositoryDialog (com.oxygenxml.git.view.remotes.RemotesRepositoryDialog)2 RemotesTableModel (com.oxygenxml.git.view.remotes.RemotesTableModel)2 BranchSelectionCombo (com.oxygenxml.git.view.staging.BranchSelectionCombo)2 JTable (javax.swing.JTable)2 Repository (org.eclipse.jgit.lib.Repository)2