Search in sources :

Example 1 with URIStructureExplorerModel

use of org.kie.workbench.common.screens.explorer.model.URIStructureExplorerModel in project kie-wb-common by kiegroup.

the class LibraryPlacesTest method setup.

@Before
public void setup() {
    when(user.getIdentifier()).thenReturn("user");
    when(sessionInfo.getIdentity()).thenReturn(user);
    when(libraryPerspective.getPlace()).thenReturn(LIBRARY_PERSPECTIVE_PLACE_REQUEST);
    when(otherPerspective.getPlace()).thenReturn(OTHER_PERSPECTIVE_PLACE_REQUEST);
    windowParameters = new HashMap<>();
    libraryServiceCaller = new CallerMock<>(libraryService);
    vfsServiceCaller = new CallerMock<>(vfsService);
    repositoryServiceCaller = new CallerMock<>(repositoryService);
    organizationalUnitServiceCaller = new CallerMock<>(organizationalUnitService);
    libraryBreadcrumbs = spy(new LibraryBreadcrumbs(breadcrumbs, translationUtils, ts, resourceUtils, projectBranchBreadcrumb));
    libraryPlaces = spy(new LibraryPlaces(breadcrumbs, ts, assetDetailEvent, libraryServiceCaller, new CallerMock<>(projectService), new CallerMock<>(moduleService), placeManager, projectContext, projectContextChangeEvent, notificationEvent, translationUtils, vfsServiceCaller, importRepositoryPopUpPresenters, assetListUpdateEvent, closeUnsavedProjectAssetsPopUpPresenter, projectsSetupEvent, libraryBreadcrumbs, sessionInfo, repositoryServiceCaller, new SyncPromises(), mock(OrganizationalUnitController.class), organizationalUnitServiceCaller, logger, cookie, perspectiveManager) {

        @Override
        protected Map<String, List<String>> getParameterMap() {
            return windowParameters;
        }
    });
    doNothing().when(libraryPlaces).expose();
    libraryPlaces.setup();
    libraryPlaces.init(mock(LibraryPerspective.class));
    activeOrganizationalUnit = mock(OrganizationalUnit.class);
    activeSpace = mock(Space.class);
    activeRepository = mock(Repository.class);
    activeBranch = new Branch("main", 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);
    when(activeOrganizationalUnit.getSpace()).thenReturn(activeSpace);
    when(activeRepository.getAlias()).thenReturn("repository");
    when(activeRepository.getIdentifier()).thenReturn("repository");
    when(activeRepository.getSpace()).thenReturn(activeSpace);
    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());
    final PathPlaceRequest pathPlaceRequest = mock(PathPlaceRequest.class);
    doReturn(mock(ObservablePath.class)).when(pathPlaceRequest).getPath();
    doReturn(pathPlaceRequest).when(libraryPlaces).createPathPlaceRequest(any());
    doReturn(importRepositoryPopUpPresenter).when(importRepositoryPopUpPresenters).get();
    lastSpaceCookie = user.getIdentifier() + "_lastSpace";
    lastProjectCookie = user.getIdentifier() + "_lastProject";
    lastBranchCookie = user.getIdentifier() + "_" + activeProject.getName() + "_lastBranch";
    doReturn("").when(cookie).get(any());
}
Also used : Space(org.uberfire.spaces.Space) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Path(org.uberfire.backend.vfs.Path) OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) SyncPromises(org.uberfire.promise.SyncPromises) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) OrganizationalUnitController(org.guvnor.structure.client.security.OrganizationalUnitController) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) LibraryBreadcrumbs(org.kie.workbench.common.screens.library.client.util.breadcrumb.LibraryBreadcrumbs) 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) ArrayList(java.util.ArrayList) Collections.emptyList(java.util.Collections.emptyList) List(java.util.List) Module(org.guvnor.common.services.project.model.Module) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Before(org.junit.Before)

Aggregations

ArrayList (java.util.ArrayList)1 Collections.emptyList (java.util.Collections.emptyList)1 List (java.util.List)1 Module (org.guvnor.common.services.project.model.Module)1 WorkspaceProject (org.guvnor.common.services.project.model.WorkspaceProject)1 OrganizationalUnitController (org.guvnor.structure.client.security.OrganizationalUnitController)1 OrganizationalUnit (org.guvnor.structure.organizationalunit.OrganizationalUnit)1 Branch (org.guvnor.structure.repositories.Branch)1 Repository (org.guvnor.structure.repositories.Repository)1 Before (org.junit.Before)1 URIStructureExplorerModel (org.kie.workbench.common.screens.explorer.model.URIStructureExplorerModel)1 LibraryPerspective (org.kie.workbench.common.screens.library.client.perspective.LibraryPerspective)1 LibraryBreadcrumbs (org.kie.workbench.common.screens.library.client.util.breadcrumb.LibraryBreadcrumbs)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1 ObservablePath (org.uberfire.backend.vfs.ObservablePath)1 Path (org.uberfire.backend.vfs.Path)1 PathPlaceRequest (org.uberfire.mvp.impl.PathPlaceRequest)1 SyncPromises (org.uberfire.promise.SyncPromises)1 Space (org.uberfire.spaces.Space)1