Search in sources :

Example 1 with ConflictButtonsPanel

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

the class FlatView2Test method testShowInterruptedRebaseDlg_thenCancel.

/**
 * <p><b>Description:</b> Show interrupted rebase dialog and press cancel.</p>
 * <p><b>Bug ID:</b> EXM-42025</p>
 *
 * @author sorin_carbunaru
 *
 * @throws Exception If it fails.
 */
@Test
public void testShowInterruptedRebaseDlg_thenCancel() throws Exception {
    String localTestRepository_1 = "target/test-resources/testShowInterruptedRebaseDlg_thenCancel-local-1";
    String localTestRepository_2 = "target/test-resources/testShowInterruptedRebaseDlg_thenCancel-local-2";
    String remoteTestRepository = "target/test-resources/testShowInterruptedRebaseDlg_thenCancel-remote";
    // Create and repositories
    Repository remoteRepo = createRepository(remoteTestRepository);
    Repository localRepo_1 = createRepository(localTestRepository_1);
    Repository localRepo_2 = createRepository(localTestRepository_2);
    bindLocalToRemote(localRepo_1, remoteRepo);
    bindLocalToRemote(localRepo_2, remoteRepo);
    new File(localTestRepository_1).mkdirs();
    new File(localTestRepository_2).mkdirs();
    // --------------  REPO 1
    GitAccess.getInstance().setRepositorySynchronously(localTestRepository_1);
    File firstRepoFile = new File(localTestRepository_1 + "/test.txt");
    firstRepoFile.createNewFile();
    setFileContent(firstRepoFile, "First version");
    GitAccess.getInstance().add(new FileStatus(GitChangeType.UNKNOWN, "test.txt"));
    GitAccess.getInstance().commit("First commit.");
    push("", "");
    // ----------------- REPO 2
    GitAccess.getInstance().setRepositorySynchronously(localTestRepository_2);
    File secondRepoFile = new File(localTestRepository_2 + "/test.txt");
    refreshSupport.call();
    waitForScheduler();
    assertFalse(secondRepoFile.exists());
    pull("", "", PullType.REBASE, false);
    assertTrue(secondRepoFile.exists());
    // Modify file and commit and push
    setFileContent(secondRepoFile, "Second versions");
    GitAccess.getInstance().add(new FileStatus(GitChangeType.MODIFIED, "test.txt"));
    GitAccess.getInstance().commit("Second commit.");
    push("", "");
    // --------------  REPO 1
    GitAccess.getInstance().setRepositorySynchronously(localTestRepository_1);
    setFileContent(firstRepoFile, "Third version");
    GitAccess.getInstance().add(new FileStatus(GitChangeType.MODIFIED, "test.txt"));
    GitAccess.getInstance().commit("Third commit.");
    // Now pull to generate conflict
    ConflictButtonsPanel rebasePanel = stagingPanel.getConflictButtonsPanel();
    assertFalse(rebasePanel.isShowing());
    flushAWT();
    PullResponse pullResponse = pull("", "", PullType.REBASE, false);
    refreshSupport.call();
    waitForScheduler();
    assertEquals(PullStatus.CONFLICTS, pullResponse.getStatus());
    assertTrue(rebasePanel.isShowing());
    GitController ppc = (GitController) stagingPanel.getGitController();
    ppc.pull(PullType.REBASE);
    flushAWT();
    sleep(300);
    JDialog interruptedRebaseDlg = findDialog(Tags.REBASE_IN_PROGRESS);
    assertNotNull(interruptedRebaseDlg);
    JButton abortBtn = findFirstButton(interruptedRebaseDlg.getRootPane(), Translator.getInstance().getTranslation(Tags.CANCEL));
    abortBtn.doClick();
    flushAWT();
    sleep(1000);
    interruptedRebaseDlg = findDialog(Tags.REBASE_IN_PROGRESS);
    assertNull(interruptedRebaseDlg);
    assertTrue(rebasePanel.isShowing());
    assertTableModels(// Unstaged
    "CONFLICT, test.txt", // Staged
    "");
}
Also used : Repository(org.eclipse.jgit.lib.Repository) FileStatus(com.oxygenxml.git.service.entities.FileStatus) PullResponse(com.oxygenxml.git.service.PullResponse) ConflictButtonsPanel(com.oxygenxml.git.view.staging.ConflictButtonsPanel) JButton(javax.swing.JButton) GitController(com.oxygenxml.git.view.event.GitController) File(java.io.File) JDialog(javax.swing.JDialog) Test(org.junit.Test)

