Search in sources :

Example 11 with SelectedResourcesProvider

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

the class TreeView2Test method testDiscard.

/**
 * Discard changes. THose files must not appear in either stage/un-stage area.
 *
 * @throws Exception If it fails.
 */
public void testDiscard() throws Exception {
    /**
     * Local repository location.
     */
    String localTestRepository = "target/test-resources/testDiscard_NewFile_local";
    /**
     * Remote repository location.
     */
    String remoteTestRepository = "target/test-resources/testDiscard_NewFile_remote";
    // Create repositories
    Repository remoteRepo = createRepository(remoteTestRepository);
    Repository localRepo = createRepository(localTestRepository);
    // Bind the local repository to the remote one.
    bindLocalToRemote(localRepo, remoteRepo);
    File file = createNewFile(localTestRepository, "test.txt", "remote");
    // Add it to the index.
    add(new FileStatus(GitChangeType.UNKNOWN, "test.txt"));
    assertTreeModels("", "ADD, test.txt");
    GitAccess.getInstance().commit("First version.");
    assertTreeModels("", "");
    // Change the file.
    setFileContent(file, "index content");
    assertTreeModels("MODIFIED, test.txt", "");
    add(new FileStatus(GitChangeType.MODIFIED, "test.txt"));
    assertTreeModels("", "CHANGED, test.txt");
    // Change the file.
    setFileContent(file, "modified content");
    // The file is present in  both areas.
    assertTreeModels("MODIFIED, test.txt", "CHANGED, test.txt");
    // Discard.
    DiscardAction discardAction = new DiscardAction(new SelectedResourcesProvider() {

        @Override
        public List<FileStatus> getOnlySelectedLeaves() {
            return null;
        }

        @Override
        public List<FileStatus> getAllSelectedResources() {
            return Arrays.asList(new FileStatus(GitChangeType.MODIFIED, "test.txt"));
        }
    }, stagingPanel.getGitController());
    discardAction.actionPerformed(null);
    waitForScheduler();
    assertTreeModels("", "");
}
Also used : DiscardAction(com.oxygenxml.git.view.staging.actions.DiscardAction) Repository(org.eclipse.jgit.lib.Repository) FileStatus(com.oxygenxml.git.service.entities.FileStatus) SelectedResourcesProvider(com.oxygenxml.git.view.staging.ChangesPanel.SelectedResourcesProvider) List(java.util.List) File(java.io.File)

Example 12 with SelectedResourcesProvider

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

the class GitViewResourceContextualMenuActionsTest method testActionsEnablingState_1.

/**
 * <p><b>Description:</b> test the enabling state of the actions
 * from the contextual menu of the staged resources.</p>
 * <p><b>Bug ID:</b> EXM-40615</p>
 *
 * @author sorin_carbunaru
 *
 * @throws Exception
 */
public void testActionsEnablingState_1() throws Exception {
    GitResourceContextualMenu menu = new GitResourceContextualMenu(new SelectedResourcesProvider() {

        @Override
        public List<FileStatus> getOnlySelectedLeaves() {
            return getAllSelectedResources();
        }

        @Override
        public List<FileStatus> getAllSelectedResources() {
            List<FileStatus> fileStatuses = new ArrayList<>();
            fileStatuses.add(new FileStatus(GitChangeType.ADD, "test.xml"));
            return fileStatuses;
        }
    }, gitCtrl, null, // For staged resources
    true, Optional.of(RepositoryState.SAFE));
    assertEquals("\n" + "Open_In_Compare [ENABLED]\n" + "Open [ENABLED]\n" + "----\n" + "Unstage [ENABLED]\n" + "Resolve_Conflict [DISABLED]\n" + "  Open_In_Compare [ENABLED]\n" + "  ----\n" + "  Resolve_Using_Mine [DISABLED]\n" + "  Resolve_Using_Theirs [DISABLED]\n" + "  Mark_Resolved [DISABLED]\n" + "  ----\n" + "  Restart_Merge [DISABLED]\n" + "Discard [ENABLED]", PopupMenuSerializer.serializePopupStructure(menu, true, true));
}
Also used : FileStatus(com.oxygenxml.git.service.entities.FileStatus) SelectedResourcesProvider(com.oxygenxml.git.view.staging.ChangesPanel.SelectedResourcesProvider) ArrayList(java.util.ArrayList) List(java.util.List) GitResourceContextualMenu(com.oxygenxml.git.view.staging.GitResourceContextualMenu)

