Search in sources :

Example 26 with WorkspaceProject

use of org.guvnor.common.services.project.model.WorkspaceProject in project kie-wb-common by kiegroup.

the class LibraryServiceImplTest method getLibraryInfoTest.

@Test
public void getLibraryInfoTest() {
    final Path path = mockPath("file://the_project");
    final WorkspaceProject project = mock(WorkspaceProject.class);
    when(project.getRootPath()).thenReturn(path);
    doReturn(true).when(ioService).exists(any());
    final Set<WorkspaceProject> projects = new HashSet<>();
    projects.add(project);
    doReturn(projects).when(projectService).getAllWorkspaceProjects(ou1);
    final LibraryInfo libraryInfo = libraryService.getLibraryInfo(ou1);
    assertEquals(new HashSet<>(projects), libraryInfo.getProjects());
}
Also used : Path(org.uberfire.backend.vfs.Path) LibraryInfo(org.kie.workbench.common.screens.library.api.LibraryInfo) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 27 with WorkspaceProject

use of org.guvnor.common.services.project.model.WorkspaceProject in project kie-wb-common by kiegroup.

the class LibraryServiceImplTest method thereIsAModuleInTheWorkbenchTest.

@Test
public void thereIsAModuleInTheWorkbenchTest() {
    Set<WorkspaceProject> projects = new HashSet<>();
    projects.add(new WorkspaceProject(ou1, repo1, new Branch("master", mock(Path.class)), mock(Module.class)));
    doReturn(projects).when(projectService).getAllWorkspaceProjects();
    final Boolean thereIsAModuleInTheWorkbench = libraryService.thereIsAProjectInTheWorkbench();
    assertTrue(thereIsAModuleInTheWorkbench);
    verify(projectService, times(1)).getAllWorkspaceProjects();
}
Also used : Path(org.uberfire.backend.vfs.Path) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) Branch(org.guvnor.structure.repositories.Branch) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 28 with WorkspaceProject

use of org.guvnor.common.services.project.model.WorkspaceProject in project kie-wb-common by kiegroup.

the class ImportRepositoryPopUpPresenter method importRepository.

public void importRepository() {
    final String repositoryUrl = view.getRepositoryURL();
    if (isEmpty(repositoryUrl)) {
        view.showError(view.getEmptyRepositoryURLValidationMessage());
        return;
    }
    OrganizationalUnit ou = context.getActiveOrganizationalUnit().orElseThrow(() -> new IllegalStateException("Cannot import project without an active organizational unit."));
    view.showBusyIndicator(view.getLoadingMessage());
    libraryService.call((WorkspaceProject project) -> {
        view.hideBusyIndicator();
        view.hide();
        libraryPlaces.goToProject(project);
    }, new DefaultErrorCallback() {

        @Override
        public boolean error(Message message, Throwable throwable) {
            view.hideBusyIndicator();
            view.showError(view.getNoProjectsToImportMessage());
            return false;
        }
    }).importProject(ou, repositoryUrl, view.getUserName(), view.getPassword());
}
Also used : OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) Message(org.jboss.errai.bus.client.api.messaging.Message) DefaultErrorCallback(org.uberfire.ext.widgets.common.client.callbacks.DefaultErrorCallback) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject)

Example 29 with WorkspaceProject

use of org.guvnor.common.services.project.model.WorkspaceProject in project kie-wb-common by kiegroup.

the class ProjectExplorerContentResolverDefaultSelectionsTest method getContentQuery.

private ProjectExplorerContentQuery getContentQuery(final Repository repository, final String branchName, final Module module) {
    final Branch branch = new Branch(branchName, mock(Path.class));
    final ProjectExplorerContentQuery moduleExplorerContentQuery = new ProjectExplorerContentQuery(repository, branch, module);
    doReturn(new WorkspaceProject(mock(OrganizationalUnit.class), repository, branch, module)).when(projectService).resolveProject(repository.getSpace(), branch);
    final ActiveOptions options = new ActiveOptions();
    options.add(Option.TREE_NAVIGATOR);
    options.add(Option.EXCLUDE_HIDDEN_ITEMS);
    options.add(Option.BUSINESS_CONTENT);
    moduleExplorerContentQuery.setOptions(options);
    return moduleExplorerContentQuery;
}
Also used : Path(org.uberfire.backend.vfs.Path) ActiveOptions(org.kie.workbench.common.screens.explorer.service.ActiveOptions) Branch(org.guvnor.structure.repositories.Branch) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) ProjectExplorerContentQuery(org.kie.workbench.common.screens.explorer.service.ProjectExplorerContentQuery)

Example 30 with WorkspaceProject

use of org.guvnor.common.services.project.model.WorkspaceProject in project kie-wb-common by kiegroup.

the class ActiveContextManager method initActiveContext.

public void initActiveContext(final WorkspaceProjectContext context) {
    WorkspaceProject activeProject = context.getActiveWorkspaceProject().orElseThrow(() -> new IllegalStateException("Cannot initialize active context without an active project."));
    initActiveContext(activeProject.getRepository(), activeProject.getBranch(), /*
                           * XXX I think these are allowed to be null but this should be
                           * documented somewhere, like on the ProjectExplorerContentQuery
                           */
    context.getActiveModule().orElse(null), context.getActivePackage().orElse(null));
}
Also used : WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject)

Aggregations

WorkspaceProject (org.guvnor.common.services.project.model.WorkspaceProject)67 Test (org.junit.Test)42 Branch (org.guvnor.structure.repositories.Branch)29 OrganizationalUnit (org.guvnor.structure.organizationalunit.OrganizationalUnit)28 Repository (org.guvnor.structure.repositories.Repository)26 Path (org.uberfire.backend.vfs.Path)26 Module (org.guvnor.common.services.project.model.Module)21 ArrayList (java.util.ArrayList)12 GitRepository (org.guvnor.structure.repositories.impl.git.GitRepository)12 WorkspaceProjectContextChangeEvent (org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent)10 ExampleOrganizationalUnit (org.kie.workbench.common.screens.examples.model.ExampleOrganizationalUnit)9 Before (org.junit.Before)8 KieModule (org.kie.workbench.common.services.shared.project.KieModule)7 POM (org.guvnor.common.services.project.model.POM)6 ExampleRepository (org.kie.workbench.common.screens.examples.model.ExampleRepository)5 ProjectAssetsQuery (org.kie.workbench.common.screens.library.api.ProjectAssetsQuery)5 ProjectScreenModel (org.kie.workbench.common.screens.projecteditor.model.ProjectScreenModel)5 Date (java.util.Date)4 HashSet (java.util.HashSet)4 ExampleProject (org.kie.workbench.common.screens.examples.model.ExampleProject)4