Example 2 with ConflictButtonsPanel

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

the class FlatView2Test method testShowInterruptedRebaseDlg_thenContinue.

/**
 * <p><b>Description:</b> Show interrupted rebase dialog and press continue.</p>
 * <p><b>Bug ID:</b> EXM-42025</p>
 *
 * @author sorin_carbunaru
 *
 * @throws Exception If it fails.
 */
@Test
public void testShowInterruptedRebaseDlg_thenContinue() throws Exception {
    try {
        String localTestRepository_1 = "target/test-resources/testShowInterruptedRebaseDlg_thenContinue-local-1";
        String localTestRepository_2 = "target/test-resources/testShowInterruptedRebaseDlg_thenContinue-local-2";
        String remoteTestRepository = "target/test-resources/testShowInterruptedRebaseDlg_thenContinue-remote";
        // Create and repositories
        Repository remoteRepo = createRepository(remoteTestRepository);
        Repository localRepo_1 = createRepository(localTestRepository_1);
        Repository localRepo_2 = createRepository(localTestRepository_2);
        bindLocalToRemote(localRepo_1, remoteRepo);
        bindLocalToRemote(localRepo_2, remoteRepo);
        new File(localTestRepository_1).mkdirs();
        new File(localTestRepository_2).mkdirs();
        // --------------  REPO 1
        GitAccess.getInstance().setRepositorySynchronously(localTestRepository_1);
        File firstRepoFile = new File(localTestRepository_1 + "/test.txt");
        firstRepoFile.createNewFile();
        setFileContent(firstRepoFile, "First version");
        GitAccess.getInstance().add(new FileStatus(GitChangeType.UNKNOWN, "test.txt"));
        GitAccess.getInstance().commit("First commit.");
        push("", "");
        // ----------------- REPO 2
        GitAccess.getInstance().setRepositorySynchronously(localTestRepository_2);
        File secondRepoFile = new File(localTestRepository_2 + "/test.txt");
        refreshSupport.call();
        flushAWT();
        sleep(400);
        assertFalse(secondRepoFile.exists());
        pull("", "", PullType.REBASE, false);
        assertTrue(secondRepoFile.exists());
        // Modify file and commit and push
        setFileContent(secondRepoFile, "Second versions");
        GitAccess.getInstance().add(new FileStatus(GitChangeType.MODIFIED, "test.txt"));
        GitAccess.getInstance().commit("Second commit.");
        push("", "");
        // --------------  REPO 1
        GitAccess.getInstance().setRepositorySynchronously(localTestRepository_1);
        setFileContent(firstRepoFile, "Third version");
        GitAccess.getInstance().add(new FileStatus(GitChangeType.MODIFIED, "test.txt"));
        GitAccess.getInstance().commit("Third commit.");
        // Now pull to generate conflict
        ConflictButtonsPanel rebasePanel = stagingPanel.getConflictButtonsPanel();
        assertFalse(rebasePanel.isShowing());
        flushAWT();
        PullResponse pullResponse = pull("", "", PullType.REBASE, false);
        refreshSupport.call();
        flushAWT();
        sleep(500);
        assertEquals(PullStatus.CONFLICTS, pullResponse.getStatus());
        assertTrue(rebasePanel.isShowing());
        // Pull again. Rebase in progress dialog is shown
        GitController ppc = (GitController) stagingPanel.getGitController();
        ppc.pull(PullType.REBASE);
        flushAWT();
        sleep(300);
        JDialog rebaseInProgressDlg = findDialog(Tags.REBASE_IN_PROGRESS);
        assertNotNull(rebaseInProgressDlg);
        // Get Cannot_continue_rebase_because_of_conflicts message
        final String[] errMessage = new String[1];
        StandalonePluginWorkspace mockedPluginWS = Mockito.mock(StandalonePluginWorkspace.class);
        Mockito.doAnswer(new Answer<Void>() {

            @Override
            public Void answer(InvocationOnMock invocation) throws Throwable {
                Object[] arguments = invocation.getArguments();
                if (arguments != null && arguments.length == 1) {
                    errMessage[0] = arguments[0].toString();
                }
                return null;
            }
        }).when(mockedPluginWS).showErrorMessage(Mockito.anyString());
        Mockito.when(mockedPluginWS.getParentFrame()).thenReturn(null);
        PluginWorkspaceProvider.setPluginWorkspace(mockedPluginWS);
        JButton continueBtn = findFirstButton(rebaseInProgressDlg.getRootPane(), Translator.getInstance().getTranslation(Tags.CONTINUE_REBASE));
        continueBtn.doClick();
        waitForScheduler();
        assertEquals("Cannot_continue_rebase_because_of_conflicts", errMessage[0]);
        // Resolve conflict
        GitControllerBase sc = new GitControllerBase(GitAccess.getInstance()) {

            @Override
            protected boolean isUserOKWithResolvingRebaseConflictUsingMineOrTheirs(ConflictResolution cmd) {
                return cmd == ConflictResolution.RESOLVE_USING_MINE;
            }
        };
        sc.asyncResolveUsingMine(Arrays.asList(new FileStatus(GitChangeType.CONFLICT, "test.txt")));
        flushAWT();
        // Pull again.
        ppc.pull(PullType.REBASE);
        flushAWT();
        sleep(300);
        // Rebase in progress dialog shown
        rebaseInProgressDlg = findDialog(Tags.REBASE_IN_PROGRESS);
        assertNotNull(rebaseInProgressDlg);
        // Now CONTINUE
        continueBtn = findFirstButton(rebaseInProgressDlg.getRootPane(), Translator.getInstance().getTranslation(Tags.CONTINUE_REBASE));
        continueBtn.doClick();
        flushAWT();
        waitForScheduler();
        sleep(1000);
        rebaseInProgressDlg = findDialog(Tags.REBASE_IN_PROGRESS);
        assertNull(rebaseInProgressDlg);
        assertFalse(rebasePanel.isShowing());
        assertTableModels(// Unstaged
        "", // Staged
        "");
    } finally {
        PluginWorkspaceProvider.setPluginWorkspace(null);
    }
}
Also used : FileStatus(com.oxygenxml.git.service.entities.FileStatus) JButton(javax.swing.JButton) GitController(com.oxygenxml.git.view.event.GitController) GitControllerBase(com.oxygenxml.git.service.GitControllerBase) Repository(org.eclipse.jgit.lib.Repository) PullResponse(com.oxygenxml.git.service.PullResponse) ConflictButtonsPanel(com.oxygenxml.git.view.staging.ConflictButtonsPanel) InvocationOnMock(org.mockito.invocation.InvocationOnMock) ConflictResolution(com.oxygenxml.git.service.ConflictResolution) StandalonePluginWorkspace(ro.sync.exml.workspace.api.standalone.StandalonePluginWorkspace) File(java.io.File) JDialog(javax.swing.JDialog) Test(org.junit.Test)

