Search in sources :

Example 51 with WorkspaceProject

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

the class LibraryPlacesTest method setup.

@Before
public void setup() {
    libraryServiceCaller = new CallerMock<>(libraryService);
    vfsServiceCaller = new CallerMock<>(vfsService);
    final UberElement libraryToolBarView = mock(UberElement.class);
    doReturn(libraryToolBarView).when(libraryToolbar).getView();
    libraryPlaces = spy(new LibraryPlaces(breadcrumbs, ts, projectMetricsEvent, assetDetailEvent, resourceUtils, libraryServiceCaller, new CallerMock<>(projectService), new CallerMock<>(moduleService), placeManager, projectContext, libraryToolbar, docks, projectContextChangeEvent, notificationEvent, translationUtils, vfsServiceCaller, projectScopedResolutionStrategySupplier, preferencesCentralInitializationEvent, importRepositoryPopUpPresenters, assetListUpdateEvent));
    libraryPlaces.setup();
    verify(libraryToolBarView).getElement();
    libraryPlaces.init(mock(LibraryPerspective.class));
    activeOrganizationalUnit = mock(OrganizationalUnit.class);
    activeRepository = mock(Repository.class);
    activeBranch = new Branch("master", mock(Path.class));
    activeModule = mock(Module.class);
    doReturn(Optional.of(activeOrganizationalUnit)).when(projectContext).getActiveOrganizationalUnit();
    activeProject = new WorkspaceProject(activeOrganizationalUnit, activeRepository, activeBranch, activeModule);
    doReturn(Optional.of(activeProject)).when(projectContext).getActiveWorkspaceProject();
    doReturn(Optional.of(activeModule)).when(projectContext).getActiveModule();
    doReturn(Optional.empty()).when(projectContext).getActiveRepositoryRoot();
    doReturn(Optional.empty()).when(projectContext).getActivePackage();
    when(current.getOrganizationalUnit()).thenReturn(activeOrganizationalUnit);
    when(current.getWorkspaceProject()).thenReturn(activeProject);
    when(current.getModule()).thenReturn(activeModule);
    final URIStructureExplorerModel model = mock(URIStructureExplorerModel.class);
    doReturn(mock(Repository.class)).when(model).getRepository();
    doReturn(mock(Module.class)).when(model).getModule();
    doReturn(mock(Path.class)).when(vfsService).get(any());
    doNothing().when(libraryPlaces).setupLibraryBreadCrumbs();
    doNothing().when(libraryPlaces).setupLibraryBreadCrumbsForAsset(any(Path.class));
    final PathPlaceRequest pathPlaceRequest = mock(PathPlaceRequest.class);
    doReturn(mock(ObservablePath.class)).when(pathPlaceRequest).getPath();
    doReturn(pathPlaceRequest).when(libraryPlaces).createPathPlaceRequest(any());
    doReturn(true).when(placeManager).closeAllPlacesOrNothing();
    doReturn(importRepositoryPopUpPresenter).when(importRepositoryPopUpPresenters).get();
}
Also used : ObservablePath(org.uberfire.backend.vfs.ObservablePath) Path(org.uberfire.backend.vfs.Path) OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) UberElement(org.uberfire.client.mvp.UberElement) LibraryPerspective(org.kie.workbench.common.screens.library.client.perspective.LibraryPerspective) URIStructureExplorerModel(org.kie.workbench.common.screens.explorer.model.URIStructureExplorerModel) Repository(org.guvnor.structure.repositories.Repository) Branch(org.guvnor.structure.repositories.Branch) PathPlaceRequest(org.uberfire.mvp.impl.PathPlaceRequest) Module(org.guvnor.common.services.project.model.Module) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Before(org.junit.Before)

Example 52 with WorkspaceProject

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

the class LibraryPlacesTest method goToSameProjectTest.

@Test
public void goToSameProjectTest() {
    final WorkspaceProject project = new WorkspaceProject(activeOrganizationalUnit, activeRepository, activeBranch, activeModule);
    libraryPlaces.goToProject(project);
    verify(projectContextChangeEvent, never()).fire(any(WorkspaceProjectContextChangeEvent.class));
    verify(placeManager, never()).closeAllPlacesOrNothing();
}
Also used : WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) WorkspaceProjectContextChangeEvent(org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent) Test(org.junit.Test)

Example 53 with WorkspaceProject

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

the class LibraryPlacesTest method goToLibraryWhenGoingBackFromProjectTest.

