use of com.jidesoft.swing.JideToggleButton in project oxygen-git-client-addon by oxygenxml.
the class FlatView5Test method testAmendCommitThatWasPushed_editCommitMesage.
/**
* <p><b>Description:</b> Amend commit that was pushed. Edit commit message.</p>
* <p><b>Bug ID:</b> EXM-41392</p>
*
* @author sorin_carbunaru
*
* @throws Exception
*/
public void testAmendCommitThatWasPushed_editCommitMesage() throws Exception {
// Create repositories
String localTestRepository = "target/test-resources/testAmendCommitThatWasPushed_2_local";
String remoteTestRepository = "target/test-resources/testAmendCommitThatWasPushed_2_remote";
Repository remoteRepo = createRepository(remoteTestRepository);
Repository localRepo = createRepository(localTestRepository);
bindLocalToRemote(localRepo, remoteRepo);
pushOneFileToRemote(localTestRepository, "init.txt", "hello");
flushAWT();
// Create a new file
new File(localTestRepository).mkdirs();
createNewFile(localTestRepository, "test.txt", "content");
// No amend by default
CommitAndStatusPanel commitPanel = stagingPanel.getCommitPanel();
JideToggleButton amendBtn = commitPanel.getAmendLastCommitToggle();
assertFalse(amendBtn.isSelected());
// >>> Stage
add(new FileStatus(GitChangeType.ADD, "test.txt"));
// >>> Commit the test file
assertEquals(0, GitAccess.getInstance().getPushesAhead());
SwingUtilities.invokeLater(() -> {
commitPanel.getCommitMessageArea().setText("FIRST COMMIT MESSAGE");
commitPanel.getCommitButton().doClick();
});
waitForScheluerBetter();
assertEquals(1, GitAccess.getInstance().getPushesAhead());
// >>> Push
push("", "");
waitForScheluerBetter();
refreshSupport.call();
waitForScheluerBetter();
assertEquals(0, GitAccess.getInstance().getPushesAhead());
SwingUtilities.invokeLater(() -> {
commitPanel.getCommitMessageArea().setText("SECOND COMMIT MESSAGE");
});
flushAWT();
PluginWorkspace pluginWSMock = Mockito.mock(StandalonePluginWorkspace.class);
Mockito.when(pluginWSMock.showConfirmDialog(Mockito.anyString(), Mockito.anyString(), Mockito.any(), Mockito.any())).thenReturn(0);
PluginWorkspaceProvider.setPluginWorkspace(pluginWSMock);
SwingUtilities.invokeLater(() -> amendBtn.setSelected(true));
waitForScheluerBetter();
flushAWT();
// The amend was cancelled. We must not see the first commit message.
assertEquals("SECOND COMMIT MESSAGE", commitPanel.getCommitMessageArea().getText());
// Not enabled because we have don't have staged files.
assertFalse(commitPanel.getCommitButton().isEnabled());
assertFalse(amendBtn.isSelected());
}
use of com.jidesoft.swing.JideToggleButton in project oxygen-git-client-addon by oxygenxml.
the class FlatView9Test method testAmendCommitThatWasPushed_changeFileContent.
/**
* <p><b>Description:</b> Amend commit that was pushed. Change file content.</p>
* <p><b>Bug ID:</b> EXM-41392</p>
*
* @author sorin_carbunaru
*
* @throws Exception
*/
@Test
public void testAmendCommitThatWasPushed_changeFileContent() throws Exception {
// Create repositories
String localTestRepository = "target/test-resources/testAmendCommitThatWasPushed_1_local";
String remoteTestRepository = "target/test-resources/testAmendCommitThatWasPushed_1_remote";
Repository remoteRepo = createRepository(remoteTestRepository);
Repository localRepo = createRepository(localTestRepository);
bindLocalToRemote(localRepo, remoteRepo);
pushOneFileToRemote(localTestRepository, "init.txt", "hello");
flushAWT();
// Create a new file
new File(localTestRepository).mkdirs();
File file = createNewFile(localTestRepository, "test.txt", "content");
// No amend by default
CommitAndStatusPanel commitPanel = stagingPanel.getCommitPanel();
JideToggleButton amendBtn = commitPanel.getAmendLastCommitToggle();
assertFalse(amendBtn.isSelected());
// >>> Stage
add(new FileStatus(GitChangeType.ADD, "test.txt"));
// >>> Commit the test file
assertEquals(0, GitAccess.getInstance().getPushesAhead());
SwingUtilities.invokeLater(() -> {
commitPanel.getCommitMessageArea().setText("FIRST COMMIT MESSAGE");
commitPanel.getCommitButton().doClick();
});
waitForScheluerBetter();
assertEquals(1, GitAccess.getInstance().getPushesAhead());
// >>> Push
push("", "");
waitForScheluerBetter();
refreshSupport.call();
waitForScheluerBetter();
assertEquals(0, GitAccess.getInstance().getPushesAhead());
// Change the file again.
setFileContent(file, "modified");
add(new FileStatus(GitChangeType.ADD, "test.txt"));
flushAWT();
SwingUtilities.invokeLater(() -> {
commitPanel.getCommitMessageArea().setText("SECOND COMMIT MESSAGE");
});
flushAWT();
PluginWorkspace pluginWSMock = Mockito.mock(StandalonePluginWorkspace.class);
Mockito.when(pluginWSMock.showConfirmDialog(Mockito.anyString(), Mockito.anyString(), Mockito.any(), Mockito.any())).thenReturn(0);
PluginWorkspaceProvider.setPluginWorkspace(pluginWSMock);
assertTrue(commitPanel.getCommitButton().isEnabled());
SwingUtilities.invokeLater(() -> amendBtn.setSelected(true));
waitForScheluerBetter();
flushAWT();
// The amend was cancelled. We must not see the first commit message.
assertEquals("SECOND COMMIT MESSAGE", commitPanel.getCommitMessageArea().getText());
// Still enabled because we have a staged file
assertTrue(commitPanel.getCommitButton().isEnabled());
assertFalse(amendBtn.isSelected());
}
Aggregations