Search in sources :

Example 11 with GitRepository

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

the class ExamplesServiceImplTest method testGetProjects_CustomDescription.

@Test
public void testGetProjects_CustomDescription() {
    final Path moduleRoot = mock(Path.class);
    final KieModule module = mock(KieModule.class);
    when(module.getRootPath()).thenReturn(moduleRoot);
    when(module.getModuleName()).thenReturn("module1");
    when(moduleRoot.toURI()).thenReturn("default:///module1");
    when(ioService.exists(any(org.uberfire.java.nio.file.Path.class))).thenReturn(true);
    when(ioService.readAllString(any(org.uberfire.java.nio.file.Path.class))).thenReturn("This is custom description.\n\n This is a new line.");
    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", "This is custom description. This is a new line.", 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) Test(org.junit.Test)

Example 12 with GitRepository

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

the class ExamplesServiceImplTest method resolveGitRepositoryClonedBefore.

@Test
public void resolveGitRepositoryClonedBefore() {
    ExampleRepository playgroundRepository = new ExampleRepository("file:///home/user/folder/.kie-wb-playground");
    service.setPlaygroundRepository(playgroundRepository);
    GitRepository repository = mock(GitRepository.class);
    Map<String, Object> repositoryEnvironment = new HashMap<>();
    repositoryEnvironment.put("origin", playgroundRepository.getUrl());
    when(repository.getEnvironment()).thenReturn(repositoryEnvironment);
    service.getClonedRepositories().add(repository);
    Repository result = service.resolveGitRepository(playgroundRepository);
    assertEquals(repository, result);
    verify(repositoryFactory, never()).newRepository(any(ConfigGroup.class));
}
Also used : GitRepository(org.guvnor.structure.repositories.impl.git.GitRepository) ExampleRepository(org.kie.workbench.common.screens.examples.model.ExampleRepository) Repository(org.guvnor.structure.repositories.Repository) GitRepository(org.guvnor.structure.repositories.impl.git.GitRepository) HashMap(java.util.HashMap) ExampleRepository(org.kie.workbench.common.screens.examples.model.ExampleRepository) ConfigGroup(org.guvnor.structure.server.config.ConfigGroup) Test(org.junit.Test)

Example 13 with GitRepository

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

the class ExamplesServiceImplTest method testGetProjects_DefaultDescription.

@Test
public void testGetProjects_DefaultDescription() {
    final Path moduleRoot = mock(Path.class);
    final KieModule module = mock(KieModule.class);
    when(module.getRootPath()).thenReturn(moduleRoot);
    when(module.getModuleName()).thenReturn("module1");
    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);
        }
    });
    service.setPlaygroundRepository(mock(ExampleRepository.class));
    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", "Example 'module1' module", 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) Test(org.junit.Test)

Example 14 with GitRepository

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

the class SocialEventModuleConstraintTest 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);
    socialEventModuleConstraint = createSocialEventModuleConstraint();
}
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)

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