@Test
public void goToLibraryWhenGoingBackFromProjectTest() {
    doReturn(Optional.of(activeOrganizationalUnit)).when(projectContext).getActiveOrganizationalUnit();
    activeProject = new WorkspaceProject(activeOrganizationalUnit, activeRepository, activeBranch, activeModule);
    doReturn(Optional.of(activeProject)).when(projectContext).getActiveWorkspaceProject();
    doReturn(Optional.of(activeModule)).when(projectContext).getActiveModule();
    final PlaceRequest placeRequest = new DefaultPlaceRequest(LibraryPlaces.LIBRARY_SCREEN);
    final PartDefinitionImpl part = new PartDefinitionImpl(placeRequest);
    part.setSelectable(false);
    libraryPlaces.goToLibrary();
    verify(libraryPlaces).closeLibraryPlaces();
    verify(placeManager).goTo(eq(part), any(PanelDefinition.class));
    verify(libraryPlaces).setupLibraryBreadCrumbsWithoutProject();
    verify(projectContextChangeEvent, never()).fire(any(WorkspaceProjectContextChangeEvent.class));
}
Also used : PathPlaceRequest(org.uberfire.mvp.impl.PathPlaceRequest) DefaultPlaceRequest(org.uberfire.mvp.impl.DefaultPlaceRequest) PlaceRequest(org.uberfire.mvp.PlaceRequest) PartDefinitionImpl(org.uberfire.workbench.model.impl.PartDefinitionImpl) PanelDefinition(org.uberfire.workbench.model.PanelDefinition) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) DefaultPlaceRequest(org.uberfire.mvp.impl.DefaultPlaceRequest) WorkspaceProjectContextChangeEvent(org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent) Test(org.junit.Test)

Example 54 with WorkspaceProject

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

the class LibraryToolbarPresenterTest method updateSelectedBranch.

@Test
public void updateSelectedBranch() throws Exception {
    final Branch devBranch = new Branch("dev", mock(Path.class));
    final WorkspaceProject devBranchProject = new WorkspaceProject(selectedOrganizationalUnit, selectedRepository, devBranch, mock(Module.class));
    Space space = new Space("test-realm");
    doReturn(space).when(selectedRepository).getSpace();
    doReturn(devBranchProject).when(projectService).resolveProject(space, devBranch);
    selectedRepositoryBranches.add(devBranch);
    doReturn(Optional.of(devBranch)).when(selectedRepository).getBranch("dev");
    presenter.init(callback);
    reset(view);
    doReturn(true).when(placeManager).closeAllPlacesOrNothing();
    doReturn("dev").when(view).getSelectedBranch();
    presenter.onUpdateSelectedBranch();
    verify(libraryPlaces).goToProject(devBranchProject);
}
Also used : Path(org.uberfire.backend.vfs.Path) Space(org.uberfire.spaces.Space) Branch(org.guvnor.structure.repositories.Branch) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) KieModule(org.kie.workbench.common.services.shared.project.KieModule) Module(org.guvnor.common.services.project.model.Module) Test(org.junit.Test)

Example 55 with WorkspaceProject

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

the class LibraryToolbarPresenterTest method setup.

@Before
public void setup() {
    presenter = new LibraryToolbarPresenter(projectContext, new CallerMock<>(projectService), libraryPlaces, view, placeManager);
    selectedOrganizationalUnit = mock(OrganizationalUnit.class);
    final Branch masterBranch = new Branch("master", mock(Path.class));
    selectedRepository = mock(Repository.class);
    selectedRepositoryBranches = new ArrayList<>();
    selectedRepositoryBranches.add(masterBranch);
    when(selectedRepository.getDefaultBranch()).thenReturn(Optional.of(masterBranch));
    when(selectedRepository.getBranches()).thenReturn(selectedRepositoryBranches);
    doReturn("repository1").when(selectedRepository).getAlias();
    callback = mock(Command.class);
    doReturn(Optional.of(selectedOrganizationalUnit)).when(projectContext).getActiveOrganizationalUnit();
    doReturn(Optional.of(new WorkspaceProject(selectedOrganizationalUnit, selectedRepository, masterBranch, mock(Module.class)))).when(projectContext).getActiveWorkspaceProject();
    when(projectContext.getActiveModule()).thenReturn(Optional.empty());
    when(projectContext.getActiveRepositoryRoot()).thenReturn(Optional.empty());
    when(projectContext.getActivePackage()).thenReturn(Optional.empty());
}
Also used : Path(org.uberfire.backend.vfs.Path) Repository(org.guvnor.structure.repositories.Repository) OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) Command(org.uberfire.mvp.Command) Branch(org.guvnor.structure.repositories.Branch) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) KieModule(org.kie.workbench.common.services.shared.project.KieModule) Module(org.guvnor.common.services.project.model.Module) CallerMock(org.uberfire.mocks.CallerMock) Before(org.junit.Before)

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