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();
}
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();
}
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));
}
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);
}
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());
}
Aggregations