Example 3 with ConflictButtonsPanel

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

the class FlatView2Test method testShowInterruptedRebaseDlg_thenAbort.

/**
 * <p><b>Description:</b> Show interrupted rebase dialog and abort.</p>
 * <p><b>Bug ID:</b> EXM-42025</p>
 *
 * @author sorin_carbunaru
 *
 * @throws Exception If it fails.
 */
@Test
public void testShowInterruptedRebaseDlg_thenAbort() throws Exception {
    String localTestRepository_1 = "target/test-resources/testShowInterruptedRebaseDlg_thenAbort-local-1";
    String localTestRepository_2 = "target/test-resources/testShowInterruptedRebaseDlg_thenAbort-local-2";
    String remoteTestRepository = "target/test-resources/testShowInterruptedRebaseDlg_thenAbort-remote";
    // Create and repositories
    Repository remoteRepo = createRepository(remoteTestRepository);
    Repository localRepo_1 = createRepository(localTestRepository_1);
    Repository localRepo_2 = createRepository(localTestRepository_2);
    bindLocalToRemote(localRepo_1, remoteRepo);
    bindLocalToRemote(localRepo_2, remoteRepo);
    new File(localTestRepository_1).mkdirs();
    new File(localTestRepository_2).mkdirs();
    // --------------  REPO 1
    GitAccess.getInstance().setRepositorySynchronously(localTestRepository_1);
    File firstRepoFile = new File(localTestRepository_1 + "/test.txt");
    firstRepoFile.createNewFile();
    setFileContent(firstRepoFile, "First version");
    GitAccess.getInstance().add(new FileStatus(GitChangeType.UNKNOWN, "test.txt"));
    GitAccess.getInstance().commit("First commit.");
    push("", "");
    // ----------------- REPO 2
    GitAccess.getInstance().setRepositorySynchronously(localTestRepository_2);
    File secondRepoFile = new File(localTestRepository_2 + "/test.txt");
    refreshSupport.call();
    waitForScheduler();
    assertFalse(secondRepoFile.exists());
    pull("", "", PullType.REBASE, false);
    assertTrue(secondRepoFile.exists());
    // Modify file and commit and push
    setFileContent(secondRepoFile, "Second versions");
    GitAccess.getInstance().add(new FileStatus(GitChangeType.MODIFIED, "test.txt"));
    GitAccess.getInstance().commit("Second commit.");
    push("", "");
    // --------------  REPO 1
    GitAccess.getInstance().setRepositorySynchronously(localTestRepository_1);
    setFileContent(firstRepoFile, "Third version");
    GitAccess.getInstance().add(new FileStatus(GitChangeType.MODIFIED, "test.txt"));
    GitAccess.getInstance().commit("Third commit.");
    // Now pull to generate conflict
    ConflictButtonsPanel rebasePanel = stagingPanel.getConflictButtonsPanel();
    assertFalse(rebasePanel.isShowing());
    flushAWT();
    PullResponse pullResponse = pull("", "", PullType.REBASE, false);
    refreshSupport.call();
    waitForScheduler();
    assertEquals(PullStatus.CONFLICTS, pullResponse.getStatus());
    assertTrue(rebasePanel.isShowing());
    Semaphore s = new Semaphore(0);
    GitController ppc = new GitController() {

        @Override
        protected void showRebaseInProgressDialog() {
            s.release();
            super.showRebaseInProgressDialog();
        }
    };
    ppc.pull(PullType.REBASE);
    s.acquire();
    flushAWT();
    JDialog interruptedRebaseDlg = findDialog(Tags.REBASE_IN_PROGRESS);
    assertNotNull(interruptedRebaseDlg);
    JButton abortBtn = findFirstButton(interruptedRebaseDlg.getRootPane(), Translator.getInstance().getTranslation(Tags.ABORT_REBASE));
    abortBtn.doClick();
    waitForScheduler();
    flushAWT();
    interruptedRebaseDlg = findDialog(Tags.REBASE_IN_PROGRESS);
    assertNull(interruptedRebaseDlg);
    assertFalse(rebasePanel.isShowing());
    assertTableModels(// Unstaged
    "", // Staged
    "");
}
Also used : Repository(org.eclipse.jgit.lib.Repository) FileStatus(com.oxygenxml.git.service.entities.FileStatus) PullResponse(com.oxygenxml.git.service.PullResponse) ConflictButtonsPanel(com.oxygenxml.git.view.staging.ConflictButtonsPanel) JButton(javax.swing.JButton) GitController(com.oxygenxml.git.view.event.GitController) Semaphore(java.util.concurrent.Semaphore) File(java.io.File) JDialog(javax.swing.JDialog) Test(org.junit.Test)

