Search in sources :

Example 1 with GitRepository

use of org.guvnor.structure.repositories.impl.git.GitRepository in project kie-wb-common by kiegroup.

the class SocialEventRepositoryConstraintTest method setUp.

@Before
public void setUp() throws Exception {
    Collection<OrganizationalUnit> ous = new ArrayList<OrganizationalUnit>();
    final OrganizationalUnitImpl ou = new OrganizationalUnitImpl("ouname", "owner", "groupid");
    final OrganizationalUnitImpl ouSpy = spy(ou);
    Collection<Repository> repositories = new ArrayList<Repository>();
    repository = new GitRepository("repo", new Space("space"));
    repositories.add(repository);
    ous.add(ouSpy);
    when(ouSpy.getRepositories()).thenReturn(repositories);
    when(organizationalUnitService.getOrganizationalUnits()).thenReturn(ous);
    when(authorizationManager.authorize(ou, user)).thenReturn(true);
    when(authorizationManager.authorize(repository, user)).thenReturn(true);
    when(userCDIContextHelper.getUser()).thenReturn(user);
    when(userCDIContextHelper.thereIsALoggedUserInScope()).thenReturn(true);
    socialEventRepositoryConstraint = createSocialEventRepositoryContraint();
}
Also used : Space(org.uberfire.spaces.Space) GitRepository(org.guvnor.structure.repositories.impl.git.GitRepository) Repository(org.guvnor.structure.repositories.Repository) GitRepository(org.guvnor.structure.repositories.impl.git.GitRepository) OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) ArrayList(java.util.ArrayList) OrganizationalUnitImpl(org.guvnor.structure.organizationalunit.impl.OrganizationalUnitImpl) Before(org.junit.Before)

Example 2 with GitRepository

use of org.guvnor.structure.repositories.impl.git.GitRepository in project kie-wb-common by kiegroup.

the class RepositoryListServiceImplTest method setup.

@Before
public void setup() {
    Set<Repository> repositories = new HashSet<Repository>();
    repositories.add(new GitRepository("dora", new Space("space")));
    final SocialEventRepositoryConstraint socialEventRepositoryConstraint = mock(SocialEventRepositoryConstraint.class);
    when(socialEventRepositoryConstraint.getAuthorizedRepositories()).thenReturn(repositories);
    service.repositoryConstraint = socialEventRepositoryConstraint;
}
Also used : Space(org.uberfire.spaces.Space) GitRepository(org.guvnor.structure.repositories.impl.git.GitRepository) Repository(org.guvnor.structure.repositories.Repository) GitRepository(org.guvnor.structure.repositories.impl.git.GitRepository) SocialEventRepositoryConstraint(org.kie.workbench.common.screens.social.hp.security.SocialEventRepositoryConstraint) HashSet(java.util.HashSet) Before(org.junit.Before)

Example 3 with GitRepository

use of org.guvnor.structure.repositories.impl.git.GitRepository in project kie-wb-common by kiegroup.

the class ProjectExplorerContentResolverTest method getGitRepository.

private GitRepository getGitRepository() {
    final GitRepository repository = new GitRepository("alias", space);
    final HashMap<String, Branch> branches = new HashMap<>();
    masterBranch = new Branch("master", PathFactory.newPath("/", "file://master@module/"));
    devBranch = new Branch("dev-1.0.0", PathFactory.newPath("/", "file://dev-1.0.0@module/"));
    branches.put("master", masterBranch);
    branches.put("dev-1.0.0", devBranch);
    repository.setBranches(branches);
    return repository;
}
Also used : GitRepository(org.guvnor.structure.repositories.impl.git.GitRepository) HashMap(java.util.HashMap) Branch(org.guvnor.structure.repositories.Branch)

Example 4 with GitRepository

use of org.guvnor.structure.repositories.impl.git.GitRepository in project kie-wb-common by kiegroup.

the class ExamplesServiceImpl method getProjects.

