Search in sources :

Example 1 with SubmoduleAccess

use of com.oxygenxml.git.service.SubmoduleAccess in project oxygen-git-client-addon by oxygenxml.

the class RefreshProjectTest method testRefreshProjectOnDiscard_3.

/**
 * Refresh on submodule discard.
 *
 * @throws Exception
 */
@PrepareForTest({ GitAccess.class })
public void testRefreshProjectOnDiscard_3() throws Exception {
    File repoDir = new File(localTestRepoPath);
    repoDir.mkdirs();
    File subModule = new File(localTestRepoPath, "subModule");
    subModule.mkdir();
    try {
        GitAccess gitAccessMock = PowerMockito.mock(GitAccess.class);
        Whitebox.setInternalState(GitAccess.class, "instance", gitAccessMock);
        SubmoduleAccess submoduleAccess = Mockito.mock(SubmoduleAccess.class);
        Mockito.doNothing().when(submoduleAccess).discardSubmodule();
        PowerMockito.when(gitAccessMock.getSubmoduleAccess()).thenReturn(submoduleAccess);
        DiscardAction discardAction = new DiscardAction(new SelectedResourcesProvider() {

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

            @Override
            public List<FileStatus> getAllSelectedResources() {
                return Arrays.asList(new FileStatus(GitChangeType.SUBMODULE, "subModule"));
            }
        }, // A mock that does nothing.
        Mockito.mock(GitControllerBase.class));
        discardAction.actionPerformed(null);
        assertEquals(subModule.getCanonicalFile().getAbsolutePath(), refreshedFolder.getAbsolutePath());
    } finally {
        FileUtils.deleteDirectory(repoDir);
    }
}
Also used : DiscardAction(com.oxygenxml.git.view.staging.actions.DiscardAction) GitControllerBase(com.oxygenxml.git.service.GitControllerBase) GitAccess(com.oxygenxml.git.service.GitAccess) FileStatus(com.oxygenxml.git.service.entities.FileStatus) SelectedResourcesProvider(com.oxygenxml.git.view.staging.ChangesPanel.SelectedResourcesProvider) List(java.util.List) File(java.io.File) SubmoduleAccess(com.oxygenxml.git.service.SubmoduleAccess) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

GitAccess (com.oxygenxml.git.service.GitAccess)1 GitControllerBase (com.oxygenxml.git.service.GitControllerBase)1 SubmoduleAccess (com.oxygenxml.git.service.SubmoduleAccess)1 FileStatus (com.oxygenxml.git.service.entities.FileStatus)1 SelectedResourcesProvider (com.oxygenxml.git.view.staging.ChangesPanel.SelectedResourcesProvider)1 DiscardAction (com.oxygenxml.git.view.staging.actions.DiscardAction)1 File (java.io.File)1 List (java.util.List)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1