Example 4 with ConflictButtonsPanel

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

the class FlatView10Test method testAbortMergeButton.

/**
 * <p><b>Description:</b> show/hide/click "Abort merge" button.</p>
 * <p><b>Bug ID:</b> EXM-46222</p>
 *
 * @author sorin_carbunaru
 *
 * @throws Exception If it fails.
 */
@Test
public void testAbortMergeButton() throws Exception {
    String localTestRepository_1 = "target/test-resources/testShowHideAbortMergeButton-local-1";
    String localTestRepository_2 = "target/test-resources/testShowHideAbortMergeButton-local-2";
    String remoteTestRepository = "target/test-resources/testShowHideAbortMergeButton-remote";
    // Create and repositories
    Repository remoteRepo = createRepository(remoteTestRepository);
    Repository localRepo_1 = createRepository(localTestRepository_1);
    Repository localRepo_2 = createRepository(localTestRepository_2);
    bindLocalToRemote(localRepo_1, remoteRepo);
    bindLocalToRemote(localRepo_2, remoteRepo);
    new File(localTestRepository_1).mkdirs();
    new File(localTestRepository_2).mkdirs();
    // --------------  REPO 1
    GitAccess.getInstance().setRepositorySynchronously(localTestRepository_1);
    File firstRepoFile = new File(localTestRepository_1 + "/test.txt");
    firstRepoFile.createNewFile();
    setFileContent(firstRepoFile, "First version");
    GitAccess.getInstance().add(new FileStatus(GitChangeType.UNKNOWN, "test.txt"));
    GitAccess.getInstance().commit("First commit.");
    push("", "");
    // ----------------- REPO 2
    GitAccess.getInstance().setRepositorySynchronously(localTestRepository_2);
    File secondRepoFile = new File(localTestRepository_2 + "/test.txt");
    refreshSupport.call();
    flushAWT();
    sleep(400);
    assertFalse(secondRepoFile.exists());
    pull("", "", PullType.MERGE_FF, false);
    assertTrue(secondRepoFile.exists());
    // Modify file and commit and push
    setFileContent(secondRepoFile, "Second versions");
    GitAccess.getInstance().add(new FileStatus(GitChangeType.MODIFIED, "test.txt"));
    GitAccess.getInstance().commit("Second commit.");
    push("", "");
    // --------------  REPO 1
    GitAccess.getInstance().setRepositorySynchronously(localTestRepository_1);
    setFileContent(firstRepoFile, "Third version");
    GitAccess.getInstance().add(new FileStatus(GitChangeType.MODIFIED, "test.txt"));
    GitAccess.getInstance().commit("Third commit.");
    // Now pull to generate conflict
    ConflictButtonsPanel abortMergeButtonPanel = stagingPanel.getConflictButtonsPanel();
    assertFalse(abortMergeButtonPanel.isShowing());
    flushAWT();
    PullResponse pullResponse = pull("", "", PullType.MERGE_FF, false);
    refreshSupport.call();
    waitForScheduler();
    assertEquals(PullStatus.CONFLICTS, pullResponse.getStatus());
    RepositoryState repositoryState = GitAccess.getInstance().getRepository().getRepositoryState();
    assertEquals(RepositoryState.MERGING, repositoryState);
    assertTrue(abortMergeButtonPanel.isShowing());
    // --------------- REPO 2
    GitAccess.getInstance().setRepositorySynchronously(localTestRepository_2);
    sleep(300);
    assertFalse(abortMergeButtonPanel.isShowing());
    // --------------- REPO 1
    GitAccess.getInstance().setRepositorySynchronously(localTestRepository_1);
    sleep(300);
    assertTrue(abortMergeButtonPanel.isShowing());
    JButton abortMergeBtn = findFirstButton(abortMergeButtonPanel, Tags.ABORT_MERGE);
    assertNotNull(abortMergeBtn);
    // Resolve using mine
    GitControllerBase gitCtrl = stagingPanel.getGitController();
    PluginWorkspace spy = Mockito.spy(PluginWorkspaceProvider.getPluginWorkspace());
    Mockito.when(spy.showConfirmDialog(Mockito.anyString(), Mockito.anyString(), Mockito.any(), Mockito.any())).thenReturn(0);
    PluginWorkspaceProvider.setPluginWorkspace(spy);
    FileStatus testFileStatus = new FileStatus(GitChangeType.CONFLICT, "test.txt");
    gitCtrl.asyncResolveUsingMine(Arrays.asList(testFileStatus));
    refreshSupport.call();
    waitForScheduler();
    flushAWT();
    abortMergeButtonPanel = stagingPanel.getConflictButtonsPanel();
    assertFalse(abortMergeButtonPanel.isShowing());
    // Restart merge
    GitAccess.getInstance().restartMerge();
    flushAWT();
    sleep(200);
    abortMergeButtonPanel = stagingPanel.getConflictButtonsPanel();
    assertTrue(abortMergeButtonPanel.isShowing());
    abortMergeBtn = findFirstButton(abortMergeButtonPanel, Tags.ABORT_MERGE);
    assertNotNull(abortMergeBtn);
    // Resolve using theirs
    gitCtrl.asyncResolveUsingTheirs(Arrays.asList(testFileStatus));
    waitForScheduler();
    flushAWT();
    abortMergeButtonPanel = stagingPanel.getConflictButtonsPanel();
    assertFalse(abortMergeButtonPanel.isShowing());
    // Restart merge
    GitAccess.getInstance().restartMerge();
    flushAWT();
    abortMergeButtonPanel = stagingPanel.getConflictButtonsPanel();
    assertTrue(abortMergeButtonPanel.isShowing());
    abortMergeBtn = findFirstButton(abortMergeButtonPanel, Tags.ABORT_MERGE);
    assertNotNull(abortMergeBtn);
    repositoryState = GitAccess.getInstance().getRepository().getRepositoryState();
    assertEquals(RepositoryState.MERGING, repositoryState);
    assertEquals(1, GitAccess.getInstance().getPullsBehind());
    assertEquals(1, GitAccess.getInstance().getPushesAhead());
    // Abort merge
    abortMergeBtn.doClick();
    flushAWT();
    abortMergeButtonPanel = stagingPanel.getConflictButtonsPanel();
    assertFalse(abortMergeButtonPanel.isShowing());
    repositoryState = GitAccess.getInstance().getRepository().getRepositoryState();
    assertEquals(RepositoryState.SAFE, repositoryState);
    assertEquals(1, GitAccess.getInstance().getPullsBehind());
    assertEquals(1, GitAccess.getInstance().getPushesAhead());
}
Also used : GitControllerBase(com.oxygenxml.git.service.GitControllerBase) PluginWorkspace(ro.sync.exml.workspace.api.PluginWorkspace) Repository(org.eclipse.jgit.lib.Repository) FileStatus(com.oxygenxml.git.service.entities.FileStatus) PullResponse(com.oxygenxml.git.service.PullResponse) ConflictButtonsPanel(com.oxygenxml.git.view.staging.ConflictButtonsPanel) JButton(javax.swing.JButton) RepositoryState(org.eclipse.jgit.lib.RepositoryState) File(java.io.File) Test(org.junit.Test)