@Override
public Set<ExampleProject> getProjects(final ExampleRepository repository) {
    if (repository == null) {
        return Collections.emptySet();
    }
    final String repositoryURL = repository.getUrl();
    if (repositoryURL == null || repositoryURL.trim().isEmpty()) {
        return Collections.emptySet();
    }
    // Avoid cloning playground repository multiple times
    Repository gitRepository = resolveGitRepository(repository);
    if (gitRepository == null) {
        return Collections.emptySet();
    }
    final Set<Module> modules = moduleService.getAllModules(gitRepository.getBranch("master").get());
    return convert(modules);
}
Also used : ExampleRepository(org.kie.workbench.common.screens.examples.model.ExampleRepository) Repository(org.guvnor.structure.repositories.Repository) GitRepository(org.guvnor.structure.repositories.impl.git.GitRepository) Module(org.guvnor.common.services.project.model.Module)

Example 5 with GitRepository

use of org.guvnor.structure.repositories.impl.git.GitRepository in project kie-wb-common by kiegroup.

the class ExamplesServiceImplTest method testGetProjects_PomDescription.

@Test
public void testGetProjects_PomDescription() {
    final Path moduleRoot = mock(Path.class);
    final POM pom = mock(POM.class);
    final KieModule module = mock(KieModule.class);
    when(pom.getDescription()).thenReturn("pom description");
    when(module.getRootPath()).thenReturn(moduleRoot);
    when(module.getModuleName()).thenReturn("module1");
    when(module.getPom()).thenReturn(pom);
    when(moduleRoot.toURI()).thenReturn("default:///module1");
    when(metadataService.getTags(any(Path.class))).thenReturn(Arrays.asList("tag1", "tag2"));
    final GitRepository repository = makeGitRepository();
    when(repositoryFactory.newRepository(any(ConfigGroup.class))).thenReturn(repository);
    when(moduleService.getAllModules(any(Branch.class))).thenReturn(new HashSet<Module>() {

        {
            add(module);
        }
    });
    final Set<ExampleProject> modules = service.getProjects(new ExampleRepository("https://github.com/guvnorngtestuser1/guvnorng-playground.git"));
    assertNotNull(modules);
    assertEquals(1, modules.size());
    assertTrue(modules.contains(new ExampleProject(moduleRoot, "module1", "pom description", Arrays.asList("tag1", "tag2"))));
}
Also used : Path(org.uberfire.backend.vfs.Path) GitRepository(org.guvnor.structure.repositories.impl.git.GitRepository) Branch(org.guvnor.structure.repositories.Branch) ExampleRepository(org.kie.workbench.common.screens.examples.model.ExampleRepository) ConfigGroup(org.guvnor.structure.server.config.ConfigGroup) Module(org.guvnor.common.services.project.model.Module) KieModule(org.kie.workbench.common.services.shared.project.KieModule) ExampleProject(org.kie.workbench.common.screens.examples.model.ExampleProject) KieModule(org.kie.workbench.common.services.shared.project.KieModule) POM(org.guvnor.common.services.project.model.POM) Test(org.junit.Test)

Aggregations

GitRepository (org.guvnor.structure.repositories.impl.git.GitRepository)14 Branch (org.guvnor.structure.repositories.Branch)9 Path (org.uberfire.backend.vfs.Path)7 Test (org.junit.Test)6 ExampleProject (org.kie.workbench.common.screens.examples.model.ExampleProject)6 Module (org.guvnor.common.services.project.model.Module)5 OrganizationalUnit (org.guvnor.structure.organizationalunit.OrganizationalUnit)5 Repository (org.guvnor.structure.repositories.Repository)5 ConfigGroup (org.guvnor.structure.server.config.ConfigGroup)5 ExampleRepository (org.kie.workbench.common.screens.examples.model.ExampleRepository)5 Space (org.uberfire.spaces.Space)5 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 Before (org.junit.Before)4 KieModule (org.kie.workbench.common.services.shared.project.KieModule)4 WorkspaceProject (org.guvnor.common.services.project.model.WorkspaceProject)3 OrganizationalUnitImpl (org.guvnor.structure.organizationalunit.impl.OrganizationalUnitImpl)3 ExampleOrganizationalUnit (org.kie.workbench.common.screens.examples.model.ExampleOrganizationalUnit)3 WorkspaceProjectContextChangeEvent (org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent)2 NewProjectEvent (org.guvnor.common.services.project.events.NewProjectEvent)2