Search in sources :

Example 21 with Repository

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

the class LibraryServiceImpl method getOrganizationalUnitRepositoryInfo.

@Override
public OrganizationalUnitRepositoryInfo getOrganizationalUnitRepositoryInfo(final OrganizationalUnit selectedOrganizationalUnit) {
    if (selectedOrganizationalUnit == null) {
        return null;
    }
    final List<OrganizationalUnit> organizationalUnits = getOrganizationalUnits();
    final OrganizationalUnit organizationalUnit = getOrganizationalUnit(selectedOrganizationalUnit.getIdentifier(), organizationalUnits).get();
    final List<Repository> repositories = new ArrayList<>(organizationalUnit.getRepositories());
    return new OrganizationalUnitRepositoryInfo(organizationalUnits, organizationalUnit, repositories);
}
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) OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) ExampleOrganizationalUnit(org.kie.workbench.common.screens.examples.model.ExampleOrganizationalUnit) OrganizationalUnitRepositoryInfo(org.kie.workbench.common.screens.library.api.OrganizationalUnitRepositoryInfo) ArrayList(java.util.ArrayList)

Example 22 with Repository

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

the class LibraryServiceImplTest method importDefaultProjectTest.

@Test
public void importDefaultProjectTest() {
    final Repository repository = mock(Repository.class);
    when(repository.getAlias()).thenReturn("example");
    final OrganizationalUnit organizationalUnit = mock(OrganizationalUnit.class);
    when(organizationalUnit.getName()).thenReturn("ou");
    when(organizationalUnit.getIdentifier()).thenReturn("ou");
    when(organizationalUnit.getRepositories()).thenReturn(singletonList(repository));
    when(ouService.getOrganizationalUnits()).thenReturn(singletonList(organizationalUnit));
    final ExampleProject exampleProject = mock(ExampleProject.class);
    doReturn("example").when(exampleProject).getName();
    final WorkspaceProject project = mock(WorkspaceProject.class);
    final Module module = mock(Module.class);
    doReturn(module).when(project).getMainModule();
    final WorkspaceProjectContextChangeEvent projectContextChangeEvent = mock(WorkspaceProjectContextChangeEvent.class);
    doReturn(project).when(projectContextChangeEvent).getWorkspaceProject();
    doReturn(projectContextChangeEvent).when(examplesService).setupExamples(any(ExampleOrganizationalUnit.class), anyList());
    final WorkspaceProject importedProject = libraryService.importProject(organizationalUnit, exampleProject);
    assertEquals(module, importedProject.getMainModule());
    verify(examplesService).setupExamples(new ExampleOrganizationalUnit(organizationalUnit.getName()), singletonList(exampleProject));
}
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) OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) ExampleOrganizationalUnit(org.kie.workbench.common.screens.examples.model.ExampleOrganizationalUnit) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) ExampleOrganizationalUnit(org.kie.workbench.common.screens.examples.model.ExampleOrganizationalUnit) WorkspaceProjectContextChangeEvent(org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent) Module(org.guvnor.common.services.project.model.Module) ExampleProject(org.kie.workbench.common.screens.examples.model.ExampleProject) Test(org.junit.Test)

Example 23 with Repository

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

the class BaseViewPresenterTest method testAutomaticModuleBuildEnabled.

@Test
public void testAutomaticModuleBuildEnabled() {
    final OrganizationalUnit ou = mock(OrganizationalUnit.class);
    final Repository repository = mock(Repository.class);
    final Module module = mock(Module.class);
    ApplicationPreferences.setUp(new HashMap<String, String>());
    when(activeContextItems.setupActiveModule(content)).thenReturn(true);
    final WorkspaceProject project = mock(WorkspaceProject.class);
    when(activeContextItems.getActiveProject()).thenReturn(project);
    when(project.getOrganizationalUnit()).thenReturn(ou);
    when(project.getRepository()).thenReturn(repository);
    when(project.getBranch()).thenReturn(new Branch("master", mock(Path.class)));
    when(activeContextItems.getActiveModule()).thenReturn(module);
    presenter.doContentCallback(content);
    verify(buildServiceActual, times(1)).build(module);
}
Also used : 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) Module(org.guvnor.common.services.project.model.Module) Test(org.junit.Test)

Example 24 with Repository

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

the class BaseViewPresenterTest method testAutomaticModuleBuildDisabledSystemProperty.

@Test
public void testAutomaticModuleBuildDisabledSystemProperty() {
    final OrganizationalUnit ou = mock(OrganizationalUnit.class);
    final Repository repository = mock(Repository.class);
    final Module module = mock(Module.class);
    String spBuildDisableModuleExplorer = null;
    try {
        spBuildDisableModuleExplorer = System.getProperty(ExplorerService.BUILD_PROJECT_PROPERTY_NAME);
        System.setProperty(ExplorerService.BUILD_PROJECT_PROPERTY_NAME, "true");
        final ExplorerPreferencesLoader preferencesLoader = new ExplorerPreferencesLoader();
        ApplicationPreferences.setUp(preferencesLoader.load());
        when(activeContextItems.setupActiveModule(content)).thenReturn(true);
        final WorkspaceProject project = mock(WorkspaceProject.class);
        when(activeContextItems.getActiveProject()).thenReturn(project);
        when(project.getOrganizationalUnit()).thenReturn(ou);
        when(project.getRepository()).thenReturn(repository);
        when(project.getBranch()).thenReturn(new Branch("master", mock(Path.class)));
        when(activeContextItems.getActiveModule()).thenReturn(module);
        presenter.doContentCallback(content);
        verify(buildServiceActual, never()).build(any(Module.class));
    } finally {
        if (spBuildDisableModuleExplorer != null) {
            System.setProperty(ExplorerService.BUILD_PROJECT_PROPERTY_NAME, spBuildDisableModuleExplorer);
        }
    }
}
Also used : 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) ExplorerPreferencesLoader(org.kie.workbench.common.screens.explorer.backend.server.preferences.ExplorerPreferencesLoader) Module(org.guvnor.common.services.project.model.Module) Test(org.junit.Test)

Example 25 with Repository

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

the class LibraryServiceImpl method importProject.

@Override
public WorkspaceProject importProject(final OrganizationalUnit targetOU, final String repositoryURL, final String username, final String password) {
    final RepositoryEnvironmentConfigurations config = new RepositoryEnvironmentConfigurations();
    config.setOrigin(repositoryURL);
    if (username != null && password != null) {
        config.setUserName(username);
        config.setPassword(password);
    }
    final String targetProjectName = inferProjectName(repositoryURL);
    final Repository repo = repoService.createRepository(targetOU, GitRepository.SCHEME.toString(), targetProjectName, config);
    return projectService.resolveProject(repo);
}
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) RepositoryEnvironmentConfigurations(org.guvnor.structure.repositories.RepositoryEnvironmentConfigurations)

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