Example 5 with ConflictButtonsPanel

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

the class FlatView2Test method testShowRebasePanel_thenAbort.

/**
 * <p><b>Description:</b> Show and hide (by aborting the rebase) the rebase panel.</p>
 * <p><b>Bug ID:</b> EXM-42025</p>
 *
 * @author sorin_carbunaru
 *
 * @throws Exception If it fails.
 */
@Test
public void testShowRebasePanel_thenAbort() throws Exception {
    String localTestRepository_1 = "target/test-resources/testShowRebasePanel_thenAbort-local-1";
    String localTestRepository_2 = "target/test-resources/testShowRebasePanel_thenAbort-local-2";
    String remoteTestRepository = "target/test-resources/testShowRebasePanel_thenAbort-remote";
    // Create and repositories
    Repository remoteRepo = createRepository(remoteTestRepository);
    Repository localRepo_1 = createRepository(localTestRepository_1);
    Repository localRepo_2 = createRepository(localTestRepository_2);
    bindLocalToRemote(localRepo_1, remoteRepo);
    bindLocalToRemote(localRepo_2, remoteRepo);
    new File(localTestRepository_1).mkdirs();
    new File(localTestRepository_2).mkdirs();
    // --------------  REPO 1
    GitAccess.getInstance().setRepositorySynchronously(localTestRepository_1);
    File firstRepoFile = new File(localTestRepository_1 + "/test.txt");
    firstRepoFile.createNewFile();
    setFileContent(firstRepoFile, "First version");
    GitAccess.getInstance().add(new FileStatus(GitChangeType.UNKNOWN, "test.txt"));
    GitAccess.getInstance().commit("First commit.");
    push("", "");
    // ----------------- REPO 2
    GitAccess.getInstance().setRepositorySynchronously(localTestRepository_2);
    File secondRepoFile = new File(localTestRepository_2 + "/test.txt");
    refreshSupport.call();
    flushAWT();
    sleep(400);
    assertFalse(secondRepoFile.exists());
    pull("", "", PullType.REBASE, false);
    assertTrue(secondRepoFile.exists());
    // Modify file and commit and push
    setFileContent(secondRepoFile, "Second versions");
    GitAccess.getInstance().add(new FileStatus(GitChangeType.MODIFIED, "test.txt"));
    GitAccess.getInstance().commit("Second commit.");
    push("", "");
    // --------------  REPO 1
    GitAccess.getInstance().setRepositorySynchronously(localTestRepository_1);
    setFileContent(firstRepoFile, "Third version");
    GitAccess.getInstance().add(new FileStatus(GitChangeType.MODIFIED, "test.txt"));
    GitAccess.getInstance().commit("Third commit.");
    // Now pull to generate conflict
    ConflictButtonsPanel rebasePanel = stagingPanel.getConflictButtonsPanel();
    assertFalse(rebasePanel.isShowing());
    flushAWT();
    PullResponse pullResponse = pull("", "", PullType.REBASE, false);
    refreshSupport.call();
    waitForScheduler();
    sleep(1000);
    assertEquals(PullStatus.CONFLICTS, pullResponse.getStatus());
    assertTrue(rebasePanel.isShowing());
    JButton abortButton = findFirstButton(rebasePanel, "Abort_rebase");
    assertNotNull(abortButton);
    abortButton.doClick();
    flushAWT();
    sleep(500);
    assertFalse(rebasePanel.isShowing());
}
Also used : Repository(org.eclipse.jgit.lib.Repository) FileStatus(com.oxygenxml.git.service.entities.FileStatus) PullResponse(com.oxygenxml.git.service.PullResponse) ConflictButtonsPanel(com.oxygenxml.git.view.staging.ConflictButtonsPanel) JButton(javax.swing.JButton) File(java.io.File) Test(org.junit.Test)

Aggregations

PullResponse (com.oxygenxml.git.service.PullResponse)7 FileStatus (com.oxygenxml.git.service.entities.FileStatus)7 ConflictButtonsPanel (com.oxygenxml.git.view.staging.ConflictButtonsPanel)7 File (java.io.File)7 Repository (org.eclipse.jgit.lib.Repository)7 Test (org.junit.Test)7 JButton (javax.swing.JButton)6 GitControllerBase (com.oxygenxml.git.service.GitControllerBase)3 GitController (com.oxygenxml.git.view.event.GitController)3 JDialog (javax.swing.JDialog)3 ConflictResolution (com.oxygenxml.git.service.ConflictResolution)2 Semaphore (java.util.concurrent.Semaphore)1 RepositoryState (org.eclipse.jgit.lib.RepositoryState)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1 PluginWorkspace (ro.sync.exml.workspace.api.PluginWorkspace)1 StandalonePluginWorkspace (ro.sync.exml.workspace.api.standalone.StandalonePluginWorkspace)1