Search in sources :

Example 1 with Row

use of org.eclipse.egit.ui.common.ExistingOrNewPage.Row in project egit by eclipse.

the class SharingWizardTest method shareProjectWithAlreadyCreatedRepos.

@Test
public void shareProjectWithAlreadyCreatedRepos() throws Exception {
    Repository repo1 = FileRepositoryBuilder.create(new File(new File(createProject(projectName1)).getParent(), ".git"));
    repo1.create();
    repo1.close();
    Repository repo2 = FileRepositoryBuilder.create(new File(createProject(projectName2), ".git"));
    repo2.create();
    repo2.close();
    Repository repo3 = FileRepositoryBuilder.create(new File(createProject(projectName3), ".git"));
    repo3.create();
    try (Git git = new Git(repo3)) {
        git.add().addFilepattern(".").call();
        git.commit().setAuthor("A U Thior", "au.thor@example.com").setMessage("Created Project 3").call();
    }
    repo3.close();
    ExistingOrNewPage existingOrNewPage = sharingWizard.openWizard(projectName1, projectName2, projectName3);
    existingOrNewPage.setInternalMode(true);
    // initial state
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    String projectPath1 = workspace.getRoot().getProject(projectName1).getLocation().toOSString();
    String projectPath2 = workspace.getRoot().getProject(projectName2).getLocation().toOSString();
    String projectPath3 = workspace.getRoot().getProject(projectName3).getLocation().toOSString();
    existingOrNewPage.assertContents(new Row[] { new Row(true, projectName1, projectPath1, ".." + File.separator + ".git"), new Row(false, projectName2, projectPath2, "", new Row[] { new Row(false, ".", "", ".git"), new Row(false, "..", "", ".." + File.separator + ".git") }), new Row(false, projectName3, projectPath3, "", new Row[] { new Row(true, ".", "", ".git"), new Row(false, "..", "", ".." + File.separator + ".git") }) }, "");
    bot.tree().getAllItems()[1].getItems()[0].check();
    existingOrNewPage.assertEnabling(false, false, true);
    SWTBotShell shell = bot.activeShell();
    bot.button(IDialogConstants.FINISH_LABEL).click();
    bot.waitUntil(Conditions.shellCloses(shell));
    ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE, null);
    assertEquals(repo1.getDirectory().getAbsolutePath(), RepositoryMapping.getMapping(workspace.getRoot().getProject(projectName1)).getRepository().getDirectory().toString());
    assertEquals(repo2.getDirectory().getAbsolutePath(), RepositoryMapping.getMapping(workspace.getRoot().getProject(projectName2)).getRepository().getDirectory().toString());
}
Also used : Repository(org.eclipse.jgit.lib.Repository) Git(org.eclipse.jgit.api.Git) IWorkspace(org.eclipse.core.resources.IWorkspace) Row(org.eclipse.egit.ui.common.ExistingOrNewPage.Row) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) File(java.io.File) ExistingOrNewPage(org.eclipse.egit.ui.common.ExistingOrNewPage) Test(org.junit.Test)

Aggregations

File (java.io.File)1 IWorkspace (org.eclipse.core.resources.IWorkspace)1 ExistingOrNewPage (org.eclipse.egit.ui.common.ExistingOrNewPage)1 Row (org.eclipse.egit.ui.common.ExistingOrNewPage.Row)1 Git (org.eclipse.jgit.api.Git)1 Repository (org.eclipse.jgit.lib.Repository)1 SWTBotShell (org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)1 Test (org.junit.Test)1