Example 13 with SelectedResourcesProvider

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

the class GitViewResourceContextualMenuActionsTest method testActionsEnablingState_21.

/**
 * <p><b>Description:</b> test the enabling state of the actions
 * from the contextual menu of the staged resources. Empty root. Merging state.</p>
 * <p><b>Bug ID:</b> EXM-40615</p>
 *
 * @author sorin_carbunaru
 *
 * @throws Exception
 */
public void testActionsEnablingState_21() throws Exception {
    // Create repositories
    String localTestRepository = "target/test-resources/testActionsEnabling6_local";
    String remoteTestRepository = "target/test-resources/testActionsEnabling6_remote";
    Repository remoteRepo = createRepository(remoteTestRepository);
    Repository localRepo = createRepository(localTestRepository);
    // Bind the local repository to the remote one.
    bindLocalToRemote(localRepo, remoteRepo);
    GitResourceContextualMenu menu = new GitResourceContextualMenu(new SelectedResourcesProvider() {

        @Override
        public List<FileStatus> getOnlySelectedLeaves() {
            return getAllSelectedResources();
        }

        @Override
        public List<FileStatus> getAllSelectedResources() {
            return Collections.emptyList();
        }
    }, gitCtrl, null, // For staged resources
    true, // In merging state
    Optional.of(RepositoryState.MERGING));
    assertEquals("\n" + "Open_In_Compare [DISABLED]\n" + "Open [DISABLED]\n" + "----\n" + "Unstage [DISABLED]\n" + "Resolve_Conflict [ENABLED]\n" + "  Open_In_Compare [DISABLED]\n" + "  ----\n" + "  Resolve_Using_Mine [DISABLED]\n" + "  Resolve_Using_Theirs [DISABLED]\n" + "  Mark_Resolved [DISABLED]\n" + "  ----\n" + "  Restart_Merge [ENABLED]\n" + "Discard [DISABLED]", PopupMenuSerializer.serializePopupStructure(menu, true, true));
}
Also used : Repository(org.eclipse.jgit.lib.Repository) SelectedResourcesProvider(com.oxygenxml.git.view.staging.ChangesPanel.SelectedResourcesProvider) ArrayList(java.util.ArrayList) List(java.util.List) GitResourceContextualMenu(com.oxygenxml.git.view.staging.GitResourceContextualMenu)

Example 14 with SelectedResourcesProvider

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

the class GitViewResourceContextualMenuActionsTest method testActionsEnablingState_4.

/**
 * <p><b>Description:</b> test the enabling state of the actions
 * from the contextual menu of the staged resources.</p>
 * <p><b>Bug ID:</b> EXM-40615</p>
 *
 * @author sorin_carbunaru
 *
 * @throws Exception
 */
public void testActionsEnablingState_4() throws Exception {
    GitResourceContextualMenu menu = new GitResourceContextualMenu(new SelectedResourcesProvider() {

        @Override
        public List<FileStatus> getOnlySelectedLeaves() {
            return getAllSelectedResources();
        }

        @Override
        public List<FileStatus> getAllSelectedResources() {
            List<FileStatus> fileStatuses = new ArrayList<>();
            fileStatuses.add(new FileStatus(GitChangeType.CHANGED, "test.xml"));
            return fileStatuses;
        }
    }, gitCtrl, null, // For staged resources
    true, Optional.of(RepositoryState.SAFE));
    assertEquals("\n" + "Open_In_Compare [ENABLED]\n" + "Open [ENABLED]\n" + "----\n" + "Unstage [ENABLED]\n" + "Resolve_Conflict [DISABLED]\n" + "  Open_In_Compare [ENABLED]\n" + "  ----\n" + "  Resolve_Using_Mine [DISABLED]\n" + "  Resolve_Using_Theirs [DISABLED]\n" + "  Mark_Resolved [DISABLED]\n" + "  ----\n" + "  Restart_Merge [DISABLED]\n" + "Discard [ENABLED]", PopupMenuSerializer.serializePopupStructure(menu, true, true));
}
Also used : FileStatus(com.oxygenxml.git.service.entities.FileStatus) SelectedResourcesProvider(com.oxygenxml.git.view.staging.ChangesPanel.SelectedResourcesProvider) ArrayList(java.util.ArrayList) List(java.util.List) GitResourceContextualMenu(com.oxygenxml.git.view.staging.GitResourceContextualMenu)

