Search in sources :

Example 31 with Repository

use of org.guvnor.structure.repositories.Repository in project kie-wb-common by kiegroup.

the class ProjectScreenTestBase method createProject.

protected WorkspaceProject createProject() {
    final Path rootPath = mock(Path.class);
    doReturn("git://modulePath").when(rootPath).toURI();
    final Module module = mock(Module.class);
    doReturn("mainModuleName").when(module).getModuleName();
    doReturn("modulePath").when(module).getIdentifier();
    doReturn(rootPath).when(module).getRootPath();
    final Path pomPath = mock(Path.class);
    doReturn(pomPath).when(module).getPomXMLPath();
    final OrganizationalUnit organizationalUnit = mock(OrganizationalUnit.class);
    final Repository repository = mock(Repository.class);
    final Path repositoryRootPath = mock(Path.class);
    doReturn(Optional.of(new Branch("master", repositoryRootPath))).when(repository).getDefaultBranch();
    doReturn("rootpath").when(repositoryRootPath).toURI();
    return new WorkspaceProject(organizationalUnit, repository, new Branch("master", mock(Path.class)), module);
}
Also used : Path(org.uberfire.backend.vfs.Path) Repository(org.guvnor.structure.repositories.Repository) OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) Branch(org.guvnor.structure.repositories.Branch) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) Module(org.guvnor.common.services.project.model.Module)

Example 32 with Repository

use of org.guvnor.structure.repositories.Repository in project kie-wb-common by kiegroup.

the class LibraryToolbarPresenterTest method activeProjectHasOnlyOneBranch.

@Test
public void activeProjectHasOnlyOneBranch() throws Exception {
    final Repository repository = mock(Repository.class);
    final ArrayList<Branch> branches = new ArrayList<>();
    branches.add(new Branch());
    doReturn(branches).when(repository).getBranches();
    doReturn(Optional.of(new WorkspaceProject(mock(OrganizationalUnit.class), repository, mock(Branch.class), mock(KieModule.class)))).when(projectContext).getActiveWorkspaceProject();
    presenter.setUpBranches();
    verify(view).clearBranches();
    verify(view).setBranchSelectorVisibility(false);
}
Also used : Repository(org.guvnor.structure.repositories.Repository) OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) Branch(org.guvnor.structure.repositories.Branch) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) ArrayList(java.util.ArrayList) KieModule(org.kie.workbench.common.services.shared.project.KieModule) Test(org.junit.Test)

Example 33 with Repository

use of org.guvnor.structure.repositories.Repository in project kie-wb-common by kiegroup.

the class LibraryToolbarPresenterTest method listBranches.

@Test
public void listBranches() throws Exception {
    final Repository repository = mock(Repository.class);
    final ArrayList<Branch> branches = new ArrayList<>();
    branches.add(new Branch("one", mock(Path.class)));
    branches.add(new Branch("two", mock(Path.class)));
    doReturn(branches).when(repository).getBranches();
    // Normally this is in the branch list, but I want to verify it gets set from the branch in the project
    final Branch selectedBranch = new Branch("selectedBranch", mock(Path.class));
    doReturn(Optional.of(new WorkspaceProject(mock(OrganizationalUnit.class), repository, selectedBranch, mock(KieModule.class)))).when(projectContext).getActiveWorkspaceProject();
    presenter.setUpBranches();
    verify(view).addBranch("one");
    verify(view).addBranch("two");
    view.setSelectedBranch("selectedBranch");
}
Also used : Path(org.uberfire.backend.vfs.Path) Repository(org.guvnor.structure.repositories.Repository) OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) Branch(org.guvnor.structure.repositories.Branch) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) ArrayList(java.util.ArrayList) KieModule(org.kie.workbench.common.services.shared.project.KieModule) Test(org.junit.Test)

Example 34 with Repository

use of org.guvnor.structure.repositories.Repository in project kie-wb-common by kiegroup.

the class ProjectScreenServiceImpl method copy.

@Override
public void copy(final WorkspaceProject project, final String newName) {
    final Repository copy = repositoryCopier.copy(project.getOrganizationalUnit(), newName, project.getRootPath());
    if (!copy.getDefaultBranch().isPresent()) {
        throw new IllegalStateException("Copy should have at least one branch.");
    }
    final Path newPomPath = Paths.convert(Paths.convert(copy.getDefaultBranch().get().getPath()).resolve("pom.xml"));
    final POM pom = pomService.load(newPomPath);
    if (pom != null) {
        pom.setName(newName);
        pom.getGav().setArtifactId(newName);
        pomService.save(newPomPath, pom, metadataService.getMetadata(newPomPath), "Renaming the project.", true);
    }
}
Also used : Path(org.uberfire.backend.vfs.Path) Repository(org.guvnor.structure.repositories.Repository) POM(org.guvnor.common.services.project.model.POM)

Example 35 with Repository

use of org.guvnor.structure.repositories.Repository in project kie-wb-common by kiegroup.

the class ProjectScreenServiceImplTest method testCopy.

@Test
public void testCopy() throws Exception {
    final WorkspaceProject project = mock(WorkspaceProject.class);
    final OrganizationalUnit ou = mock(OrganizationalUnit.class);
    final Path projectRoot = mock(Path.class);
    doReturn(ou).when(project).getOrganizationalUnit();
    doReturn(projectRoot).when(project).getRootPath();
    final Repository newRepository = mock(Repository.class);
    final Path newRepositoryRoot = PathFactory.newPath("root", "file:///root");
    doReturn(Optional.of(new Branch("master", newRepositoryRoot))).when(newRepository).getDefaultBranch();
    doReturn(newRepository).when(repositoryCopier).copy(ou, "newName", projectRoot);
    final ArgumentCaptor<POM> pomArgumentCaptor = ArgumentCaptor.forClass(POM.class);
    final POM pom = new POM();
    doReturn(pom).when(pomService).load(any(Path.class));
    final Metadata metadata = mock(Metadata.class);
    doReturn(metadata).when(metadataService).getMetadata(any(Path.class));
    service.copy(project, "newName");
    verify(pomService).save(any(Path.class), pomArgumentCaptor.capture(), eq(metadata), eq("Renaming the project."), eq(true));
    final POM updatedPom = pomArgumentCaptor.getValue();
    assertEquals("newName", updatedPom.getName());
    assertEquals("newName", updatedPom.getGav().getArtifactId());
}
Also used : Path(org.uberfire.backend.vfs.Path) Repository(org.guvnor.structure.repositories.Repository) OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) Branch(org.guvnor.structure.repositories.Branch) Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) MavenRepositoryMetadata(org.guvnor.common.services.project.model.MavenRepositoryMetadata) POM(org.guvnor.common.services.project.model.POM) Test(org.junit.Test)

Aggregations

Repository (org.guvnor.structure.repositories.Repository)51 Test (org.junit.Test)25 OrganizationalUnit (org.guvnor.structure.organizationalunit.OrganizationalUnit)21 Branch (org.guvnor.structure.repositories.Branch)21 WorkspaceProject (org.guvnor.common.services.project.model.WorkspaceProject)20 GitRepository (org.guvnor.structure.repositories.impl.git.GitRepository)15 Module (org.guvnor.common.services.project.model.Module)14 ArrayList (java.util.ArrayList)13 Path (org.uberfire.backend.vfs.Path)13 ExampleRepository (org.kie.workbench.common.screens.examples.model.ExampleRepository)10 POM (org.guvnor.common.services.project.model.POM)7 KieModule (org.kie.workbench.common.services.shared.project.KieModule)7 ExampleOrganizationalUnit (org.kie.workbench.common.screens.examples.model.ExampleOrganizationalUnit)5 HashMap (java.util.HashMap)4 MavenRepositoryMetadata (org.guvnor.common.services.project.model.MavenRepositoryMetadata)4 Before (org.junit.Before)4 Metadata (org.guvnor.common.services.shared.metadata.model.Metadata)3 RepositoryEnvironmentConfigurations (org.guvnor.structure.repositories.RepositoryEnvironmentConfigurations)3 ConfigGroup (org.guvnor.structure.server.config.ConfigGroup)3 Space (org.uberfire.spaces.Space)3