Example 15 with SelectedResourcesProvider

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

the class GitViewResourceContextualMenuActionsTest method testActionsEnablingState_2.

/**
 * <p><b>Description:</b> test the enabling state of the actions
 * from the contextual menu of the staged resources.</p>
 * <p><b>Bug ID:</b> EXM-40615</p>
 *
 * @author sorin_carbunaru
 *
 * @throws Exception
 */
public void testActionsEnablingState_2() throws Exception {
    GitResourceContextualMenu menu = new GitResourceContextualMenu(new SelectedResourcesProvider() {

        @Override
        public List<FileStatus> getOnlySelectedLeaves() {
            return getAllSelectedResources();
        }

        @Override
        public List<FileStatus> getAllSelectedResources() {
            List<FileStatus> fileStatuses = new ArrayList<>();
            fileStatuses.add(new FileStatus(GitChangeType.ADD, "test.xml"));
            fileStatuses.add(new FileStatus(GitChangeType.ADD, "test2.xml"));
            return fileStatuses;
        }
    }, gitCtrl, null, // For staged resources
    true, Optional.of(RepositoryState.SAFE));
    assertEquals("\n" + "Open_In_Compare [DISABLED]\n" + "Open [ENABLED]\n" + "----\n" + "Unstage [ENABLED]\n" + "Resolve_Conflict [DISABLED]\n" + "  Open_In_Compare [DISABLED]\n" + "  ----\n" + "  Resolve_Using_Mine [DISABLED]\n" + "  Resolve_Using_Theirs [DISABLED]\n" + "  Mark_Resolved [DISABLED]\n" + "  ----\n" + "  Restart_Merge [DISABLED]\n" + "Discard [ENABLED]", PopupMenuSerializer.serializePopupStructure(menu, true, true));
}
Also used : FileStatus(com.oxygenxml.git.service.entities.FileStatus) SelectedResourcesProvider(com.oxygenxml.git.view.staging.ChangesPanel.SelectedResourcesProvider) ArrayList(java.util.ArrayList) List(java.util.List) GitResourceContextualMenu(com.oxygenxml.git.view.staging.GitResourceContextualMenu)

Aggregations

SelectedResourcesProvider (com.oxygenxml.git.view.staging.ChangesPanel.SelectedResourcesProvider)27 List (java.util.List)27 FileStatus (com.oxygenxml.git.service.entities.FileStatus)26 ArrayList (java.util.ArrayList)22 GitResourceContextualMenu (com.oxygenxml.git.view.staging.GitResourceContextualMenu)21 File (java.io.File)6 Repository (org.eclipse.jgit.lib.Repository)6 DiscardAction (com.oxygenxml.git.view.staging.actions.DiscardAction)5 GitControllerBase (com.oxygenxml.git.service.GitControllerBase)3 GitAccess (com.oxygenxml.git.service.GitAccess)1 SubmoduleAccess (com.oxygenxml.git.service.SubmoduleAccess)1 HistoryController (com.oxygenxml.git.view.history.HistoryController)1 ShowBlameForUnstagedResourceAction (com.oxygenxml.git.view.staging.actions.ShowBlameForUnstagedResourceAction)1 URL (java.net.URL)1 JTextArea (javax.swing.JTextArea)1 Highlight (javax.swing.text.Highlighter.Highlight)1 RevCommit (org.eclipse.jgit.revwalk.RevCommit)1 Test (org.junit.Test)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1